preferences.cpp 71 KB

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