preferences.cpp 74 KB

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