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
390 from wx
import EmptyIcon
396 '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x0e\x00\x00\x00\x10\x08\x06\
397 \x00\x00\x00&\x94N:\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\
398 \x01mIDAT(\x91\x9d\x93/\x8e\xf30\x10\xc5\x7f[\xed\x05\xca\x82,Ef\xc6e\x01Vx{\
399 \x89\x04\x16\x94\x97\x045\xa8\xa0\xa44G\x08\xc9\x01\xa2\x80\x1e $ld\xc9\xa8w\
400 \x08\xf0\xa2x\x93~\x1f\xda\x91F\xb2\xfd\xe6=\xcd?\x7f\xcd\xf3\x1c\xf8\x83}/\
401 \x87i\x9a\x000\xc6D\xb0\xeb:\x86a MS\xce\xe7\xf3\x968M\x13}\xdf\xe3\x9cCD\
402 \xb8\xddn\x18c\xe8\xba\x8e\xb2,\xc9\xb2\x0c\x11\x01\xd8\x90w\xc6\x18\x94R\
403 \xf1\xa1\xef{\xba\xae\xa3i\x1a\xb4\xd6h\xad)\x8a\x02\xe7\\\xccj\x93\xea\xa2\
404 \nP\xd75\xd7\xeb\x15\x00\xef\xfdFt)e\xb7\x80\x8b\xbas\x8e$I\xe2}\xc1\x8b\xa2\
405 \xd8\xf4b\x07\xa0\x94\xe2\xf5za\xad\xc5Z\xcb\xfb\xfdFD\xe8\xfb\x9e\x05\x17\
406 \x11\x9cs4M\xf3K<\x9dNdY\xc60\x0cx\xef\x11\x11\xea\xbaF)\x85s\x8e\xba\xae)\
407 \xcb\x12\x11!M\xd3_"\xc0\xfd~\xc7Z\x8bs\x0e\x80$I\xa2:@UU1u\x00\xe6y\x0ek\
408 \x1f\xc71\x1c\x0e\x87\xd0\xb6m\xd8\xef\xf7\xe1\xf1x\x84\xcb\xe5\x12\xe6y\x0e\
409 \xc7\xe31\xc6\xed\xf80\x11!\xcb2\xbc\xf7TUE\x9e\xe71=\xadul\xce\xf7\'Qk\x8d\
410 \xf7\x9e<\xcf\x81\xed&Yk\xb7\xe3\xf84\xa5\x14\xc6\x18D\x84\xe7\xf3\x19\x83\
411 \xd75\xfe\x97\xb8\x0eXo\xcc2\x9e\x7f\x9a3\x8ech\xdb6|6l\xf15\xf6\xf5\xd7o\
412 \xf5\x03\xaf\x9f\xfa@\x02\xe4\xdc\xf9\x00\x00\x00\x00IEND\xaeB`\x82'
416 return BitmapFromImage(getPerlImage())
419 stream
= cStringIO
.StringIO(getPerlData())
420 return ImageFromStream(stream
)
424 icon
.CopyFromBitmap(getPerlBitmap())