preferences.cpp 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878
  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 <Q3CString>
  34. #include <QDir>
  35. #include <QPair>
  36. #include <Q3ValueList>
  37. #include <kconfig.h>
  38. #include "ktigcc.h"
  39. #include "preferences.h"
  40. #include "preferencesdlg.h"
  41. #include "tpr.h"
  42. // versions of the syntax highlighting description file:
  43. // 1.00 = KTIGCC 20060807 Beta
  44. // 1.01 = current
  45. #define CURRENT_SYNFILE_VERSION "1.01"
  46. TIGCCPrefs preferences;
  47. static void genAllCaseVariants(QString keyword, unsigned pos,
  48. QStringList &stringList)
  49. {
  50. // WARNING: Exponential complexity in the keyword length. Yuck!
  51. // Blame Kate's lack of flexibility.
  52. // Also note that this just LOOKS like a functional recursion, there ARE side
  53. // effects.
  54. QChar c=keyword[pos];
  55. if (c.isNull())
  56. stringList.append(keyword);
  57. else {
  58. QChar upper=c.upper();
  59. QChar lower=c.lower();
  60. if (lower==upper)
  61. genAllCaseVariants(keyword,pos+1,stringList);
  62. else {
  63. keyword[pos]=upper;
  64. genAllCaseVariants(keyword,pos+1,stringList);
  65. keyword[pos]=lower;
  66. genAllCaseVariants(keyword,pos+1,stringList);
  67. keyword[pos]=c;
  68. }
  69. }
  70. }
  71. static void writeSyntaxXML(const Syn_SettingsForDoc &synprefs,
  72. const QString &name, const QString &internalName)
  73. {
  74. // Create XML document.
  75. QDomDocument doc("language");
  76. QDomElement root=doc.createElement("language");
  77. doc.appendChild(root);
  78. // Work around bad interfaces...
  79. #define ADD_ATTR(node,aname,aval) do { \
  80. QDomAttr newattr=doc.createAttribute((aname)); \
  81. newattr.setValue((aval)); \
  82. (node).setAttributeNode(newattr); \
  83. } while(0)
  84. #define ADD_TEXT(node,text) do { \
  85. QDomText newtext=doc.createTextNode((text)); \
  86. (node).appendChild(newtext); \
  87. } while(0)
  88. #define CHILD_NODE(child,node,chname) \
  89. QDomElement child=doc.createElement((chname));\
  90. (node).appendChild(child)
  91. bool allWordListsCaseInsensitive=TRUE;
  92. for (Q3ValueList<Syn_WordList>::ConstIterator it=synprefs.wordLists.begin();
  93. it!=synprefs.wordLists.end(); ++it) {
  94. const Syn_WordList &wordList=*it;
  95. if (wordList.caseSensitive) allWordListsCaseInsensitive=FALSE;
  96. }
  97. ADD_ATTR(root,"name","TIGCC "+name);
  98. ADD_ATTR(root,"section","KTIGCC");
  99. ADD_ATTR(root,"extensions","");
  100. ADD_ATTR(root,"version",CURRENT_SYNFILE_VERSION);
  101. ADD_ATTR(root,"kateversion","2.5");
  102. ADD_ATTR(root,"author","KTIGCC (autogenerated)");
  103. ADD_ATTR(root,"license","GPL");
  104. CHILD_NODE(highlighting,root,"highlighting");
  105. CHILD_NODE(general,root,"general");
  106. for (Q3ValueList<Syn_WordList>::ConstIterator it=synprefs.wordLists.begin();
  107. it!=synprefs.wordLists.end(); ++it) {
  108. const Syn_WordList &wordList=*it;
  109. CHILD_NODE(list,highlighting,"list");
  110. ADD_ATTR(list,"name",wordList.name);
  111. QStringList stringList;
  112. if (wordList.caseSensitive || allWordListsCaseInsensitive)
  113. stringList=wordList.list;
  114. else {
  115. // This is really ugly. Why can't Kate allow me to specify
  116. // case-sensitivity per word list?
  117. for (QStringList::ConstIterator it=wordList.list.begin();
  118. it!=wordList.list.end(); ++it) {
  119. const QString &keyword=*it;
  120. // This is bad, but I need to cap time, memory and disk space
  121. // requirements somewhere.
  122. if (keyword.length()<=10)
  123. genAllCaseVariants(keyword,0,stringList);
  124. else
  125. stringList.append(keyword);
  126. }
  127. }
  128. for (QStringList::ConstIterator it=stringList.begin(); it!=stringList.end();
  129. ++it) {
  130. const QString &keyword=*it;
  131. CHILD_NODE(item,list,"item");
  132. ADD_TEXT(item,keyword);
  133. }
  134. }
  135. CHILD_NODE(contexts,highlighting,"contexts");
  136. CHILD_NODE(defaultContext,contexts,"context");
  137. ADD_ATTR(defaultContext,"name","Default");
  138. ADD_ATTR(defaultContext,"attribute","Normal");
  139. ADD_ATTR(defaultContext,"lineEndContext","#stay");
  140. for (Q3ValueList<Syn_CustomStyle>::ConstIterator it=synprefs.customStyles.begin();
  141. it!=synprefs.customStyles.end(); ++it) {
  142. const Syn_CustomStyle &customStyle=*it;
  143. switch (customStyle.beginning.length()) {
  144. case 0: // Ignore these ones altogether.
  145. break;
  146. case 1:
  147. {
  148. CHILD_NODE(detectCustomStyle,defaultContext,"DetectChar");
  149. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  150. ADD_ATTR(detectCustomStyle,"context",customStyle.name);
  151. if (customStyle.lineStartOnly)
  152. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  153. ADD_ATTR(detectCustomStyle,"char",customStyle.beginning.left(1));
  154. }
  155. break;
  156. case 2:
  157. {
  158. CHILD_NODE(detectCustomStyle,defaultContext,"Detect2Chars");
  159. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  160. ADD_ATTR(detectCustomStyle,"context",customStyle.name);
  161. if (customStyle.lineStartOnly)
  162. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  163. ADD_ATTR(detectCustomStyle,"char",customStyle.beginning.left(1));
  164. ADD_ATTR(detectCustomStyle,"char1",customStyle.beginning.mid(1,1));
  165. }
  166. break;
  167. default:
  168. {
  169. CHILD_NODE(detectCustomStyle,defaultContext,"StringDetect");
  170. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  171. ADD_ATTR(detectCustomStyle,"context",customStyle.name);
  172. if (customStyle.lineStartOnly)
  173. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  174. ADD_ATTR(detectCustomStyle,"String",customStyle.beginning);
  175. }
  176. break;
  177. }
  178. }
  179. for (Q3ValueList<Syn_WordList>::ConstIterator it=synprefs.wordLists.begin();
  180. it!=synprefs.wordLists.end(); ++it) {
  181. const Syn_WordList &wordList=*it;
  182. CHILD_NODE(detectWordList,defaultContext,"keyword");
  183. ADD_ATTR(detectWordList,"attribute",wordList.name);
  184. ADD_ATTR(detectWordList,"context","#stay");
  185. ADD_ATTR(detectWordList,"String",wordList.name);
  186. }
  187. CHILD_NODE(numFloat,defaultContext,"Float");
  188. ADD_ATTR(numFloat,"attribute","Number");
  189. ADD_ATTR(numFloat,"context","#stay");
  190. CHILD_NODE(numFloatSuffix,numFloat,"AnyChar");
  191. ADD_ATTR(numFloatSuffix,"String","fF");
  192. ADD_ATTR(numFloatSuffix,"attribute","Number");
  193. ADD_ATTR(numFloatSuffix,"context","#stay");
  194. CHILD_NODE(numInt,defaultContext,"RegExpr");
  195. ADD_ATTR(numInt,"String","\\b\\d\\w*");
  196. ADD_ATTR(numInt,"attribute","Number");
  197. ADD_ATTR(numInt,"context","#stay");
  198. CHILD_NODE(numHex,defaultContext,"RegExpr");
  199. ADD_ATTR(numHex,"String","\\$\\w+");
  200. ADD_ATTR(numHex,"attribute","Number");
  201. ADD_ATTR(numHex,"context","#stay");
  202. CHILD_NODE(symbols,defaultContext,"AnyChar");
  203. ADD_ATTR(symbols,"String","<{[)]}>;:,.=+-*/\\|\"\'!?&%#@^~");
  204. ADD_ATTR(symbols,"attribute","Symbol");
  205. ADD_ATTR(symbols,"context","#stay");
  206. unsigned numParenthesisColors=synprefs.parenthesisColors.count();
  207. CHILD_NODE(parenOpen,defaultContext,"DetectChar");
  208. ADD_ATTR(parenOpen,"char","(");
  209. if (numParenthesisColors) {
  210. ADD_ATTR(parenOpen,"attribute","Paren0");
  211. ADD_ATTR(parenOpen,"context","Paren0");
  212. } else {
  213. ADD_ATTR(parenOpen,"attribute","Symbol");
  214. ADD_ATTR(parenOpen,"context","#stay");
  215. }
  216. for (unsigned i=0; i<numParenthesisColors; i++) {
  217. CHILD_NODE(pareniContext,contexts,"context");
  218. QString parenp1="Paren%1";
  219. QString pareni=parenp1.arg(i);
  220. QString pareni1=parenp1.arg((i+1==numParenthesisColors)?0:(i+1));
  221. ADD_ATTR(pareniContext,"name",pareni);
  222. ADD_ATTR(pareniContext,"attribute","Normal");
  223. ADD_ATTR(pareniContext,"lineEndContext","#stay");
  224. CHILD_NODE(push,pareniContext,"DetectChar");
  225. ADD_ATTR(push,"char","(");
  226. ADD_ATTR(push,"attribute",pareni1);
  227. ADD_ATTR(push,"context",pareni1);
  228. CHILD_NODE(pop,pareniContext,"DetectChar");
  229. ADD_ATTR(pop,"char",")");
  230. ADD_ATTR(pop,"attribute",pareni);
  231. ADD_ATTR(pop,"context","#pop");
  232. CHILD_NODE(includeRules,pareniContext,"IncludeRules");
  233. ADD_ATTR(includeRules,"context","Default");
  234. }
  235. for (Q3ValueList<Syn_CustomStyle>::ConstIterator it=synprefs.customStyles.begin();
  236. it!=synprefs.customStyles.end(); ++it) {
  237. const Syn_CustomStyle &customStyle=*it;
  238. bool endsWithNewline=(customStyle.ending=="\n");
  239. bool endsWithSpace=(customStyle.ending==" ");
  240. bool noIgnoreEndingAfter=customStyle.ignoreEndingAfter.isNull();
  241. bool needIgnoreContext=!endsWithNewline && !noIgnoreEndingAfter;
  242. CHILD_NODE(customStyleContext,contexts,"context");
  243. ADD_ATTR(customStyleContext,"name",customStyle.name);
  244. ADD_ATTR(customStyleContext,"attribute",customStyle.name);
  245. ADD_ATTR(customStyleContext,"lineEndContext",(endsWithNewline||
  246. (endsWithSpace&&noIgnoreEndingAfter))?"#pop":"#stay");
  247. if (endsWithNewline && customStyle.ignoreEndingAfter=='\\') {
  248. CHILD_NODE(lineContinue,customStyleContext,"LineContinue");
  249. ADD_ATTR(lineContinue,"attribute",customStyle.name);
  250. ADD_ATTR(lineContinue,"context","#stay");
  251. } else if (needIgnoreContext) {
  252. CHILD_NODE(detectCustomStyle,customStyleContext,"DetectChar");
  253. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  254. ADD_ATTR(detectCustomStyle,"context",customStyle.name+" Ignore");
  255. ADD_ATTR(detectCustomStyle,"char",QString(customStyle.ignoreEndingAfter));
  256. if (customStyle.ignoreEndingAfter=='\\') {
  257. CHILD_NODE(detectCustomStyleTrigraph,customStyleContext,"StringDetect");
  258. ADD_ATTR(detectCustomStyleTrigraph,"attribute",customStyle.name);
  259. ADD_ATTR(detectCustomStyleTrigraph,"context",customStyle.name+" Ignore");
  260. ADD_ATTR(detectCustomStyleTrigraph,"String","?""?""/");
  261. }
  262. }
  263. if (endsWithSpace) {
  264. CHILD_NODE(detectCustomStyle,customStyleContext,"DetectSpaces");
  265. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  266. ADD_ATTR(detectCustomStyle,"context","#pop");
  267. } else if (!endsWithNewline) {
  268. switch (customStyle.ending.length()) {
  269. case 0: // No ending...
  270. break;
  271. case 1:
  272. {
  273. CHILD_NODE(detectCustomStyle,customStyleContext,"DetectChar");
  274. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  275. ADD_ATTR(detectCustomStyle,"context","#pop");
  276. ADD_ATTR(detectCustomStyle,"char",customStyle.ending.left(1));
  277. }
  278. break;
  279. case 2:
  280. {
  281. CHILD_NODE(detectCustomStyle,customStyleContext,"Detect2Chars");
  282. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  283. ADD_ATTR(detectCustomStyle,"context","#pop");
  284. ADD_ATTR(detectCustomStyle,"char",customStyle.ending.left(1));
  285. ADD_ATTR(detectCustomStyle,"char1",customStyle.ending.mid(1,1));
  286. }
  287. break;
  288. default:
  289. {
  290. CHILD_NODE(detectCustomStyle,customStyleContext,"StringDetect");
  291. ADD_ATTR(detectCustomStyle,"attribute",customStyle.name);
  292. ADD_ATTR(detectCustomStyle,"context","#pop");
  293. ADD_ATTR(detectCustomStyle,"String",customStyle.ending);
  294. }
  295. break;
  296. }
  297. }
  298. if (customStyle.switchable) {
  299. for (Q3ValueList<Syn_CustomStyle>::ConstIterator it2=synprefs.customStyles.begin();
  300. it2!=synprefs.customStyles.end(); ++it2) {
  301. if (it2==it) continue;
  302. const Syn_CustomStyle &otherCustomStyle=*it2;
  303. if (otherCustomStyle.ending==customStyle.ending) {
  304. switch (otherCustomStyle.beginning.length()) {
  305. case 0: // Ignore these ones altogether.
  306. break;
  307. case 1:
  308. {
  309. CHILD_NODE(detectCustomStyle,customStyleContext,"DetectChar");
  310. ADD_ATTR(detectCustomStyle,"attribute",otherCustomStyle.name);
  311. ADD_ATTR(detectCustomStyle,"context","#pop");
  312. if (otherCustomStyle.lineStartOnly)
  313. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  314. ADD_ATTR(detectCustomStyle,"char",otherCustomStyle.beginning.left(1));
  315. ADD_ATTR(detectCustomStyle,"lookAhead","true");
  316. }
  317. break;
  318. case 2:
  319. {
  320. CHILD_NODE(detectCustomStyle,customStyleContext,"Detect2Chars");
  321. ADD_ATTR(detectCustomStyle,"attribute",otherCustomStyle.name);
  322. ADD_ATTR(detectCustomStyle,"context","#pop");
  323. if (otherCustomStyle.lineStartOnly)
  324. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  325. ADD_ATTR(detectCustomStyle,"char",otherCustomStyle.beginning.left(1));
  326. ADD_ATTR(detectCustomStyle,"char1",otherCustomStyle.beginning.mid(1,1));
  327. ADD_ATTR(detectCustomStyle,"lookAhead","true");
  328. }
  329. break;
  330. default:
  331. {
  332. CHILD_NODE(detectCustomStyle,customStyleContext,"StringDetect");
  333. ADD_ATTR(detectCustomStyle,"attribute",otherCustomStyle.name);
  334. ADD_ATTR(detectCustomStyle,"context","#pop");
  335. if (otherCustomStyle.lineStartOnly)
  336. ADD_ATTR(detectCustomStyle,"firstNonSpace","true");
  337. ADD_ATTR(detectCustomStyle,"String",otherCustomStyle.beginning);
  338. ADD_ATTR(detectCustomStyle,"lookAhead","true");
  339. }
  340. break;
  341. }
  342. }
  343. }
  344. }
  345. if (needIgnoreContext) {
  346. CHILD_NODE(customStyleIgnoreContext,contexts,"context");
  347. ADD_ATTR(customStyleIgnoreContext,"name",customStyle.name+" Ignore");
  348. ADD_ATTR(customStyleIgnoreContext,"attribute",customStyle.name);
  349. ADD_ATTR(customStyleIgnoreContext,"lineEndContext","#pop");
  350. CHILD_NODE(pop,customStyleIgnoreContext,"RegExpr");
  351. ADD_ATTR(pop,"attribute",customStyle.name);
  352. ADD_ATTR(pop,"context","#pop");
  353. ADD_ATTR(pop,"String",".");
  354. }
  355. }
  356. CHILD_NODE(itemDatas,highlighting,"itemDatas");
  357. #define DEF_ITEM_DATA(idname,color,style) do { \
  358. CHILD_NODE(itemData,itemDatas,"itemData");\
  359. ADD_ATTR(itemData,"name",(idname));\
  360. ADD_ATTR(itemData,"defStyleNum","dsNormal");\
  361. QColor idcolor=(color);\
  362. if (idcolor.isValid())\
  363. ADD_ATTR(itemData,"color",idcolor.name());\
  364. Syn_Style idstyle=(style);\
  365. if (idstyle&SYNS_CUSTOM) {\
  366. ADD_ATTR(itemData,"bold",(idstyle&SYNS_BOLD)?"1":"0");\
  367. ADD_ATTR(itemData,"underline",(idstyle&SYNS_UNDERLINE)?"1":"0");\
  368. ADD_ATTR(itemData,"italic",(idstyle&SYNS_ITALIC)?"1":"0");\
  369. ADD_ATTR(itemData,"strikeOut",(idstyle&SYNS_STRIKEOUT)?"1":"0");\
  370. }\
  371. } while(0)
  372. DEF_ITEM_DATA("Normal",QColor(),0);
  373. DEF_ITEM_DATA("Number",synprefs.numberColor,synprefs.numberStyle);
  374. DEF_ITEM_DATA("Symbol",synprefs.symbolColor,synprefs.symbolStyle);
  375. unsigned i=0;
  376. for (Q3ValueList<QColor>::ConstIterator it=synprefs.parenthesisColors.begin();
  377. it!=synprefs.parenthesisColors.end(); ++it, i++) {
  378. DEF_ITEM_DATA(QString("Paren%1").arg(i),*it,synprefs.parenthesisStyle);
  379. }
  380. for (Q3ValueList<Syn_CustomStyle>::ConstIterator it=synprefs.customStyles.begin();
  381. it!=synprefs.customStyles.end(); ++it) {
  382. const Syn_CustomStyle &customStyle=*it;
  383. DEF_ITEM_DATA(customStyle.name,customStyle.color,customStyle.style);
  384. }
  385. for (Q3ValueList<Syn_WordList>::ConstIterator it=synprefs.wordLists.begin();
  386. it!=synprefs.wordLists.end(); ++it) {
  387. const Syn_WordList &wordList=*it;
  388. DEF_ITEM_DATA(wordList.name,wordList.color,wordList.style);
  389. }
  390. #undef DEF_ITEM_DATA
  391. CHILD_NODE(keywords,general,"keywords");
  392. ADD_ATTR(keywords,"casesensitive",allWordListsCaseInsensitive?"0":"1");
  393. ADD_ATTR(keywords,"additionalDeliminator","\'\"#@");
  394. CHILD_NODE(indentation,general,"indentation");
  395. ADD_ATTR(indentation,"mode","normal");
  396. #undef ADD_ATTR
  397. #undef ADD_TEXT
  398. #undef CHILD_NODE
  399. // Write it to disk.
  400. QString xmlFileName=QString("%1/.kde/share/apps/katepart/syntax/ktigcc%2.xml")
  401. .arg(QDir::homePath()).arg(internalName);
  402. mkdir_multi(xmlFileName);
  403. std::FILE *f=std::fopen(xmlFileName,"w");
  404. if (f) {
  405. if (fputs("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  406. "<!-- Syntax highlighting description autogenerated by KTIGCC.\n"
  407. " All changes to this file will be lost! -->\n",f)<0) {
  408. fclose(f);
  409. return;
  410. }
  411. (void) fputs(doc.toByteArray(2),f);
  412. fclose(f);
  413. }
  414. }
  415. static void updateSyntaxXML(void)
  416. {
  417. writeSyntaxXML(preferences.synC,"C","c");
  418. writeSyntaxXML(preferences.synS,"GNU As","s");
  419. writeSyntaxXML(preferences.synAsm,"A68k","asm");
  420. writeSyntaxXML(preferences.synQll,"Quill","qll");
  421. }
  422. // True if version1 is newer than version2.
  423. static bool isNewerVersion(const QString &version1, const QString &version2)
  424. {
  425. QStringList vl1=QStringList::split('.',version1);
  426. QStringList vl2=QStringList::split('.',version2);
  427. QStringList::Iterator it1=vl1.begin(), it2=vl2.begin();
  428. for (; it1!=vl1.end() && it2!=vl2.end(); ++it1, ++it2) {
  429. bool ok1, ok2;
  430. unsigned v1=(*it1).toUInt(&ok1), v2=(*it2).toUInt(&ok2);
  431. if (!ok1 || !ok2) return TRUE;
  432. if (v1>v2) return TRUE;
  433. else if (v1<v2) return FALSE;
  434. }
  435. return (it1!=vl1.end());
  436. }
  437. static bool checkSynHighlightVersion(const QString &internalName)
  438. {
  439. QString xmlFileName=QString("%1/.kde/share/apps/katepart/syntax/ktigcc%2.xml")
  440. .arg(QDir::homePath()).arg(internalName);
  441. QDomDocument doc("language");
  442. QFile file(xmlFileName);
  443. if (!file.open(QIODevice::ReadOnly))
  444. return FALSE;
  445. if (!doc.setContent(&file)) {
  446. file.close();
  447. return FALSE;
  448. }
  449. file.close();
  450. QDomNode language=doc.elementsByTagName("language").item(0);
  451. if (language.isNull() || language.nodeType()!=QDomNode::ElementNode)
  452. return FALSE;
  453. QDomAttr version=language.toElement().attributeNode("version");
  454. if (version.isNull())
  455. return FALSE;
  456. QString versionNumber=version.value();
  457. return !isNewerVersion(CURRENT_SYNFILE_VERSION,versionNumber);
  458. }
  459. static void checkSynHighlightVersions(void)
  460. {
  461. if (!checkSynHighlightVersion("c"))
  462. writeSyntaxXML(preferences.synC,"C","c");
  463. if (!checkSynHighlightVersion("s"))
  464. writeSyntaxXML(preferences.synS,"GNU As","s");
  465. if (!checkSynHighlightVersion("asm"))
  466. writeSyntaxXML(preferences.synAsm,"A68k","asm");
  467. if (!checkSynHighlightVersion("qll"))
  468. writeSyntaxXML(preferences.synQll,"Quill","qll");
  469. }
  470. static bool loadSyntaxPreference(Syn_SettingsForDoc &synprefs, const QString &group)
  471. {
  472. pconfig->setGroup(group+" Syntax Highlighting");
  473. synprefs.enabled=pconfig->readBoolEntry("Enabled",true);
  474. synprefs.numberColor=pconfig->readColorEntry("Number Color");
  475. if (!synprefs.numberColor.isValid()) return FALSE;
  476. synprefs.symbolColor=pconfig->readColorEntry("Symbol Color");
  477. if (!synprefs.symbolColor.isValid()) return FALSE;
  478. unsigned numParenthesisColors=pconfig->readUnsignedNumEntry("Num Parenthesis Colors");
  479. for (unsigned i=0; i<numParenthesisColors; i++) {
  480. QColor parenthesisColor=pconfig->readColorEntry(QString("Parenthesis Color %1").arg(i));
  481. if (!parenthesisColor.isValid()) return FALSE;
  482. synprefs.parenthesisColors.append(parenthesisColor);
  483. }
  484. synprefs.numberStyle=pconfig->readUnsignedNumEntry("Number Style");
  485. synprefs.symbolStyle=pconfig->readUnsignedNumEntry("Symbol Style");
  486. synprefs.parenthesisStyle=pconfig->readUnsignedNumEntry("Parenthesis Style");
  487. unsigned numCustomStyles=pconfig->readUnsignedNumEntry("Num Custom Styles");
  488. for (unsigned i=0; i<numCustomStyles; i++) {
  489. Syn_CustomStyle customStyle;
  490. customStyle.name=pconfig->readEntry(QString("Custom Style %1 Name").arg(i),QString("Style %1").arg(i));
  491. customStyle.beginning=pconfig->readEntry(QString("Custom Style %1 Beginning").arg(i));
  492. customStyle.ending=pconfig->readEntry(QString("Custom Style %1 Ending").arg(i));
  493. customStyle.ignoreEndingAfter=pconfig->readEntry(QString("Custom Style %1 Ignore Ending After").arg(i))[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=QStringList::split('\n',
  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");
  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= QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  798. "AND\n"
  799. "ANDI\n"
  800. "EOR\n"
  801. "EORI\n"
  802. "NOT\n"
  803. "OR\n"
  804. "ORI\n");
  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=QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  826. "BCHG\n"
  827. "BCLR\n"
  828. "BSET\n"
  829. "BTST\n");
  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= QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  960. "ILLEGAL\n"
  961. "RTE\n"
  962. "TRAP\n");
  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=QStringList::split('\n',
  969. "B\n"
  970. "L\n"
  971. "S\n"
  972. "W\n");
  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=QStringList::split('\n',
  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");
  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= QStringList::split('\n',
  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");
  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= QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  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");
  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= QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  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");
  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= QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  1293. "CONTINUE\n"
  1294. "ELSE\n");
  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= QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  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");
  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= QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  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");
  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=QStringList::split('\n',
  1545. "BEEP\n"
  1546. "BLOCK\n"
  1547. "BORDER\n"
  1548. "BRIGHT\n"
  1549. "FLASH\n"
  1550. "INK\n"
  1551. "PAPER\n");
  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=QStringList::split('\n',
  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");
  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.lazyLoading=pconfig->readBoolEntry("Lazy Loading",true);
  1743. preferences.autoBlocks=pconfig->readBoolEntry("Auto Blocks",true);
  1744. preferences.removeTrailingSpaces=pconfig->readBoolEntry("Remove Trailing Spaces",false);
  1745. updateEditorPreferences();
  1746. // Coding
  1747. if (pconfig->hasKey("Num Coding Templates")) {
  1748. unsigned numTemplates=pconfig->readUnsignedNumEntry("Num Coding Templates");
  1749. preferences.templates.clear();
  1750. for (unsigned i=0; i<numTemplates; i++) {
  1751. preferences.templates.append(qMakePair(
  1752. pconfig->readEntry(QString("Coding Template %1 Name").arg(i)),
  1753. pconfig->readEntry(QString("Coding Template %1 Text").arg(i))));
  1754. }
  1755. } else {
  1756. preferences.templates.clear();
  1757. // These are 7-bit ASCII, so either fromLatin1 or fromUtf8 will work.
  1758. // fromLatin1 is probably faster.
  1759. preferences.templates
  1760. << qMakePair(QString::fromLatin1("do"),QString::fromLatin1("do {\n\t|\n} while ();"))
  1761. << qMakePair(QString::fromLatin1("for"),QString::fromLatin1("for (|; ; ) {"))
  1762. << qMakePair(QString::fromLatin1("if"),QString::fromLatin1("if (|) {"))
  1763. << qMakePair(QString::fromLatin1("if else"),QString::fromLatin1("if (|) {\n} else {\n}"))
  1764. << qMakePair(QString::fromLatin1("switch"),QString::fromLatin1("switch (|) {\n\tcase:\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n}"))
  1765. << qMakePair(QString::fromLatin1("while"),QString::fromLatin1("while (|) {"));
  1766. }
  1767. // Syntax
  1768. if (!loadSyntaxPreferences())
  1769. defaultSynHighlight();
  1770. checkSynHighlightVersions();
  1771. }
  1772. void savePreferences(void)
  1773. {
  1774. pconfig->setGroup("Preferences");
  1775. // General
  1776. pconfig->writeEntry("Stop at First Error",(bool)preferences.stopAtFirstError);
  1777. pconfig->writeEntry("Jump to Error",(bool)preferences.jumpToError);
  1778. pconfig->writeEntry("Success Message",(bool)preferences.successMessage);
  1779. pconfig->writeEntry("Delete Asm Files",(bool)preferences.deleteAsmFiles);
  1780. pconfig->writeEntry("Delete Object Files",(bool)preferences.deleteObjFiles);
  1781. pconfig->writeEntry("Split Source Files",(bool)preferences.splitSourceFiles);
  1782. pconfig->writeEntry("Allow Implicit Declaration",(bool)preferences.allowImplicitDeclaration);
  1783. pconfig->writeEntry("Auto Save",(bool)preferences.autoSave);
  1784. pconfig->writeEntry("Download Headlines",(bool)preferences.downloadHeadlines);
  1785. pconfig->writeEntry("Delete Overwritten Errors",(bool)preferences.deleteOverwrittenErrors);
  1786. pconfig->writeEntry("Use System Icons",(bool)preferences.useSystemIcons);
  1787. // Transfer
  1788. pconfig->writeEntry("Link Target",(int)preferences.linkTarget);
  1789. pconfig->writeEntry("Link Port",(int)preferences.linkPort);
  1790. pconfig->writeEntry("Link Cable",(int)preferences.linkCable);
  1791. // Editor
  1792. pconfig->writeEntry("Tab Width C",(unsigned)preferences.tabWidthC);
  1793. pconfig->writeEntry("Tab Width Asm",(unsigned)preferences.tabWidthAsm);
  1794. pconfig->writeEntry("Use Background Color",(bool)preferences.useBgColor);
  1795. pconfig->writeEntry("Background Color",preferences.bgColor);
  1796. pconfig->writeEntry("Editor Font",preferences.editorFont);
  1797. pconfig->writeEntry("Use Calc Charset",(bool)preferences.useCalcCharset);
  1798. pconfig->writeEntry("Lazy Loading",(bool)preferences.lazyLoading);
  1799. pconfig->writeEntry("Auto Blocks",(bool)preferences.autoBlocks);
  1800. pconfig->writeEntry("Remove Trailing Spaces",(bool)preferences.removeTrailingSpaces);
  1801. updateEditorPreferences();
  1802. // Coding
  1803. unsigned i=0;
  1804. for (Q3ValueList<QPair<QString,QString> >::ConstIterator it=preferences.templates.begin();
  1805. it!=preferences.templates.end(); ++it, i++) {
  1806. pconfig->writeEntry(QString("Coding Template %1 Name").arg(i),(*it).first);
  1807. pconfig->writeEntry(QString("Coding Template %1 Text").arg(i),(*it).second);
  1808. }
  1809. pconfig->writeEntry("Num Coding Templates",i);
  1810. // Syntax, save to disk
  1811. saveSyntaxPreferences();
  1812. }
  1813. int showPreferencesDialog(QWidget *parent, bool haveA68k, bool haveQuill)
  1814. {
  1815. preferences.haveA68k=haveA68k;
  1816. preferences.haveQuill=haveQuill;
  1817. Preferences *prefdlg=new Preferences(parent);
  1818. prefdlg->exec();
  1819. int result=prefdlg->result();
  1820. delete prefdlg;
  1821. if (result==QDialog::Accepted)
  1822. savePreferences();
  1823. return result;
  1824. }