preferences.cpp 70 KB

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