Actions
Feature #1815
closedSave clock with long channels names in 2 line view
Start date:
04/29/2014
Due date:
% Done:
100%
Estimated time:
Description
In 2 line view, clock is overwritten by long channel names. Copperhead created a patch at end of 2013, what I tested up now successfully:
Index: b/watch.c =================================================================== --- a/watch.c +++ b/watch.c @@ -15,6 +15,7 @@ #include <stdint.h> #include <time.h> #include <ctype.h> +#include <string> #include "watch.h" #include "setup.h" @@ -435,9 +436,13 @@ if(bAllowCurrentTime && currentTime) { int t = pFont->Width(*currentTime); int w = pFont->Width(*scHeader); - if((w + t + 3) < theSetup.m_cWidth && t < theSetup.m_cWidth) { - this->DrawText(theSetup.m_cWidth - t, 0, *currentTime); - } + this->DrawText(theSetup.m_cWidth - t, 0, *currentTime); + std::string name(*scHeader); + while((w + t + 3) > theSetup.m_cWidth) { + name = name.substr(0,name.length()-1); + w = pFont->Width(name.c_str()); + } + *scHeader = name.c_str(); } this->DrawText(0, 0, *scHeader); }
So, might it be possible to bring that upstream?
Updated by anbr over 10 years ago
- Status changed from New to Feedback
- Target version set to 0.3.0
I think, your patch is'nt "UTF-8" save. A better solution could follow patch.
Please test it, before i commit it.
diff --git a/watch.c b/watch.c index e103284..c69905f 100644 --- a/watch.c +++ b/watch.c @@ -459,9 +459,20 @@ bool cVFDWatch::RenderScreenSinglePage(bool bReDraw) { if(bAllowCurrentTime && currentTime) { int t = pFont->Width(*currentTime); int w = pFont->Width(*scHeader); - if((w + t + 3) < theSetup.m_cWidth && t < theSetup.m_cWidth) { - this->DrawText(theSetup.m_cWidth - t, 0, *currentTime); - } + this->DrawText(theSetup.m_cWidth - t, 0, *currentTime); + cString s(*scHeader); + while((w + t + 3) > theSetup.m_cWidth) { + int length = Utf8StrLen(*s); + if(length <= 0) break; + uint lastChar = Utf8CharGet(*s,length); + int sizeChar = Utf8CharSet(lastChar); + if(sizeChar) + s.Truncate(sizeChar * -1); + else + break; + w = pFont->Width(s); + } + *scHeader = s; } this->DrawText(0, 0, *scHeader); }
Updated by fnu over 10 years ago
Hehe, as you may have read, I wasn't the original author ... ;-)
I will test today and come back.
Updated by fnu over 10 years ago
Ok, looks very good on 2 VDRs, no issues with the UTF-8 changes :thumbsup:
Updated by anbr over 10 years ago
- Status changed from Feedback to Closed
- % Done changed from 0 to 100
Applied in changeset 3d87cc0b6a062a39b9385f33bdec88ee25967776.
Updated by anbr over 10 years ago
Sorry, I apply a strongly different patch, with a better source maintainability.
When you experience problems, please reopen this ticket.
Updated by fnu over 10 years ago
Thanks :thumbsup:
I'll create a new package based on last git level, test and come back with feedback.
Actions