123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875 |
- /*
- ktigcc - TIGCC IDE for KDE
- Copyright (C) 2004-2006 Kevin Kofler
- Copyright (C) 2006 Joey Adams
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
- #include <cstdio>
- #include <cstdlib>
- #include <unistd.h>
- #include <sys/stat.h>
- #include <sys/dir.h>
- #include <kapplication.h>
- #include <kcmdlineargs.h>
- #include <kaboutdata.h>
- #include <qtextcodec.h>
- #include <qcolor.h>
- #include <qfont.h>
- #include <qdom.h>
- #include <q3cstring.h>
- #include <qdir.h>
- #include <qpair.h>
- //Added by qt3to4:
- #include <Q3ValueList>
- #include <kconfig.h>
- #include "ktigcc.h"
- #include "preferences.h"
- #include "preferencesdlg.h"
- #include "tpr.h"
- // versions of the syntax highlighting description file:
- // 1.00 = KTIGCC 20060807 Beta
- // 1.01 = current
- #define CURRENT_SYNFILE_VERSION "1.01"
- TIGCCPrefs preferences;
- static void genAllCaseVariants(QString keyword, unsigned pos,
- QStringList &stringList)
- {
- // WARNING: Exponential complexity in the keyword length. Yuck!
- // Blame Kate's lack of flexibility.
- // Also note that this just LOOKS like a functional recursion, there ARE side
- // effects.
- QChar c=keyword[pos];
- if (c.isNull())
- stringList.append(keyword);
- else {
- QChar upper=c.upper();
- QChar lower=c.lower();
- if (lower==upper)
- genAllCaseVariants(keyword,pos+1,stringList);
- else {
- keyword[pos]=upper;
- genAllCaseVariants(keyword,pos+1,stringList);
- keyword[pos]=lower;
- genAllCaseVariants(keyword,pos+1,stringList);
- keyword[pos]=c;
- }
- }
- }
- static void writeSyntaxXML(const Syn_SettingsForDoc &synprefs,
- const QString &name, const QString &internalName)
- {
- // Create XML document.
- QDomDocument doc("language");
- QDomElement root=doc.createElement("language");
- doc.appendChild(root);
- // Work around bad interfaces...
- #define ADD_ATTR(node,aname,aval) do { \
- QDomAttr newattr=doc.createAttribute((aname)); \
- newattr.setValue((aval)); \
- (node).setAttributeNode(newattr); \
- } while(0)
- #define ADD_TEXT(node,text) do { \
- QDomText newtext=doc.createTextNode((text)); \
- (node).appendChild(newtext); \
- } while(0)
- #define CHILD_NODE(child,node,chname) \
- QDomElement child=doc.createElement((chname));\
- (node).appendChild(child)
- bool allWordListsCaseInsensitive=TRUE;
- for (Q3ValueList<Syn_WordList>::ConstIterator it=synprefs.wordLists.begin();
- it!=synprefs.wordLists.end(); ++it) {
- const Syn_WordList &wordList=*it;
- if (wordList.caseSensitive) allWordListsCaseInsensitive=FALSE;
- }
- ADD_ATTR(root,"name","TIGCC "+name);
- ADD_ATTR(root,"section","KTIGCC");
- ADD_ATTR(root,"extensions","");
- ADD_ATTR(root,"version",CURRENT_SYNFILE_VERSION);
- ADD_ATTR(root,"kateversion","2.5");
- ADD_ATTR(root,"author","KTIGCC (autogenerated)");
- ADD_ATTR(root,"license","GPL");
- CHILD_NODE(highlighting,root,"highlighting");
- CHILD_NODE(general,root,"general");
- for (Q3ValueList<Syn_WordList>::ConstIterator it=synprefs.wordLists.begin();
- it!=synprefs.wordLists.end(); ++it) {
- const Syn_WordList &wordList=*it;
- CHILD_NODE(list,highlighting,"list");
- ADD_ATTR(list,"name",wordList.name);
- QStringList stringList;
- if (wordList.caseSensitive || allWordListsCaseInsensitive)
- stringList=wordList.list;
- else {
- // This is really ugly. Why can't Kate allow me to specify
- // case-sensitivity per word list?
- for (QStringList::ConstIterator it=wordList.list.begin();
- it!=wordList.list.end(); ++it) {
- const QString &keyword=*it;
- // This is bad, but I need to cap time, memory and disk space
- // requirements somewhere.
- if (keyword.length()<=10)
- genAllCaseVariants(keyword,0,stringList);
- else
- stringList.append(keyword);
- }
- }
- for (QStringList::ConstIterator it=stringList.begin(); it!=stringList.end();
- ++it) {
- const QString &keyword=*it;
- CHILD_NODE(item,list,"item");
- ADD_TEXT(item,keyword);
- }
- }
- CHILD_NODE(contexts,highlighting,"contexts");
- CHILD_NODE(defaultContext,contexts,"context");
- ADD_ATTR(defaultContext,"name","Default");
- ADD_ATTR(defaultContext,"attribute","Normal");
- ADD_ATTR(defaultContext,"lineEndContext","#stay");
- for (Q3ValueList<Syn_CustomStyle>::ConstIterator it=synprefs.customStyles.begin();
- it!=synprefs.customStyles.end(); ++it) {
- const Syn_CustomStyle &customStyle=*it;
- switch (customStyle.beginning.length()) {
- case 0: // Ignore these ones altogether.
- break;
- case 1:
- {
- CHILD_NODE(detectCustomStyle,defaultContext,"DetectChar");
- ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
- ADD_ATTR(detectCustomStyle,"context",customStyle.name);
- if (customStyle.lineStartOnly)
- ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
- ADD_ATTR(detectCustomStyle,"char",customStyle.beginning.left(1));
- }
- break;
- case 2:
- {
- CHILD_NODE(detectCustomStyle,defaultContext,"Detect2Chars");
- ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
- ADD_ATTR(detectCustomStyle,"context",customStyle.name);
- if (customStyle.lineStartOnly)
- ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
- ADD_ATTR(detectCustomStyle,"char",customStyle.beginning.left(1));
- ADD_ATTR(detectCustomStyle,"char1",customStyle.beginning.mid(1,1));
- }
- break;
- default:
- {
- CHILD_NODE(detectCustomStyle,defaultContext,"StringDetect");
- ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
- ADD_ATTR(detectCustomStyle,"context",customStyle.name);
- if (customStyle.lineStartOnly)
- ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
- ADD_ATTR(detectCustomStyle,"String",customStyle.beginning);
- }
- break;
- }
- }
- for (Q3ValueList<Syn_WordList>::ConstIterator it=synprefs.wordLists.begin();
- it!=synprefs.wordLists.end(); ++it) {
- const Syn_WordList &wordList=*it;
- CHILD_NODE(detectWordList,defaultContext,"keyword");
- ADD_ATTR(detectWordList,"attribute",wordList.name);
- ADD_ATTR(detectWordList,"context","#stay");
- ADD_ATTR(detectWordList,"String",wordList.name);
- }
- CHILD_NODE(numFloat,defaultContext,"Float");
- ADD_ATTR(numFloat,"attribute","Number");
- ADD_ATTR(numFloat,"context","#stay");
- CHILD_NODE(numFloatSuffix,numFloat,"AnyChar");
- ADD_ATTR(numFloatSuffix,"String","fF");
- ADD_ATTR(numFloatSuffix,"attribute","Number");
- ADD_ATTR(numFloatSuffix,"context","#stay");
- CHILD_NODE(numInt,defaultContext,"RegExpr");
- ADD_ATTR(numInt,"String","\\b\\d\\w*");
- ADD_ATTR(numInt,"attribute","Number");
- ADD_ATTR(numInt,"context","#stay");
- CHILD_NODE(numHex,defaultContext,"RegExpr");
- ADD_ATTR(numHex,"String","\\$\\w+");
- ADD_ATTR(numHex,"attribute","Number");
- ADD_ATTR(numHex,"context","#stay");
- CHILD_NODE(symbols,defaultContext,"AnyChar");
- ADD_ATTR(symbols,"String","<{[)]}>;:,.=+-*/\\|\"\'!?&%#@^~");
- ADD_ATTR(symbols,"attribute","Symbol");
- ADD_ATTR(symbols,"context","#stay");
- unsigned numParenthesisColors=synprefs.parenthesisColors.count();
- CHILD_NODE(parenOpen,defaultContext,"DetectChar");
- ADD_ATTR(parenOpen,"char","(");
- if (numParenthesisColors) {
- ADD_ATTR(parenOpen,"attribute","Paren0");
- ADD_ATTR(parenOpen,"context","Paren0");
- } else {
- ADD_ATTR(parenOpen,"attribute","Symbol");
- ADD_ATTR(parenOpen,"context","#stay");
- }
- for (unsigned i=0; i<numParenthesisColors; i++) {
- CHILD_NODE(pareniContext,contexts,"context");
- QString parenp1="Paren%1";
- QString pareni=parenp1.arg(i);
- QString pareni1=parenp1.arg((i+1==numParenthesisColors)?0:(i+1));
- ADD_ATTR(pareniContext,"name",pareni);
- ADD_ATTR(pareniContext,"attribute","Normal");
- ADD_ATTR(pareniContext,"lineEndContext","#stay");
- CHILD_NODE(push,pareniContext,"DetectChar");
- ADD_ATTR(push,"char","(");
- ADD_ATTR(push,"attribute",pareni1);
- ADD_ATTR(push,"context",pareni1);
- CHILD_NODE(pop,pareniContext,"DetectChar");
- ADD_ATTR(pop,"char",")");
- ADD_ATTR(pop,"attribute",pareni);
- ADD_ATTR(pop,"context","#pop");
- CHILD_NODE(includeRules,pareniContext,"IncludeRules");
- ADD_ATTR(includeRules,"context","Default");
- }
- for (Q3ValueList<Syn_CustomStyle>::ConstIterator it=synprefs.customStyles.begin();
- it!=synprefs.customStyles.end(); ++it) {
- const Syn_CustomStyle &customStyle=*it;
- bool endsWithNewline=(customStyle.ending=="\n");
- bool endsWithSpace=(customStyle.ending==" ");
- bool noIgnoreEndingAfter=customStyle.ignoreEndingAfter.isNull();
- bool needIgnoreContext=!endsWithNewline && !noIgnoreEndingAfter;
- CHILD_NODE(customStyleContext,contexts,"context");
- ADD_ATTR(customStyleContext,"name",customStyle.name);
- ADD_ATTR(customStyleContext,"attribute",customStyle.name);
- ADD_ATTR(customStyleContext,"lineEndContext",(endsWithNewline||
- (endsWithSpace&&noIgnoreEndingAfter))?"#pop":"#stay");
- if (endsWithNewline && customStyle.ignoreEndingAfter=="\\") {
- CHILD_NODE(lineContinue,customStyleContext,"LineContinue");
- ADD_ATTR(lineContinue,"attribute",customStyle.name);
- ADD_ATTR(lineContinue,"context","#stay");
- } else if (needIgnoreContext) {
- CHILD_NODE(detectCustomStyle,customStyleContext,"DetectChar");
- ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
- ADD_ATTR(detectCustomStyle,"context",customStyle.name+" Ignore");
- ADD_ATTR(detectCustomStyle,"char",QString(customStyle.ignoreEndingAfter));
- if (customStyle.ignoreEndingAfter=='\\') {
- CHILD_NODE(detectCustomStyleTrigraph,customStyleContext,"StringDetect");
- ADD_ATTR(detectCustomStyleTrigraph,"attribute",customStyle.name);
- ADD_ATTR(detectCustomStyleTrigraph,"context",customStyle.name+" Ignore");
- ADD_ATTR(detectCustomStyleTrigraph,"String","?""?""/");
- }
- }
- if (endsWithSpace) {
- CHILD_NODE(detectCustomStyle,customStyleContext,"DetectSpaces");
- ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
- ADD_ATTR(detectCustomStyle,"context","#pop");
- } else if (!endsWithNewline) {
- switch (customStyle.ending.length()) {
- case 0: // No ending...
- break;
- case 1:
- {
- CHILD_NODE(detectCustomStyle,customStyleContext,"DetectChar");
- ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
- ADD_ATTR(detectCustomStyle,"context","#pop");
- ADD_ATTR(detectCustomStyle,"char",customStyle.ending.left(1));
- }
- break;
- case 2:
- {
- CHILD_NODE(detectCustomStyle,customStyleContext,"Detect2Chars");
- ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
- ADD_ATTR(detectCustomStyle,"context","#pop");
- ADD_ATTR(detectCustomStyle,"char",customStyle.ending.left(1));
- ADD_ATTR(detectCustomStyle,"char1",customStyle.ending.mid(1,1));
- }
- break;
- default:
- {
- CHILD_NODE(detectCustomStyle,customStyleContext,"StringDetect");
- ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
- ADD_ATTR(detectCustomStyle,"context","#pop");
- ADD_ATTR(detectCustomStyle,"String",customStyle.ending);
- }
- break;
- }
- }
- if (customStyle.switchable) {
- for (Q3ValueList<Syn_CustomStyle>::ConstIterator it2=synprefs.customStyles.begin();
- it2!=synprefs.customStyles.end(); ++it2) {
- if (it2==it) continue;
- const Syn_CustomStyle &otherCustomStyle=*it2;
- if (otherCustomStyle.ending==customStyle.ending) {
- switch (otherCustomStyle.beginning.length()) {
- case 0: // Ignore these ones altogether.
- break;
- case 1:
- {
- CHILD_NODE(detectCustomStyle,customStyleContext,"DetectChar");
- ADD_ATTR(detectCustomStyle,"attribute",otherCustomStyle.name);
- ADD_ATTR(detectCustomStyle,"context","#pop");
- if (otherCustomStyle.lineStartOnly)
- ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
- ADD_ATTR(detectCustomStyle,"char",otherCustomStyle.beginning.left(1));
- ADD_ATTR(detectCustomStyle,"lookAhead","true");
- }
- break;
- case 2:
- {
- CHILD_NODE(detectCustomStyle,customStyleContext,"Detect2Chars");
- ADD_ATTR(detectCustomStyle,"attribute",otherCustomStyle.name);
- ADD_ATTR(detectCustomStyle,"context","#pop");
- if (otherCustomStyle.lineStartOnly)
- ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
- ADD_ATTR(detectCustomStyle,"char",otherCustomStyle.beginning.left(1));
- ADD_ATTR(detectCustomStyle,"char1",otherCustomStyle.beginning.mid(1,1));
- ADD_ATTR(detectCustomStyle,"lookAhead","true");
- }
- break;
- default:
- {
- CHILD_NODE(detectCustomStyle,customStyleContext,"StringDetect");
- ADD_ATTR(detectCustomStyle,"attribute",otherCustomStyle.name);
- ADD_ATTR(detectCustomStyle,"context","#pop");
- if (otherCustomStyle.lineStartOnly)
- ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
- ADD_ATTR(detectCustomStyle,"String",otherCustomStyle.beginning);
- ADD_ATTR(detectCustomStyle,"lookAhead","true");
- }
- break;
- }
- }
- }
- }
- if (needIgnoreContext) {
- CHILD_NODE(customStyleIgnoreContext,contexts,"context");
- ADD_ATTR(customStyleIgnoreContext,"name",customStyle.name+" Ignore");
- ADD_ATTR(customStyleIgnoreContext,"attribute",customStyle.name);
- ADD_ATTR(customStyleIgnoreContext,"lineEndContext","#pop");
- CHILD_NODE(pop,customStyleIgnoreContext,"RegExpr");
- ADD_ATTR(pop,"attribute",customStyle.name);
- ADD_ATTR(pop,"context","#pop");
- ADD_ATTR(pop,"String",".");
- }
- }
- CHILD_NODE(itemDatas,highlighting,"itemDatas");
- #define DEF_ITEM_DATA(idname,color,style) do { \
- CHILD_NODE(itemData,itemDatas,"itemData");\
- ADD_ATTR(itemData,"name",(idname));\
- ADD_ATTR(itemData,"defStyleNum","dsNormal");\
- QColor idcolor=(color);\
- if (idcolor.isValid())\
- ADD_ATTR(itemData,"color",idcolor.name());\
- Syn_Style idstyle=(style);\
- if (idstyle&SYNS_CUSTOM) {\
- ADD_ATTR(itemData,"bold",(idstyle&SYNS_BOLD)?"1":"0");\
- ADD_ATTR(itemData,"underline",(idstyle&SYNS_UNDERLINE)?"1":"0");\
- ADD_ATTR(itemData,"italic",(idstyle&SYNS_ITALIC)?"1":"0");\
- ADD_ATTR(itemData,"strikeOut",(idstyle&SYNS_STRIKEOUT)?"1":"0");\
- }\
- } while(0)
- DEF_ITEM_DATA("Normal",QColor(),0);
- DEF_ITEM_DATA("Number",synprefs.numberColor,synprefs.numberStyle);
- DEF_ITEM_DATA("Symbol",synprefs.symbolColor,synprefs.symbolStyle);
- unsigned i=0;
- for (Q3ValueList<QColor>::ConstIterator it=synprefs.parenthesisColors.begin();
- it!=synprefs.parenthesisColors.end(); ++it, i++) {
- DEF_ITEM_DATA(QString("Paren%1").arg(i),*it,synprefs.parenthesisStyle);
- }
- for (Q3ValueList<Syn_CustomStyle>::ConstIterator it=synprefs.customStyles.begin();
- it!=synprefs.customStyles.end(); ++it) {
- const Syn_CustomStyle &customStyle=*it;
- DEF_ITEM_DATA(customStyle.name,customStyle.color,customStyle.style);
- }
- for (Q3ValueList<Syn_WordList>::ConstIterator it=synprefs.wordLists.begin();
- it!=synprefs.wordLists.end(); ++it) {
- const Syn_WordList &wordList=*it;
- DEF_ITEM_DATA(wordList.name,wordList.color,wordList.style);
- }
- #undef DEF_ITEM_DATA
- CHILD_NODE(keywords,general,"keywords");
- ADD_ATTR(keywords,"casesensitive",allWordListsCaseInsensitive?"0":"1");
- ADD_ATTR(keywords,"additionalDeliminator","\'\"#@");
- CHILD_NODE(indentation,general,"indentation");
- ADD_ATTR(indentation,"mode","normal");
- #undef ADD_ATTR
- #undef ADD_TEXT
- #undef CHILD_NODE
- // Write it to disk.
- QString xmlFileName=QString("%1/.kde/share/apps/katepart/syntax/ktigcc%2.xml")
- .arg(QDir::homeDirPath()).arg(internalName);
- mkdir_multi(xmlFileName);
- std::FILE *f=std::fopen(xmlFileName,"w");
- if (f) {
- if (fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- "<!-- Syntax highlighting description autogenerated by KTIGCC.\n"
- " All changes to this file will be lost! -->\n",f)<0) {
- fclose(f);
- return;
- }
- (void) fputs(doc.toCString(2),f);
- fclose(f);
- }
- }
- static void updateSyntaxXML(void)
- {
- writeSyntaxXML(preferences.synC,"C","c");
- writeSyntaxXML(preferences.synS,"GNU As","s");
- writeSyntaxXML(preferences.synAsm,"A68k","asm");
- writeSyntaxXML(preferences.synQll,"Quill","qll");
- }
- // True if version1 is newer than version2.
- static bool isNewerVersion(const QString &version1, const QString &version2)
- {
- QStringList vl1=QStringList::split('.',version1);
- QStringList vl2=QStringList::split('.',version2);
- QStringList::Iterator it1=vl1.begin(), it2=vl2.begin();
- for (; it1!=vl1.end() && it2!=vl2.end(); ++it1, ++it2) {
- bool ok1, ok2;
- unsigned v1=(*it1).toUInt(&ok1), v2=(*it2).toUInt(&ok2);
- if (!ok1 || !ok2) return TRUE;
- if (v1>v2) return TRUE;
- else if (v1<v2) return FALSE;
- }
- return (it1!=vl1.end());
- }
- static bool checkSynHighlightVersion(const QString &internalName)
- {
- QString xmlFileName=QString("%1/.kde/share/apps/katepart/syntax/ktigcc%2.xml")
- .arg(QDir::homeDirPath()).arg(internalName);
- QDomDocument doc("language");
- QFile file(xmlFileName);
- if (!file.open(QIODevice::ReadOnly))
- return FALSE;
- if (!doc.setContent(&file)) {
- file.close();
- return FALSE;
- }
- file.close();
- QDomNode language=doc.elementsByTagName("language").item(0);
- if (language.isNull() || language.nodeType()!=QDomNode::ElementNode)
- return FALSE;
- QDomAttr version=language.toElement().attributeNode("version");
- if (version.isNull())
- return FALSE;
- QString versionNumber=version.value();
- return !isNewerVersion(CURRENT_SYNFILE_VERSION,versionNumber);
- }
- static void checkSynHighlightVersions(void)
- {
- if (!checkSynHighlightVersion("c"))
- writeSyntaxXML(preferences.synC,"C","c");
- if (!checkSynHighlightVersion("s"))
- writeSyntaxXML(preferences.synS,"GNU As","s");
- if (!checkSynHighlightVersion("asm"))
- writeSyntaxXML(preferences.synAsm,"A68k","asm");
- if (!checkSynHighlightVersion("qll"))
- writeSyntaxXML(preferences.synQll,"Quill","qll");
- }
- static bool loadSyntaxPreference(Syn_SettingsForDoc &synprefs, const QString &group)
- {
- pconfig->setGroup(group+" Syntax Highlighting");
- synprefs.enabled=pconfig->readBoolEntry("Enabled",true);
- synprefs.numberColor=pconfig->readColorEntry("Number Color");
- if (!synprefs.numberColor.isValid()) return FALSE;
- synprefs.symbolColor=pconfig->readColorEntry("Symbol Color");
- if (!synprefs.symbolColor.isValid()) return FALSE;
- unsigned numParenthesisColors=pconfig->readUnsignedNumEntry("Num Parenthesis Colors");
- for (unsigned i=0; i<numParenthesisColors; i++) {
- QColor parenthesisColor=pconfig->readColorEntry(QString("Parenthesis Color %1").arg(i));
- if (!parenthesisColor.isValid()) return FALSE;
- synprefs.parenthesisColors.append(parenthesisColor);
- }
- synprefs.numberStyle=pconfig->readUnsignedNumEntry("Number Style");
- synprefs.symbolStyle=pconfig->readUnsignedNumEntry("Symbol Style");
- synprefs.parenthesisStyle=pconfig->readUnsignedNumEntry("Parenthesis Style");
- unsigned numCustomStyles=pconfig->readUnsignedNumEntry("Num Custom Styles");
- for (unsigned i=0; i<numCustomStyles; i++) {
- Syn_CustomStyle customStyle;
- customStyle.name=pconfig->readEntry(QString("Custom Style %1 Name").arg(i),QString("Style %1").arg(i));
- customStyle.beginning=pconfig->readEntry(QString("Custom Style %1 Beginning").arg(i));
- customStyle.ending=pconfig->readEntry(QString("Custom Style %1 Ending").arg(i));
- customStyle.ignoreEndingAfter=pconfig->readEntry(QString("Custom Style %1 Ignore Ending After").arg(i))[0];
- customStyle.switchable=pconfig->readBoolEntry(QString("Custom Style %1 Switchable").arg(i));
- customStyle.lineStartOnly=pconfig->readBoolEntry(QString("Custom Style %1 Line Start Only").arg(i));
- customStyle.color=pconfig->readColorEntry(QString("Custom Style %1 Color").arg(i));
- customStyle.style=pconfig->readUnsignedNumEntry(QString("Custom Style %1 Style").arg(i));
- synprefs.customStyles.append(customStyle);
- }
- unsigned numWordLists=pconfig->readUnsignedNumEntry("Num Word Lists");
- for (unsigned i=0; i<numWordLists; i++) {
- Syn_WordList wordList;
- wordList.name=pconfig->readEntry(QString("Word List %1 Name").arg(i),QString("Word List %1").arg(i));
- wordList.list=pconfig->readListEntry(QString("Word List %1 List").arg(i));
- wordList.color=pconfig->readColorEntry(QString("Word List %1 Color").arg(i));
- wordList.style=pconfig->readUnsignedNumEntry(QString("Word List %1 Style").arg(i));
- wordList.caseSensitive=pconfig->readBoolEntry(QString("Word List %1 Case Sensitive").arg(i));
- synprefs.wordLists.append(wordList);
- }
- return TRUE;
- }
- static bool loadSyntaxPreferences(void)
- {
- return loadSyntaxPreference(preferences.synC,"C")
- && loadSyntaxPreference(preferences.synS,"GNU As")
- && loadSyntaxPreference(preferences.synAsm,"A68k")
- && loadSyntaxPreference(preferences.synQll,"Quill");
- }
- static void saveSyntaxPreference(const Syn_SettingsForDoc &synprefs, const QString &group)
- {
- unsigned i;
- pconfig->setGroup(group+" Syntax Highlighting");
- pconfig->writeEntry("Enabled",synprefs.enabled);
- pconfig->writeEntry("Number Color",synprefs.numberColor);
- pconfig->writeEntry("Symbol Color",synprefs.symbolColor);
- for (Q3ValueList<QColor>::ConstIterator it=(i=0,synprefs.parenthesisColors.begin());
- it!=synprefs.parenthesisColors.end(); ++it, i++) {
- pconfig->writeEntry(QString("Parenthesis Color %1").arg(i),*it);
- }
- pconfig->writeEntry("Num Parenthesis Colors",i);
- pconfig->writeEntry("Number Style",(unsigned)synprefs.numberStyle);
- pconfig->writeEntry("Symbol Style",(unsigned)synprefs.symbolStyle);
- pconfig->writeEntry("Parenthesis Style",(unsigned)synprefs.parenthesisStyle);
- for (Q3ValueList<Syn_CustomStyle>::ConstIterator it=(i=0,synprefs.customStyles.begin());
- it!=synprefs.customStyles.end(); ++it, i++) {
- const Syn_CustomStyle &customStyle=*it;
- pconfig->writeEntry(QString("Custom Style %1 Name").arg(i),customStyle.name);
- pconfig->writeEntry(QString("Custom Style %1 Beginning").arg(i),customStyle.beginning);
- pconfig->writeEntry(QString("Custom Style %1 Ending").arg(i),customStyle.ending);
- pconfig->writeEntry(QString("Custom Style %1 Ignore Ending After").arg(i),QString(customStyle.ignoreEndingAfter));
- pconfig->writeEntry(QString("Custom Style %1 Switchable").arg(i),customStyle.switchable);
- pconfig->writeEntry(QString("Custom Style %1 Line Start Only").arg(i),customStyle.lineStartOnly);
- pconfig->writeEntry(QString("Custom Style %1 Color").arg(i),customStyle.color);
- pconfig->writeEntry(QString("Custom Style %1 Style").arg(i),(unsigned)customStyle.style);
- }
- pconfig->writeEntry("Num Custom Styles",i);
- for (Q3ValueList<Syn_WordList>::ConstIterator it=(i=0,synprefs.wordLists.begin());
- it!=synprefs.wordLists.end(); ++it, i++) {
- const Syn_WordList &wordList=*it;
- pconfig->writeEntry(QString("Word List %1 Name").arg(i),wordList.name);
- pconfig->writeEntry(QString("Word List %1 List").arg(i),wordList.list);
- pconfig->writeEntry(QString("Word List %1 Color").arg(i),wordList.color);
- pconfig->writeEntry(QString("Word List %1 Style").arg(i),(unsigned)wordList.style);
- pconfig->writeEntry(QString("Word List %1 Case Sensitive").arg(i),wordList.caseSensitive);
- }
- pconfig->writeEntry("Num Word Lists",i);
- }
- static void saveSyntaxPreferences(void)
- {
- saveSyntaxPreference(preferences.synC,"C");
- saveSyntaxPreference(preferences.synS,"GNU As");
- saveSyntaxPreference(preferences.synAsm,"A68k");
- saveSyntaxPreference(preferences.synQll,"Quill");
- updateSyntaxXML();
- // Save to disk
- pconfig->sync();
- }
- void resetSyntaxPreference(Syn_SettingsForDoc *syn)
- {
- bool synIsC=(syn==&(preferences.synC) || syn==&(preferences.tempSynC));
- bool synIsS=(syn==&(preferences.synS) || syn==&(preferences.tempSynS));
- bool synIsAsm=(syn==&(preferences.synAsm) || syn==&(preferences.tempSynAsm));
- bool synIsQll=(syn==&(preferences.synQll) || syn==&(preferences.tempSynQll));
- syn->enabled=true;
- syn->numberColor=(synIsQll?QColor(128,64,64):QColor(128,0,0));
- syn->symbolColor=QColor(128,128,0);
- syn->parenthesisColors.clear();
- if (synIsQll)
- syn->parenthesisColors << QColor(0,0,0) << QColor(255,0,128);
- else
- syn->parenthesisColors << QColor(128,0,128) << QColor(0,128,192)
- << QColor(255,128,128) << QColor(0,128,0);
- syn->numberStyle=0;
- syn->symbolStyle=SYNS_CUSTOM|SYNS_BOLD;
- syn->parenthesisStyle=SYNS_CUSTOM|SYNS_BOLD;
-
- Syn_CustomStyle Comment_Area;
- Comment_Area.name="Comment Area";
- Comment_Area.beginning="/*";
- Comment_Area.ending="*/";
- Comment_Area.ignoreEndingAfter=0;
- Comment_Area.switchable=false;
- Comment_Area.lineStartOnly=false;
- Comment_Area.color=QColor(0,128,0);
- Comment_Area.style=SYNS_CUSTOM|SYNS_ITALIC;
- Syn_CustomStyle Comment_Line;
- Comment_Line.name="Comment Line";
- Comment_Line.beginning="//";
- Comment_Line.ending="\n";
- Comment_Line.ignoreEndingAfter=0;
- Comment_Line.switchable=false;
- Comment_Line.lineStartOnly=false;
- Comment_Line.color=QColor(0,128,0);
- Comment_Line.style=SYNS_CUSTOM|SYNS_ITALIC;
- Syn_CustomStyle SCS_String;
- SCS_String.name="String";
- SCS_String.beginning="\"";
- SCS_String.ending="\"";
- SCS_String.ignoreEndingAfter='\\';
- SCS_String.switchable=false;
- SCS_String.lineStartOnly=false;
- SCS_String.color=QColor(128,0,0);
- SCS_String.style=0;
- Syn_CustomStyle Character;
- Character.name="Character";
- Character.beginning="\'";
- Character.ending="\'";
- Character.ignoreEndingAfter='\\';
- Character.switchable=false;
- Character.lineStartOnly=false;
- Character.color=QColor(128,0,0);
- Character.style=0;
- Syn_CustomStyle Preprocessor_Directive;
- Preprocessor_Directive.name="Preprocessor Directive";
- Preprocessor_Directive.beginning="#";
- Preprocessor_Directive.ending=" ";
- Preprocessor_Directive.ignoreEndingAfter=0;
- Preprocessor_Directive.switchable=false;
- Preprocessor_Directive.lineStartOnly=false;
- Preprocessor_Directive.color=QColor(0,128,128);
- Preprocessor_Directive.style=SYNS_CUSTOM|SYNS_BOLD;
- Syn_CustomStyle Comment_Line_Pipe;
- Comment_Line_Pipe.name="Comment Line (|)";
- Comment_Line_Pipe.beginning="|";
- Comment_Line_Pipe.ending="\n";
- Comment_Line_Pipe.ignoreEndingAfter=0;
- Comment_Line_Pipe.switchable=false;
- Comment_Line_Pipe.lineStartOnly=false;
- Comment_Line_Pipe.color=QColor(0,128,0);
- Comment_Line_Pipe.style=SYNS_CUSTOM|SYNS_ITALIC;
- Syn_CustomStyle Comment_Line_Pound;
- Comment_Line_Pound.name="Comment Line (#)";
- Comment_Line_Pound.beginning="#";
- Comment_Line_Pound.ending="\n";
- Comment_Line_Pound.ignoreEndingAfter=0;
- Comment_Line_Pound.switchable=false;
- Comment_Line_Pound.lineStartOnly=true;
- Comment_Line_Pound.color=QColor(0,128,0);
- Comment_Line_Pound.style=SYNS_CUSTOM|SYNS_ITALIC;
- Syn_CustomStyle Comment_Line_Semicolon;
- Comment_Line_Semicolon.name="Comment";
- Comment_Line_Semicolon.beginning=";";
- Comment_Line_Semicolon.ending="\n";
- Comment_Line_Semicolon.ignoreEndingAfter=0;
- Comment_Line_Semicolon.switchable=false;
- Comment_Line_Semicolon.lineStartOnly=false;
- Comment_Line_Semicolon.color=QColor(0,128,0);
- Comment_Line_Semicolon.style=SYNS_CUSTOM|SYNS_ITALIC;
- Syn_CustomStyle String_DoubleQuoted;
- String_DoubleQuoted.name="String (double-quoted)";
- String_DoubleQuoted.beginning="\"";
- String_DoubleQuoted.ending="\"";
- String_DoubleQuoted.ignoreEndingAfter=0;
- String_DoubleQuoted.switchable=false;
- String_DoubleQuoted.lineStartOnly=false;
- String_DoubleQuoted.color=QColor(128,0,0);
- String_DoubleQuoted.style=0;
- Syn_CustomStyle String_SingleQuoted;
- String_SingleQuoted.name="String (single-quoted)";
- String_SingleQuoted.beginning="\'";
- String_SingleQuoted.ending="\'";
- String_SingleQuoted.ignoreEndingAfter=0;
- String_SingleQuoted.switchable=false;
- String_SingleQuoted.lineStartOnly=false;
- String_SingleQuoted.color=QColor(128,0,0);
- String_SingleQuoted.style=0;
- Syn_CustomStyle Compiler_Directive;
- Compiler_Directive.name="Compiler Directive";
- Compiler_Directive.beginning="#";
- Compiler_Directive.ending="\n";
- Compiler_Directive.ignoreEndingAfter='\\';
- Compiler_Directive.switchable=true;
- Compiler_Directive.lineStartOnly=false;
- Compiler_Directive.color=QColor(0,128,128);
- Compiler_Directive.style=SYNS_CUSTOM|SYNS_BOLD;
- syn->customStyles.clear();
- if (synIsC)
- syn->customStyles << Comment_Area << Comment_Line << SCS_String << Character << Preprocessor_Directive;
- else if (synIsS)
- syn->customStyles << Comment_Area << Comment_Line_Pipe << Comment_Line_Pound << SCS_String << Character;
- else if (synIsAsm)
- syn->customStyles << Comment_Line_Semicolon << String_DoubleQuoted << String_SingleQuoted;
- else if (synIsQll)
- syn->customStyles << Comment_Area << Comment_Line << SCS_String << Character << Compiler_Directive;
- Syn_WordList C_Keywords;
- C_Keywords.name="C Keywords";
- C_Keywords.list=QStringList::split('\n',
- "__alignof__\n"
- "__asm__\n"
- "__attribute__\n"
- "__complex__\n"
- "__const__\n"
- "__extension__\n"
- "__imag__\n"
- "__inline__\n"
- "__label__\n"
- "__real__\n"
- "__typeof__\n"
- "asm\n"
- "auto\n"
- "break\n"
- "case\n"
- "char\n"
- "const\n"
- "continue\n"
- "default\n"
- "do\n"
- "double\n"
- "else\n"
- "enum\n"
- "extern\n"
- "float\n"
- "for\n"
- "goto\n"
- "if\n"
- "inline\n"
- "int\n"
- "long\n"
- "register\n"
- "return\n"
- "short\n"
- "signed\n"
- "sizeof\n"
- "static\n"
- "struct\n"
- "switch\n"
- "typedef\n"
- "typeof\n"
- "union\n"
- "unsigned\n"
- "void\n"
- "volatile\n"
- "while\n");
- C_Keywords.color=QColor(0,0,255);
- C_Keywords.style=SYNS_CUSTOM|SYNS_BOLD;
- C_Keywords.caseSensitive=true;
- Syn_WordList Data_Movement;
- Data_Movement.name="Data Movement";
- Data_Movement.list= QStringList::split('\n',
- "EXG\n"
- "LEA\n"
- "LINK\n"
- "MOV\n"
- "MOVE\n"
- "MOVEA\n"
- "MOVEM\n"
- "MOVEP\n"
- "MOVEQ\n"
- "MOVM\n"
- "MOVP\n"
- "MOVQ\n"
- "PEA\n"
- "UNLK\n");
- Data_Movement.color=QColor(0,0,255);
- Data_Movement.style=0;
- Data_Movement.caseSensitive=false;
- Syn_WordList Integer_Arithmetic;
- Integer_Arithmetic.name="Integer Arithmetic";
- Integer_Arithmetic.list=QStringList::split('\n',
- "ADD\n"
- "ADDA\n"
- "ADDI\n"
- "ADDQ\n"
- "ADDX\n"
- "CLR\n"
- "CMP\n"
- "CMPA\n"
- "CMPI\n"
- "CMPM\n"
- "DIVS\n"
- "DIVU\n"
- "EXT\n"
- "MULS\n"
- "MULU\n"
- "NEG\n"
- "NEGX\n"
- "SUB\n"
- "SUBA\n"
- "SUBI\n"
- "SUBQ\n"
- "SUBX\n"
- "TAS\n");
- Integer_Arithmetic.color=QColor(0,0,255);
- Integer_Arithmetic.style=0;
- Integer_Arithmetic.caseSensitive=false;
- Syn_WordList Logical_Instructions;
- Logical_Instructions.name="Logical Instructions";
- Logical_Instructions.list=QStringList::split('\n',
- "AND\n"
- "ANDI\n"
- "EOR\n"
- "EORI\n"
- "NOT\n"
- "OR\n"
- "ORI\n");
- Logical_Instructions.color=QColor(0,0,255);
- Logical_Instructions.style=0;
- Logical_Instructions.caseSensitive=false;
- Syn_WordList ShiftRotation_Instructions;
- ShiftRotation_Instructions.name="Shift/Rotation Instructions";
- ShiftRotation_Instructions.list=QStringList::split('\n',
- "ASL\n"
- "ASR\n"
- "LSL\n"
- "LSR\n"
- "ROL\n"
- "ROR\n"
- "ROXL\n"
- "ROXR\n"
- "SWAP\n");
- ShiftRotation_Instructions.color=QColor(0,0,255);
- ShiftRotation_Instructions.style=0;
- ShiftRotation_Instructions.caseSensitive=false;
- Syn_WordList Bit_Manipulation;
- Bit_Manipulation.name="Bit Manipulation";
- Bit_Manipulation.list=QStringList::split('\n',
- "BCHG\n"
- "BCLR\n"
- "BSET\n"
- "BTST\n");
- Bit_Manipulation.color=QColor(0,0,255);
- Bit_Manipulation.style=0;
- Bit_Manipulation.caseSensitive=false;
- Syn_WordList Program_Control;
- Program_Control.name="Program Control";
- Program_Control.list= QStringList::split('\n',
- "BCC\n"
- "BCS\n"
- "BEQ\n"
- "BGE\n"
- "BGT\n"
- "BHI\n"
- "BLE\n"
- "BLS\n"
- "BLT\n"
- "BMI\n"
- "BNE\n"
- "BPL\n"
- "BRA\n"
- "BSR\n"
- "BVC\n"
- "BVS\n"
- "JBCC\n"
- "JBCS\n"
- "JBEQ\n"
- "JBGE\n"
- "JBGT\n"
- "JBHI\n"
- "JBLE\n"
- "JBLS\n"
- "JBLT\n"
- "JBMI\n"
- "JBNE\n"
- "JBPL\n"
- "JBRA\n"
- "JBSR\n"
- "JBVC\n"
- "JBVS\n"
- "JSR\n"
- "JRA\n"
- "JMP\n"
- "NOP\n"
- "RTR\n"
- "RTS\n"
- "SCC\n"
- "SCS\n"
- "SEQ\n"
- "SF\n"
- "SGE\n"
- "SGT\n"
- "SHI\n"
- "SLE\n"
- "SLS\n"
- "SLT\n"
- "SMI\n"
- "SNE\n"
- "SPL\n"
- "ST\n"
- "SVC\n"
- "SVS\n"
- "TST\n"
- "JHI\n"
- "JLS\n"
- "JCC\n"
- "JCS\n"
- "JNE\n"
- "JEQ\n"
- "JVC\n"
- "JVS\n"
- "JPL\n"
- "JMI\n"
- "JGE\n"
- "JLT\n"
- "JGT\n"
- "JLE\n"
- "DBHI\n"
- "DBLS\n"
- "DBCC\n"
- "DBCS\n"
- "DBNE\n"
- "DBEQ\n"
- "DBVC\n"
- "DBVS\n"
- "DBPL\n"
- "DBMI\n"
- "DBGE\n"
- "DBLT\n"
- "DBGT\n"
- "DBLE\n"
- "DBF\n"
- "DBRA\n"
- "DBT\n"
- "FJNE\n"
- "FJEQ\n"
- "FJGE\n"
- "FJLT\n"
- "FJGT\n"
- "FJLE\n"
- "FJF\n"
- "FJT\n"
- "FJGL\n"
- "FJGLE\n"
- "FJNGE\n"
- "FJNGL\n"
- "FJNGLE\n"
- "FJNGT\n"
- "FJNLE\n"
- "FJNLT\n"
- "FJOGE\n"
- "FJOGL\n"
- "FJOGT\n"
- "FJOLE\n"
- "FJOLT\n"
- "FJOR\n"
- "FJSEQ\n"
- "FJSF\n"
- "FJSNE\n"
- "FJST\n"
- "FJUEQ\n"
- "FJUGE\n"
- "FJUGT\n"
- "FJULE\n"
- "FJULT\n"
- "FJUN\n");
- Program_Control.color=QColor(0,0,255);
- Program_Control.style=0;
- Program_Control.caseSensitive=false;
- Syn_WordList System_Control;
- System_Control.name="System Control";
- System_Control.list=QStringList::split('\n',
- "ILLEGAL\n"
- "RTE\n"
- "TRAP\n");
- System_Control.color=QColor(0,0,255);
- System_Control.style=0;
- System_Control.caseSensitive=false;
- Syn_WordList SWL_Extensions;
- SWL_Extensions.name="Extensions";
- SWL_Extensions.list=QStringList::split('\n',
- "B\n"
- "L\n"
- "S\n"
- "W\n");
- SWL_Extensions.color=QColor(0,128,64);
- SWL_Extensions.style=0;
- SWL_Extensions.caseSensitive=false;
- Syn_WordList Assembler_Directives;
- Assembler_Directives.name="Assembler Directives";
- Assembler_Directives.list=QStringList::split('\n',
- "abort\n"
- "align\n"
- "altmacro\n"
- "ascii\n"
- "asciz\n"
- "balign\n"
- "balignw\n"
- "balignl\n"
- "byte\n"
- "comm\n"
- "data\n"
- "def\n"
- "dim\n"
- "double\n"
- "eject\n"
- "else\n"
- "end\n"
- "elseif\n"
- "endef\n"
- "endfunc\n"
- "endif\n"
- "endm\n"
- "endr\n"
- "equ\n"
- "equiv\n"
- "err\n"
- "even\n"
- "exitm\n"
- "extern\n"
- "fail\n"
- "file\n"
- "fill\n"
- "float\n"
- "func\n"
- "global\n"
- "globl\n"
- "hword\n"
- "ident\n"
- "if\n"
- "include\n"
- "incbin\n"
- "int\n"
- "irp\n"
- "irpc\n"
- "lcomm\n"
- "lflags\n"
- "line\n"
- "ln\n"
- "list\n"
- "long\n"
- "macro\n"
- "mri\n"
- "noaltmacro\n"
- "nolist\n"
- "octa\n"
- "org\n"
- "p2align\n"
- "p2alignw\n"
- "p2alignl\n"
- "print\n"
- "psize\n"
- "purgem\n"
- "quad\n"
- "rept\n"
- "sbttl\n"
- "scl\n"
- "section\n"
- "set\n"
- "short\n"
- "single\n"
- "size\n"
- "sleb128\n"
- "skip\n"
- "space\n"
- "stabd\n"
- "stabn\n"
- "stabs\n"
- "string\n"
- "struct\n"
- "tag\n"
- "text\n"
- "title\n"
- "type\n"
- "uleb128\n"
- "val\n"
- "vtable_entry\n"
- "word\n"
- "xdef\n");
- Assembler_Directives.color=QColor(0,0,255);
- Assembler_Directives.style=SYNS_CUSTOM|SYNS_BOLD;
- Assembler_Directives.caseSensitive=true;
- Syn_WordList SWL_Registers;
- SWL_Registers.name="Registers";
- SWL_Registers.list= QStringList::split('\n',
- "a0\n"
- "a1\n"
- "a2\n"
- "a3\n"
- "a4\n"
- "a5\n"
- "a6\n"
- "a7\n"
- "d0\n"
- "d1\n"
- "d2\n"
- "d3\n"
- "d4\n"
- "d5\n"
- "d6\n"
- "d7\n"
- "fp\n"
- "pc\n"
- "sp\n"
- "sr\n");
- SWL_Registers.color=QColor(255,0,0);
- SWL_Registers.style=SYNS_CUSTOM|SYNS_UNDERLINE;
- SWL_Registers.caseSensitive=false;
- Syn_WordList Data_Movement_a68k;
- Data_Movement_a68k.name="Data Movement";
- Data_Movement_a68k.list= QStringList::split('\n',
- "EXG\n"
- "LEA\n"
- "LINK\n"
- "MOVE\n"
- "MOVEA\n"
- "MOVEM\n"
- "MOVEP\n"
- "MOVEQ\n"
- "PEA\n"
- "UNLK\n");
- Data_Movement_a68k.color=QColor(0,0,255);
- Data_Movement_a68k.style=0;
- Data_Movement_a68k.caseSensitive=false;
- Syn_WordList ShiftRotation_Instructions_a68k;
- ShiftRotation_Instructions_a68k.name="Shift/Rotation Instructions";
- ShiftRotation_Instructions_a68k.list=QStringList::split('\n',
- "ASL\n"
- "ASR\n"
- "LSL\n"
- "LSR\n"
- "ROL\n"
- "ROLX\n"
- "ROR\n"
- "RORX\n"
- "ROXL\n"
- "ROXR\n"
- "SWAP\n");
- ShiftRotation_Instructions_a68k.color=QColor(0,0,255);
- ShiftRotation_Instructions_a68k.style=0;
- ShiftRotation_Instructions_a68k.caseSensitive=false;
- Syn_WordList Program_Control_a68k;
- Program_Control_a68k.name="Program Control";
- Program_Control_a68k.list=QStringList::split('\n',
- "BCC\n"
- "BCS\n"
- "BEQ\n"
- "BGE\n"
- "BGT\n"
- "BHI\n"
- "BHS\n"
- "BLE\n"
- "BLO\n"
- "BLS\n"
- "BLT\n"
- "BMI\n"
- "BNE\n"
- "BPL\n"
- "BRA\n"
- "BSR\n"
- "BVC\n"
- "BVS\n"
- "DBCC\n"
- "DBCS\n"
- "DBEQ\n"
- "DBF\n"
- "DBGE\n"
- "DBGT\n"
- "DBHI\n"
- "DBHS\n"
- "DBLE\n"
- "DBLO\n"
- "DBLS\n"
- "DBLT\n"
- "DBMI\n"
- "DBNE\n"
- "DBPL\n"
- "DBRA\n"
- "DBT\n"
- "DBVC\n"
- "DBVS\n"
- "JMP\n"
- "JSR\n"
- "NOP\n"
- "RTR\n"
- "RTS\n"
- "SCC\n"
- "SCS\n"
- "SEQ\n"
- "SF\n"
- "SGE\n"
- "SGT\n"
- "SHI\n"
- "SHS\n"
- "SLE\n"
- "SLO\n"
- "SLS\n"
- "SLT\n"
- "SMI\n"
- "SNE\n"
- "SPL\n"
- "ST\n"
- "SVC\n"
- "SVS\n"
- "TST\n");
- Program_Control_a68k.color=QColor(0,0,255);
- Program_Control_a68k.style=0;
- Program_Control_a68k.caseSensitive=false;
- Syn_WordList Assembler_Directives_a68k;
- Assembler_Directives_a68k.name="Assembler Directives";
- Assembler_Directives_a68k.list= QStringList::split('\n',
- "BSS\n"
- "CNOP\n"
- "CSEG\n"
- "DSEG\n"
- "DC\n"
- "DCB\n"
- "DS\n"
- "END\n"
- "ENDC\n"
- "ENDIF\n"
- "ENDM\n"
- "EQU\n"
- "EQUR\n"
- "EVEN\n"
- "FAR\n"
- "IDNT\n"
- "IFC\n"
- "IFD\n"
- "IFEQ\n"
- "IFGE\n"
- "IFGT\n"
- "IFLE\n"
- "IFLT\n"
- "IFNC\n"
- "IFND\n"
- "IFNE\n"
- "INCBIN\n"
- "INCLUDE\n"
- "LIST\n"
- "MACRO\n"
- "NEAR\n"
- "NOLIST\n"
- "ORG\n"
- "PAGE\n"
- "PUBLIC\n"
- "REG\n"
- "RORG\n"
- "SECTION\n"
- "SET\n"
- "SPC\n"
- "TITLE\n"
- "TTL\n"
- "XDEF\n"
- "XREF\n");
- Assembler_Directives_a68k.color=QColor(0,0,255);
- Assembler_Directives_a68k.style=SYNS_CUSTOM|SYNS_BOLD;
- Assembler_Directives_a68k.caseSensitive=false;
- Syn_WordList SWL_Sections;
- SWL_Sections.name="Sections";
- SWL_Sections.list=QStringList::split('\n',
- "$$ACTIONS\n"
- "$$CONNECTIONS\n"
- "$$END\n"
- "$$END_TEST\n"
- "$$EVENTS\n"
- "$$EXTERN\n"
- "$$LOCATIONS\n"
- "$$MESSAGES\n"
- "$$OBJECTS\n"
- "$$OLDSTYLE_SYSTEM_MESSAGES\n"
- "$$PICTURES\n"
- "$$PICTURES_TEST\n"
- "$$SYSTEM_MESSAGES\n"
- "$$TITLE\n"
- "$$VOCABULARY\n");
- SWL_Sections.color=QColor(255,0,0);
- SWL_Sections.style=SYNS_CUSTOM|SYNS_BOLD;
- SWL_Sections.caseSensitive=true;
- Syn_WordList Section_Specific_Keywords;
- Section_Specific_Keywords.name="Section-specific Keywords";
- Section_Specific_Keywords.list= QStringList::split('\n',
- "ACTION\n"
- "BITMAP\n"
- "CBLOCK\n"
- "CONN\n"
- "DEFINE\n"
- "DRAWING\n"
- "END_BITMAP\n"
- "END_CBLOCK\n"
- "END_DRAWING\n"
- "END_PACKED_BITMAP\n"
- "EVENT\n"
- "FROM\n"
- "LOC\n"
- "MSG\n"
- "OBJ\n"
- "PACKED_BITMAP\n"
- "WORD\n");
- Section_Specific_Keywords.color=QColor(64,128,128);
- Section_Specific_Keywords.style=SYNS_CUSTOM|SYNS_BOLD;
- Section_Specific_Keywords.caseSensitive=true;
- Syn_WordList AdditionalKeywords;
- AdditionalKeywords.name="Additional Keywords";
- AdditionalKeywords.list=QStringList::split('\n',
- "CONTINUE\n"
- "ELSE\n");
- AdditionalKeywords.color=QColor(64,128,128);
- AdditionalKeywords.style=SYNS_CUSTOM|SYNS_BOLD;
- AdditionalKeywords.caseSensitive=true;
- Syn_WordList PredefinedAliases;
- PredefinedAliases.name="Predefined Aliases";
- PredefinedAliases.list= QStringList::split('\n',
- "$ALSOSEE\n"
- "$ARG\n"
- "$CARRIED\n"
- "$CENTER\n"
- "$CNT1\n"
- "$CNT2\n"
- "$CNT3\n"
- "$CNT4\n"
- "$CONT\n"
- "$CURLOC\n"
- "$DARK\n"
- "$DARKCNT\n"
- "$DESC\n"
- "$DESC_CNT\n"
- "$DESC_DARKCNT\n"
- "$DESC_NOLIGHTCNT\n"
- "$DONE\n"
- "$ENDGAME\n"
- "$EXIT\n"
- "$FAIL\n"
- "$FONT\n"
- "$FULLSCR\n"
- "$GCONTROL\n"
- "$LSOURCE\n"
- "$MAXCAR\n"
- "$NOLIGHTCNT\n"
- "$NOUN\n"
- "$NOWHERE\n"
- "$NULL\n"
- "$NUMCAR\n"
- "$PROMPT\n"
- "$RESTART\n"
- "$SCORE\n"
- "$SPECIAL\n"
- "$SUBROUTINE\n"
- "$TURNHI\n"
- "$TURNLO\n"
- "$VERB\n"
- "$WORN\n");
- PredefinedAliases.color=QColor(128,0,128);
- PredefinedAliases.style=SYNS_CUSTOM|SYNS_BOLD;
- PredefinedAliases.caseSensitive=true;
- Syn_WordList SWL_Conditions;
- SWL_Conditions.name="Conditions";
- SWL_Conditions.list=QStringList::split('\n',
- "ABSENT\n"
- "AT\n"
- "ATGT\n"
- "ATLT\n"
- "CARRIED\n"
- "CHANCE\n"
- "CREATED\n"
- "EQ\n"
- "EQWORD\n"
- "EXTWORD\n"
- "GT\n"
- "HERE\n"
- "ISAT\n"
- "ISDESC\n"
- "ISNOTAT\n"
- "ISNOTNULL\n"
- "ISNULL\n"
- "LT\n"
- "NEQWORD\n"
- "NOTAT\n"
- "NOTCARR\n"
- "NOTCREATED\n"
- "NOTEQ\n"
- "NOTHERE\n"
- "NOTSAME\n"
- "NOTWORN\n"
- "NOTZERO\n"
- "PRESENT\n"
- "SAME\n"
- "TRYMOVE\n"
- "WORN\n"
- "ZERO\n");
- SWL_Conditions.color=QColor(0,0,255);
- SWL_Conditions.style=SYNS_CUSTOM|SYNS_BOLD;
- SWL_Conditions.caseSensitive=true;
- Syn_WordList SWL_Actions;
- SWL_Actions.name="Actions";
- SWL_Actions.list= QStringList::split('\n',
- "ADD\n"
- "ALSOSEE\n"
- "ANYKEY\n"
- "AUTOD\n"
- "AUTOG\n"
- "AUTOR\n"
- "AUTOW\n"
- "BIGFONT\n"
- "CANCEL\n"
- "CLEAR\n"
- "CLS\n"
- "COPYFF\n"
- "COPYFO\n"
- "COPYOF\n"
- "COPYOO\n"
- "CREATE\n"
- "DECCAR\n"
- "DESC\n"
- "DESTROY\n"
- "DONE\n"
- "DROP\n"
- "DROPALL\n"
- "END\n"
- "ENDDESC\n"
- "EXIT\n"
- "EXTERN\n"
- "GET\n"
- "GETWORD\n"
- "GOTO\n"
- "INCCAR\n"
- "INVEN\n"
- "LET\n"
- "LISTAT\n"
- "LISTOBJ\n"
- "LOAD\n"
- "MAXCAR\n"
- "MES\n"
- "MESFLAG\n"
- "MESSAGE\n"
- "MINUS\n"
- "NEWLINE\n"
- "NOTDONE\n"
- "OK\n"
- "PAUSE\n"
- "PICNORM\n"
- "PICOFF\n"
- "PICON\n"
- "PLACE\n"
- "PLUS\n"
- "PRINT\n"
- "PROMPT\n"
- "PUTO\n"
- "QUIT\n"
- "QVERSION\n"
- "RAMLOAD\n"
- "RAMSAVE\n"
- "RANDOM\n"
- "REDRAW\n"
- "REMOVE\n"
- "RESTART\n"
- "SAVE\n"
- "SCORE\n"
- "SET\n"
- "SETNOUN\n"
- "SETVERB\n"
- "SHOWLOC\n"
- "SMLFONT\n"
- "SUB\n"
- "SWAP\n"
- "SYSMESS\n"
- "TURNS\n"
- "WEAR\n"
- "WHATO\n"
- "WHEREO\n"
- "ZAPSCR\n");
- SWL_Actions.color=QColor(0,0,160);
- SWL_Actions.style=SYNS_CUSTOM|SYNS_BOLD;
- SWL_Actions.caseSensitive=true;
- Syn_WordList Drawing_Primitives;
- Drawing_Primitives.name="Drawing primitives";
- Drawing_Primitives.list=QStringList::split('\n',
- "AMOVE\n"
- "CALL\n"
- "ELLIPSE\n"
- "FILL\n"
- "INV_ELLIPSE\n"
- "INV_LINE\n"
- "INV_PLOT\n"
- "INV_RPLOT\n"
- "LINE\n"
- "MOVE\n"
- "PLOT\n"
- "RPLOT\n"
- "SHADE\n"
- "XOR_ELLIPSE\n"
- "XOR_LINE\n"
- "XOR_PLOT\n"
- "XOR_RPLOT\n");
- Drawing_Primitives.color=QColor(0,64,128);
- Drawing_Primitives.style=SYNS_CUSTOM|SYNS_BOLD;
- Drawing_Primitives.caseSensitive=true;
- Syn_WordList Drawing_Directions;
- Drawing_Directions.name="Drawing directions";
- Drawing_Directions.list=QStringList::split('\n',
- "DOWN\n"
- "DOWN_LEFT\n"
- "DOWN_RIGHT\n"
- "LEFT\n"
- "LEFT_DOWN\n"
- "LEFT_UP\n"
- "RIGHT\n"
- "RIGHT_DOWN\n"
- "RIGHT_UP\n"
- "UP\n"
- "UP_LEFT\n"
- "UP_RIGHT\n");
- Drawing_Directions.color=QColor(0,128,0);
- Drawing_Directions.style=SYNS_CUSTOM|SYNS_BOLD;
- Drawing_Directions.caseSensitive=true;
- Syn_WordList Shading_Patterns;
- Shading_Patterns.name="Shading patterns";
- Shading_Patterns.list=QStringList::split('\n',
- "$BKSLASHFILL\n"
- "$BRICKFILL\n"
- "$CHAINFILL\n"
- "$CIRCLEFILL\n"
- "$CLOSEDASHFILL\n"
- "$CLOSEDOTFILL\n"
- "$CLOSEWAVEFILL\n"
- "$CROSSFILL\n"
- "$DASHFILL\n"
- "$DOTFILL\n"
- "$HATCHFILL\n"
- "$INTERLEAVEFILL\n"
- "$LIGHTDOTFILL\n"
- "$LIGHTLINEFILL\n"
- "$LINEFILL\n"
- "$SLASHFILL\n"
- "$SOLIDFILL\n"
- "$SQDOTFILL\n"
- "$SQUAREFILL\n"
- "$THICKBKSLASHFILL\n"
- "$THICKHATCHFILL\n"
- "$THICKLINEFILL\n"
- "$THICKSLASHFILL\n"
- "$VDASHFILL\n"
- "$VINTERLEAVEFILL\n"
- "$VLDOTFILL\n"
- "$VLIGHTLINEFILL\n"
- "$VLINEFILL\n"
- "$VTHICKLINEFILL\n"
- "$WAVEFILL\n"
- "$WIDEDOTFILL\n"
- "$XMARKFILL\n"
- "$ZIGZAGFILL\n");
- Shading_Patterns.color=QColor(128,0,128);
- Shading_Patterns.style=SYNS_CUSTOM|SYNS_BOLD;
- Shading_Patterns.caseSensitive=true;
- Syn_WordList NonFunctional_Keywords;
- NonFunctional_Keywords.name="Non-functional keywords";
- NonFunctional_Keywords.list=QStringList::split('\n',
- "BEEP\n"
- "BLOCK\n"
- "BORDER\n"
- "BRIGHT\n"
- "FLASH\n"
- "INK\n"
- "PAPER\n");
- NonFunctional_Keywords.color=QColor(192,192,192);
- NonFunctional_Keywords.style=SYNS_CUSTOM|SYNS_BOLD;
- NonFunctional_Keywords.caseSensitive=true;
- Syn_WordList External_Symbols;
- External_Symbols.name="External symbols";
- External_Symbols.list=QStringList::split('\n',
- "$ACTIONS$\n"
- "$ARG$\n"
- "$BMPUT$\n"
- "$BPCKPUT$\n"
- "$BUFFER$\n"
- "$CONNECTIONS$\n"
- "$EVENTS$\n"
- "$EXTERN$\n"
- "$FLAGS$\n"
- "$FLAGS_BACKUP$\n"
- "$GDF$\n"
- "$GETLINE$\n"
- "$LOCATIONS$\n"
- "$LQL$\n"
- "$MAXCAR$\n"
- "$MESSAGES$\n"
- "$NFLAG$\n"
- "$NLOC$\n"
- "$NMSG$\n"
- "$NOBJ$\n"
- "$NSYSMSG$\n"
- "$NWORD$\n"
- "$OBJECTS$\n"
- "$PDRAW$\n"
- "$PICTURE$\n"
- "$PRINT$\n"
- "$RAM_SAVED$\n"
- "$SCALEX$\n"
- "$SCALEY$\n"
- "$SSCR$\n"
- "$SYSTEM_MESSAGES$\n"
- "$WORDS$\n");
- External_Symbols.color=QColor(0,128,64);
- External_Symbols.style=SYNS_CUSTOM|SYNS_BOLD;
- External_Symbols.caseSensitive=true;
-
- syn->wordLists.clear();
- if (synIsC)
- syn->wordLists << C_Keywords;
- else if (synIsS)
- syn->wordLists << Data_Movement << Integer_Arithmetic << Logical_Instructions << ShiftRotation_Instructions << Bit_Manipulation << Program_Control << System_Control << SWL_Extensions << Assembler_Directives << SWL_Registers;
- else if (synIsAsm)
- syn->wordLists << Data_Movement_a68k << Integer_Arithmetic << Logical_Instructions << ShiftRotation_Instructions_a68k << Bit_Manipulation << Program_Control_a68k << System_Control << SWL_Extensions << Assembler_Directives_a68k << SWL_Registers;
- else if (synIsQll)
- syn->wordLists << C_Keywords << SWL_Sections << Section_Specific_Keywords << AdditionalKeywords << PredefinedAliases << SWL_Conditions << SWL_Actions << Drawing_Primitives << Drawing_Directions << Shading_Patterns << NonFunctional_Keywords << External_Symbols;
- }
- static void defaultSynHighlight(void)
- {
- resetSyntaxPreference(&(preferences.synC));
- resetSyntaxPreference(&(preferences.synS));
- resetSyntaxPreference(&(preferences.synAsm));
- resetSyntaxPreference(&(preferences.synQll));
- saveSyntaxPreferences();
- }
- // Update the Kate schema from our internal ones.
- static void updateEditorPreferences(void)
- {
- KConfig kateschema("kateschemarc");
- QColor color;
- if (preferences.useBgColor) {
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color Background",preferences.bgColor);
- kateschema.writeEntry("Color Highlighted Line",preferences.bgColor);
- } else {
- kateschema.setGroup("kate - Normal");
- color=QColor(255,255,255);
- color=kateschema.readColorEntry("Color Background",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color Background",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(240,240,240);
- color=kateschema.readColorEntry("Color Highlighted Line",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color Highlighted Line",color);
- }
- kateschema.setGroup("kate - Normal");
- color=QColor(255,255,153);
- color=kateschema.readColorEntry("Color Highlighted Bracket",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color Highlighted Bracket",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(234,233,232);
- color=kateschema.readColorEntry("Color Icon Bar",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color Icon Bar",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(0,0,0);
- color=kateschema.readColorEntry("Color Line Number",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color Line Number",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(0,0,255);
- color=kateschema.readColorEntry("Color MarkType1",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color MarkType1",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(255,0,0);
- color=kateschema.readColorEntry("Color MarkType2",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color MarkType2",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(255,255,0);
- color=kateschema.readColorEntry("Color MarkType3",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color MarkType3",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(255,0,255);
- color=kateschema.readColorEntry("Color MarkType4",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color MarkType4",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(160,160,164);
- color=kateschema.readColorEntry("Color MarkType5",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color MarkType5",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(0,255,0);
- color=kateschema.readColorEntry("Color MarkType6",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color MarkType6",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(255,0,0);
- color=kateschema.readColorEntry("Color MarkType7",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color MarkType7",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(76,89,166);
- color=kateschema.readColorEntry("Color Selection",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color Selection",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(0,0,0);
- color=kateschema.readColorEntry("Color Tab Marker",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color Tab Marker",color);
- kateschema.setGroup("kate - Normal");
- color=QColor(120,120,120);
- color=kateschema.readColorEntry("Color Word Wrap Marker",&color);
- kateschema.setGroup("ktigcc - Normal");
- kateschema.writeEntry("Color Word Wrap Marker",color);
- kateschema.writeEntry("Font",preferences.editorFont);
- }
- void loadPreferences(void)
- {
- // This doesn't really _load_ a preference...
- if (!pconfig->hasGroup("Kate Document Defaults")) {
- pconfig->setGroup("Kate Document Defaults");
- pconfig->writeEntry("Tab Handling",0);
- pconfig->writeEntry("Basic Config Flags",0x1000020u);
- pconfig->sync();
- }
- pconfig->setGroup("Preferences");
- // General
- preferences.stopAtFirstError=pconfig->readBoolEntry("Stop at First Error",false);
- preferences.jumpToError=pconfig->readBoolEntry("Jump to Error",true);
- preferences.successMessage=pconfig->readBoolEntry("Success Message",true);
- preferences.deleteAsmFiles=pconfig->readBoolEntry("Delete Asm Files",true);
- preferences.deleteObjFiles=pconfig->readBoolEntry("Delete Object Files",false);
- preferences.splitSourceFiles=pconfig->readBoolEntry("Split Source Files",true);
- preferences.allowImplicitDeclaration=pconfig->readBoolEntry("Allow Implicit Declaration",true);
- preferences.autoSave=pconfig->readBoolEntry("Auto Save",true);
- preferences.downloadHeadlines=pconfig->readBoolEntry("Download Headlines",false);
- preferences.deleteOverwrittenErrors=pconfig->readBoolEntry("Delete Overwritten Errors",true);
- preferences.useSystemIcons=pconfig->readBoolEntry("Use System Icons",true);
- // Transfer
- preferences.linkTarget=(LinkTargets)pconfig->readNumEntry("Link Target",LT_NONE);
- preferences.linkPort=(CablePort)pconfig->readNumEntry("Link Port",PORT_1);
- preferences.linkCable=(CableModel)pconfig->readNumEntry("Link Cable",CABLE_GRY);
- // Don't allow selecting a USB cable if libticables2 has been compiled without
- // USB support or if USB support can't be used.
- if (!have_usb) {
- if (preferences.linkCable==CABLE_SLV || preferences.linkCable==CABLE_USB) {
- preferences.linkCable=CABLE_GRY;
- preferences.linkTarget=LT_NONE;
- }
- }
- // Editor
- preferences.tabWidthC=pconfig->readUnsignedNumEntry("Tab Width C",2);
- preferences.tabWidthAsm=pconfig->readUnsignedNumEntry("Tab Width Asm",8);
- preferences.useBgColor=pconfig->readBoolEntry("Use Background Color",false);
- QColor white(255,255,255);
- preferences.bgColor=pconfig->readColorEntry("Background Color",&white);
- QFont defaultFont("Monospace",10);
- preferences.editorFont=pconfig->readFontEntry("Editor Font",&defaultFont);
- preferences.useCalcCharset=pconfig->readBoolEntry("Use Calc Charset",true);
- preferences.lazyLoading=pconfig->readBoolEntry("Lazy Loading",true);
- preferences.autoBlocks=pconfig->readBoolEntry("Auto Blocks",true);
- preferences.removeTrailingSpaces=pconfig->readBoolEntry("Remove Trailing Spaces",false);
- updateEditorPreferences();
- // Coding
- if (pconfig->hasKey("Num Coding Templates")) {
- unsigned numTemplates=pconfig->readUnsignedNumEntry("Num Coding Templates");
- preferences.templates.clear();
- for (unsigned i=0; i<numTemplates; i++) {
- preferences.templates.append(qMakePair(
- pconfig->readEntry(QString("Coding Template %1 Name").arg(i)),
- pconfig->readEntry(QString("Coding Template %1 Text").arg(i))));
- }
- } else {
- preferences.templates.clear();
- // These are 7-bit ASCII, so either fromLatin1 or fromUtf8 will work.
- // fromLatin1 is probably faster.
- preferences.templates
- << qMakePair(QString::fromLatin1("do"),QString::fromLatin1("do {\n\t|\n} while ();"))
- << qMakePair(QString::fromLatin1("for"),QString::fromLatin1("for (|; ; ) {"))
- << qMakePair(QString::fromLatin1("if"),QString::fromLatin1("if (|) {"))
- << qMakePair(QString::fromLatin1("if else"),QString::fromLatin1("if (|) {\n} else {\n}"))
- << qMakePair(QString::fromLatin1("switch"),QString::fromLatin1("switch (|) {\n\tcase:\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n}"))
- << qMakePair(QString::fromLatin1("while"),QString::fromLatin1("while (|) {"));
- }
- // Syntax
- if (!loadSyntaxPreferences())
- defaultSynHighlight();
- checkSynHighlightVersions();
- }
- void savePreferences(void)
- {
- pconfig->setGroup("Preferences");
- // General
- pconfig->writeEntry("Stop at First Error",(bool)preferences.stopAtFirstError);
- pconfig->writeEntry("Jump to Error",(bool)preferences.jumpToError);
- pconfig->writeEntry("Success Message",(bool)preferences.successMessage);
- pconfig->writeEntry("Delete Asm Files",(bool)preferences.deleteAsmFiles);
- pconfig->writeEntry("Delete Object Files",(bool)preferences.deleteObjFiles);
- pconfig->writeEntry("Split Source Files",(bool)preferences.splitSourceFiles);
- pconfig->writeEntry("Allow Implicit Declaration",(bool)preferences.allowImplicitDeclaration);
- pconfig->writeEntry("Auto Save",(bool)preferences.autoSave);
- pconfig->writeEntry("Download Headlines",(bool)preferences.downloadHeadlines);
- pconfig->writeEntry("Delete Overwritten Errors",(bool)preferences.deleteOverwrittenErrors);
- pconfig->writeEntry("Use System Icons",(bool)preferences.useSystemIcons);
- // Transfer
- pconfig->writeEntry("Link Target",(int)preferences.linkTarget);
- pconfig->writeEntry("Link Port",(int)preferences.linkPort);
- pconfig->writeEntry("Link Cable",(int)preferences.linkCable);
- // Editor
- pconfig->writeEntry("Tab Width C",(unsigned)preferences.tabWidthC);
- pconfig->writeEntry("Tab Width Asm",(unsigned)preferences.tabWidthAsm);
- pconfig->writeEntry("Use Background Color",(bool)preferences.useBgColor);
- pconfig->writeEntry("Background Color",preferences.bgColor);
- pconfig->writeEntry("Editor Font",preferences.editorFont);
- pconfig->writeEntry("Use Calc Charset",(bool)preferences.useCalcCharset);
- pconfig->writeEntry("Lazy Loading",(bool)preferences.lazyLoading);
- pconfig->writeEntry("Auto Blocks",(bool)preferences.autoBlocks);
- pconfig->writeEntry("Remove Trailing Spaces",(bool)preferences.removeTrailingSpaces);
- updateEditorPreferences();
- // Coding
- unsigned i=0;
- for (Q3ValueList<QPair<QString,QString> >::ConstIterator it=preferences.templates.begin();
- it!=preferences.templates.end(); ++it, i++) {
- pconfig->writeEntry(QString("Coding Template %1 Name").arg(i),(*it).first);
- pconfig->writeEntry(QString("Coding Template %1 Text").arg(i),(*it).second);
- }
- pconfig->writeEntry("Num Coding Templates",i);
- // Syntax, save to disk
- saveSyntaxPreferences();
- }
- int showPreferencesDialog(QWidget *parent, bool haveA68k, bool haveQuill)
- {
- preferences.haveA68k=haveA68k;
- preferences.haveQuill=haveQuill;
- Preferences *prefdlg=new Preferences(parent);
- prefdlg->exec();
- int result=prefdlg->result();
- delete prefdlg;
- if (result==QDialog::Accepted)
- savePreferences();
- return result;
- }
|