|
@@ -262,67 +262,71 @@ millis_t MarlinUI::next_button_update_ms; // = 0
|
262
|
262
|
|
263
|
263
|
#endif
|
264
|
264
|
|
265
|
|
- void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) {
|
266
|
|
- SETCURSOR(col, row);
|
267
|
|
- if (!string) return;
|
268
|
|
-
|
269
|
|
- auto _newline = [&col, &row]{
|
270
|
|
- col = 0; row++; // Move col to string len (plus space)
|
271
|
|
- SETCURSOR(0, row); // Simulate carriage return
|
272
|
|
- };
|
273
|
|
-
|
274
|
|
- uint8_t *p = (uint8_t*)string;
|
275
|
|
- wchar_t ch;
|
276
|
|
- if (wordwrap) {
|
277
|
|
- uint8_t *wrd = nullptr, c = 0;
|
278
|
|
- // find the end of the part
|
279
|
|
- for (;;) {
|
280
|
|
- if (!wrd) wrd = p; // Get word start /before/ advancing
|
281
|
|
- p = get_utf8_value_cb(p, cb_read_byte, &ch);
|
282
|
|
- const bool eol = !ch; // zero ends the string
|
283
|
|
- // End or a break between phrases?
|
284
|
|
- if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
|
285
|
|
- if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces
|
286
|
|
- // Past the right and the word is not too long?
|
287
|
|
- if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap?
|
288
|
|
- c += !eol; // +1 so the space will be printed
|
289
|
|
- col += c; // advance col to new position
|
290
|
|
- while (c) { // character countdown
|
291
|
|
- --c; // count down to zero
|
292
|
|
- wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
|
293
|
|
- lcd_put_wchar(ch); // character to the LCD
|
|
265
|
+ #if !HAS_GRAPHICAL_TFT
|
|
266
|
+
|
|
267
|
+ void _wrap_string(uint8_t &col, uint8_t &row, const char * const string, read_byte_cb_t cb_read_byte, bool wordwrap/*=false*/) {
|
|
268
|
+ SETCURSOR(col, row);
|
|
269
|
+ if (!string) return;
|
|
270
|
+
|
|
271
|
+ auto _newline = [&col, &row]{
|
|
272
|
+ col = 0; row++; // Move col to string len (plus space)
|
|
273
|
+ SETCURSOR(0, row); // Simulate carriage return
|
|
274
|
+ };
|
|
275
|
+
|
|
276
|
+ uint8_t *p = (uint8_t*)string;
|
|
277
|
+ wchar_t ch;
|
|
278
|
+ if (wordwrap) {
|
|
279
|
+ uint8_t *wrd = nullptr, c = 0;
|
|
280
|
+ // find the end of the part
|
|
281
|
+ for (;;) {
|
|
282
|
+ if (!wrd) wrd = p; // Get word start /before/ advancing
|
|
283
|
+ p = get_utf8_value_cb(p, cb_read_byte, &ch);
|
|
284
|
+ const bool eol = !ch; // zero ends the string
|
|
285
|
+ // End or a break between phrases?
|
|
286
|
+ if (eol || ch == ' ' || ch == '-' || ch == '+' || ch == '.') {
|
|
287
|
+ if (!c && ch == ' ') { if (wrd) wrd++; continue; } // collapse extra spaces
|
|
288
|
+ // Past the right and the word is not too long?
|
|
289
|
+ if (col + c > LCD_WIDTH && col >= (LCD_WIDTH) / 4) _newline(); // should it wrap?
|
|
290
|
+ c += !eol; // +1 so the space will be printed
|
|
291
|
+ col += c; // advance col to new position
|
|
292
|
+ while (c) { // character countdown
|
|
293
|
+ --c; // count down to zero
|
|
294
|
+ wrd = get_utf8_value_cb(wrd, cb_read_byte, &ch); // get characters again
|
|
295
|
+ lcd_put_wchar(ch); // character to the LCD
|
|
296
|
+ }
|
|
297
|
+ if (eol) break; // all done!
|
|
298
|
+ wrd = nullptr; // set up for next word
|
294
|
299
|
}
|
295
|
|
- if (eol) break; // all done!
|
296
|
|
- wrd = nullptr; // set up for next word
|
|
300
|
+ else c++; // count word characters
|
297
|
301
|
}
|
298
|
|
- else c++; // count word characters
|
299
|
302
|
}
|
300
|
|
- }
|
301
|
|
- else {
|
302
|
|
- for (;;) {
|
303
|
|
- p = get_utf8_value_cb(p, cb_read_byte, &ch);
|
304
|
|
- if (!ch) break;
|
305
|
|
- lcd_put_wchar(ch);
|
306
|
|
- col++;
|
307
|
|
- if (col >= LCD_WIDTH) _newline();
|
|
303
|
+ else {
|
|
304
|
+ for (;;) {
|
|
305
|
+ p = get_utf8_value_cb(p, cb_read_byte, &ch);
|
|
306
|
+ if (!ch) break;
|
|
307
|
+ lcd_put_wchar(ch);
|
|
308
|
+ col++;
|
|
309
|
+ if (col >= LCD_WIDTH) _newline();
|
|
310
|
+ }
|
308
|
311
|
}
|
309
|
312
|
}
|
310
|
|
- }
|
311
|
313
|
|
312
|
|
- void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
|
313
|
|
- const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0;
|
314
|
|
- uint8_t col = 0, row = 0;
|
315
|
|
- if (!string && plen + slen <= LCD_WIDTH) {
|
316
|
|
- col = (LCD_WIDTH - plen - slen) / 2;
|
317
|
|
- row = LCD_HEIGHT > 3 ? 1 : 0;
|
318
|
|
- }
|
319
|
|
- wrap_string_P(col, row, pref, true);
|
320
|
|
- if (string) {
|
321
|
|
- if (col) { col = 0; row++; } // Move to the start of the next line
|
322
|
|
- wrap_string(col, row, string);
|
|
314
|
+ void MarlinUI::draw_select_screen_prompt(PGM_P const pref, const char * const string/*=nullptr*/, PGM_P const suff/*=nullptr*/) {
|
|
315
|
+ const uint8_t plen = utf8_strlen_P(pref), slen = suff ? utf8_strlen_P(suff) : 0;
|
|
316
|
+ uint8_t col = 0, row = 0;
|
|
317
|
+ if (!string && plen + slen <= LCD_WIDTH) {
|
|
318
|
+ col = (LCD_WIDTH - plen - slen) / 2;
|
|
319
|
+ row = LCD_HEIGHT > 3 ? 1 : 0;
|
|
320
|
+ }
|
|
321
|
+ wrap_string_P(col, row, pref, true);
|
|
322
|
+ if (string) {
|
|
323
|
+ if (col) { col = 0; row++; } // Move to the start of the next line
|
|
324
|
+ wrap_string(col, row, string);
|
|
325
|
+ }
|
|
326
|
+ if (suff) wrap_string_P(col, row, suff);
|
323
|
327
|
}
|
324
|
|
- if (suff) wrap_string_P(col, row, suff);
|
325
|
|
- }
|
|
328
|
+
|
|
329
|
+ #endif // !HAS_GRAPHICAL_TFT
|
326
|
330
|
|
327
|
331
|
#endif // HAS_LCD_MENU
|
328
|
332
|
|