Browse Source

Fix word wrapping on select screens

Scott Lahteine 5 years ago
parent
commit
a17f057daa
No account linked to committer's email address
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      Marlin/src/lcd/ultralcd.cpp

+ 4
- 4
Marlin/src/lcd/ultralcd.cpp View File

205
     if (!string) return;
205
     if (!string) return;
206
 
206
 
207
     uint8_t *p = (uint8_t*)string;
207
     uint8_t *p = (uint8_t*)string;
208
+    wchar_t ch;
208
     if (wordwrap) {
209
     if (wordwrap) {
209
       uint8_t *wrd = p, c = 0;
210
       uint8_t *wrd = p, c = 0;
210
       for (;;) {
211
       for (;;) {
211
-        wchar_t ch;
212
         p = get_utf8_value_cb(p, cb_read_byte, &ch);
212
         p = get_utf8_value_cb(p, cb_read_byte, &ch);
213
         const bool eol = !ch;
213
         const bool eol = !ch;
214
         if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
214
         if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
215
           if (!c && ch == ' ') continue; // collapse extra spaces
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
             x = 0; y++;               // move x to string len (plus space)
217
             x = 0; y++;               // move x to string len (plus space)
218
             SETCURSOR(0, y);          // simulate carriage return
218
             SETCURSOR(0, y);          // simulate carriage return
219
           }
219
           }
220
           c += !eol;                  // +1 so the space will be printed
220
           c += !eol;                  // +1 so the space will be printed
221
           x += c;                     // advance x to new position
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
             wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
224
             wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
224
             lcd_put_wchar(ch);        // word (plus space) to the LCD
225
             lcd_put_wchar(ch);        // word (plus space) to the LCD
225
           }
226
           }
234
     }
235
     }
235
     else {
236
     else {
236
       for (;;) {
237
       for (;;) {
237
-        wchar_t ch;
238
         p = get_utf8_value_cb(p, cb_read_byte, &ch);
238
         p = get_utf8_value_cb(p, cb_read_byte, &ch);
239
         if (!ch) break;
239
         if (!ch) break;
240
         lcd_put_wchar(ch);
240
         lcd_put_wchar(ch);

Loading…
Cancel
Save