qscilexeravs.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. // This module implements the QsciLexerAVS class.
  2. //
  3. // Copyright (c) 2017 Riverbank Computing Limited <info@riverbankcomputing.com>
  4. //
  5. // This file is part of QScintilla.
  6. //
  7. // This file may be used under the terms of the GNU General Public License
  8. // version 3.0 as published by the Free Software Foundation and appearing in
  9. // the file LICENSE included in the packaging of this file. Please review the
  10. // following information to ensure the GNU General Public License version 3.0
  11. // requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  12. //
  13. // If you do not wish to use this file under the terms of the GPL version 3.0
  14. // then you may purchase a commercial license. For more information contact
  15. // info@riverbankcomputing.com.
  16. //
  17. // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  18. // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. #include "Qsci/qscilexeravs.h"
  20. #include <qcolor.h>
  21. #include <qfont.h>
  22. #include <qsettings.h>
  23. // The ctor.
  24. QsciLexerAVS::QsciLexerAVS(QObject *parent)
  25. : QsciLexer(parent),
  26. fold_comments(false), fold_compact(true)
  27. {
  28. }
  29. // The dtor.
  30. QsciLexerAVS::~QsciLexerAVS()
  31. {
  32. }
  33. // Returns the language name.
  34. const char *QsciLexerAVS::language() const
  35. {
  36. return "AVS";
  37. }
  38. // Returns the lexer name.
  39. const char *QsciLexerAVS::lexer() const
  40. {
  41. return "avs";
  42. }
  43. // Return the style used for braces.
  44. int QsciLexerAVS::braceStyle() const
  45. {
  46. return Operator;
  47. }
  48. // Return the string of characters that comprise a word.
  49. const char *QsciLexerAVS::wordCharacters() const
  50. {
  51. return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_#";
  52. }
  53. // Returns the foreground colour of the text for a style.
  54. QColor QsciLexerAVS::defaultColor(int style) const
  55. {
  56. switch (style)
  57. {
  58. case Default:
  59. case Operator:
  60. return QColor(0x00, 0x00, 0x00);
  61. case BlockComment:
  62. case NestedBlockComment:
  63. case LineComment:
  64. return QColor(0x00, 0x7f, 0x00);
  65. case Number:
  66. case Function:
  67. return QColor(0x00, 0x7f, 0x7f);
  68. case String:
  69. case TripleString:
  70. return QColor(0x7f, 0x00, 0x7f);
  71. case Keyword:
  72. case Filter:
  73. case ClipProperty:
  74. return QColor(0x00, 0x00, 0x7f);
  75. case Plugin:
  76. return QColor(0x00, 0x80, 0xc0);
  77. case KeywordSet6:
  78. return QColor(0x80, 0x00, 0xff);
  79. }
  80. return QsciLexer::defaultColor(style);
  81. }
  82. // Returns the font of the text for a style.
  83. QFont QsciLexerAVS::defaultFont(int style) const
  84. {
  85. QFont f;
  86. switch (style)
  87. {
  88. case BlockComment:
  89. case NestedBlockComment:
  90. case LineComment:
  91. #if defined(Q_OS_WIN)
  92. f = QFont("Comic Sans MS", 9);
  93. #elif defined(Q_OS_MAC)
  94. f = QFont("Georgia", 13);
  95. #else
  96. f = QFont("Bitstream Vera Serif", 9);
  97. #endif
  98. break;
  99. case Keyword:
  100. case Filter:
  101. case Plugin:
  102. f = QsciLexer::defaultFont(style);
  103. f.setBold(true);
  104. break;
  105. default:
  106. f = QsciLexer::defaultFont(style);
  107. }
  108. return f;
  109. }
  110. // Returns the set of keywords.
  111. const char *QsciLexerAVS::keywords(int set) const
  112. {
  113. if (set == 1)
  114. return "true false return global";
  115. if (set == 2)
  116. return
  117. "addborders alignedsplice amplify amplifydb animate applyrange "
  118. "assumebff assumefieldbased assumefps assumeframebased "
  119. "assumesamplerate assumescaledfps assumetff audiodub audiodubex "
  120. "avifilesource avisource bicubicresize bilinearresize "
  121. "blackmanresize blackness blankclip blur bob cache changefps "
  122. "colorbars colorkeymask coloryuv compare complementparity "
  123. "conditionalfilter conditionalreader convertaudio "
  124. "convertaudioto16bit convertaudioto24bit convertaudioto32bit "
  125. "convertaudioto8bit convertaudiotofloat convertbacktoyuy2 "
  126. "convertfps converttobackyuy2 converttomono converttorgb "
  127. "converttorgb24 converttorgb32 converttoy8 converttoyv16 "
  128. "converttoyv24 converttoyv411 converttoyuy2 converttoyv12 crop "
  129. "cropbottom delayaudio deleteframe dissolve distributor "
  130. "doubleweave duplicateframe ensurevbrmp3sync fadein fadein0 "
  131. "fadein2 fadeio fadeio0 fadeio2 fadeout fadeout0 fadeout2 "
  132. "fixbrokenchromaupsampling fixluminance fliphorizontal "
  133. "flipvertical frameevaluate freezeframe gaussresize "
  134. "generalconvolution getchannel getchannels getmtmode getparity "
  135. "grayscale greyscale histogram horizontalreduceby2 imagereader "
  136. "imagesource imagewriter info interleave internalcache "
  137. "internalcachemt invert killaudio killvideo lanczos4resize "
  138. "lanczosresize layer letterbox levels limiter loop mask maskhs "
  139. "max merge mergeargb mergechannels mergechroma mergeluma mergergb "
  140. "messageclip min mixaudio monotostereo normalize null "
  141. "opendmlsource overlay peculiarblend pointresize pulldown "
  142. "reduceby2 resampleaudio resetmask reverse rgbadjust scriptclip "
  143. "segmentedavisource segmenteddirectshowsource selecteven "
  144. "selectevery selectodd selectrangeevery separatefields setmtmode "
  145. "sharpen showalpha showblue showfiveversions showframenumber "
  146. "showgreen showred showsmpte showtime sincresize skewrows "
  147. "spatialsoften spline16resize spline36resize spline64resize ssrc "
  148. "stackhorizontal stackvertical subtitle subtract supereq "
  149. "swapfields swapuv temporalsoften timestretch tone trim turn180 "
  150. "turnleft turnright tweak unalignedsplice utoy utoy8 version "
  151. "verticalreduceby2 vtoy vtoy8 wavsource weave writefile "
  152. "writefileend writefileif writefilestart ytouv";
  153. if (set == 3)
  154. return
  155. "addgrain addgrainc agc_hdragc analyzelogo animeivtc asharp "
  156. "audiograph autocrop autoyuy2 avsrecursion awarpsharp "
  157. "bassaudiosource bicublinresize bifrost binarize blendfields "
  158. "blindpp blockbuster bordercontrol cfielddiff cframediff "
  159. "chromashift cnr2 colormatrix combmask contra convolution3d "
  160. "convolution3dyv12 dctfilter ddcc deblendlogo deblock deblock_qed "
  161. "decimate decomb dedup deen deflate degrainmedian depan "
  162. "depanestimate depaninterleave depanscenes depanstabilize "
  163. "descratch despot dfttest dgbob dgsource directshowsource "
  164. "distancefunction dss2 dup dupmc edeen edgemask ediupsizer eedi2 "
  165. "eedi3 eedi3_rpow2 expand faerydust fastbicubicresize "
  166. "fastbilinearresize fastediupsizer dedgemask fdecimate "
  167. "ffaudiosource ffdshow ffindex ffmpegsource ffmpegsource2 "
  168. "fft3dfilter fft3dgpu ffvideosource fielddeinterlace fielddiff "
  169. "fillmargins fity2uv fity2u fity2v fitu2y fitv2y fluxsmooth "
  170. "fluxsmoothst fluxsmootht framediff framenumber frfun3b frfun7 "
  171. "gicocu golddust gradfun2db grapesmoother greedyhma grid "
  172. "guavacomb hqdn3d hybridfupp hysteresymask ibob "
  173. "improvesceneswitch inflate inpand inpaintlogo interframe "
  174. "interlacedresize interlacedwarpedresize interleaved2planar "
  175. "iscombed iscombedt iscombedtivtc kerneldeint leakkernelbob "
  176. "leakkerneldeint limitedsharpen limitedsharpenfaster logic lsfmod "
  177. "lumafilter lumayv12 manalyse maskeddeinterlace maskedmerge "
  178. "maskedmix mblockfps mcompensate mctemporaldenoise "
  179. "mctemporaldenoisepp mdegrain1 mdegrain2 mdegrain3 mdepan "
  180. "medianblur mergehints mflow mflowblur mflowfps mflowinter "
  181. "minblur mipsmooth mmask moderatesharpen monitorfilter motionmask "
  182. "mpasource mpeg2source mrecalculate mscdetection msharpen mshow "
  183. "msmooth msu_fieldshiftfixer msu_frc msuper mt mt_adddiff "
  184. "mt_average mt_binarize mt_circle mt_clamp mt_convolution "
  185. "mt_deflate mt_diamond mt_edge mt_ellipse mt_expand "
  186. "mt_freeellipse mt_freelosange mt_freerectangle mt_hysteresis "
  187. "mt_infix mt_inflate mt_inpand mt_invert mt_logic mt_losange "
  188. "mt_lut mt_lutf mt_luts mt_lutspa mt_lutsx mt_lutxy mt_lutxyz "
  189. "mt_makediff mt_mappedblur mt_merge mt_motion mt_polish "
  190. "mt_rectangle mt_square mti mtsource multidecimate mvanalyse "
  191. "mvblockfps mvchangecompensate mvcompensate mvdegrain1 mvdegrain2 "
  192. "mvdegrain3 mvdenoise mvdepan mvflow mvflowblur mvflowfps "
  193. "mvflowfps2 mvflowinter mvincrease mvmask mvrecalculate "
  194. "mvscdetection mvshow nicac3source nicdtssource niclpcmsource "
  195. "nicmpasource nicmpg123source nnedi nnedi2 nnedi2_rpow2 nnedi3 "
  196. "nnedi3_rpow2 nomosmooth overlaymask peachsmoother pixiedust "
  197. "planar2interleaved qtgmc qtinput rawavsource rawsource "
  198. "reduceflicker reinterpolate411 removedirt removedust removegrain "
  199. "removegrainhd removetemporalgrain repair requestlinear "
  200. "reversefielddominance rgb3dlut rgdeinterlace rgsdeinterlace "
  201. "rgblut rotate sangnom seesaw sharpen2 showchannels "
  202. "showcombedtivtc smartdecimate smartdeinterlace smdegrain "
  203. "smoothdeinterlace smoothuv soothess soxfilter spacedust sshiq "
  204. "ssim ssiq stmedianfilter t3dlut tanisotropic tbilateral tcanny "
  205. "tcomb tcombmask tcpserver tcpsource tdecimate tdeint tedgemask "
  206. "telecide temporalcleaner temporalrepair temporalsmoother "
  207. "tfieldblank tfm tisophote tivtc tmaskblank tmaskedmerge "
  208. "tmaskedmerge3 tmm tmonitor tnlmeans tomsmocomp toon textsub "
  209. "ttempsmooth ttempsmoothf tunsharp unblock uncomb undot unfilter "
  210. "unsharpmask vaguedenoiser variableblur verticalcleaner "
  211. "videoscope vinverse vobsub vqmcalc warpedresize warpsharp "
  212. "xsharpen yadif yadifmod yuy2lut yv12convolution "
  213. "yv12interlacedreduceby2 yv12interlacedselecttopfields yv12layer "
  214. "yv12lut yv12lutxy yv12substract yv12torgb24 yv12toyuy2";
  215. if (set == 4)
  216. return
  217. "abs apply assert bool ceil chr clip continueddenominator "
  218. "continuednumerator cos default defined eval averagechromau "
  219. "averagechromav averageluma chromaudifference chromavdifference "
  220. "lumadifference exist exp findstr float floor frac hexvalue "
  221. "import int isbool isclip isfloat isint isstring lcase leftstr "
  222. "load_stdcall_plugin loadcplugin loadplugin loadvfapiplugin "
  223. "loadvirtualdubplugin log midstr muldiv nop opt_allowfloataudio "
  224. "opt_avipadscanlines opt_dwchannelmask opt_usewaveextensible "
  225. "opt_vdubplanarhack pi pow rand revstr rightstr round scriptdir "
  226. "scriptfile scriptname select setmemorymax "
  227. "setplanarlegacyalignment rgbdifference rgbdifferencefromprevious "
  228. "rgbdifferencetonext udifferencefromprevious udifferencetonext "
  229. "setworkingdir sign sin spline sqrt string strlen time ucase "
  230. "undefined value versionnumber versionstring uplanemax "
  231. "uplanemedian uplanemin uplaneminmaxdifference "
  232. "vdifferencefromprevious vdifferencetonext vplanemax vplanemedian "
  233. "vplanemin vplaneminmaxdifference ydifferencefromprevious "
  234. "ydifferencetonext yplanemax yplanemedian yplanemin "
  235. "yplaneminmaxdifference";
  236. if (set == 5)
  237. return
  238. "audiobits audiochannels audiolength audiolengthf audiorate "
  239. "framecount framerate frameratedenominator frameratenumerator "
  240. "getleftchannel getrightchannel hasaudio hasvideo height "
  241. "isaudiofloat isaudioint isfieldbased isframebased isinterleaved "
  242. "isplanar isrgb isrgb24 isrgb32 isyuv isyuy2 isyv12 width";
  243. return 0;
  244. }
  245. // Returns the user name of a style.
  246. QString QsciLexerAVS::description(int style) const
  247. {
  248. switch (style)
  249. {
  250. case Default:
  251. return tr("Default");
  252. case BlockComment:
  253. return tr("Block comment");
  254. case NestedBlockComment:
  255. return tr("Nested block comment");
  256. case LineComment:
  257. return tr("Line comment");
  258. case Number:
  259. return tr("Number");
  260. case Operator:
  261. return tr("Operator");
  262. case Identifier:
  263. return tr("Identifier");
  264. case String:
  265. return tr("Double-quoted string");
  266. case TripleString:
  267. return tr("Triple double-quoted string");
  268. case Keyword:
  269. return tr("Keyword");
  270. case Filter:
  271. return tr("Filter");
  272. case Plugin:
  273. return tr("Plugin");
  274. case Function:
  275. return tr("Function");
  276. case ClipProperty:
  277. return tr("Clip property");
  278. case KeywordSet6:
  279. return tr("User defined");
  280. }
  281. return QString();
  282. }
  283. // Refresh all properties.
  284. void QsciLexerAVS::refreshProperties()
  285. {
  286. setCommentProp();
  287. setCompactProp();
  288. }
  289. // Read properties from the settings.
  290. bool QsciLexerAVS::readProperties(QSettings &qs,const QString &prefix)
  291. {
  292. int rc = true;
  293. fold_comments = qs.value(prefix + "foldcomments", false).toBool();
  294. fold_compact = qs.value(prefix + "foldcompact", true).toBool();
  295. return rc;
  296. }
  297. // Write properties to the settings.
  298. bool QsciLexerAVS::writeProperties(QSettings &qs,const QString &prefix) const
  299. {
  300. int rc = true;
  301. qs.setValue(prefix + "foldcomments", fold_comments);
  302. qs.setValue(prefix + "foldcompact", fold_compact);
  303. return rc;
  304. }
  305. // Return true if comments can be folded.
  306. bool QsciLexerAVS::foldComments() const
  307. {
  308. return fold_comments;
  309. }
  310. // Set if comments can be folded.
  311. void QsciLexerAVS::setFoldComments(bool fold)
  312. {
  313. fold_comments = fold;
  314. setCommentProp();
  315. }
  316. // Set the "fold.comment" property.
  317. void QsciLexerAVS::setCommentProp()
  318. {
  319. emit propertyChanged("fold.comment",(fold_comments ? "1" : "0"));
  320. }
  321. // Return true if folds are compact.
  322. bool QsciLexerAVS::foldCompact() const
  323. {
  324. return fold_compact;
  325. }
  326. // Set if folds are compact
  327. void QsciLexerAVS::setFoldCompact(bool fold)
  328. {
  329. fold_compact = fold;
  330. setCompactProp();
  331. }
  332. // Set the "fold.compact" property.
  333. void QsciLexerAVS::setCompactProp()
  334. {
  335. emit propertyChanged("fold.compact",(fold_compact ? "1" : "0"));
  336. }