preferences.cpp 73 KB

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