preferences.cpp 71 KB

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