~ubuntu-branches/ubuntu/raring/wxwidgets2.8/raring

« back to all changes in this revision

Viewing changes to wxPython/wx/tools/Editra/src/syntax/_inno.py

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2012-01-07 13:59:25 UTC
  • mfrom: (1.1.9) (5.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120107135925-2601miy9ullcon9j
Tags: 2.8.12.1-6ubuntu1
* Resync from Debian, changes that were kept:
  - debian/rules: re-enable mediactrl. This allows libwx_gtk2u_media-2.8 to be
    built, as this is required by some applications (LP: #632984)
  - debian/control: Build-dep on libxt-dev for mediactrl.
  - Patches
    + fix-bashism-in-example
* Add conflict on python-wxgtk2.8 (<< 2.8.12.1-6ubuntu1~) to python-wxversion
  to guarantee upgrade ordering when moving from pycentral to dh_python2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
"""
15
15
 
16
16
__author__ = "Cody Precord <cprecord@editra.org>"
17
 
__svnid__ = "$Id: _inno.py 63834 2010-04-03 06:04:33Z CJP $"
18
 
__revision__ = "$Revision: 63834 $"
 
17
__svnid__ = "$Id: _inno.py 66104 2010-11-10 20:18:29Z CJP $"
 
18
__revision__ = "$Revision: 66104 $"
19
19
 
20
20
#-----------------------------------------------------------------------------#
21
21
# Imports
 
22
import wx
22
23
import wx.stc as stc
23
24
import re
24
25
 
101
102
                (stc.STC_INNO_KEYWORD_USER, 'default_style'),
102
103
                (stc.STC_INNO_PARAMETER, 'keyword2_style'),
103
104
                (stc.STC_INNO_PREPROC, 'pre_style'),
104
 
                (stc.STC_INNO_PREPROC_INLINE, 'pre_style'),
105
105
                (stc.STC_INNO_SECTION, 'scalar_style'),
106
106
                (stc.STC_INNO_STRING_DOUBLE, 'string_style'),
107
107
                (stc.STC_INNO_STRING_SINGLE, 'char_style')]
108
108
 
 
109
if wx.VERSION >= (2, 9, 0, 0, ''):
 
110
    SYNTAX_ITEMS.append((stc.STC_INNO_INLINE_EXPANSION, 'default_style')) #TODO
 
111
else:
 
112
    SYNTAX_ITEMS.append((stc.STC_INNO_PREPROC_INLINE, 'pre_style'))
 
113
 
109
114
#---- Extra Properties ----#
110
115
FOLD = ("fold", "1")
111
116
FOLD_COMP = ("fold.compact", "1")
140
145
 
141
146
#-----------------------------------------------------------------------------#
142
147
 
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
 
148
def AutoIndenter(estc, pos, ichar):
 
149
    """Auto indent Inno Setup Scripts.
 
150
    @param estc: EditraStyledTextCtrl
147
151
    @param pos: current carat position
148
152
    @param ichar: Indentation character
149
 
    @return: string
150
153
 
151
154
    """
152
155
    rtxt = u''
153
 
    line = stc.GetCurrentLine()
154
 
    text = stc.GetTextRange(stc.PositionFromLine(line), pos)
 
156
    line = estc.GetCurrentLine()
 
157
    text = estc.GetTextRange(estc.PositionFromLine(line), pos)
 
158
    eolch = estc.GetEOLChar()
155
159
 
156
 
    indent = stc.GetLineIndentation(line)
 
160
    indent = estc.GetLineIndentation(line)
157
161
    if ichar == u"\t":
158
 
        tabw = stc.GetTabWidth()
 
162
        tabw = estc.GetTabWidth()
159
163
    else:
160
 
        tabw = stc.GetIndent()
 
164
        tabw = estc.GetIndent()
161
165
 
162
166
    i_space = indent / tabw
163
 
    ndent = u"\n" + ichar * i_space
 
167
    ndent = eolch + ichar * i_space
164
168
    rtxt = ndent + ((indent - (tabw * i_space)) * u' ')
165
169
 
166
170
    if_pat = re.compile('if\s+.*\sthen')
168
172
    if text == u'begin' or if_pat.match(text):
169
173
        rtxt += ichar
170
174
 
171
 
    return rtxt
 
175
    # Put text in the buffer
 
176
    estc.AddText(rtxt)