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