No line breaks in text boxes (1 Viewer)

safran64

Portal Member
June 25, 2007
30
0
Home Country
Germany Germany
TV-Server Version:
MediaPortal Version: MP 0.2.3 SVN 15269
MediaPortal Skin: Blue Two
Windows Version: Win XP Pro
CPU Type:
HDD:
Memory:
Motherboard:
Motherboard Chipset:
Motherboard Bios:
Video Card:
Video Card Driver:
Sound Card:
Sound Card AC3:
Sound Card Driver:
1. TV Card:
1. TV Card Type:
1. TV Card Driver:
2. TV Card:
2. TV Card Type:
2. TV Card Driver:
3. TV Card:
3. TV Card Type:
3. TV Card Driver:
4. TV Card:
4. TV Card Type:
4. TV Card Driver:
MPEG2 Video Codec:
MPEG2 Audio Codec:
Satelite/CableTV Provider:
HTPC Case:
Cooling:
Power Supply:
Remote:
TV:
TV - HTPC Connection:


Hi,

I had to recognize that it is not possible to display line breaks in a text (video descriptions, etc.) within text boxes (<texbox> or <textboxscrollup>). Since I found the following section in the source code I thought it would work by adding "\n" to start new lines. Unfortunately it doesn't.

GUITextScrollUpControl.cs (line 440):
Code:
...
_listItems.Clear();
      // start wordwrapping
      // Set a flag so we can determine initial justification effects
      // bool bStartingNewLine = true;
      // bool bBreakAtSpace = false;
      int pos = 0;
      int lpos = 0;
      int iLastSpace = -1;
      int iLastSpaceInLine = -1;
      string szLine = "";
      strText = strText.Replace("\r", " ");
      strText.Trim();
      while (pos < strText.Length)
      {
        // Get the current letter in the string
        char letter = strText[pos];

       [COLOR="Red"] // Handle the newline character[/COLOR]
        if (letter == '[COLOR="Red"]\n[/COLOR]')
        {
          if (szLine.Length > 0 || _listItems.Count > 0)
          {
              GUIListItem item = new GUIListItem(szLine);
            item.DimColor = DimColor;
            _listItems.Add(item);
          }
          iLastSpace = -1;
          iLastSpaceInLine = -1;
          lpos = 0;
          szLine = "";
        }
        else
        {
          if (letter == ' ')
          {
...
(similar in GUITextControl.cs)

The \n is shown like normal charakters, e.g.

"Bla bla bla. \n Bla bla bla."

instead of

"Bla bla bla.
Bla bla bla."

("\r" is replaced correctly by " " .

Since I'm not a programmer I can't identify the problem.



[EDIT]

Okay found out, the magic word is "letter" and "\n" are TWO letters! ;)
By choosing a barely used character, like e.g. "§", as a 'line breaker' I was able to solve the problem.

In the video descriptions (AMC or MP Movie databases) you set a "§" (without ") where you want a line break.
In the GUITextScrollUpControl.cs (see above) you change
if (letter == '\n') -> if (letter == '§')
After compiling and starting the new MediaPortal you'll have got text boxes with linebreakes :D
And the best thing is you can even insert empty lines by the use of "§§"!

Examples:
Text:
Bla bla bla.§Bla bla bla.
Textbox result:
Bla bla bla.
Bla bla bla.

Text:
Bla bla bla.§§Bla bla bla.
Textbox result:
Bla bla bla.

Bla bla bla.

So for me it works.

I also tried to make it a little bit more universal by implementing
strText = strText.Replace("\n", "§");
strText = strText.Replace("<BR>", "§");
But that didn't work. Maybe someone else has got a better idea...
 

Users who are viewing this thread

Top Bottom