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