preferences.cpp 73 KB

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