Pārlūkot izejas kodu

Fix word wrapping on select screens

Scott Lahteine 5 gadus atpakaļ
vecāks
revīzija
a17f057daa
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 4 papildinājumiem un 4 dzēšanām
  1. 4
    4
      Marlin/src/lcd/ultralcd.cpp

+ 4
- 4
Marlin/src/lcd/ultralcd.cpp Parādīt failu

@@ -205,21 +205,22 @@ millis_t next_button_update_ms;
205 205
     if (!string) return;
206 206
 
207 207
     uint8_t *p = (uint8_t*)string;
208
+    wchar_t ch;
208 209
     if (wordwrap) {
209 210
       uint8_t *wrd = p, c = 0;
210 211
       for (;;) {
211
-        wchar_t ch;
212 212
         p = get_utf8_value_cb(p, cb_read_byte, &ch);
213 213
         const bool eol = !ch;
214 214
         if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
215 215
           if (!c && ch == ' ') continue; // collapse extra spaces
216
-          if (x + c > LCD_WIDTH && c < (LCD_WIDTH) * 3 / 4) { // should it wrap?
216
+          if (x + c > LCD_WIDTH && x >= (LCD_WIDTH) / 4) { // should it wrap?
217 217
             x = 0; y++;               // move x to string len (plus space)
218 218
             SETCURSOR(0, y);          // simulate carriage return
219 219
           }
220 220
           c += !eol;                  // +1 so the space will be printed
221 221
           x += c;                     // advance x to new position
222
-          while (c--) {               // character countdown
222
+          while (c) {                 // character countdown
223
+            --c;                      // count down to zero
223 224
             wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
224 225
             lcd_put_wchar(ch);        // word (plus space) to the LCD
225 226
           }
@@ -234,7 +235,6 @@ millis_t next_button_update_ms;
234 235
     }
235 236
     else {
236 237
       for (;;) {
237
-        wchar_t ch;
238 238
         p = get_utf8_value_cb(p, cb_read_byte, &ch);
239 239
         if (!ch) break;
240 240
         lcd_put_wchar(ch);

Notiek ielāde…
Atcelt
Saglabāt