preferences.cpp 72 KB

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