1 #----------------------------------------------------------------------------
3 # Purpose: Perl Script Editor for pydocview tbat uses the Styled Text Control
9 # Copyright: (c) 2005 ActiveGrid, Inc.
10 # License: wxWindows License
11 #----------------------------------------------------------------------------
19 class PerlDocument(CodeEditor
.CodeDocument
):
24 class PerlView(CodeEditor
.CodeView
):
27 def GetCtrlClass(self
):
28 """ Used in split window to instantiate new instances """
32 def GetAutoCompleteHint(self
):
33 pos
= self
.GetCtrl().GetCurrentPos()
37 validLetters
= string
.letters
+ string
.digits
+ '_/'
43 char
= chr(self
.GetCtrl().GetCharAt(pos
))
44 if char
not in validLetters
:
51 def GetAutoCompleteDefaultKeywords(self
):
55 class PerlService(CodeEditor
.CodeService
):
59 CodeEditor
.CodeService
.__init
__(self
)
62 class PerlCtrl(CodeEditor
.CodeCtrl
):
65 def __init__(self
, parent
, id=-1, style
=wx
.NO_FULL_REPAINT_ON_RESIZE
):
66 CodeEditor
.CodeCtrl
.__init
__(self
, parent
, id, style
)
67 self
.SetLexer(wx
.stc
.STC_LEX_PERL
)
68 self
.SetKeyWords(0, string
.join(PERLKEYWORDS
))
71 def CanWordWrap(self
):
75 def SetViewDefaults(self
):
76 CodeEditor
.CodeCtrl
.SetViewDefaults(self
, configPrefix
= "Perl", hasWordWrap
= True, hasTabs
= True)
79 def GetFontAndColorFromConfig(self
):
80 return CodeEditor
.CodeCtrl
.GetFontAndColorFromConfig(self
, configPrefix
= "Perl")
83 def UpdateStyles(self
):
84 CodeEditor
.CodeCtrl
.UpdateStyles(self
)
86 if not self
.GetFont():
89 faces
= { 'font' : self
.GetFont().GetFaceName(),
90 'size' : self
.GetFont().GetPointSize(),
91 'size2': self
.GetFont().GetPointSize() - 2,
92 'color' : "%02x%02x%02x" % (self
.GetFontColor().Red(), self
.GetFontColor().Green(), self
.GetFontColor().Blue())
96 self
.StyleSetSpec(wx
.stc
.STC_PL_DEFAULT
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
97 self
.StyleSetSpec(wx
.stc
.STC_PL_COMMENTLINE
, "face:%(font)s,fore:#007F00,italic,face:%(font)s,size:%(size)d" % faces
)
98 self
.StyleSetSpec(wx
.stc
.STC_PL_NUMBER
, "face:%(font)s,fore:#007F7F,size:%(size)d" % faces
)
99 self
.StyleSetSpec(wx
.stc
.STC_PL_CHARACTER
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
100 self
.StyleSetSpec(wx
.stc
.STC_PL_STRING
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
101 self
.StyleSetSpec(wx
.stc
.STC_PL_STRING_Q
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
102 self
.StyleSetSpec(wx
.stc
.STC_PL_STRING_QQ
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
103 self
.StyleSetSpec(wx
.stc
.STC_PL_STRING_QX
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
104 self
.StyleSetSpec(wx
.stc
.STC_PL_STRING_QR
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
105 self
.StyleSetSpec(wx
.stc
.STC_PL_STRING_QW
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
106 self
.StyleSetSpec(wx
.stc
.STC_PL_BACKTICKS
, "face:%(font)s,fore:#7F007F,face:%(font)s,size:%(size)d" % faces
)
107 self
.StyleSetSpec(wx
.stc
.STC_PL_WORD
, "face:%(font)s,fore:#00007F,bold,size:%(size)d" % faces
) # keyword
108 self
.StyleSetSpec(wx
.stc
.STC_PL_IDENTIFIER
, "face:%(font)s,fore:#%(color)s,face:%(font)s,size:%(size)d" % faces
)
111 self
.StyleSetSpec(wx
.stc
.STC_PL_ARRAY
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
112 self
.StyleSetSpec(wx
.stc
.STC_PL_DATASECTION
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
113 self
.StyleSetSpec(wx
.stc
.STC_PL_ERROR
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
114 self
.StyleSetSpec(wx
.stc
.STC_PL_HASH
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
115 self
.StyleSetSpec(wx
.stc
.STC_PL_HERE_DELIM
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
116 self
.StyleSetSpec(wx
.stc
.STC_PL_HERE_Q
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
117 self
.StyleSetSpec(wx
.stc
.STC_PL_HERE_QQ
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
118 self
.StyleSetSpec(wx
.stc
.STC_PL_HERE_QX
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
119 self
.StyleSetSpec(wx
.stc
.STC_PL_LONGQUOTE
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
120 self
.StyleSetSpec(wx
.stc
.STC_PL_OPERATOR
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
121 self
.StyleSetSpec(wx
.stc
.STC_PL_POD
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
122 self
.StyleSetSpec(wx
.stc
.STC_PL_PREPROCESSOR
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
123 self
.StyleSetSpec(wx
.stc
.STC_PL_PUNCTUATION
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
124 self
.StyleSetSpec(wx
.stc
.STC_PL_REGEX
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
125 self
.StyleSetSpec(wx
.stc
.STC_PL_REGSUBST
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
126 self
.StyleSetSpec(wx
.stc
.STC_PL_SCALAR
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
127 self
.StyleSetSpec(wx
.stc
.STC_PL_SYMBOLTABLE
, "face:%(font)s,fore:#000000,face:%(font)s,size:%(size)d" % faces
)
130 class PerlOptionsPanel(STCTextEditor
.TextOptionsPanel
):
132 def __init__(self
, parent
, id):
133 STCTextEditor
.TextOptionsPanel
.__init
__(self
, parent
, id, configPrefix
= "Perl", label
= "Perl", hasWordWrap
= True, hasTabs
= True)
386 #----------------------------------------------------------------------------
387 # Icon Bitmaps - generated by encode_bitmaps.py
388 #----------------------------------------------------------------------------
389 from wx
import ImageFromStream
, BitmapFromImage
395 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
396 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
397 \x00\x01\x81IDAT8\x8d\xa5S1n\xe30\x10\x1cJ\xf9\x80;U\x04\x04~\xc06\xdc\xa9\
398 \x10\xd4\xb3K\xf2\x01\xf9\x01F\x92\xce\x8d:vI\x84\xdc\xd5\xaa\xdc%\xd1\x17\
399 \x0c\x17ns\xa7\x07,\x16\xe0G6E@B\x91\x9c*\x0b\x10 \xb9\xe4\xecpg\xa8T\x92\
400 \xe27q5^\xbc\xbf\xbd\n\x00\\\xdf\xdc\xaa\xb0\xf7\xfc\xf4(\xcc\x8c<\xcfqw\xff\
401 \xa0\xa6\x00PI\x8aa\x18\xa4m[\xd9\xedvb\xad\x95a\x18D%)\xfa\xbe\x97\xc5b!\
402 \xd6Z\xb1\xd6J\xdb\xb6\xa2\x92\x14\xe3\x91\x00\xc0r\xb5VZ\xeb\x08z<\x1e\xf1\
403 \xfe\xf6*]\xd7\xc1\x18\x03c\x0c\xea\xba\x063\xe3\xff\xbf\x0f\xf9\xf1\tD\x14\
404 \xe7\xce9\xec\xf7{\x00\x80\xf7\xfe\x1b\xf88\x920\xf1\xde\xc7j\xcc\x8c,\xcb\
405 \xe2:\xe4\xeb\xba\x06\x80o,"\x03\xad5\x0e\x87C\xacz>\x9fAD\xb1\xba\xd6\x1aD\
406 \x04f\x063\xcf\x19\\\xdf\xdc\xaa\xa2(p:\x9d\xe0\xbd\x07\x11\xc19\x07\xad5\
407 \x98\x19\xce9l\xb7[\x10\x11\xf2<\x9f\x03\x00\xc0\xcb\x9f\xbf\xaa,\xcbX!\xcb2\
408 t]\x17\xf3M\xd3\xc4\'\xc5\x98\xca\x12d\xddl6\x12d\x0c\x12\xab$\x85\xb5Vf2N\
409 \x83\x88P\x14\x05\xbc\xf7h\x9a\x06UUE\xda\xc6\x98\xcbM\x1c\x871\x06\xde{TU\
410 \x05\xe0\xcb\'\xe1RY\x96X\xae\xd6\xd1\x91\x17\x19\x00_]_\xae\xd6\x8a\x88\xf0\
411 \xfc\xf4(\xe1\xd2\xb4\x07?\x02\x8c\x0f\x8e\x1d85\xd2\xc5\x06\xf6}?\xf3|\x18\
412 \xb3\xdco\xbf\xf3\'`\xa6\xbc1\xa7\xd6\xcb\xbf\x00\x00\x00\x00IEND\xaeB`\x82'\
416 return BitmapFromImage(getPerlImage())
419 stream
= cStringIO
.StringIO(getPerlData())
420 return ImageFromStream(stream
)
423 return wx
.IconFromBitmap(getPerlBitmap())