preferences.cpp 69 KB

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