#include "menuDefs.h" using namespace Menu; bool prompt::hasTitle(navNode& nav) const {return (nav.target->has(showTitle)||(nav.root->showTitle&&!nav.target->has(noTitle)));} idx_t prompt::printRaw(menuOut& out,idx_t len) const { trace(MENU_DEBUG_OUT<<"prompt::printRaw"<operator[](idx))==this) ) { trace(MENU_DEBUG_OUT<<*(prompt*)this<<" some parentDraw or asPad menu... idx:"<=sz()) n=sz()-1;//never trusting web! return n; } bool menuNode::async(const char*uri,navRoot& root,idx_t lvl) { trace(MENU_DEBUG_OUT<<*(prompt*)this<<" menuNode::async "<lvl:"<<(root.level>lvl)<lvl&&root.path[lvl].sel==n&&root.path[lvl+1].target==&operator[](n)) )) { _trace(Serial<<"menuNode, escTo "<operator[](i%sz());} #ifdef MENU_FMT_WRAPS classes textField::type() const {return textFieldClass;} #endif #ifdef MENU_ASYNC const char* textField::typeName() const {return "textField";} #endif void textField::doNav(navNode& nav,navCmd cmd) { trace(MENU_DEBUG_OUT<<"textField::doNav:"<exit(); } else { charEdit=!charEdit; dirty=true; edited=true; } break; case escCmd: dirty=true; if (charEdit) charEdit=false; else { edited=false; cursor=0; nav.root->exit(); } break; case upCmd: if (charEdit) { const char* v=validator(cursor); char *at=strchr(v,buffer()[cursor]); idx_t pos=at?at-v+1:1; if (pos>=(idx_t)strlen(v)) pos=0; buffer()[cursor]=v[pos]; dirty=true; } else { if(cursor<(idx_t)strlen(buffer())-1) cursor++; edited=false; } dirty=true; break; case downCmd: if (charEdit) { const char* v=validator(cursor); char *at=strchr(v,buffer()[cursor]);//at is not stored on the class to save memory idx_t pos=at?at-v-1:0; if (pos<0) pos=strlen(v)-1; buffer()[cursor]=v[pos]; dirty=true; } else { if (cursor) cursor--; edited=false; } dirty=true; break; default:break; } trace(MENU_DEBUG_OUT<<"cursor:"<=w?cursor-w:0; trace(MENU_DEBUG_OUT<<"at:"<(nav,out,sub,test); } void menuNode::clearChanged(const navNode &nav,const menuOut& out,bool sub) { trace(MENU_DEBUG_OUT<<" menuOut::clearChanged "<(nav,out,sub,false); } #ifdef MENU_FMT_WRAPS classes menuNode::type() const {return menuClass;} #endif #ifdef MENU_ASYNC const char* menuNode::typeName() const {return "mn";} #endif //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // navTarget - any menu object that can process keys/input // //////////////////////////////////////////////////////////////////////////////// void navTarget::doNav(navNode& nav,navCmd cmd) { trace(MENU_DEBUG_OUT<<"navTarget::doNav"<useNavChars&&(c==options->getCmdChar(upCmd) ||c==options->getCmdChar(downCmd) ||c==options->getCmdChar(enterCmd) ||c==options->getCmdChar(escCmd))) { navTarget::parseInput(nav,in); return; } switch(c) {//special cases case 0x0D://enter in.read(); charEdit=false; dirty=true; // edited=false; cursor=0; nav.root->exit(); return; case 0x08://backspace in.read(); buffer()[cursor]=validator(cursor)[0]; if (cursor) cursor--; dirty=true; return; default: { const char* v=validator(cursor); char *at=strchr(v,c); if (at) { in.read(); buffer()[cursor]=c; if (cursor<(idx_t)strlen(buffer())-1) cursor++; dirty=true; return; } // MENU_DEBUG_OUT<nav2D||!canTune()) {//then exit edition tunning=false; dirty=true; constrainField(); nav.event(nav.root->useUpdateEvent?updateEvent:enterEvent); nav.root->exit(); return; } else tunning=true; dirty=true; break; case upCmd: stepit(1); break; case downCmd: stepit(-1); break; default:break; } if (dirty)//sending enter or update event nav.event(nav.root->useUpdateEvent?updateEvent:enterEvent); } Used fieldBase::printTo(navRoot &root,bool sel,menuOut& out, idx_t idx,idx_t len,idx_t panelNr) { trace(MENU_DEBUG_OUT<<"fieldBase::printTo"<':':'):' '); l++; if (l0) l-=operator[](at).printRaw(out,l); #ifdef MENU_FMT_WRAPS } #endif #ifdef MENU_FMT_WRAPS out.fmtEnd(*this,type()==selectClass?menuOut::fmtSelect:menuOut::fmtChoose,root.node(),idx); #endif trace(MENU_DEBUG_OUT<<"menuVariantBase::printTo ended!"<0) { #ifdef MENU_FMT_WRAPS out.fmtStart(*this,menuOut::fmtToggle,root.node(),idx); #endif l+=operator[](at).printRaw(out,len-l); #ifdef MENU_FMT_WRAPS out.fmtEnd(*this,menuOut::fmtToggle,root.node(),idx); #endif- } return l; } void menuVariantBase::doNav(navNode& nav,navCmd cmd) { trace(MENU_DEBUG_OUT<<"menuVariantBase::doNav"<exit(); } } template bool menuNode::_changes(const navNode &nav,const menuOut& out,bool sub,bool test) { if (clear) dirty=false; else if (dirty) { trace(if (test) MENU_DEBUG_OUT<<"just dirty!"<level; if (parentDraw()) { if (clear) nav.root->path[level-1].target->clearChanged(nav.root->path[level-1],out,sub); else { trace(MENU_DEBUG_OUT<<"return changed of parent-draw element"<path[level-1].target->changed(nav.root->path[level-1],out,sub,test); } } idx_t my=out.maxY()-((has(showTitle)||(nav.root->showTitle&&!has(noTitle)))?1:0); menuNode* target=nav.root->path[level].target; idx_t t=out.tops[level-(target->has(_asPad)||target->has(_parentDraw))]; trace(MENU_DEBUG_OUT<<"t:"<=sz()) break; if (clear) operator[](t).clearChanged(nav,out,false); { trace(MENU_DEBUG_OUT<<"checking:"<level<