1
###############################################################################
3
# Purpose: Syntax configuration module for Inno Setup Scripts #
4
# Author: Cody Precord <cprecord@editra.org> #
5
# Copyright: (c) 2008 Cody Precord <staff@editra.org> #
6
# License: wxWindows License #
7
###############################################################################
12
@summary: Lexer configuration module for Inno Setup Scripts
16
__author__ = "Cody Precord <cprecord@editra.org>"
17
__svnid__ = "$Id: _inno.py 68798 2011-08-20 17:17:05Z CJP $"
18
__revision__ = "$Revision: 68798 $"
20
#-----------------------------------------------------------------------------#
30
#-----------------------------------------------------------------------------#
32
#---- Keyword Definitions ----#
33
SECTION_KW = (0, "code components custommessages dirs files icons ini "
34
"installdelete langoptions languages messages registry run "
35
"setup types tasks uninstalldelete uninstallrun _istool")
37
KEYWORDS = (1, "allowcancelduringinstall allownoicons allowrootdirectory "
38
"allowuncpath alwaysrestart alwaysshowcomponentslist "
39
"alwaysshowdironreadypage alwaysshowgrouponreadypage "
40
"alwaysusepersonalgroup appcomments appcontact appcopyright "
41
"appenddefaultdirname appenddefaultgroupname appid appmodifypath "
42
"appmutex appname apppublisher apppublisherurl appreadmefile "
43
"appsupporturl appupdatesurl appvername appversion "
44
"architecturesallowed architecturesinstallin64bitmode backcolor "
45
"backcolor2 backcolordirection backsolid changesassociations "
46
"changesenvironment compression copyrightfontname "
47
"copyrightfontsize createappdir createuninstallregkey "
48
"defaultdirname defaultgroupname defaultuserinfoname "
49
"defaultuserinfoorg defaultuserinfoserial dialogfontname "
50
"dialogfontsize direxistswarning disabledirpage "
51
"disablefinishedpage disableprogramgrouppage disablereadymemo "
52
"disablereadypage disablestartupprompt diskclustersize "
53
"diskslicesize diskspanning enablesdirdoesntexistwarning "
54
"encryption extradiskspacerequired flatcomponentslist "
55
"infoafterfile infobeforefile internalcompresslevel "
56
"languagedetectionmethod languagecodepage languageid languagename "
57
"licensefile mergeduplicatefiles minversion onlybelowversion "
58
"outputbasefilename outputdir outputmanifestfile password "
59
"privilegesrequired reservebytes restartifneededbyrun "
60
"setupiconfile showcomponentsizes showlanguagedialog "
61
"showtaskstreelines slicesperdisk solidcompression sourcedir "
62
"timestamprounding timestampsinutc titlefontname titlefontsize "
63
"touchdate touchtime uninstallable uninstalldisplayicon "
64
"uninstalldisplayname uninstallfilesdir uninstalllogmode "
65
"uninstallrestartcomputer updateuninstalllogappname "
66
"usepreviousappdir usepreviousgroup useprevioussetuptype "
67
"useprevioustasks useprevioususerinfo userinfopage usesetupldr "
68
"versioninfocompany versioninfocopyright versioninfodescription "
69
"versioninfotextversion versioninfoversion welcomefontname "
70
"welcomefontsize windowshowcaption windowstartmaximized "
71
"windowresizable windowvisible wizardimagebackcolor "
72
"wizardimagefile wizardimagestretch wizardsmallimagefile")
74
PARAM_KW = (2, "afterinstall attribs beforeinstall check comment components "
75
"copymode description destdir destname excludes "
76
"extradiskspacerequired filename flags fontinstall "
77
"groupdescription hotkey infoafterfile infobeforefile "
78
"iconfilename iconindex key languages licensefile messagesfile "
79
"minversion name onlybelowversion parameters permissions root "
80
"runonceid section source statusmsg string subkey tasks type "
81
"types valuedata valuename valuetype workingdir")
83
PREPROC_KW = (3, "append define dim else emit endif endsub error expr file for "
84
"if ifdef ifexist ifndef ifnexist include insert pragma sub "
87
PASCAL_KW = (4, "begin break case const continue do downto else end except "
88
"finally for function if of procedure repeat then to try until "
89
"uses var while with")
93
#---- End Keyword Definitions ----#
95
#---- Syntax Style Specs ----#
96
SYNTAX_ITEMS = [(stc.STC_INNO_COMMENT, 'comment_style'),
97
(stc.STC_INNO_COMMENT_PASCAL, 'comment_style'),
98
(stc.STC_INNO_DEFAULT, 'default_style'),
99
(stc.STC_INNO_IDENTIFIER, 'default_style'),
100
(stc.STC_INNO_KEYWORD, 'keyword_style'),
101
(stc.STC_INNO_KEYWORD_PASCAL, 'keyword4_style'),
102
(stc.STC_INNO_KEYWORD_USER, 'default_style'),
103
(stc.STC_INNO_PARAMETER, 'keyword2_style'),
104
(stc.STC_INNO_PREPROC, 'pre_style'),
105
(stc.STC_INNO_SECTION, 'scalar_style'),
106
(stc.STC_INNO_STRING_DOUBLE, 'string_style'),
107
(stc.STC_INNO_STRING_SINGLE, 'char_style')]
109
if wx.VERSION >= (2, 9, 0, 0, ''):
110
SYNTAX_ITEMS.append((stc.STC_INNO_INLINE_EXPANSION, 'default_style')) #TODO
112
SYNTAX_ITEMS.append((stc.STC_INNO_PREPROC_INLINE, 'pre_style'))
114
#---- Extra Properties ----#
116
FOLD_COMP = ("fold.compact", "1")
118
#-----------------------------------------------------------------------------#
120
class SyntaxData(syndata.SyntaxDataBase):
121
"""SyntaxData object for Inno Setup Scripts"""
122
def __init__(self, langid):
123
super(SyntaxData, self).__init__(langid)
126
self.SetLexer(stc.STC_LEX_INNOSETUP)
127
self.RegisterFeature(synglob.FEATURE_AUTOINDENT, AutoIndenter)
129
def GetKeywords(self):
130
"""Returns Specified Keywords List """
131
return [SECTION_KW, KEYWORDS, PARAM_KW, PREPROC_KW, PASCAL_KW]
133
def GetSyntaxSpec(self):
134
"""Syntax Specifications """
137
def GetProperties(self):
138
"""Returns a list of Extra Properties to set """
141
def GetCommentPattern(self):
142
"""Returns a list of characters used to comment a block of code """
143
# Note: Inno can also use pascal comments (i.e {})
146
#-----------------------------------------------------------------------------#
148
def AutoIndenter(estc, pos, ichar):
149
"""Auto indent Inno Setup Scripts.
150
@param estc: EditraStyledTextCtrl
151
@param pos: current carat position
152
@param ichar: Indentation character
156
line = estc.GetCurrentLine()
157
text = estc.GetTextRange(estc.PositionFromLine(line), pos)
158
eolch = estc.GetEOLChar()
160
indent = estc.GetLineIndentation(line)
162
tabw = estc.GetTabWidth()
164
tabw = estc.GetIndent()
166
i_space = indent / tabw
167
ndent = eolch + ichar * i_space
168
rtxt = ndent + ((indent - (tabw * i_space)) * u' ')
170
if_pat = re.compile('if\s+.*\sthen')
172
if text == u'begin' or if_pat.match(text):
175
# Put text in the buffer