preferences.cpp 72 KB

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