Преглед на файлове

fix add linebreaks function of text fields with formatted text

Kolja Strohm преди 6 месеца
родител
ревизия
de94611915
променени са 1 файла, в които са добавени 18 реда и са изтрити 32 реда
  1. 18 32
      TextFeld.cpp

+ 18 - 32
TextFeld.cpp

@@ -696,41 +696,30 @@ Text TextFeld::addLineBreaksToText(const char* txt, const char* spacing) const
     {
         if (last.fontSize != tm->current.fontSize)
         {
-            char tmp[3] = {2, (char)tm->current.fontSize, 0};
-            result += tmp;
+            Text param("\x2");
+            param.appendHex((char)tm->current.fontSize);
+            result += param;
             last.fontSize = tm->current.fontSize;
         }
         if (last.fontColor != tm->current.fontColor)
         {
-            char tmp[6] = {3,
-                (char)((tm->current.fontColor >> 24) & 0xFF),
-                (char)((tm->current.fontColor >> 16) & 0xFF),
-                (char)((tm->current.fontColor >> 8) & 0xFF),
-                (char)(tm->current.fontColor & 0xFF),
-                0};
-            result += tmp;
+            Text param("\x3");
+            param.appendHex(tm->current.fontColor);
+            result += param;
             last.fontColor = tm->current.fontColor;
         }
         if (last.selectedColor != tm->current.selectedColor)
         {
-            char tmp[6] = {4,
-                (char)((tm->current.selectedColor >> 24) & 0xFF),
-                (char)((tm->current.selectedColor >> 16) & 0xFF),
-                (char)((tm->current.selectedColor >> 8) & 0xFF),
-                (char)(tm->current.selectedColor & 0xFF),
-                0};
-            result += tmp;
+            Text param("\x4");
+            param.appendHex(tm->current.selectedColor);
+            result += param;
             last.selectedColor = tm->current.selectedColor;
         }
         if (last.selectedBackcroundColor != tm->current.selectedBackcroundColor)
         {
-            char tmp[6] = {5,
-                (char)((tm->current.selectedBackcroundColor >> 24) & 0xFF),
-                (char)((tm->current.selectedBackcroundColor >> 16) & 0xFF),
-                (char)((tm->current.selectedBackcroundColor >> 8) & 0xFF),
-                (char)(tm->current.selectedBackcroundColor & 0xFF),
-                0};
-            result += tmp;
+            Text param("\x5");
+            param.appendHex(tm->current.selectedBackcroundColor);
+            result += param;
             last.selectedBackcroundColor = tm->current.selectedBackcroundColor;
         }
         if (last.underlined != tm->current.underlined)
@@ -741,19 +730,16 @@ Text TextFeld::addLineBreaksToText(const char* txt, const char* spacing) const
         }
         if (last.interactParam != tm->current.interactParam)
         {
-            char tmp[6] = {8,
-                (char)((tm->current.interactParam >> 24) & 0xFF),
-                (char)((tm->current.interactParam >> 16) & 0xFF),
-                (char)((tm->current.interactParam >> 8) & 0xFF),
-                (char)(tm->current.interactParam & 0xFF),
-                0};
-            result += tmp;
+            Text param("\x8");
+            param.appendHex(tm->current.interactParam);
+            result += param;
             last.interactParam = tm->current.interactParam;
         }
         if (last.rendererIndex != tm->current.rendererIndex)
         {
-            char tmp[3] = {6, (char)tm->current.rendererIndex, 0};
-            result += tmp;
+            Text param("\x6");
+            param.appendHex((char)tm->current.rendererIndex);
+            result += param;
             last.rendererIndex = tm->current.rendererIndex;
         }
         if (txt[i] == ' ')