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)
390 #----------------------------------------------------------------------------
391 # Icon Bitmaps - generated by encode_bitmaps.py
392 #----------------------------------------------------------------------------
393 from wx
import ImageFromStream
, BitmapFromImage
399 "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
400 \x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
401 \x00\x01CIDAT8\x8d\x95\x93\xbfN\x02A\x10\x87\xbf[\xef\x05\xach|\x02m}\x008\
402 \x881Z\xd2\x1a\x13\x0bKx\x02{\xa3\xa13\xc6\xc6\xc6\xd2DZ+s\\\x83\x95\x1d\xa2\
403 &V\x104\x01/p\x01\t\xa0\xe8X\xc0\x9d\x87\xdc^\xf0\x97Lfw3\xdf\xec\xcc\xfe1\
404 \xca\x95\xba0\x95\xeb\xf5\x01h\xb4\xda\x00x\xde\x90\x83\xfd\r\x838\x95+u\xa9\
405 \rDj\x03\x91\xe7\xbe\xc8}wb\xa7\xc5\xb2\xdc\xbe\x89\xe4\x8f\xae\xc4PK\xe8L\
406 \xc5%\xef\x8da{7K\xee\xf0Rt1\xa6\xeb\xf5Y\x01>\xbea\xf45Y\xec\x8e&\xe5\xdf]\
407 \xdb4\xdd\x0e\xaf/-\xed&&\x110\xc0\xfa\x96\xc5\xf1N\x06\x80\xe5\xb5\xac6\x81\
408 \x82y\xb87\x9e\r\xeaT\x8b3s+\x95\x14+\x95\x14\x00\xd5h\xb5\xe9\x8e\xe6a\x7f\
409 \xf70\x14\xf6\xfeXy\xde0\x08\xf2\xe1\xf6gt\xb9V*)v\xc9\t\xae\xd5.9\x86\x19\
410 \x05\x9e\xefe\xe6i\x8dT\xd3\xed\xfc\x0b\x0e\xb7\x00\xd3C\xd4\x95\x1c'\xbf\
411 \x15\x15\xbe\xe3\xc6;l\x9e\xdc\x00\xbf\xfe/`\x97\x1c#|\x0e&@\xb1p\x16\x04>U\
412 \x1fI\x00\x17\xb9<\t\xa0\xc9*\t\x1e\xf4\xa5D\xbd\xeft:-q~\xe1\xbf\xb0\x88b\
413 \x13\x84{\x8d\x9a\x03\xfc\x00\xea\x7f\xa9A\xa7\xc3Vo\x00\x00\x00\x00IEND\xae\
418 return BitmapFromImage(getPerlImage())
421 stream
= cStringIO
.StringIO(getPerlData())
422 return ImageFromStream(stream
)
425 return wx
.IconFromBitmap(getPerlBitmap())