preferences.cpp 73 KB

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