preferences.cpp 73 KB

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