Skip to content

Commit d484d36

Browse files
committed
https://github.com/neu-rah/ArduinoMenu/issues/240
1 parent ebe3b4d commit d484d36

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ArduinoMenu library
2-
version=4.17.19
2+
version=4.17.20
33
author=Rui Azevedo, [email protected]
44
maintainer=neu-rah, [email protected]
55
sentence=Generic menu/interactivity system

src/items.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,22 @@ Used textField::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len
207207
out.fmtStart(*this,menuOut::fmtTextField,root.node(),idx);
208208
#endif
209209
idx_t tit=hasTitle(root.node())?1:0;
210+
idx_t c=l+1;//initial cursor, after label
210211
idx_t line=idx+tit;//-out.tops[root.level];
211-
idx_t c=l+1;
212-
idx_t w=len-l;
213-
idx_t at=cursor>=w?cursor-w:0;
214-
trace(MENU_DEBUG_OUT<<"at:"<<at<<" tit:"<<tit<<" line:"<<line<<" cursor:"<<cursor<<" l:"<<l<<" len:"<<len);//<<endl;)
215-
while(buffer()[at]&&l++<len)
216-
if (at==cursor&&editing) {
217-
// MENU_DEBUG_OUT<<"idx:"<<idx<<" line:"<<line<<" at:"<<at<<" l:"<<l<<endl;
218-
// c=l+1;
212+
idx_t ew=len-c;//editable width
213+
idx_t at=cursor>=ew?cursor-ew:0;//adjust print start
214+
while(buffer()[at]&&l++<len) {//while not string terminated or buffer length reached
215+
trace(if (editing) MENU_DEBUG_OUT<<endl<<"{"<<at<<"}");
216+
if (at==cursor&&editing) {//edit cursor
217+
trace(MENU_DEBUG_OUT<<"ew:"<<ew<<" cursor:"<<cursor<<" l:"<<l<<" len:"<<len<<endl);
218+
c=l;//store cursor position
219219
l+=out.startCursor(root,l,line,charEdit);//draw text cursor or color code start
220220
out.write(buffer()[at++]);//draw focused character
221221
l+=out.endCursor(root,l,line,charEdit);//draw text cursor or color code end
222-
} else out.write(buffer()[at++]);
223-
out.editCursor(root,c+cursor,line,editing,charEdit);//reposition a gfx cursor
222+
} else out.write(buffer()[at++]);//just the character
223+
}
224+
//this is the cursor frame
225+
out.editCursor(root,c,line,editing,charEdit);//reposition a gfx cursor
224226
#ifdef MENU_FMT_WRAPS
225227
out.fmtEnd(*this,menuOut::fmtTextField,root.node(),idx);
226228
#endif

src/menuIO/serialOut.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
#include "serialOut.h"
33

44
namespace Menu {
5-
constMEM panel default_serial_panels[] MEMMODE={{0,0,40,10}};
5+
#ifdef MENU_DEBUG
6+
constexpr idx_t w=16;
7+
#else
8+
constexpr idx_t w=40;
9+
#endif
10+
constMEM panel default_serial_panels[] MEMMODE={{0,0,w,10}};//arbitrary serial panel dimensions
611
navNode* default_serial_nodes[sizeof(default_serial_panels)/sizeof(panel)];
712
panelsList default_serial_panel_list(
813
default_serial_panels,

0 commit comments

Comments
 (0)