🧑💻 Extend LCD string substitution (#24278)
This commit is contained in:
@@ -53,15 +53,17 @@ class MenuItemBase {
|
||||
// Index to interject in the item label and/or for use by its action.
|
||||
static int8_t itemIndex;
|
||||
|
||||
// An optional pointer for use in display or by the action
|
||||
static FSTR_P itemString;
|
||||
// Optional pointers for use in display or by the action
|
||||
static FSTR_P itemStringF;
|
||||
static const char* itemStringC;
|
||||
|
||||
// Store the index of the item ahead of use by indexed items
|
||||
FORCE_INLINE static void init(const int8_t ind=0, FSTR_P const fstr=nullptr) { itemIndex = ind; itemString = fstr; }
|
||||
// Store an index and string for later substitution
|
||||
FORCE_INLINE static void init(const int8_t ind=0, FSTR_P const fstr=nullptr) { itemIndex = ind; itemStringF = fstr; itemStringC = nullptr; }
|
||||
FORCE_INLINE static void init(const int8_t ind, const char * const cstr) { itemIndex = ind; itemStringC = cstr; itemStringF = nullptr; }
|
||||
|
||||
// Implementation-specific:
|
||||
// Draw an item either selected (pre_char) or not (space) with post_char
|
||||
// Menus may set up itemIndex, itemString and pass them to string-building or string-emitting functions
|
||||
// Menus may set up itemIndex, itemStringC/F and pass them to string-building or string-emitting functions
|
||||
static void _draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char pre_char, const char post_char);
|
||||
|
||||
// Draw an item either selected ('>') or not (space) with post_char
|
||||
@@ -90,8 +92,8 @@ class MenuItem_back : public MenuItemBase {
|
||||
// YESNO_ITEM(LABEL,FY,FN,...)
|
||||
class MenuItem_confirm : public MenuItemBase {
|
||||
public:
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, ...) {
|
||||
_draw(sel, row, fstr, '>', LCD_STR_ARROW_RIGHT[0]);
|
||||
FORCE_INLINE static void draw(const bool sel, const uint8_t row, FSTR_P const ftpl, ...) {
|
||||
_draw(sel, row, ftpl, '>', LCD_STR_ARROW_RIGHT[0]);
|
||||
}
|
||||
// Implemented for HD44780 and DOGM
|
||||
// Draw the prompt, buttons, and state
|
||||
@@ -170,10 +172,10 @@ class MenuEditItemBase : public MenuItemBase {
|
||||
public:
|
||||
// Implementation-specific:
|
||||
// Draw the current item at specified row with edit data
|
||||
static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, const char * const inStr, const bool pgm=false);
|
||||
static void draw(const bool sel, const uint8_t row, FSTR_P const ftpl, const char * const inStr, const bool pgm=false);
|
||||
|
||||
static void draw(const bool sel, const uint8_t row, FSTR_P const fstr, FSTR_P const inStr) {
|
||||
draw(sel, row, fstr, FTOP(inStr), true);
|
||||
static void draw(const bool sel, const uint8_t row, FSTR_P const ftpl, FSTR_P const fstr) {
|
||||
draw(sel, row, ftpl, FTOP(fstr), true);
|
||||
}
|
||||
|
||||
// Implementation-specific:
|
||||
|
||||
Reference in New Issue
Block a user