preferences.cpp 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800
  1. /*
  2. ktigcc - TIGCC IDE for KDE
  3. Copyright (C) 2004-2007 Kevin Kofler
  4. Copyright (C) 2006 Joey Adams
  5. Copyright (C) 2007 Konrad Meyer
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software Foundation,
  16. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #include <cstdio>
  19. #include <cstdlib>
  20. #include <unistd.h>
  21. #include <kapplication.h>
  22. #include <kcmdlineargs.h>
  23. #include <kaboutdata.h>
  24. #include <kglobal.h>
  25. #include <kstandarddirs.h>
  26. #include <QTextCodec>
  27. #include <QColor>
  28. #include <QFont>
  29. #include <QDomDocument>
  30. #include <QDomElement>
  31. #include <QDomNode>
  32. #include <QDomAttr>
  33. #include <QDomText>
  34. #include <QDir>
  35. #include <QPair>
  36. #include <QLinkedList>
  37. #include <kconfig.h>
  38. #include "ktigcc.h"
  39. #include "preferences.h"
  40. #include "preferencesdlg.h"
  41. #include "tpr.h"
  42. // versions of the syntax highlighting description file:
  43. // 1.00 = KTIGCC 20060807 Beta
  44. // 1.01 = KTIGCC 20060814 Beta - 1.07
  45. // 1.02 = current KTIGCC 1 (since 1.08)
  46. // 1.80 = KTIGCC 2 up to 1.80-20070702
  47. // 1.81 = current KTIGCC 2 (since 1.80-20070702)
  48. #define CURRENT_SYNFILE_VERSION "1.81"
  49. TIGCCPrefs preferences;
  50. static void writeSyntaxXML(const Syn_SettingsForDoc &synprefs,
  51. const QString &name, const QString &internalName)
  52. {
  53. // Create XML document.
  54. QDomDocument doc("language");
  55. QDomElement root=doc.createElement("language");
  56. doc.appendChild(root);
  57. // Work around bad interfaces...
  58. #define ADD_ATTR(node,aname,aval) do { \
  59. QDomAttr newattr=doc.createAttribute((aname)); \
  60. newattr.setValue((aval)); \
  61. (node).setAttributeNode(newattr); \
  62. } while(0)
  63. #define ADD_TEXT(node,text) do { \
  64. QDomText newtext=doc.createTextNode((text)); \
  65. (node).appendChild(newtext); \
  66. } while(0)
  67. #define CHILD_NODE(child,node,chname) \
  68. QDomElement child=doc.createElement((chname));\
  69. (node).appendChild(child)
  70. bool allWordListsCaseInsensitive=TRUE;
  71. foreach (const Syn_WordList &wordList, synprefs.wordLists)
  72. if (wordList.caseSensitive) allWordListsCaseInsensitive=FALSE;
  73. ADD_ATTR(root,"name","TIGCC "+name);
  74. ADD_ATTR(root,"section","KTIGCC");
  75. ADD_ATTR(root,"extensions","");
  76. ADD_ATTR(root,"version",CURRENT_SYNFILE_VERSION);
  77. ADD_ATTR(root,"kateversion","2.5");
  78. ADD_ATTR(root,"author","KTIGCC (autogenerated)");
  79. ADD_ATTR(root,"license","GPL");
  80. CHILD_NODE(highlighting,root,"highlighting");
  81. CHILD_NODE(general,root,"general");
  82. foreach (const Syn_WordList &wordList, synprefs.wordLists) {
  83. CHILD_NODE(list,highlighting,"list");
  84. ADD_ATTR(list,"name",wordList.name);
  85. QStringList stringList=wordList.list;
  86. foreach (QString keyword, stringList) {
  87. CHILD_NODE(item,list,"item");
  88. ADD_TEXT(item,keyword);
  89. }
  90. }
  91. CHILD_NODE(contexts,highlighting,"contexts");
  92. CHILD_NODE(defaultContext,contexts,"context");
  93. ADD_ATTR(defaultContext,"name","Default");
  94. ADD_ATTR(defaultContext,"attribute","Normal");
  95. ADD_ATTR(defaultContext,"lineEndContext","#stay");
  96. foreach (const Syn_CustomStyle &customStyle, synprefs.customStyles) {
  97. switch (customStyle.beginning.length()) {
  98. case 0: // Ignore these ones altogether.
  99. break;
  100. case 1:
  101. {
  102. CHILD_NODE(detectCustomStyle,defaultContext,"DetectChar");
  103. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  104. ADD_ATTR(detectCustomStyle,"context",customStyle.name);
  105. if (customStyle.lineStartOnly)
  106. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  107. ADD_ATTR(detectCustomStyle,"char",customStyle.beginning.left(1));
  108. }
  109. break;
  110. case 2:
  111. {
  112. CHILD_NODE(detectCustomStyle,defaultContext,"Detect2Chars");
  113. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  114. ADD_ATTR(detectCustomStyle,"context",customStyle.name);
  115. if (customStyle.lineStartOnly)
  116. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  117. ADD_ATTR(detectCustomStyle,"char",customStyle.beginning.left(1));
  118. ADD_ATTR(detectCustomStyle,"char1",customStyle.beginning.mid(1,1));
  119. }
  120. break;
  121. default:
  122. {
  123. CHILD_NODE(detectCustomStyle,defaultContext,"StringDetect");
  124. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  125. ADD_ATTR(detectCustomStyle,"context",customStyle.name);
  126. if (customStyle.lineStartOnly)
  127. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  128. ADD_ATTR(detectCustomStyle,"String",customStyle.beginning);
  129. }
  130. break;
  131. }
  132. }
  133. foreach (const Syn_WordList &wordList, synprefs.wordLists) {
  134. CHILD_NODE(detectWordList,defaultContext,"keyword");
  135. ADD_ATTR(detectWordList,"attribute",wordList.name);
  136. ADD_ATTR(detectWordList,"context","#stay");
  137. ADD_ATTR(detectWordList,"String",wordList.name);
  138. if (!(wordList.caseSensitive || allWordListsCaseInsensitive))
  139. ADD_ATTR(detectWordList,"insensitive","true");
  140. }
  141. CHILD_NODE(numFloat,defaultContext,"Float");
  142. ADD_ATTR(numFloat,"attribute","Number");
  143. ADD_ATTR(numFloat,"context","#stay");
  144. CHILD_NODE(numFloatSuffix,numFloat,"AnyChar");
  145. ADD_ATTR(numFloatSuffix,"String","fF");
  146. ADD_ATTR(numFloatSuffix,"attribute","Number");
  147. ADD_ATTR(numFloatSuffix,"context","#stay");
  148. CHILD_NODE(numInt,defaultContext,"RegExpr");
  149. ADD_ATTR(numInt,"String","\\b\\d\\w*");
  150. ADD_ATTR(numInt,"attribute","Number");
  151. ADD_ATTR(numInt,"context","#stay");
  152. CHILD_NODE(numHex,defaultContext,"RegExpr");
  153. ADD_ATTR(numHex,"String","\\$\\w+");
  154. ADD_ATTR(numHex,"attribute","Number");
  155. ADD_ATTR(numHex,"context","#stay");
  156. CHILD_NODE(symbols,defaultContext,"AnyChar");
  157. ADD_ATTR(symbols,"String","<{[)]}>;:,.=+-*/\\|\"\'!?&%#@^~");
  158. ADD_ATTR(symbols,"attribute","Symbol");
  159. ADD_ATTR(symbols,"context","#stay");
  160. unsigned numParenthesisColors=synprefs.parenthesisColors.count();
  161. CHILD_NODE(parenOpen,defaultContext,"DetectChar");
  162. ADD_ATTR(parenOpen,"char","(");
  163. if (numParenthesisColors) {
  164. ADD_ATTR(parenOpen,"attribute","Paren0");
  165. ADD_ATTR(parenOpen,"context","Paren0");
  166. } else {
  167. ADD_ATTR(parenOpen,"attribute","Symbol");
  168. ADD_ATTR(parenOpen,"context","#stay");
  169. }
  170. for (unsigned i=0; i<numParenthesisColors; i++) {
  171. CHILD_NODE(pareniContext,contexts,"context");
  172. QString parenp1="Paren%1";
  173. QString pareni=parenp1.arg(i);
  174. QString pareni1=parenp1.arg((i+1==numParenthesisColors)?0:(i+1));
  175. ADD_ATTR(pareniContext,"name",pareni);
  176. ADD_ATTR(pareniContext,"attribute","Normal");
  177. ADD_ATTR(pareniContext,"lineEndContext","#stay");
  178. CHILD_NODE(push,pareniContext,"DetectChar");
  179. ADD_ATTR(push,"char","(");
  180. ADD_ATTR(push,"attribute",pareni1);
  181. ADD_ATTR(push,"context",pareni1);
  182. CHILD_NODE(pop,pareniContext,"DetectChar");
  183. ADD_ATTR(pop,"char",")");
  184. ADD_ATTR(pop,"attribute",pareni);
  185. ADD_ATTR(pop,"context","#pop");
  186. CHILD_NODE(includeRules,pareniContext,"IncludeRules");
  187. ADD_ATTR(includeRules,"context","Default");
  188. }
  189. for (QLinkedList<Syn_CustomStyle>::ConstIterator it=synprefs.customStyles.begin();
  190. it!=synprefs.customStyles.end(); ++it) {
  191. const Syn_CustomStyle &customStyle=*it;
  192. bool endsWithNewline=(customStyle.ending=="\n");
  193. bool endsWithSpace=(customStyle.ending==" ");
  194. bool noIgnoreEndingAfter=customStyle.ignoreEndingAfter.isNull();
  195. bool needIgnoreContext=!endsWithNewline && !noIgnoreEndingAfter;
  196. CHILD_NODE(customStyleContext,contexts,"context");
  197. ADD_ATTR(customStyleContext,"name",customStyle.name);
  198. ADD_ATTR(customStyleContext,"attribute",customStyle.name);
  199. ADD_ATTR(customStyleContext,"lineEndContext",(endsWithNewline||
  200. (endsWithSpace&&noIgnoreEndingAfter))?"#pop":"#stay");
  201. if (endsWithNewline && customStyle.ignoreEndingAfter=='\\') {
  202. CHILD_NODE(lineContinue,customStyleContext,"LineContinue");
  203. ADD_ATTR(lineContinue,"attribute",customStyle.name);
  204. ADD_ATTR(lineContinue,"context","#stay");
  205. } else if (needIgnoreContext) {
  206. CHILD_NODE(detectCustomStyle,customStyleContext,"DetectChar");
  207. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  208. ADD_ATTR(detectCustomStyle,"context",customStyle.name+" Ignore");
  209. ADD_ATTR(detectCustomStyle,"char",QString(customStyle.ignoreEndingAfter));
  210. if (customStyle.ignoreEndingAfter=='\\') {
  211. CHILD_NODE(detectCustomStyleTrigraph,customStyleContext,"StringDetect");
  212. ADD_ATTR(detectCustomStyleTrigraph,"attribute",customStyle.name);
  213. ADD_ATTR(detectCustomStyleTrigraph,"context",customStyle.name+" Ignore");
  214. ADD_ATTR(detectCustomStyleTrigraph,"String","?""?""/");
  215. }
  216. }
  217. if (endsWithSpace) {
  218. CHILD_NODE(detectCustomStyle,customStyleContext,"DetectSpaces");
  219. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  220. ADD_ATTR(detectCustomStyle,"context","#pop");
  221. } else if (!endsWithNewline) {
  222. switch (customStyle.ending.length()) {
  223. case 0: // No ending...
  224. break;
  225. case 1:
  226. {
  227. CHILD_NODE(detectCustomStyle,customStyleContext,"DetectChar");
  228. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  229. ADD_ATTR(detectCustomStyle,"context","#pop");
  230. ADD_ATTR(detectCustomStyle,"char",customStyle.ending.left(1));
  231. }
  232. break;
  233. case 2:
  234. {
  235. CHILD_NODE(detectCustomStyle,customStyleContext,"Detect2Chars");
  236. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  237. ADD_ATTR(detectCustomStyle,"context","#pop");
  238. ADD_ATTR(detectCustomStyle,"char",customStyle.ending.left(1));
  239. ADD_ATTR(detectCustomStyle,"char1",customStyle.ending.mid(1,1));
  240. }
  241. break;
  242. default:
  243. {
  244. CHILD_NODE(detectCustomStyle,customStyleContext,"StringDetect");
  245. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  246. ADD_ATTR(detectCustomStyle,"context","#pop");
  247. ADD_ATTR(detectCustomStyle,"String",customStyle.ending);
  248. }
  249. break;
  250. }
  251. }
  252. if (customStyle.switchable) {
  253. for (QLinkedList<Syn_CustomStyle>::ConstIterator it2=synprefs.customStyles.begin();
  254. it2!=synprefs.customStyles.end(); ++it2) {
  255. if (it2==it) continue;
  256. const Syn_CustomStyle &otherCustomStyle=*it2;
  257. if (otherCustomStyle.ending==customStyle.ending) {
  258. switch (otherCustomStyle.beginning.length()) {
  259. case 0: // Ignore these ones altogether.
  260. break;
  261. case 1:
  262. {
  263. CHILD_NODE(detectCustomStyle,customStyleContext,"DetectChar");
  264. ADD_ATTR(detectCustomStyle,"attribute",otherCustomStyle.name);
  265. ADD_ATTR(detectCustomStyle,"context","#pop");
  266. if (otherCustomStyle.lineStartOnly)
  267. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  268. ADD_ATTR(detectCustomStyle,"char",otherCustomStyle.beginning.left(1));
  269. ADD_ATTR(detectCustomStyle,"lookAhead","true");
  270. }
  271. break;
  272. case 2:
  273. {
  274. CHILD_NODE(detectCustomStyle,customStyleContext,"Detect2Chars");
  275. ADD_ATTR(detectCustomStyle,"attribute",otherCustomStyle.name);
  276. ADD_ATTR(detectCustomStyle,"context","#pop");
  277. if (otherCustomStyle.lineStartOnly)
  278. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  279. ADD_ATTR(detectCustomStyle,"char",otherCustomStyle.beginning.left(1));
  280. ADD_ATTR(detectCustomStyle,"char1",otherCustomStyle.beginning.mid(1,1));
  281. ADD_ATTR(detectCustomStyle,"lookAhead","true");
  282. }
  283. break;
  284. default:
  285. {
  286. CHILD_NODE(detectCustomStyle,customStyleContext,"StringDetect");
  287. ADD_ATTR(detectCustomStyle,"attribute",otherCustomStyle.name);
  288. ADD_ATTR(detectCustomStyle,"context","#pop");
  289. if (otherCustomStyle.lineStartOnly)
  290. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  291. ADD_ATTR(detectCustomStyle,"String",otherCustomStyle.beginning);
  292. ADD_ATTR(detectCustomStyle,"lookAhead","true");
  293. }
  294. break;
  295. }
  296. }
  297. }
  298. }
  299. if (needIgnoreContext) {
  300. CHILD_NODE(customStyleIgnoreContext,contexts,"context");
  301. ADD_ATTR(customStyleIgnoreContext,"name",customStyle.name+" Ignore");
  302. ADD_ATTR(customStyleIgnoreContext,"attribute",customStyle.name);
  303. ADD_ATTR(customStyleIgnoreContext,"lineEndContext","#pop");
  304. CHILD_NODE(pop,customStyleIgnoreContext,"RegExpr");
  305. ADD_ATTR(pop,"attribute",customStyle.name);
  306. ADD_ATTR(pop,"context","#pop");
  307. ADD_ATTR(pop,"String",".");
  308. }
  309. }
  310. CHILD_NODE(itemDatas,highlighting,"itemDatas");
  311. #define DEF_ITEM_DATA(idname,color,style) do { \
  312. CHILD_NODE(itemData,itemDatas,"itemData");\
  313. ADD_ATTR(itemData,"name",(idname));\
  314. ADD_ATTR(itemData,"defStyleNum","dsNormal");\
  315. QColor idcolor=(color);\
  316. if (idcolor.isValid())\
  317. ADD_ATTR(itemData,"color",idcolor.name());\
  318. Syn_Style idstyle=(style);\
  319. if (idstyle&SYNS_CUSTOM) {\
  320. ADD_ATTR(itemData,"bold",(idstyle&SYNS_BOLD)?"1":"0");\
  321. ADD_ATTR(itemData,"underline",(idstyle&SYNS_UNDERLINE)?"1":"0");\
  322. ADD_ATTR(itemData,"italic",(idstyle&SYNS_ITALIC)?"1":"0");\
  323. ADD_ATTR(itemData,"strikeOut",(idstyle&SYNS_STRIKEOUT)?"1":"0");\
  324. }\
  325. } while(0)
  326. DEF_ITEM_DATA("Normal",QColor(),0);
  327. DEF_ITEM_DATA("Number",synprefs.numberColor,synprefs.numberStyle);
  328. DEF_ITEM_DATA("Symbol",synprefs.symbolColor,synprefs.symbolStyle);
  329. unsigned i=0;
  330. foreach (const QColor &color, synprefs.parenthesisColors)
  331. DEF_ITEM_DATA(QString("Paren%1").arg(i++),color,synprefs.parenthesisStyle);
  332. foreach (const Syn_CustomStyle &customStyle, synprefs.customStyles)
  333. DEF_ITEM_DATA(customStyle.name,customStyle.color,customStyle.style);
  334. foreach (const Syn_WordList &wordList, synprefs.wordLists)
  335. DEF_ITEM_DATA(wordList.name,wordList.color,wordList.style);
  336. #undef DEF_ITEM_DATA
  337. CHILD_NODE(keywords,general,"keywords");
  338. ADD_ATTR(keywords,"casesensitive",allWordListsCaseInsensitive?"0":"1");
  339. ADD_ATTR(keywords,"additionalDeliminator","\'\"#@");
  340. #undef ADD_ATTR
  341. #undef ADD_TEXT
  342. #undef CHILD_NODE
  343. // Write it to disk.
  344. QString xmlFileName=QString("%1/share/apps/katepart/syntax/ktigcc%2.xml")
  345. .arg(KGlobal::dirs()->localkdedir()).arg(internalName);
  346. mkdir_multi(xmlFileName);
  347. std::FILE *f=std::fopen(xmlFileName,"w");
  348. if (f) {
  349. if (fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  350. "<!-- Syntax highlighting description autogenerated by KTIGCC.\n"
  351. " All changes to this file will be lost! -->\n",f)<0) {
  352. fclose(f);
  353. return;
  354. }
  355. (void) fputs(doc.toByteArray(2),f);
  356. fclose(f);
  357. }
  358. }
  359. static void updateSyntaxXML(void)
  360. {
  361. writeSyntaxXML(preferences.synC,"C","c");
  362. writeSyntaxXML(preferences.synS,"GNU As","s");
  363. writeSyntaxXML(preferences.synAsm,"A68k","asm");
  364. writeSyntaxXML(preferences.synQll,"Quill","qll");
  365. }
  366. // True if version1 is newer than version2.
  367. static bool isNewerVersion(const QString &version1, const QString &version2)
  368. {
  369. QStringList vl1=version1.split('.',QString::SkipEmptyParts);
  370. QStringList vl2=version2.split('.',QString::SkipEmptyParts);
  371. QStringList::Iterator it1=vl1.begin(), it2=vl2.begin();
  372. for (; it1!=vl1.end() && it2!=vl2.end(); ++it1, ++it2) {
  373. bool ok1, ok2;
  374. unsigned v1=(*it1).toUInt(&ok1), v2=(*it2).toUInt(&ok2);
  375. if (!ok1 || !ok2) return TRUE;
  376. if (v1>v2) return TRUE;
  377. else if (v1<v2) return FALSE;
  378. }
  379. return (it1!=vl1.end());
  380. }
  381. static bool checkSynHighlightVersion(const QString &internalName)
  382. {
  383. QString xmlFileName=QString("%1/share/apps/katepart/syntax/ktigcc%2.xml")
  384. .arg(KGlobal::dirs()->localkdedir()).arg(internalName);
  385. QDomDocument doc("language");
  386. QFile file(xmlFileName);
  387. if (!file.open(QIODevice::ReadOnly))
  388. return FALSE;
  389. if (!doc.setContent(&file)) {
  390. file.close();
  391. return FALSE;
  392. }
  393. file.close();
  394. QDomNode language=doc.elementsByTagName("language").item(0);
  395. if (language.isNull() || language.nodeType()!=QDomNode::ElementNode)
  396. return FALSE;
  397. QDomAttr version=language.toElement().attributeNode("version");
  398. if (version.isNull())
  399. return FALSE;
  400. QString versionNumber=version.value();
  401. return !isNewerVersion(CURRENT_SYNFILE_VERSION,versionNumber);
  402. }
  403. static void checkSynHighlightVersions(void)
  404. {
  405. if (!checkSynHighlightVersion("c"))
  406. writeSyntaxXML(preferences.synC,"C","c");
  407. if (!checkSynHighlightVersion("s"))
  408. writeSyntaxXML(preferences.synS,"GNU As","s");
  409. if (!checkSynHighlightVersion("asm"))
  410. writeSyntaxXML(preferences.synAsm,"A68k","asm");
  411. if (!checkSynHighlightVersion("qll"))
  412. writeSyntaxXML(preferences.synQll,"Quill","qll");
  413. }
  414. static bool loadSyntaxPreference(Syn_SettingsForDoc &synprefs, const QString &group)
  415. {
  416. pconfig->setGroup(group+" Syntax Highlighting");
  417. synprefs.enabled=pconfig->readBoolEntry("Enabled",true);
  418. synprefs.numberColor=pconfig->readEntry("Number Color",QColor());
  419. if (!synprefs.numberColor.isValid()) return FALSE;
  420. synprefs.symbolColor=pconfig->readEntry("Symbol Color",QColor());
  421. if (!synprefs.symbolColor.isValid()) return FALSE;
  422. unsigned numParenthesisColors=pconfig->readUnsignedNumEntry("Num Parenthesis Colors");
  423. for (unsigned i=0; i<numParenthesisColors; i++) {
  424. QColor parenthesisColor=pconfig->readEntry(QString("Parenthesis Color %1").arg(i),QColor());
  425. if (!parenthesisColor.isValid()) return FALSE;
  426. synprefs.parenthesisColors.append(parenthesisColor);
  427. }
  428. synprefs.numberStyle=pconfig->readUnsignedNumEntry("Number Style");
  429. synprefs.symbolStyle=pconfig->readUnsignedNumEntry("Symbol Style");
  430. synprefs.parenthesisStyle=pconfig->readUnsignedNumEntry("Parenthesis Style");
  431. unsigned numCustomStyles=pconfig->readUnsignedNumEntry("Num Custom Styles");
  432. for (unsigned i=0; i<numCustomStyles; i++) {
  433. Syn_CustomStyle customStyle;
  434. customStyle.name=pconfig->readEntry(QString("Custom Style %1 Name").arg(i),QString("Style %1").arg(i));
  435. customStyle.beginning=pconfig->readEntry(QString("Custom Style %1 Beginning").arg(i));
  436. customStyle.ending=pconfig->readEntry(QString("Custom Style %1 Ending").arg(i));
  437. QString ignoreEndingAfter=pconfig->readEntry(QString("Custom Style %1 Ignore Ending After").arg(i));
  438. customStyle.ignoreEndingAfter=ignoreEndingAfter.isEmpty()?QChar():ignoreEndingAfter[0];
  439. customStyle.switchable=pconfig->readBoolEntry(QString("Custom Style %1 Switchable").arg(i));
  440. customStyle.lineStartOnly=pconfig->readBoolEntry(QString("Custom Style %1 Line Start Only").arg(i));
  441. customStyle.color=pconfig->readEntry(QString("Custom Style %1 Color").arg(i),QColor());
  442. customStyle.style=pconfig->readUnsignedNumEntry(QString("Custom Style %1 Style").arg(i));
  443. synprefs.customStyles.append(customStyle);
  444. }
  445. unsigned numWordLists=pconfig->readUnsignedNumEntry("Num Word Lists");
  446. for (unsigned i=0; i<numWordLists; i++) {
  447. Syn_WordList wordList;
  448. wordList.name=pconfig->readEntry(QString("Word List %1 Name").arg(i),QString("Word List %1").arg(i));
  449. wordList.list=pconfig->readListEntry(QString("Word List %1 List").arg(i));
  450. wordList.color=pconfig->readEntry(QString("Word List %1 Color").arg(i),QColor());
  451. wordList.style=pconfig->readUnsignedNumEntry(QString("Word List %1 Style").arg(i));
  452. wordList.caseSensitive=pconfig->readBoolEntry(QString("Word List %1 Case Sensitive").arg(i));
  453. synprefs.wordLists.append(wordList);
  454. }
  455. return TRUE;
  456. }
  457. static bool loadSyntaxPreferences(void)
  458. {
  459. return loadSyntaxPreference(preferences.synC,"C")
  460. && loadSyntaxPreference(preferences.synS,"GNU As")
  461. && loadSyntaxPreference(preferences.synAsm,"A68k")
  462. && loadSyntaxPreference(preferences.synQll,"Quill");
  463. }
  464. static void saveSyntaxPreference(const Syn_SettingsForDoc &synprefs, const QString &group)
  465. {
  466. unsigned i;
  467. pconfig->setGroup(group+" Syntax Highlighting");
  468. pconfig->writeEntry("Enabled",synprefs.enabled);
  469. pconfig->writeEntry("Number Color",synprefs.numberColor);
  470. pconfig->writeEntry("Symbol Color",synprefs.symbolColor);
  471. i=0;
  472. foreach (const QColor &color, synprefs.parenthesisColors)
  473. pconfig->writeEntry(QString("Parenthesis Color %1").arg(i++),color);
  474. pconfig->writeEntry("Num Parenthesis Colors",i);
  475. pconfig->writeEntry("Number Style",(unsigned)synprefs.numberStyle);
  476. pconfig->writeEntry("Symbol Style",(unsigned)synprefs.symbolStyle);
  477. pconfig->writeEntry("Parenthesis Style",(unsigned)synprefs.parenthesisStyle);
  478. i=0;
  479. foreach (const Syn_CustomStyle &customStyle, synprefs.customStyles) {
  480. pconfig->writeEntry(QString("Custom Style %1 Name").arg(i),customStyle.name);
  481. pconfig->writeEntry(QString("Custom Style %1 Beginning").arg(i),customStyle.beginning);
  482. pconfig->writeEntry(QString("Custom Style %1 Ending").arg(i),customStyle.ending);
  483. pconfig->writeEntry(QString("Custom Style %1 Ignore Ending After").arg(i),QString(customStyle.ignoreEndingAfter));
  484. pconfig->writeEntry(QString("Custom Style %1 Switchable").arg(i),customStyle.switchable);
  485. pconfig->writeEntry(QString("Custom Style %1 Line Start Only").arg(i),customStyle.lineStartOnly);
  486. pconfig->writeEntry(QString("Custom Style %1 Color").arg(i),customStyle.color);
  487. pconfig->writeEntry(QString("Custom Style %1 Style").arg(i++),(unsigned)customStyle.style);
  488. }
  489. pconfig->writeEntry("Num Custom Styles",i);
  490. i=0;
  491. foreach (const Syn_WordList &wordList, synprefs.wordLists) {
  492. pconfig->writeEntry(QString("Word List %1 Name").arg(i),wordList.name);
  493. pconfig->writeEntry(QString("Word List %1 List").arg(i),wordList.list);
  494. pconfig->writeEntry(QString("Word List %1 Color").arg(i),wordList.color);
  495. pconfig->writeEntry(QString("Word List %1 Style").arg(i),(unsigned)wordList.style);
  496. pconfig->writeEntry(QString("Word List %1 Case Sensitive").arg(i++),wordList.caseSensitive);
  497. }
  498. pconfig->writeEntry("Num Word Lists",i);
  499. }
  500. static void saveSyntaxPreferences(void)
  501. {
  502. saveSyntaxPreference(preferences.synC,"C");
  503. saveSyntaxPreference(preferences.synS,"GNU As");
  504. saveSyntaxPreference(preferences.synAsm,"A68k");
  505. saveSyntaxPreference(preferences.synQll,"Quill");
  506. updateSyntaxXML();
  507. // Save to disk
  508. pconfig->sync();
  509. }
  510. void resetSyntaxPreference(Syn_SettingsForDoc *syn)
  511. {
  512. bool synIsC=(syn==&(preferences.synC) || syn==&(preferences.tempSynC));
  513. bool synIsS=(syn==&(preferences.synS) || syn==&(preferences.tempSynS));
  514. bool synIsAsm=(syn==&(preferences.synAsm) || syn==&(preferences.tempSynAsm));
  515. bool synIsQll=(syn==&(preferences.synQll) || syn==&(preferences.tempSynQll));
  516. syn->enabled=true;
  517. syn->numberColor=(synIsQll?QColor(128,64,64):QColor(128,0,0));
  518. syn->symbolColor=QColor(128,128,0);
  519. syn->parenthesisColors.clear();
  520. if (synIsQll)
  521. syn->parenthesisColors << QColor(0,0,0) << QColor(255,0,128);
  522. else
  523. syn->parenthesisColors << QColor(128,0,128) << QColor(0,128,192)
  524. << QColor(255,128,128) << QColor(0,128,0);
  525. syn->numberStyle=0;
  526. syn->symbolStyle=SYNS_CUSTOM|SYNS_BOLD;
  527. syn->parenthesisStyle=SYNS_CUSTOM|SYNS_BOLD;
  528. Syn_CustomStyle Comment_Area;
  529. Comment_Area.name="Comment Area";
  530. Comment_Area.beginning="/*";
  531. Comment_Area.ending="*/";
  532. Comment_Area.ignoreEndingAfter=0;
  533. Comment_Area.switchable=false;
  534. Comment_Area.lineStartOnly=false;
  535. Comment_Area.color=QColor(0,128,0);
  536. Comment_Area.style=SYNS_CUSTOM|SYNS_ITALIC;
  537. Syn_CustomStyle Comment_Line;
  538. Comment_Line.name="Comment Line";
  539. Comment_Line.beginning="//";
  540. Comment_Line.ending="\n";
  541. Comment_Line.ignoreEndingAfter=0;
  542. Comment_Line.switchable=false;
  543. Comment_Line.lineStartOnly=false;
  544. Comment_Line.color=QColor(0,128,0);
  545. Comment_Line.style=SYNS_CUSTOM|SYNS_ITALIC;
  546. Syn_CustomStyle SCS_String;
  547. SCS_String.name="String";
  548. SCS_String.beginning="\"";
  549. SCS_String.ending="\"";
  550. SCS_String.ignoreEndingAfter='\\';
  551. SCS_String.switchable=false;
  552. SCS_String.lineStartOnly=false;
  553. SCS_String.color=QColor(128,0,0);
  554. SCS_String.style=0;
  555. Syn_CustomStyle Character;
  556. Character.name="Character";
  557. Character.beginning="\'";
  558. Character.ending="\'";
  559. Character.ignoreEndingAfter='\\';
  560. Character.switchable=false;
  561. Character.lineStartOnly=false;
  562. Character.color=QColor(128,0,0);
  563. Character.style=0;
  564. Syn_CustomStyle Preprocessor_Directive;
  565. Preprocessor_Directive.name="Preprocessor Directive";
  566. Preprocessor_Directive.beginning="#";
  567. Preprocessor_Directive.ending=" ";
  568. Preprocessor_Directive.ignoreEndingAfter=0;
  569. Preprocessor_Directive.switchable=false;
  570. Preprocessor_Directive.lineStartOnly=false;
  571. Preprocessor_Directive.color=QColor(0,128,128);
  572. Preprocessor_Directive.style=SYNS_CUSTOM|SYNS_BOLD;
  573. Syn_CustomStyle Comment_Line_Pipe;
  574. Comment_Line_Pipe.name="Comment Line (|)";
  575. Comment_Line_Pipe.beginning="|";
  576. Comment_Line_Pipe.ending="\n";
  577. Comment_Line_Pipe.ignoreEndingAfter=0;
  578. Comment_Line_Pipe.switchable=false;
  579. Comment_Line_Pipe.lineStartOnly=false;
  580. Comment_Line_Pipe.color=QColor(0,128,0);
  581. Comment_Line_Pipe.style=SYNS_CUSTOM|SYNS_ITALIC;
  582. Syn_CustomStyle Comment_Line_Pound;
  583. Comment_Line_Pound.name="Comment Line (#)";
  584. Comment_Line_Pound.beginning="#";
  585. Comment_Line_Pound.ending="\n";
  586. Comment_Line_Pound.ignoreEndingAfter=0;
  587. Comment_Line_Pound.switchable=false;
  588. Comment_Line_Pound.lineStartOnly=true;
  589. Comment_Line_Pound.color=QColor(0,128,0);
  590. Comment_Line_Pound.style=SYNS_CUSTOM|SYNS_ITALIC;
  591. Syn_CustomStyle Comment_Line_Semicolon;
  592. Comment_Line_Semicolon.name="Comment";
  593. Comment_Line_Semicolon.beginning=";";
  594. Comment_Line_Semicolon.ending="\n";
  595. Comment_Line_Semicolon.ignoreEndingAfter=0;
  596. Comment_Line_Semicolon.switchable=false;
  597. Comment_Line_Semicolon.lineStartOnly=false;
  598. Comment_Line_Semicolon.color=QColor(0,128,0);
  599. Comment_Line_Semicolon.style=SYNS_CUSTOM|SYNS_ITALIC;
  600. Syn_CustomStyle String_DoubleQuoted;
  601. String_DoubleQuoted.name="String (double-quoted)";
  602. String_DoubleQuoted.beginning="\"";
  603. String_DoubleQuoted.ending="\"";
  604. String_DoubleQuoted.ignoreEndingAfter=0;
  605. String_DoubleQuoted.switchable=false;
  606. String_DoubleQuoted.lineStartOnly=false;
  607. String_DoubleQuoted.color=QColor(128,0,0);
  608. String_DoubleQuoted.style=0;
  609. Syn_CustomStyle String_SingleQuoted;
  610. String_SingleQuoted.name="String (single-quoted)";
  611. String_SingleQuoted.beginning="\'";
  612. String_SingleQuoted.ending="\'";
  613. String_SingleQuoted.ignoreEndingAfter=0;
  614. String_SingleQuoted.switchable=false;
  615. String_SingleQuoted.lineStartOnly=false;
  616. String_SingleQuoted.color=QColor(128,0,0);
  617. String_SingleQuoted.style=0;
  618. Syn_CustomStyle Compiler_Directive;
  619. Compiler_Directive.name="Compiler Directive";
  620. Compiler_Directive.beginning="#";
  621. Compiler_Directive.ending="\n";
  622. Compiler_Directive.ignoreEndingAfter='\\';
  623. Compiler_Directive.switchable=true;
  624. Compiler_Directive.lineStartOnly=false;
  625. Compiler_Directive.color=QColor(0,128,128);
  626. Compiler_Directive.style=SYNS_CUSTOM|SYNS_BOLD;
  627. syn->customStyles.clear();
  628. if (synIsC)
  629. syn->customStyles << Comment_Area << Comment_Line << SCS_String << Character << Preprocessor_Directive;
  630. else if (synIsS)
  631. syn->customStyles << Comment_Area << Comment_Line_Pipe << Comment_Line_Pound << SCS_String << Character;
  632. else if (synIsAsm)
  633. syn->customStyles << Comment_Line_Semicolon << String_DoubleQuoted << String_SingleQuoted;
  634. else if (synIsQll)
  635. syn->customStyles << Comment_Area << Comment_Line << SCS_String << Character << Compiler_Directive;
  636. Syn_WordList C_Keywords;
  637. C_Keywords.name="C Keywords";
  638. C_Keywords.list=QString(
  639. "__alignof__\n"
  640. "__asm__\n"
  641. "__attribute__\n"
  642. "__complex__\n"
  643. "__const__\n"
  644. "__extension__\n"
  645. "__imag__\n"
  646. "__inline__\n"
  647. "__label__\n"
  648. "__real__\n"
  649. "__typeof__\n"
  650. "asm\n"
  651. "auto\n"
  652. "break\n"
  653. "case\n"
  654. "char\n"
  655. "const\n"
  656. "continue\n"
  657. "default\n"
  658. "do\n"
  659. "double\n"
  660. "else\n"
  661. "enum\n"
  662. "extern\n"
  663. "float\n"
  664. "for\n"
  665. "goto\n"
  666. "if\n"
  667. "inline\n"
  668. "int\n"
  669. "long\n"
  670. "register\n"
  671. "return\n"
  672. "short\n"
  673. "signed\n"
  674. "sizeof\n"
  675. "static\n"
  676. "struct\n"
  677. "switch\n"
  678. "typedef\n"
  679. "typeof\n"
  680. "union\n"
  681. "unsigned\n"
  682. "void\n"
  683. "volatile\n"
  684. "while\n").split('\n',QString::SkipEmptyParts);
  685. C_Keywords.color=QColor(0,0,255);
  686. C_Keywords.style=SYNS_CUSTOM|SYNS_BOLD;
  687. C_Keywords.caseSensitive=true;
  688. Syn_WordList Data_Movement;
  689. Data_Movement.name="Data Movement";
  690. Data_Movement.list= QString(
  691. "EXG\n"
  692. "LEA\n"
  693. "LINK\n"
  694. "MOV\n"
  695. "MOVE\n"
  696. "MOVEA\n"
  697. "MOVEM\n"
  698. "MOVEP\n"
  699. "MOVEQ\n"
  700. "MOVM\n"
  701. "MOVP\n"
  702. "MOVQ\n"
  703. "PEA\n"
  704. "UNLK\n").split('\n',QString::SkipEmptyParts);
  705. Data_Movement.color=QColor(0,0,255);
  706. Data_Movement.style=0;
  707. Data_Movement.caseSensitive=false;
  708. Syn_WordList Integer_Arithmetic;
  709. Integer_Arithmetic.name="Integer Arithmetic";
  710. Integer_Arithmetic.list=QString(
  711. "ADD\n"
  712. "ADDA\n"
  713. "ADDI\n"
  714. "ADDQ\n"
  715. "ADDX\n"
  716. "CLR\n"
  717. "CMP\n"
  718. "CMPA\n"
  719. "CMPI\n"
  720. "CMPM\n"
  721. "DIVS\n"
  722. "DIVU\n"
  723. "EXT\n"
  724. "MULS\n"
  725. "MULU\n"
  726. "NEG\n"
  727. "NEGX\n"
  728. "SUB\n"
  729. "SUBA\n"
  730. "SUBI\n"
  731. "SUBQ\n"
  732. "SUBX\n"
  733. "TAS\n").split('\n',QString::SkipEmptyParts);
  734. Integer_Arithmetic.color=QColor(0,0,255);
  735. Integer_Arithmetic.style=0;
  736. Integer_Arithmetic.caseSensitive=false;
  737. Syn_WordList Logical_Instructions;
  738. Logical_Instructions.name="Logical Instructions";
  739. Logical_Instructions.list=QString(
  740. "AND\n"
  741. "ANDI\n"
  742. "EOR\n"
  743. "EORI\n"
  744. "NOT\n"
  745. "OR\n"
  746. "ORI\n").split('\n',QString::SkipEmptyParts);
  747. Logical_Instructions.color=QColor(0,0,255);
  748. Logical_Instructions.style=0;
  749. Logical_Instructions.caseSensitive=false;
  750. Syn_WordList ShiftRotation_Instructions;
  751. ShiftRotation_Instructions.name="Shift/Rotation Instructions";
  752. ShiftRotation_Instructions.list=QString(
  753. "ASL\n"
  754. "ASR\n"
  755. "LSL\n"
  756. "LSR\n"
  757. "ROL\n"
  758. "ROR\n"
  759. "ROXL\n"
  760. "ROXR\n"
  761. "SWAP\n").split('\n',QString::SkipEmptyParts);
  762. ShiftRotation_Instructions.color=QColor(0,0,255);
  763. ShiftRotation_Instructions.style=0;
  764. ShiftRotation_Instructions.caseSensitive=false;
  765. Syn_WordList Bit_Manipulation;
  766. Bit_Manipulation.name="Bit Manipulation";
  767. Bit_Manipulation.list=QString(
  768. "BCHG\n"
  769. "BCLR\n"
  770. "BSET\n"
  771. "BTST\n").split('\n',QString::SkipEmptyParts);
  772. Bit_Manipulation.color=QColor(0,0,255);
  773. Bit_Manipulation.style=0;
  774. Bit_Manipulation.caseSensitive=false;
  775. Syn_WordList Program_Control;
  776. Program_Control.name="Program Control";
  777. Program_Control.list= QString(
  778. "BCC\n"
  779. "BCS\n"
  780. "BEQ\n"
  781. "BGE\n"
  782. "BGT\n"
  783. "BHI\n"
  784. "BLE\n"
  785. "BLS\n"
  786. "BLT\n"
  787. "BMI\n"
  788. "BNE\n"
  789. "BPL\n"
  790. "BRA\n"
  791. "BSR\n"
  792. "BVC\n"
  793. "BVS\n"
  794. "JBCC\n"
  795. "JBCS\n"
  796. "JBEQ\n"
  797. "JBGE\n"
  798. "JBGT\n"
  799. "JBHI\n"
  800. "JBLE\n"
  801. "JBLS\n"
  802. "JBLT\n"
  803. "JBMI\n"
  804. "JBNE\n"
  805. "JBPL\n"
  806. "JBRA\n"
  807. "JBSR\n"
  808. "JBVC\n"
  809. "JBVS\n"
  810. "JSR\n"
  811. "JRA\n"
  812. "JMP\n"
  813. "NOP\n"
  814. "RTR\n"
  815. "RTS\n"
  816. "SCC\n"
  817. "SCS\n"
  818. "SEQ\n"
  819. "SF\n"
  820. "SGE\n"
  821. "SGT\n"
  822. "SHI\n"
  823. "SLE\n"
  824. "SLS\n"
  825. "SLT\n"
  826. "SMI\n"
  827. "SNE\n"
  828. "SPL\n"
  829. "ST\n"
  830. "SVC\n"
  831. "SVS\n"
  832. "TST\n"
  833. "JHI\n"
  834. "JLS\n"
  835. "JCC\n"
  836. "JCS\n"
  837. "JNE\n"
  838. "JEQ\n"
  839. "JVC\n"
  840. "JVS\n"
  841. "JPL\n"
  842. "JMI\n"
  843. "JGE\n"
  844. "JLT\n"
  845. "JGT\n"
  846. "JLE\n"
  847. "DBHI\n"
  848. "DBLS\n"
  849. "DBCC\n"
  850. "DBCS\n"
  851. "DBNE\n"
  852. "DBEQ\n"
  853. "DBVC\n"
  854. "DBVS\n"
  855. "DBPL\n"
  856. "DBMI\n"
  857. "DBGE\n"
  858. "DBLT\n"
  859. "DBGT\n"
  860. "DBLE\n"
  861. "DBF\n"
  862. "DBRA\n"
  863. "DBT\n"
  864. "FJNE\n"
  865. "FJEQ\n"
  866. "FJGE\n"
  867. "FJLT\n"
  868. "FJGT\n"
  869. "FJLE\n"
  870. "FJF\n"
  871. "FJT\n"
  872. "FJGL\n"
  873. "FJGLE\n"
  874. "FJNGE\n"
  875. "FJNGL\n"
  876. "FJNGLE\n"
  877. "FJNGT\n"
  878. "FJNLE\n"
  879. "FJNLT\n"
  880. "FJOGE\n"
  881. "FJOGL\n"
  882. "FJOGT\n"
  883. "FJOLE\n"
  884. "FJOLT\n"
  885. "FJOR\n"
  886. "FJSEQ\n"
  887. "FJSF\n"
  888. "FJSNE\n"
  889. "FJST\n"
  890. "FJUEQ\n"
  891. "FJUGE\n"
  892. "FJUGT\n"
  893. "FJULE\n"
  894. "FJULT\n"
  895. "FJUN\n").split('\n',QString::SkipEmptyParts);
  896. Program_Control.color=QColor(0,0,255);
  897. Program_Control.style=0;
  898. Program_Control.caseSensitive=false;
  899. Syn_WordList System_Control;
  900. System_Control.name="System Control";
  901. System_Control.list=QString(
  902. "ILLEGAL\n"
  903. "RTE\n"
  904. "TRAP\n").split('\n',QString::SkipEmptyParts);
  905. System_Control.color=QColor(0,0,255);
  906. System_Control.style=0;
  907. System_Control.caseSensitive=false;
  908. Syn_WordList SWL_Extensions;
  909. SWL_Extensions.name="Extensions";
  910. SWL_Extensions.list=QString(
  911. "B\n"
  912. "L\n"
  913. "S\n"
  914. "W\n").split('\n',QString::SkipEmptyParts);
  915. SWL_Extensions.color=QColor(0,128,64);
  916. SWL_Extensions.style=0;
  917. SWL_Extensions.caseSensitive=false;
  918. Syn_WordList Assembler_Directives;
  919. Assembler_Directives.name="Assembler Directives";
  920. Assembler_Directives.list=QString(
  921. "abort\n"
  922. "align\n"
  923. "altmacro\n"
  924. "ascii\n"
  925. "asciz\n"
  926. "balign\n"
  927. "balignw\n"
  928. "balignl\n"
  929. "byte\n"
  930. "comm\n"
  931. "data\n"
  932. "def\n"
  933. "dim\n"
  934. "double\n"
  935. "eject\n"
  936. "else\n"
  937. "end\n"
  938. "elseif\n"
  939. "endef\n"
  940. "endfunc\n"
  941. "endif\n"
  942. "endm\n"
  943. "endr\n"
  944. "equ\n"
  945. "equiv\n"
  946. "err\n"
  947. "even\n"
  948. "exitm\n"
  949. "extern\n"
  950. "fail\n"
  951. "file\n"
  952. "fill\n"
  953. "float\n"
  954. "func\n"
  955. "global\n"
  956. "globl\n"
  957. "hword\n"
  958. "ident\n"
  959. "if\n"
  960. "include\n"
  961. "incbin\n"
  962. "int\n"
  963. "irp\n"
  964. "irpc\n"
  965. "lcomm\n"
  966. "lflags\n"
  967. "line\n"
  968. "ln\n"
  969. "list\n"
  970. "long\n"
  971. "macro\n"
  972. "mri\n"
  973. "noaltmacro\n"
  974. "nolist\n"
  975. "octa\n"
  976. "org\n"
  977. "p2align\n"
  978. "p2alignw\n"
  979. "p2alignl\n"
  980. "print\n"
  981. "psize\n"
  982. "purgem\n"
  983. "quad\n"
  984. "rept\n"
  985. "sbttl\n"
  986. "scl\n"
  987. "section\n"
  988. "set\n"
  989. "short\n"
  990. "single\n"
  991. "size\n"
  992. "sleb128\n"
  993. "skip\n"
  994. "space\n"
  995. "stabd\n"
  996. "stabn\n"
  997. "stabs\n"
  998. "string\n"
  999. "struct\n"
  1000. "tag\n"
  1001. "text\n"
  1002. "title\n"
  1003. "type\n"
  1004. "uleb128\n"
  1005. "val\n"
  1006. "vtable_entry\n"
  1007. "word\n"
  1008. "xdef\n").split('\n',QString::SkipEmptyParts);
  1009. Assembler_Directives.color=QColor(0,0,255);
  1010. Assembler_Directives.style=SYNS_CUSTOM|SYNS_BOLD;
  1011. Assembler_Directives.caseSensitive=true;
  1012. Syn_WordList SWL_Registers;
  1013. SWL_Registers.name="Registers";
  1014. SWL_Registers.list= QString(
  1015. "a0\n"
  1016. "a1\n"
  1017. "a2\n"
  1018. "a3\n"
  1019. "a4\n"
  1020. "a5\n"
  1021. "a6\n"
  1022. "a7\n"
  1023. "d0\n"
  1024. "d1\n"
  1025. "d2\n"
  1026. "d3\n"
  1027. "d4\n"
  1028. "d5\n"
  1029. "d6\n"
  1030. "d7\n"
  1031. "fp\n"
  1032. "pc\n"
  1033. "sp\n"
  1034. "sr\n").split('\n',QString::SkipEmptyParts);
  1035. SWL_Registers.color=QColor(255,0,0);
  1036. SWL_Registers.style=SYNS_CUSTOM|SYNS_UNDERLINE;
  1037. SWL_Registers.caseSensitive=false;
  1038. Syn_WordList Data_Movement_a68k;
  1039. Data_Movement_a68k.name="Data Movement";
  1040. Data_Movement_a68k.list= QString(
  1041. "EXG\n"
  1042. "LEA\n"
  1043. "LINK\n"
  1044. "MOVE\n"
  1045. "MOVEA\n"
  1046. "MOVEM\n"
  1047. "MOVEP\n"
  1048. "MOVEQ\n"
  1049. "PEA\n"
  1050. "UNLK\n").split('\n',QString::SkipEmptyParts);
  1051. Data_Movement_a68k.color=QColor(0,0,255);
  1052. Data_Movement_a68k.style=0;
  1053. Data_Movement_a68k.caseSensitive=false;
  1054. Syn_WordList ShiftRotation_Instructions_a68k;
  1055. ShiftRotation_Instructions_a68k.name="Shift/Rotation Instructions";
  1056. ShiftRotation_Instructions_a68k.list=QString(
  1057. "ASL\n"
  1058. "ASR\n"
  1059. "LSL\n"
  1060. "LSR\n"
  1061. "ROL\n"
  1062. "ROLX\n"
  1063. "ROR\n"
  1064. "RORX\n"
  1065. "ROXL\n"
  1066. "ROXR\n"
  1067. "SWAP\n").split('\n',QString::SkipEmptyParts);
  1068. ShiftRotation_Instructions_a68k.color=QColor(0,0,255);
  1069. ShiftRotation_Instructions_a68k.style=0;
  1070. ShiftRotation_Instructions_a68k.caseSensitive=false;
  1071. Syn_WordList Program_Control_a68k;
  1072. Program_Control_a68k.name="Program Control";
  1073. Program_Control_a68k.list=QString(
  1074. "BCC\n"
  1075. "BCS\n"
  1076. "BEQ\n"
  1077. "BGE\n"
  1078. "BGT\n"
  1079. "BHI\n"
  1080. "BHS\n"
  1081. "BLE\n"
  1082. "BLO\n"
  1083. "BLS\n"
  1084. "BLT\n"
  1085. "BMI\n"
  1086. "BNE\n"
  1087. "BPL\n"
  1088. "BRA\n"
  1089. "BSR\n"
  1090. "BVC\n"
  1091. "BVS\n"
  1092. "DBCC\n"
  1093. "DBCS\n"
  1094. "DBEQ\n"
  1095. "DBF\n"
  1096. "DBGE\n"
  1097. "DBGT\n"
  1098. "DBHI\n"
  1099. "DBHS\n"
  1100. "DBLE\n"
  1101. "DBLO\n"
  1102. "DBLS\n"
  1103. "DBLT\n"
  1104. "DBMI\n"
  1105. "DBNE\n"
  1106. "DBPL\n"
  1107. "DBRA\n"
  1108. "DBT\n"
  1109. "DBVC\n"
  1110. "DBVS\n"
  1111. "JMP\n"
  1112. "JSR\n"
  1113. "NOP\n"
  1114. "RTR\n"
  1115. "RTS\n"
  1116. "SCC\n"
  1117. "SCS\n"
  1118. "SEQ\n"
  1119. "SF\n"
  1120. "SGE\n"
  1121. "SGT\n"
  1122. "SHI\n"
  1123. "SHS\n"
  1124. "SLE\n"
  1125. "SLO\n"
  1126. "SLS\n"
  1127. "SLT\n"
  1128. "SMI\n"
  1129. "SNE\n"
  1130. "SPL\n"
  1131. "ST\n"
  1132. "SVC\n"
  1133. "SVS\n"
  1134. "TST\n").split('\n',QString::SkipEmptyParts);
  1135. Program_Control_a68k.color=QColor(0,0,255);
  1136. Program_Control_a68k.style=0;
  1137. Program_Control_a68k.caseSensitive=false;
  1138. Syn_WordList Assembler_Directives_a68k;
  1139. Assembler_Directives_a68k.name="Assembler Directives";
  1140. Assembler_Directives_a68k.list= QString(
  1141. "BSS\n"
  1142. "CNOP\n"
  1143. "CSEG\n"
  1144. "DSEG\n"
  1145. "DC\n"
  1146. "DCB\n"
  1147. "DS\n"
  1148. "END\n"
  1149. "ENDC\n"
  1150. "ENDIF\n"
  1151. "ENDM\n"
  1152. "EQU\n"
  1153. "EQUR\n"
  1154. "EVEN\n"
  1155. "FAR\n"
  1156. "IDNT\n"
  1157. "IFC\n"
  1158. "IFD\n"
  1159. "IFEQ\n"
  1160. "IFGE\n"
  1161. "IFGT\n"
  1162. "IFLE\n"
  1163. "IFLT\n"
  1164. "IFNC\n"
  1165. "IFND\n"
  1166. "IFNE\n"
  1167. "INCBIN\n"
  1168. "INCLUDE\n"
  1169. "LIST\n"
  1170. "MACRO\n"
  1171. "NEAR\n"
  1172. "NOLIST\n"
  1173. "ORG\n"
  1174. "PAGE\n"
  1175. "PUBLIC\n"
  1176. "REG\n"
  1177. "RORG\n"
  1178. "SECTION\n"
  1179. "SET\n"
  1180. "SPC\n"
  1181. "TITLE\n"
  1182. "TTL\n"
  1183. "XDEF\n"
  1184. "XREF\n").split('\n',QString::SkipEmptyParts);
  1185. Assembler_Directives_a68k.color=QColor(0,0,255);
  1186. Assembler_Directives_a68k.style=SYNS_CUSTOM|SYNS_BOLD;
  1187. Assembler_Directives_a68k.caseSensitive=false;
  1188. Syn_WordList SWL_Sections;
  1189. SWL_Sections.name="Sections";
  1190. SWL_Sections.list=QString(
  1191. "$$ACTIONS\n"
  1192. "$$CONNECTIONS\n"
  1193. "$$END\n"
  1194. "$$END_TEST\n"
  1195. "$$EVENTS\n"
  1196. "$$EXTERN\n"
  1197. "$$LOCATIONS\n"
  1198. "$$MESSAGES\n"
  1199. "$$OBJECTS\n"
  1200. "$$OLDSTYLE_SYSTEM_MESSAGES\n"
  1201. "$$PICTURES\n"
  1202. "$$PICTURES_TEST\n"
  1203. "$$SYSTEM_MESSAGES\n"
  1204. "$$TITLE\n"
  1205. "$$VOCABULARY\n").split('\n',QString::SkipEmptyParts);
  1206. SWL_Sections.color=QColor(255,0,0);
  1207. SWL_Sections.style=SYNS_CUSTOM|SYNS_BOLD;
  1208. SWL_Sections.caseSensitive=true;
  1209. Syn_WordList Section_Specific_Keywords;
  1210. Section_Specific_Keywords.name="Section-specific Keywords";
  1211. Section_Specific_Keywords.list= QString(
  1212. "ACTION\n"
  1213. "BITMAP\n"
  1214. "CBLOCK\n"
  1215. "CONN\n"
  1216. "DEFINE\n"
  1217. "DRAWING\n"
  1218. "END_BITMAP\n"
  1219. "END_CBLOCK\n"
  1220. "END_DRAWING\n"
  1221. "END_PACKED_BITMAP\n"
  1222. "EVENT\n"
  1223. "FROM\n"
  1224. "LOC\n"
  1225. "MSG\n"
  1226. "OBJ\n"
  1227. "PACKED_BITMAP\n"
  1228. "WORD\n").split('\n',QString::SkipEmptyParts);
  1229. Section_Specific_Keywords.color=QColor(64,128,128);
  1230. Section_Specific_Keywords.style=SYNS_CUSTOM|SYNS_BOLD;
  1231. Section_Specific_Keywords.caseSensitive=true;
  1232. Syn_WordList AdditionalKeywords;
  1233. AdditionalKeywords.name="Additional Keywords";
  1234. AdditionalKeywords.list=QString(
  1235. "CONTINUE\n"
  1236. "ELSE\n").split('\n',QString::SkipEmptyParts);
  1237. AdditionalKeywords.color=QColor(64,128,128);
  1238. AdditionalKeywords.style=SYNS_CUSTOM|SYNS_BOLD;
  1239. AdditionalKeywords.caseSensitive=true;
  1240. Syn_WordList PredefinedAliases;
  1241. PredefinedAliases.name="Predefined Aliases";
  1242. PredefinedAliases.list= QString(
  1243. "$ALSOSEE\n"
  1244. "$ARG\n"
  1245. "$CARRIED\n"
  1246. "$CENTER\n"
  1247. "$CNT1\n"
  1248. "$CNT2\n"
  1249. "$CNT3\n"
  1250. "$CNT4\n"
  1251. "$CONT\n"
  1252. "$CURLOC\n"
  1253. "$DARK\n"
  1254. "$DARKCNT\n"
  1255. "$DESC\n"
  1256. "$DESC_CNT\n"
  1257. "$DESC_DARKCNT\n"
  1258. "$DESC_NOLIGHTCNT\n"
  1259. "$DONE\n"
  1260. "$ENDGAME\n"
  1261. "$EXIT\n"
  1262. "$FAIL\n"
  1263. "$FONT\n"
  1264. "$FULLSCR\n"
  1265. "$GCONTROL\n"
  1266. "$LSOURCE\n"
  1267. "$MAXCAR\n"
  1268. "$NOLIGHTCNT\n"
  1269. "$NOUN\n"
  1270. "$NOWHERE\n"
  1271. "$NULL\n"
  1272. "$NUMCAR\n"
  1273. "$PROMPT\n"
  1274. "$RESTART\n"
  1275. "$SCORE\n"
  1276. "$SPECIAL\n"
  1277. "$SUBROUTINE\n"
  1278. "$TURNHI\n"
  1279. "$TURNLO\n"
  1280. "$VERB\n"
  1281. "$WORN\n").split('\n',QString::SkipEmptyParts);
  1282. PredefinedAliases.color=QColor(128,0,128);
  1283. PredefinedAliases.style=SYNS_CUSTOM|SYNS_BOLD;
  1284. PredefinedAliases.caseSensitive=true;
  1285. Syn_WordList SWL_Conditions;
  1286. SWL_Conditions.name="Conditions";
  1287. SWL_Conditions.list=QString(
  1288. "ABSENT\n"
  1289. "AT\n"
  1290. "ATGT\n"
  1291. "ATLT\n"
  1292. "CARRIED\n"
  1293. "CHANCE\n"
  1294. "CREATED\n"
  1295. "EQ\n"
  1296. "EQWORD\n"
  1297. "EXTWORD\n"
  1298. "GT\n"
  1299. "HERE\n"
  1300. "ISAT\n"
  1301. "ISDESC\n"
  1302. "ISNOTAT\n"
  1303. "ISNOTNULL\n"
  1304. "ISNULL\n"
  1305. "LT\n"
  1306. "NEQWORD\n"
  1307. "NOTAT\n"
  1308. "NOTCARR\n"
  1309. "NOTCREATED\n"
  1310. "NOTEQ\n"
  1311. "NOTHERE\n"
  1312. "NOTSAME\n"
  1313. "NOTWORN\n"
  1314. "NOTZERO\n"
  1315. "PRESENT\n"
  1316. "SAME\n"
  1317. "TRYMOVE\n"
  1318. "WORN\n"
  1319. "ZERO\n").split('\n',QString::SkipEmptyParts);
  1320. SWL_Conditions.color=QColor(0,0,255);
  1321. SWL_Conditions.style=SYNS_CUSTOM|SYNS_BOLD;
  1322. SWL_Conditions.caseSensitive=true;
  1323. Syn_WordList SWL_Actions;
  1324. SWL_Actions.name="Actions";
  1325. SWL_Actions.list= QString(
  1326. "ADD\n"
  1327. "ALSOSEE\n"
  1328. "ANYKEY\n"
  1329. "AUTOD\n"
  1330. "AUTOG\n"
  1331. "AUTOR\n"
  1332. "AUTOW\n"
  1333. "BIGFONT\n"
  1334. "CANCEL\n"
  1335. "CLEAR\n"
  1336. "CLS\n"
  1337. "COPYFF\n"
  1338. "COPYFO\n"
  1339. "COPYOF\n"
  1340. "COPYOO\n"
  1341. "CREATE\n"
  1342. "DECCAR\n"
  1343. "DESC\n"
  1344. "DESTROY\n"
  1345. "DONE\n"
  1346. "DROP\n"
  1347. "DROPALL\n"
  1348. "END\n"
  1349. "ENDDESC\n"
  1350. "EXIT\n"
  1351. "EXTERN\n"
  1352. "GET\n"
  1353. "GETWORD\n"
  1354. "GOTO\n"
  1355. "INCCAR\n"
  1356. "INVEN\n"
  1357. "LET\n"
  1358. "LISTAT\n"
  1359. "LISTOBJ\n"
  1360. "LOAD\n"
  1361. "MAXCAR\n"
  1362. "MES\n"
  1363. "MESFLAG\n"
  1364. "MESSAGE\n"
  1365. "MINUS\n"
  1366. "NEWLINE\n"
  1367. "NOTDONE\n"
  1368. "OK\n"
  1369. "PAUSE\n"
  1370. "PICNORM\n"
  1371. "PICOFF\n"
  1372. "PICON\n"
  1373. "PLACE\n"
  1374. "PLUS\n"
  1375. "PRINT\n"
  1376. "PROMPT\n"
  1377. "PUTO\n"
  1378. "QUIT\n"
  1379. "QVERSION\n"
  1380. "RAMLOAD\n"
  1381. "RAMSAVE\n"
  1382. "RANDOM\n"
  1383. "REDRAW\n"
  1384. "REMOVE\n"
  1385. "RESTART\n"
  1386. "SAVE\n"
  1387. "SCORE\n"
  1388. "SET\n"
  1389. "SETNOUN\n"
  1390. "SETVERB\n"
  1391. "SHOWLOC\n"
  1392. "SMLFONT\n"
  1393. "SUB\n"
  1394. "SWAP\n"
  1395. "SYSMESS\n"
  1396. "TURNS\n"
  1397. "WEAR\n"
  1398. "WHATO\n"
  1399. "WHEREO\n"
  1400. "ZAPSCR\n").split('\n',QString::SkipEmptyParts);
  1401. SWL_Actions.color=QColor(0,0,160);
  1402. SWL_Actions.style=SYNS_CUSTOM|SYNS_BOLD;
  1403. SWL_Actions.caseSensitive=true;
  1404. Syn_WordList Drawing_Primitives;
  1405. Drawing_Primitives.name="Drawing primitives";
  1406. Drawing_Primitives.list=QString(
  1407. "AMOVE\n"
  1408. "CALL\n"
  1409. "ELLIPSE\n"
  1410. "FILL\n"
  1411. "INV_ELLIPSE\n"
  1412. "INV_LINE\n"
  1413. "INV_PLOT\n"
  1414. "INV_RPLOT\n"
  1415. "LINE\n"
  1416. "MOVE\n"
  1417. "PLOT\n"
  1418. "RPLOT\n"
  1419. "SHADE\n"
  1420. "XOR_ELLIPSE\n"
  1421. "XOR_LINE\n"
  1422. "XOR_PLOT\n"
  1423. "XOR_RPLOT\n").split('\n',QString::SkipEmptyParts);
  1424. Drawing_Primitives.color=QColor(0,64,128);
  1425. Drawing_Primitives.style=SYNS_CUSTOM|SYNS_BOLD;
  1426. Drawing_Primitives.caseSensitive=true;
  1427. Syn_WordList Drawing_Directions;
  1428. Drawing_Directions.name="Drawing directions";
  1429. Drawing_Directions.list=QString(
  1430. "DOWN\n"
  1431. "DOWN_LEFT\n"
  1432. "DOWN_RIGHT\n"
  1433. "LEFT\n"
  1434. "LEFT_DOWN\n"
  1435. "LEFT_UP\n"
  1436. "RIGHT\n"
  1437. "RIGHT_DOWN\n"
  1438. "RIGHT_UP\n"
  1439. "UP\n"
  1440. "UP_LEFT\n"
  1441. "UP_RIGHT\n").split('\n',QString::SkipEmptyParts);
  1442. Drawing_Directions.color=QColor(0,128,0);
  1443. Drawing_Directions.style=SYNS_CUSTOM|SYNS_BOLD;
  1444. Drawing_Directions.caseSensitive=true;
  1445. Syn_WordList Shading_Patterns;
  1446. Shading_Patterns.name="Shading patterns";
  1447. Shading_Patterns.list=QString(
  1448. "$BKSLASHFILL\n"
  1449. "$BRICKFILL\n"
  1450. "$CHAINFILL\n"
  1451. "$CIRCLEFILL\n"
  1452. "$CLOSEDASHFILL\n"
  1453. "$CLOSEDOTFILL\n"
  1454. "$CLOSEWAVEFILL\n"
  1455. "$CROSSFILL\n"
  1456. "$DASHFILL\n"
  1457. "$DOTFILL\n"
  1458. "$HATCHFILL\n"
  1459. "$INTERLEAVEFILL\n"
  1460. "$LIGHTDOTFILL\n"
  1461. "$LIGHTLINEFILL\n"
  1462. "$LINEFILL\n"
  1463. "$SLASHFILL\n"
  1464. "$SOLIDFILL\n"
  1465. "$SQDOTFILL\n"
  1466. "$SQUAREFILL\n"
  1467. "$THICKBKSLASHFILL\n"
  1468. "$THICKHATCHFILL\n"
  1469. "$THICKLINEFILL\n"
  1470. "$THICKSLASHFILL\n"
  1471. "$VDASHFILL\n"
  1472. "$VINTERLEAVEFILL\n"
  1473. "$VLDOTFILL\n"
  1474. "$VLIGHTLINEFILL\n"
  1475. "$VLINEFILL\n"
  1476. "$VTHICKLINEFILL\n"
  1477. "$WAVEFILL\n"
  1478. "$WIDEDOTFILL\n"
  1479. "$XMARKFILL\n"
  1480. "$ZIGZAGFILL\n").split('\n',QString::SkipEmptyParts);
  1481. Shading_Patterns.color=QColor(128,0,128);
  1482. Shading_Patterns.style=SYNS_CUSTOM|SYNS_BOLD;
  1483. Shading_Patterns.caseSensitive=true;
  1484. Syn_WordList NonFunctional_Keywords;
  1485. NonFunctional_Keywords.name="Non-functional keywords";
  1486. NonFunctional_Keywords.list=QString(
  1487. "BEEP\n"
  1488. "BLOCK\n"
  1489. "BORDER\n"
  1490. "BRIGHT\n"
  1491. "FLASH\n"
  1492. "INK\n"
  1493. "PAPER\n").split('\n',QString::SkipEmptyParts);
  1494. NonFunctional_Keywords.color=QColor(192,192,192);
  1495. NonFunctional_Keywords.style=SYNS_CUSTOM|SYNS_BOLD;
  1496. NonFunctional_Keywords.caseSensitive=true;
  1497. Syn_WordList External_Symbols;
  1498. External_Symbols.name="External symbols";
  1499. External_Symbols.list=QString(
  1500. "$ACTIONS$\n"
  1501. "$ARG$\n"
  1502. "$BMPUT$\n"
  1503. "$BPCKPUT$\n"
  1504. "$BUFFER$\n"
  1505. "$CONNECTIONS$\n"
  1506. "$EVENTS$\n"
  1507. "$EXTERN$\n"
  1508. "$FLAGS$\n"
  1509. "$FLAGS_BACKUP$\n"
  1510. "$GDF$\n"
  1511. "$GETLINE$\n"
  1512. "$LOCATIONS$\n"
  1513. "$LQL$\n"
  1514. "$MAXCAR$\n"
  1515. "$MESSAGES$\n"
  1516. "$NFLAG$\n"
  1517. "$NLOC$\n"
  1518. "$NMSG$\n"
  1519. "$NOBJ$\n"
  1520. "$NSYSMSG$\n"
  1521. "$NWORD$\n"
  1522. "$OBJECTS$\n"
  1523. "$PDRAW$\n"
  1524. "$PICTURE$\n"
  1525. "$PRINT$\n"
  1526. "$RAM_SAVED$\n"
  1527. "$SCALEX$\n"
  1528. "$SCALEY$\n"
  1529. "$SSCR$\n"
  1530. "$SYSTEM_MESSAGES$\n"
  1531. "$WORDS$\n").split('\n',QString::SkipEmptyParts);
  1532. External_Symbols.color=QColor(0,128,64);
  1533. External_Symbols.style=SYNS_CUSTOM|SYNS_BOLD;
  1534. External_Symbols.caseSensitive=true;
  1535. syn->wordLists.clear();
  1536. if (synIsC)
  1537. syn->wordLists << C_Keywords;
  1538. else if (synIsS)
  1539. syn->wordLists << Data_Movement << Integer_Arithmetic << Logical_Instructions << ShiftRotation_Instructions << Bit_Manipulation << Program_Control << System_Control << SWL_Extensions << Assembler_Directives << SWL_Registers;
  1540. else if (synIsAsm)
  1541. 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;
  1542. else if (synIsQll)
  1543. 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;
  1544. }
  1545. static void defaultSynHighlight(void)
  1546. {
  1547. resetSyntaxPreference(&(preferences.synC));
  1548. resetSyntaxPreference(&(preferences.synS));
  1549. resetSyntaxPreference(&(preferences.synAsm));
  1550. resetSyntaxPreference(&(preferences.synQll));
  1551. saveSyntaxPreferences();
  1552. }
  1553. // Update the Kate schema from our internal ones.
  1554. static void updateEditorPreferences(void)
  1555. {
  1556. KConfig kateschema("kateschemarc");
  1557. QColor color;
  1558. if (preferences.useBgColor) {
  1559. kateschema.setGroup("ktigcc - Normal");
  1560. kateschema.writeEntry("Color Background",preferences.bgColor);
  1561. kateschema.writeEntry("Color Highlighted Line",preferences.bgColor);
  1562. } else {
  1563. kateschema.setGroup("kate - Normal");
  1564. color=kateschema.readEntry("Color Background",QColor(255,255,255));
  1565. kateschema.setGroup("ktigcc - Normal");
  1566. kateschema.writeEntry("Color Background",color);
  1567. kateschema.setGroup("kate - Normal");
  1568. color=kateschema.readEntry("Color Highlighted Line",QColor(240,240,240));
  1569. kateschema.setGroup("ktigcc - Normal");
  1570. kateschema.writeEntry("Color Highlighted Line",color);
  1571. }
  1572. kateschema.setGroup("kate - Normal");
  1573. color=kateschema.readEntry("Color Highlighted Bracket",QColor(255,255,153));
  1574. kateschema.setGroup("ktigcc - Normal");
  1575. kateschema.writeEntry("Color Highlighted Bracket",color);
  1576. kateschema.setGroup("kate - Normal");
  1577. color=kateschema.readEntry("Color Icon Bar",QColor(234,233,232));
  1578. kateschema.setGroup("ktigcc - Normal");
  1579. kateschema.writeEntry("Color Icon Bar",color);
  1580. kateschema.setGroup("kate - Normal");
  1581. color=kateschema.readEntry("Color Line Number",QColor(0,0,0));
  1582. kateschema.setGroup("ktigcc - Normal");
  1583. kateschema.writeEntry("Color Line Number",color);
  1584. kateschema.setGroup("kate - Normal");
  1585. color=kateschema.readEntry("Color MarkType1",QColor(0,0,255));
  1586. kateschema.setGroup("ktigcc - Normal");
  1587. kateschema.writeEntry("Color MarkType1",color);
  1588. kateschema.setGroup("kate - Normal");
  1589. color=kateschema.readEntry("Color MarkType2",QColor(255,0,0));
  1590. kateschema.setGroup("ktigcc - Normal");
  1591. kateschema.writeEntry("Color MarkType2",color);
  1592. kateschema.setGroup("kate - Normal");
  1593. color=kateschema.readEntry("Color MarkType3",QColor(255,255,0));
  1594. kateschema.setGroup("ktigcc - Normal");
  1595. kateschema.writeEntry("Color MarkType3",color);
  1596. kateschema.setGroup("kate - Normal");
  1597. color=kateschema.readEntry("Color MarkType4",QColor(255,0,255));
  1598. kateschema.setGroup("ktigcc - Normal");
  1599. kateschema.writeEntry("Color MarkType4",color);
  1600. kateschema.setGroup("kate - Normal");
  1601. color=kateschema.readEntry("Color MarkType5",QColor(160,160,164));
  1602. kateschema.setGroup("ktigcc - Normal");
  1603. kateschema.writeEntry("Color MarkType5",color);
  1604. kateschema.setGroup("kate - Normal");
  1605. color=kateschema.readEntry("Color MarkType6",QColor(0,255,0));
  1606. kateschema.setGroup("ktigcc - Normal");
  1607. kateschema.writeEntry("Color MarkType6",color);
  1608. kateschema.setGroup("kate - Normal");
  1609. color=kateschema.readEntry("Color MarkType7",QColor(255,0,0));
  1610. kateschema.setGroup("ktigcc - Normal");
  1611. kateschema.writeEntry("Color MarkType7",color);
  1612. kateschema.setGroup("kate - Normal");
  1613. color=kateschema.readEntry("Color Selection",QColor(76,89,166));
  1614. kateschema.setGroup("ktigcc - Normal");
  1615. kateschema.writeEntry("Color Selection",color);
  1616. kateschema.setGroup("kate - Normal");
  1617. color=kateschema.readEntry("Color Tab Marker",QColor(0,0,0));
  1618. kateschema.setGroup("ktigcc - Normal");
  1619. kateschema.writeEntry("Color Tab Marker",color);
  1620. kateschema.setGroup("kate - Normal");
  1621. color=kateschema.readEntry("Color Word Wrap Marker",QColor(120,120,120));
  1622. kateschema.setGroup("ktigcc - Normal");
  1623. kateschema.writeEntry("Color Word Wrap Marker",color);
  1624. kateschema.writeEntry("Font",preferences.editorFont);
  1625. }
  1626. void loadPreferences(void)
  1627. {
  1628. // This doesn't really _load_ a preference...
  1629. if (!pconfig->hasGroup("Kate Document Defaults")) {
  1630. pconfig->setGroup("Kate Document Defaults");
  1631. pconfig->writeEntry("Tab Handling",0);
  1632. pconfig->writeEntry("Basic Config Flags",0x1000020u);
  1633. pconfig->sync();
  1634. }
  1635. pconfig->setGroup("Preferences");
  1636. // General
  1637. preferences.stopAtFirstError=pconfig->readBoolEntry("Stop at First Error",false);
  1638. preferences.jumpToError=pconfig->readBoolEntry("Jump to Error",true);
  1639. preferences.successMessage=pconfig->readBoolEntry("Success Message",true);
  1640. preferences.deleteAsmFiles=pconfig->readBoolEntry("Delete Asm Files",true);
  1641. preferences.deleteObjFiles=pconfig->readBoolEntry("Delete Object Files",false);
  1642. preferences.splitSourceFiles=pconfig->readBoolEntry("Split Source Files",true);
  1643. preferences.allowImplicitDeclaration=pconfig->readBoolEntry("Allow Implicit Declaration",true);
  1644. preferences.autoSave=pconfig->readBoolEntry("Auto Save",true);
  1645. preferences.downloadHeadlines=pconfig->readBoolEntry("Download Headlines",false);
  1646. preferences.deleteOverwrittenErrors=pconfig->readBoolEntry("Delete Overwritten Errors",true);
  1647. preferences.useSystemIcons=pconfig->readBoolEntry("Use System Icons",true);
  1648. // Transfer
  1649. preferences.linkTarget=(LinkTargets)pconfig->readNumEntry("Link Target",LT_NONE);
  1650. preferences.linkPort=(CablePort)pconfig->readNumEntry("Link Port",PORT_1);
  1651. preferences.linkCable=(CableModel)pconfig->readNumEntry("Link Cable",CABLE_GRY);
  1652. // Don't allow selecting a USB cable if libticables2 has been compiled without
  1653. // USB support or if USB support can't be used.
  1654. if (!have_usb) {
  1655. if (preferences.linkCable==CABLE_SLV || preferences.linkCable==CABLE_USB) {
  1656. preferences.linkCable=CABLE_GRY;
  1657. preferences.linkTarget=LT_NONE;
  1658. }
  1659. }
  1660. // Editor
  1661. preferences.tabWidthC=pconfig->readUnsignedNumEntry("Tab Width C",2);
  1662. preferences.tabWidthAsm=pconfig->readUnsignedNumEntry("Tab Width Asm",8);
  1663. preferences.useBgColor=pconfig->readBoolEntry("Use Background Color",false);
  1664. preferences.bgColor=pconfig->readEntry("Background Color",QColor(255,255,255));
  1665. preferences.editorFont=pconfig->readEntry("Editor Font",QFont("Monospace",10));
  1666. preferences.useCalcCharset=pconfig->readBoolEntry("Use Calc Charset",true);
  1667. preferences.autoBlocks=pconfig->readBoolEntry("Auto Blocks",true);
  1668. preferences.removeTrailingSpaces=pconfig->readBoolEntry("Remove Trailing Spaces",false);
  1669. updateEditorPreferences();
  1670. // Coding
  1671. if (pconfig->hasKey("Num Coding Templates")) {
  1672. unsigned numTemplates=pconfig->readUnsignedNumEntry("Num Coding Templates");
  1673. preferences.templates.clear();
  1674. for (unsigned i=0; i<numTemplates; i++) {
  1675. preferences.templates.append(qMakePair(
  1676. pconfig->readEntry(QString("Coding Template %1 Name").arg(i)),
  1677. pconfig->readEntry(QString("Coding Template %1 Text").arg(i))));
  1678. }
  1679. } else {
  1680. preferences.templates.clear();
  1681. // These are 7-bit ASCII, so either fromLatin1 or fromUtf8 will work.
  1682. // fromLatin1 is probably faster.
  1683. preferences.templates
  1684. << qMakePair(QString::fromLatin1("do"),QString::fromLatin1("do {\n\t|\n} while ();"))
  1685. << qMakePair(QString::fromLatin1("for"),QString::fromLatin1("for (|; ; ) {"))
  1686. << qMakePair(QString::fromLatin1("if"),QString::fromLatin1("if (|) {"))
  1687. << qMakePair(QString::fromLatin1("if else"),QString::fromLatin1("if (|) {\n} else {\n}"))
  1688. << qMakePair(QString::fromLatin1("switch"),QString::fromLatin1("switch (|) {\n\tcase:\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n}"))
  1689. << qMakePair(QString::fromLatin1("while"),QString::fromLatin1("while (|) {"));
  1690. }
  1691. // Syntax
  1692. if (!loadSyntaxPreferences())
  1693. defaultSynHighlight();
  1694. checkSynHighlightVersions();
  1695. }
  1696. void savePreferences(void)
  1697. {
  1698. pconfig->setGroup("Preferences");
  1699. // General
  1700. pconfig->writeEntry("Stop at First Error",(bool)preferences.stopAtFirstError);
  1701. pconfig->writeEntry("Jump to Error",(bool)preferences.jumpToError);
  1702. pconfig->writeEntry("Success Message",(bool)preferences.successMessage);
  1703. pconfig->writeEntry("Delete Asm Files",(bool)preferences.deleteAsmFiles);
  1704. pconfig->writeEntry("Delete Object Files",(bool)preferences.deleteObjFiles);
  1705. pconfig->writeEntry("Split Source Files",(bool)preferences.splitSourceFiles);
  1706. pconfig->writeEntry("Allow Implicit Declaration",(bool)preferences.allowImplicitDeclaration);
  1707. pconfig->writeEntry("Auto Save",(bool)preferences.autoSave);
  1708. pconfig->writeEntry("Download Headlines",(bool)preferences.downloadHeadlines);
  1709. pconfig->writeEntry("Delete Overwritten Errors",(bool)preferences.deleteOverwrittenErrors);
  1710. pconfig->writeEntry("Use System Icons",(bool)preferences.useSystemIcons);
  1711. // Transfer
  1712. pconfig->writeEntry("Link Target",(int)preferences.linkTarget);
  1713. pconfig->writeEntry("Link Port",(int)preferences.linkPort);
  1714. pconfig->writeEntry("Link Cable",(int)preferences.linkCable);
  1715. // Editor
  1716. pconfig->writeEntry("Tab Width C",(unsigned)preferences.tabWidthC);
  1717. pconfig->writeEntry("Tab Width Asm",(unsigned)preferences.tabWidthAsm);
  1718. pconfig->writeEntry("Use Background Color",(bool)preferences.useBgColor);
  1719. pconfig->writeEntry("Background Color",preferences.bgColor);
  1720. pconfig->writeEntry("Editor Font",preferences.editorFont);
  1721. pconfig->writeEntry("Use Calc Charset",(bool)preferences.useCalcCharset);
  1722. pconfig->writeEntry("Auto Blocks",(bool)preferences.autoBlocks);
  1723. pconfig->writeEntry("Remove Trailing Spaces",(bool)preferences.removeTrailingSpaces);
  1724. updateEditorPreferences();
  1725. // Coding
  1726. unsigned i=0;
  1727. typedef const QPair<QString,QString> &StringPairConstRef;
  1728. foreach (StringPairConstRef pair, preferences.templates) {
  1729. pconfig->writeEntry(QString("Coding Template %1 Name").arg(i),pair.first);
  1730. pconfig->writeEntry(QString("Coding Template %1 Text").arg(i++),pair.second);
  1731. }
  1732. pconfig->writeEntry("Num Coding Templates",i);
  1733. // Syntax, save to disk
  1734. saveSyntaxPreferences();
  1735. }
  1736. int showPreferencesDialog(QWidget *parent, bool haveA68k, bool haveQuill)
  1737. {
  1738. preferences.haveA68k=haveA68k;
  1739. preferences.haveQuill=haveQuill;
  1740. Preferences *prefdlg=new Preferences(parent);
  1741. prefdlg->exec();
  1742. int result=prefdlg->result();
  1743. delete prefdlg;
  1744. if (result==QDialog::Accepted)
  1745. savePreferences();
  1746. return result;
  1747. }