// Parse emacs modeline FXbool Modeline::parseEmacsModeline(const FXchar* s){ FXString key; FXString val; while(*s!='\0'){ while(*s==';' || *s=='\t' || *s==' ') s++; if(*s=='\0' || (*s=='-' && *(s+1)=='*' && *(s+2)=='-')) break; key=FXString::null; val=FXString::null; while(*s!='\0' && *s!=':' && *s!=';' && *s!='\t' && *s!=' '){ key+=*s++; } while(*s=='\t' || *s==' ') s++; if(*s=='\0') break; if(*s!=':') continue; s++; while(*s=='\t' || *s==' ') s++; if(*s=='\0') break; while(*s!='\0' && *s!=';' && *s!='\t' && *s!=' '){ val+=*s++; } if(comparecase(key,"Mode")==0){ setLanguage(val); } else if(key=="tab-width"){ setTabWidth(val.toInt()); } else if(key=="indent-tabs-mode"){ setTabMode(val=="nil"); } else if(key=="autowrap"){ setWrapMode(val!="nil"); } } return true; }
// Parse VIM modeline FXbool Modeline::parseVimModeline(const FXchar* s){ FXbool set=false; FXbool yes=true; FXString key; FXString val; while(*s!='\0' && !(*s==':' && set)){ while(*s==':' || *s=='\t' || *s==' ') s++; if(*s=='\0') break; if(*s=='s' && *(s+1)=='e' && *(s+1)==' '){ s+=3; set=true; } else if(*s=='s' && *(s+1)=='e' && *(s+2)=='t' && *(s+3)==' '){ s+=4; set=true; } yes=true; if(*s=='n' && *(s+1)=='o'){ s+=2; yes=false; } key=FXString::null; val=FXString::null; while(*s!='\0' && *s!=':' && *s!='=' && *s!='\t' && *s!=' '){ key+=*s++; } if(*s=='='){ s++; while(*s!='\0' && *s!=':' && *s!='\t' && *s!=' '){ val+=*s++; } } if(key=="ft" || key=="filetype"){ setLanguage(val); } else if(key=="et" || key=="expandtab"){ setTabMode(yes); } else if(key=="wrap"){ setWrapMode(yes); } else if(key=="ai"){ setAutoIndent(yes); } else if(key=="ts" || key=="tabstop"){ setTabWidth(val.toInt()); } else if(key=="textwidth"){ setWrapWidth(val.toInt()); } } return true; }
// Parse Adie modelines FXbool Modeline::parseAdieModeline(const FXchar* s){ FXString key; FXString val; while(*s!='\0' && *s!=':'){ key=FXString::null; val=FXString::null; while(*s=='\t' || *s==' ') s++; if(*s=='\0') break; while(*s!='\0' && *s!=':' && *s!='=' && *s!='\t' && *s!=' '){ key+=*s++; } while(*s=='\t' || *s==' ') s++; if(*s=='\0') break; if(*s!='=') continue; s++; while(*s=='\t' || *s==' ') s++; if(*s=='\0') break; while(*s!='\0' && *s!=':' && *s!='\t' && *s!=' '){ val+=*s++; } if(key=="la"){ setLanguage(val); } else if(key=="ts"){ setTabWidth(val.toInt()); } else if(key=="ww"){ setWrapWidth(val.toInt()); } else if(key=="et"){ setTabMode(val!="0"); } else if(key=="wr"){ setWrapMode(val!="0"); } else if(key=="ai"){ setAutoIndent(val!="0"); } } return true; }