138
153
lxml = launchxml.LaunchXml()
139
lxml.LoadFromString(xml_str)
140
for hndlr in lxml.GetHandlers().values():
141
HANDLERS[hndlr.GetLangId()] = XmlHandlerDelegate(hndlr)
155
for hndlr in lxml.GetHandlers():
156
FileTypeHandler.RegisterClass(XmlHandlerDelegate(hndlr))
148
"""Get a dictionary capturing the current state of all handlers
149
@return: dict { handlername : (default, [commands]) }
153
for handler in HANDLERS.values():
154
rdict[handler.GetName()] = (handler.GetDefault(), handler.GetCommands())
158
"""Set the state of all handlers based on a dictionary of values
159
@param state: dict { handlername : (default, [(alias, command), ]) }
162
for ftype, vals in state.iteritems():
163
handler = GetHandlerByName(ftype)
164
handler.SetCommands(vals[1])
165
handler.SetDefault(vals)
167
162
#-----------------------------------------------------------------------------#
168
163
# Handler Base Class and Handler implementations
167
"""Metadata namespace, acts as a container object for all FileTypeHandler
172
_defaults = {"typeid" : -1, # Editra Language ID
173
"name" : DEFAULT_HANDLER, # Language Display Name (derived from ID)
174
"commands" : dict(), # Commands alias -> commandline
175
"default" : u"", # Default command alias
176
"error" : None, # Error regular expression
177
"hotspot" : None, # Hotspot expression (line, filename)
178
"transient" : False} # Transient configuration (bool)
179
def __init__(self, meta_attrs):
180
for (attr,default) in self._defaults.items():
181
attr_val = meta_attrs.get(attr, default)
182
setattr(self, attr, copy.copy(attr_val))
184
class HandlerMeta(type):
185
"""Metaclass for manipulating a handler classes metadata converts
186
all user defined 'meta' classes to a Meta class with all unset attributes
187
initialized to the default setting.
190
def __new__(mcls,name,bases,attrs):
191
cls = super(HandlerMeta,mcls).__new__(mcls,name,bases,attrs)
193
if hasattr(cls, 'meta'):
194
for attr in dir(cls.meta):
195
if not attr.startswith("_"):
196
meta_attrs[attr] = getattr(cls.meta,attr)
197
cls.meta = Meta(meta_attrs)
200
#-----------------------------------------------------------------------------#
170
202
class FileTypeHandler(object):
171
203
"""Base default Output handler all output handlers should derive from
172
204
this class. This base class is used when an output handler is request
173
205
but no special one exists.
208
__metaclass__ = HandlerMeta
209
handler_cache = dict()
176
211
def __init__(self):
177
object.__init__(self)
178
self.commands = dict()
181
__name__ = DEFAULT_HANDLER
183
def AppendCommand(self, cmd):
212
super(FileTypeHandler, self).__init__()
214
if self.meta.typeid != -1:
215
self.meta.name = synglob.GetDescriptionFromId(self.meta.typeid)
218
def __ClassFactory(ftype):
219
"""Generate a new class for ones that don't have a
220
specialized implementation.
221
@return: new FileTypeHandler class
224
class DynamicHandler(FileTypeHandler):
227
name = synglob.GetDescriptionFromId(ftype)
228
return DynamicHandler
231
def FactoryCreate(cls, ftype):
232
"""Create an instance of a FileTypeHandler for the given
233
file type. One of the two arguments must be provided. If
234
both are provided the ftype argument will take preference.
235
@keyword ftype: Editra file type ID
236
@keyword name: File type description string
239
obj = cls.handler_cache.get(ftype, None)
241
# Check existing custom subclasses for a proper implementation
242
for handler in cls.__subclasses__():
243
if ftype != -1 and handler.meta.typeid == ftype:
247
# Dynamically create a new class
248
obj = cls.__ClassFactory(ftype)
249
cls.RegisterClass(obj)
252
# Load custom settings for non-transient filetypes
253
if not obj.meta.transient:
254
data = GetUserSettings(obj.GetName())
256
obj.SetCommands(data[1])
261
def AppendCommand(cls, cmd):
184
262
"""Add a command to the list of commands known to this handler
185
263
@param cmd: Tuple of (Command alias, executable path or name)
188
266
if isinstance(cmd, tuple):
189
self.commands[cmd[0]] = cmd[1]
194
def GetAliases(self):
267
cls.meta.commands[cmd[0]] = cmd[1]
270
def RegisterClass(cls, handler):
271
"""Register a filetype handler in the handler
273
@param handler: FileTypeHandler
276
cls.handler_cache[handler.meta.typeid] = handler
195
280
"""Get the list of command aliases"""
196
return sorted(self.commands.keys())
281
return sorted(cls.meta.commands.keys())
198
def GetCommand(self, alias):
284
def GetCommand(cls, alias):
199
285
"""Get the command for a given alias"""
200
return self.commands.get(alias, alias)
286
return cls.meta.commands.get(alias, alias)
202
def GetCommands(self):
289
def GetCommands(cls):
203
290
"""Get the set of commands available for this file type"""
204
return sorted(self.commands.items())
291
return sorted(cls.meta.commands.items())
206
def GetDefault(self):
207
295
"""Get the preferred default command
299
return cls.meta.default
213
301
def GetEnvironment(self):
214
302
"""Get the dictionary of environmental variables to run the
348
469
_OpenToLine(ifile, line, mainw)
350
def StyleText(self, stc, start, txt):
351
"""Style NSIS output messages"""
353
err, more = _StyleError(stc, start, txt, BashHandler.RE_BASH_ERROR)
357
sty = super(BashHandler, self).StyleText(stc, start, txt)[0]
360
471
#-----------------------------------------------------------------------------#
362
473
class BatchHandler(FileTypeHandler):
363
474
"""FileTypeHandler for Dos batch files"""
365
FileTypeHandler.__init__(self)
366
self.commands = dict(cmd='cmd /c')
476
typeid = synglob.ID_LANG_BATCH
477
commands = dict(cmd='cmd /c')
371
480
#-----------------------------------------------------------------------------#
373
482
class BooHandler(FileTypeHandler):
374
483
"""FileTypeHandler for Boo"""
376
FileTypeHandler.__init__(self)
377
self.commands = dict(booi='booi')
378
self.default = 'booi'
485
typeid = synglob.ID_LANG_BOO
486
commands = dict(booi='booi')
489
#-----------------------------------------------------------------------------#
491
class CHandler(FileTypeHandler):
492
"""FileTypeHandler for C Files"""
494
typeid = synglob.ID_LANG_C
495
commands = {'gcc -c' : 'gcc -c'}
498
class CPPHandler(FileTypeHandler):
499
"""FileTypeHandler for C++ Files"""
501
typeid = synglob.ID_LANG_CPP
502
commands = {'g++ -c' : 'g++ -c'}
382
505
#-----------------------------------------------------------------------------#
384
507
class CamlHandler(FileTypeHandler):
385
508
"""FileTypeHandler for Caml"""
386
RE_CAML_ERROR = re.compile(r'File "(.+)", line (.+), characters .+:')
389
FileTypeHandler.__init__(self)
390
self.commands = dict(ocaml='ocaml')
391
self.default = 'ocaml'
395
def HandleHotSpot(self, mainw, outbuffer, line, fname):
396
"""Hotspots are error messages, find the file/line of the
397
error in question and open the file to that point in the buffer.
400
ifile, line = _FindFileLine(outbuffer, line, fname,
401
CamlHandler.RE_CAML_ERROR)
402
_OpenToLine(ifile, line, mainw)
404
def StyleText(self, stc, start, txt):
405
"""Style OCaml Information and Error messages from script output."""
407
err, more = _StyleError(stc, start, txt, CamlHandler.RE_CAML_ERROR)
411
sty = super(CamlHandler, self).StyleText(stc, start, txt)[0]
510
typeid = synglob.ID_LANG_CAML
511
commands = dict(ocaml='ocaml')
512
error = re.compile(r'File "(.+)", line (.+), characters .+:')
513
hotspot = re.compile(r'File "(.+)", line (.+), characters .+:')
414
515
#-----------------------------------------------------------------------------#
416
517
class CSHHandler(FileTypeHandler):
417
518
"""FileTypeHandler for C-Shell"""
419
FileTypeHandler.__init__(self)
420
self.commands = dict(csh='csh')
520
typeid = synglob.ID_LANG_CSH
521
commands = dict(csh='csh')
425
524
#-----------------------------------------------------------------------------#
427
526
class DHandler(FileTypeHandler):
428
527
"""FileTypeHandler for D"""
430
FileTypeHandler.__init__(self)
431
self.commands = dict(dmd='dmd -run')
529
typeid = synglob.ID_LANG_D
530
commands = dict(dmd='dmd -run')
436
533
#-----------------------------------------------------------------------------#
438
535
class FeriteHandler(FileTypeHandler):
439
536
"""FileTypeHandler for Ferite"""
441
FileTypeHandler.__init__(self)
442
self.commands = dict(ferite='ferite')
443
self.default = 'ferite'
538
typeid = synglob.ID_LANG_FERITE
539
commands = dict(ferite='ferite')
447
542
#-----------------------------------------------------------------------------#
449
544
class HaskellHandler(FileTypeHandler):
450
545
"""FileTypeHandler for Haskell"""
451
RE_HASKELL_ERROR = re.compile('(.+):(.+):[0-9]+:.+ error .+')
454
FileTypeHandler.__init__(self)
455
self.commands = {'ghc --make' : 'ghc --make'}
456
self.default = 'ghc --make'
460
def HandleHotSpot(self, mainw, outbuffer, line, fname):
461
"""Hotspots are error messages, find the file/line of the
462
error in question and open the file to that point in the buffer.
465
ifile, line = _FindFileLine(outbuffer, line, fname,
466
HaskellHandler.RE_HASKELL_ERROR)
467
_OpenToLine(ifile, line, mainw)
469
def StyleText(self, stc, start, txt):
470
"""Style GHC Information and Error messages from script output."""
472
err, more = _StyleError(stc, start, txt, HaskellHandler.RE_HASKELL_ERROR)
476
sty = super(HaskellHandler, self).StyleText(stc, start, txt)[0]
547
typeid = synglob.ID_LANG_HASKELL
548
commands = {'ghc --make' : 'ghc --make'}
549
default = 'ghc --make'
550
error = re.compile('(.+):(.+):[0-9]+:.+ error .+')
551
hotspot = re.compile('(.+):(.+):[0-9]+:.+ error .+')
479
553
#-----------------------------------------------------------------------------#
481
555
class HaxeHandler(FileTypeHandler):
482
556
"""FileTypeHandler for haXe"""
483
RE_HAXE_ERROR = re.compile('([a-zA-Z_.]+)\(([0-9]+)\):.*')
486
FileTypeHandler.__init__(self)
487
self.commands = dict(neko='neko', nekoc='nekoc')
488
self.default = 'nekoc'
492
def HandleHotSpot(self, mainw, outbuffer, line, fname):
493
"""Hotspots are error messages, find the file/line of the
494
error in question and open the file to that point in the buffer.
497
ifile, line = _FindFileLine(outbuffer, line, fname,
498
HaxeHandler.RE_HAXE_ERROR)
499
_OpenToLine(ifile, line, mainw)
501
def StyleText(self, stc, start, txt):
502
"""Style haXe output messages"""
504
err, more = _StyleError(stc, start, txt, HaxeHandler.RE_HAXE_ERROR)
508
sty = super(HaxeHandler, self).StyleText(stc, start, txt)[0]
558
typeid = synglob.ID_LANG_HAXE
559
commands = dict(neko='neko', nekoc='nekoc')
561
error = re.compile('([a-zA-Z_.]+)\(([0-9]+)\):.*')
562
hotspot = re.compile('([a-zA-Z_.]+)\(([0-9]+)\):.*')
511
564
#-----------------------------------------------------------------------------#
513
566
class HTMLHandler(FileTypeHandler):
514
567
"""FileTypeHandler for HTML"""
516
FileTypeHandler.__init__(self)
569
typeid = synglob.ID_LANG_HTML
517
570
if u'darwin' in sys.platform:
518
self.commands = dict(Safari='open -a Safari.app',
519
Camino='open -a Camino.app',
520
Firefox='open -a Firefox.app',
521
Opera='open -a Opera.app')
522
self.default = 'Safari'
571
commands = dict(Safari='open -a Safari.app',
572
Camino='open -a Camino.app',
573
Firefox='open -a Firefox.app',
574
Opera='open -a Opera.app')
523
576
elif sys.platform.startswith('win'):
524
self.commands = dict(ie='iexplorer.exe',
525
firefox='firefox.exe',
577
commands = dict(ie='iexplorer.exe',
578
firefox='firefox.exe',
529
self.commands = dict(firefox='firefox',
531
self.default = 'firefox'
582
commands = dict(firefox='firefox', opera='opera')
535
585
#-----------------------------------------------------------------------------#
537
587
class InnoSetupHandler(FileTypeHandler):
538
588
"""FileTypeHandler for Inno Setup Scripts"""
540
FileTypeHandler.__init__(self)
541
self.commands = dict(iscc='iscc.exe', Compil32='Compil32.exe /cc')
542
self.default = 'iscc'
544
__name__ = 'inno setup script'
590
typeid = synglob.ID_LANG_INNO
591
commands = dict(iscc='iscc.exe', Compil32='Compil32.exe /cc')
546
594
#-----------------------------------------------------------------------------#
548
596
class KornHandler(FileTypeHandler):
549
597
"""FileTypeHandler for Korn Shell scripts"""
551
FileTypeHandler.__init__(self)
552
self.commands = dict(ksh='ksh')
555
__name__ = 'korn shell'
599
typeid = synglob.ID_LANG_KSH
600
commands = dict(ksh='ksh')
557
603
#-----------------------------------------------------------------------------#
559
605
class STATAHandler(FileTypeHandler):
560
606
"""FileTypeHandler for Stata"""
562
FileTypeHandler.__init__(self)
563
self.commands = dict(stata='stata', xstata='xstata')
564
self.default = 'stata'
608
typeid = synglob.ID_LANG_STATA
609
commands = dict(stata='stata', xstata='xstata')
568
612
#-----------------------------------------------------------------------------#
570
614
class LatexHandler(FileTypeHandler):
571
615
"""FileTypeHandler for LaTex"""
573
FileTypeHandler.__init__(self)
574
self.commands = dict(latex='latex', dvips='dvips',
575
pdflatex='pdflatex', ps2pdf='ps2pdf',
576
dvipng='dvipng', latex2html='latex2html')
577
self.default = 'latex'
617
typeid = synglob.ID_LANG_LATEX
618
commands = dict(latex='latex', dvips='dvips',
619
pdflatex='pdflatex', ps2pdf='ps2pdf',
620
dvipng='dvipng', latex2html='latex2html')
581
623
#-----------------------------------------------------------------------------#
583
625
class LuaHandler(FileTypeHandler):
584
626
"""FileTypeHandler for Lua"""
585
RE_LUA_ERROR = re.compile('.*: (.+):([0-9]+):.*')
588
FileTypeHandler.__init__(self)
589
self.commands = dict(lua='lua', luac='luac')
594
def HandleHotSpot(self, mainw, outbuffer, line, fname):
595
"""Hotspots are error messages, find the file/line of the
596
error in question and open the file to that point in the buffer.
599
ifile, line = _FindFileLine(outbuffer, line, fname,
600
LuaHandler.RE_LUA_ERROR)
601
_OpenToLine(ifile, line, mainw)
603
def StyleText(self, stc, start, txt):
604
"""Style NSIS output messages"""
606
err, more = _StyleError(stc, start, txt, LuaHandler.RE_LUA_ERROR)
610
sty = super(LuaHandler, self).StyleText(stc, start, txt)[0]
628
typeid = synglob.ID_LANG_LUA
629
commands = dict(lua='lua', luac='luac')
631
error = re.compile('.*: (.+):([0-9]+):.*')
632
hotspot = re.compile('.*: (.+):([0-9]+):.*')
613
634
#-----------------------------------------------------------------------------#
615
636
class NewLispHandler(FileTypeHandler):
616
637
"""FileTypeHandler for newLisp"""
619
FileTypeHandler.__init__(self)
620
self.commands = dict(newlisp='newlisp')
621
self.default = 'newlisp'
639
typeid = synglob.ID_LANG_NEWLISP
640
commands = dict(newlisp='newlisp')
625
643
#-----------------------------------------------------------------------------#
627
645
class NSISHandler(FileTypeHandler):
628
646
"""FileTypeHandler for NSIS scripts"""
629
RE_NSIS_ERROR = re.compile(r'Error .* "(.+)" on line ([0-9]+) ')
632
FileTypeHandler.__init__(self)
633
self.commands = dict(makensis='makensis')
634
self.default = 'makensis'
638
def HandleHotSpot(self, mainw, outbuffer, line, fname):
639
"""Hotspots are error messages, find the file/line of the
640
error in question and open the file to that point in the buffer.
643
ifile, line = _FindFileLine(outbuffer, line, fname,
644
NSISHandler.RE_NSIS_ERROR)
645
_OpenToLine(ifile, line, mainw)
647
def StyleText(self, stc, start, txt):
648
"""Style NSIS output messages"""
650
err, more = _StyleError(stc, start, txt, NSISHandler.RE_NSIS_ERROR)
654
sty = super(NSISHandler, self).StyleText(stc, start, txt)[0]
648
typeid = synglob.ID_LANG_NSIS
649
commands = dict(makensis='makensis')
651
error = re.compile(r'Error .* "(.+)" on line ([0-9]+) ')
652
hotspot = re.compile(r'Error .* "(.+)" on line ([0-9]+) ')
657
654
#-----------------------------------------------------------------------------#
659
656
class PhpHandler(FileTypeHandler):
660
657
"""FileTypeHandler for Php"""
661
RE_PHP_ERROR = re.compile(r'[a-zA-Z]+ error: .* in (.+) on line ([0-9]+).*')
664
FileTypeHandler.__init__(self)
665
self.commands = dict(php='php -f')
670
def HandleHotSpot(self, mainw, outbuffer, line, fname):
671
"""Hotspots are error messages, find the file/line of the
672
error in question and open the file to that point in the buffer.
675
ifile, line = _FindFileLine(outbuffer, line, fname,
676
PhpHandler.RE_PHP_ERROR)
677
_OpenToLine(ifile, line, mainw)
679
def StyleText(self, stc, start, txt):
680
"""Style php Information and Error messages from script
685
err, more = _StyleError(stc, start, txt, PhpHandler.RE_PHP_ERROR)
689
sty = super(PhpHandler, self).StyleText(stc, start, txt)[0]
659
typeid = synglob.ID_LANG_PHP
660
commands = dict(php='php -f')
662
error = re.compile(r'[a-zA-Z]+ error: .* in (.+) on line ([0-9]+).*')
663
hotspot = re.compile(r'[a-zA-Z]+ error: .* in (.+) on line ([0-9]+).*')
692
665
#-----------------------------------------------------------------------------#
694
667
class PikeHandler(FileTypeHandler):
695
668
"""FileTypeHandler for Pike"""
697
FileTypeHandler.__init__(self)
698
self.commands = dict(pike='pike')
699
self.default = 'pike'
670
typeid = synglob.ID_LANG_PIKE
671
commands = dict(pike='pike')
703
674
#-----------------------------------------------------------------------------#
705
676
class PerlHandler(FileTypeHandler):
706
677
"""FileTypeHandler for Perl scripts"""
707
RE_PERL_ERROR = re.compile(r'.+ at (.+) line ([0-9]+)[,\.].*')
710
FileTypeHandler.__init__(self)
711
self.commands = dict(perl='perl')
712
self.default = 'perl'
716
def HandleHotSpot(self, mainw, outbuffer, line, fname):
717
"""Hotspots are error messages, find the file/line of the
718
error in question and open the file to that point in the buffer.
721
ifile, line = _FindFileLine(outbuffer, line, fname,
722
PerlHandler.RE_PERL_ERROR)
723
_OpenToLine(ifile, line, mainw)
725
def StyleText(self, stc, start, txt):
726
"""Style perl Information and Error messages from script
731
err, more = _StyleError(stc, start, txt, PerlHandler.RE_PERL_ERROR)
735
sty = super(PerlHandler, self).StyleText(stc, start, txt)[0]
679
typeid = synglob.ID_LANG_PERL
680
commands = dict(perl='perl')
682
hotspot = re.compile(r'.+ at (.+) line ([0-9]+)[,\.].*')
738
684
#-----------------------------------------------------------------------------#
740
686
class PostScriptHandler(FileTypeHandler):
741
687
"""FileTypeHandler for Post/GhostScript"""
743
FileTypeHandler.__init__(self)
689
typeid = synglob.ID_LANG_PS
744
690
if sys.platform.startswith('win'):
745
self.commands = dict(gswin32c='gswin32c')
746
self.default = 'gs2in32c'
691
commands = dict(gswin32c='gswin32c')
747
693
elif 'darwin' in sys.platform:
748
self.commands = dict(pstopdf='pstopdf')
749
self.default = 'pstopdf'
694
commands = dict(pstopdf='pstopdf')
751
self.commands = dict(gs='gs')
754
__name__ = 'postscript'
697
commands = dict(gs='gs')
756
700
#-----------------------------------------------------------------------------#
758
702
class PythonHandler(FileTypeHandler):
759
703
"""FileTypeHandler for Python"""
760
RE_PY_ERROR = re.compile('File "(.+)", line ([0-9]+)') # Python Exceptions
761
704
RE_PL_ERR = re.compile(r'\s*([REWCF]):\s*([0-9]+):.*') # Pylint Output
764
FileTypeHandler.__init__(self)
765
self.commands = dict(python='python -u', pylint='pylint',
707
typeid = synglob.ID_LANG_PYTHON
708
commands = dict(python='python -u', pylint='pylint',
766
709
pylinterr='pylint -e')
767
self.default = 'python'
711
error = re.compile('File "(.+)", line ([0-9]+)')
712
hotspot = re.compile('File "(.+)", line ([0-9]+)')
771
714
def GetEnvironment(self):
772
715
"""Get the environment to run the python script in"""
788
732
eline = max(0, int(match.group(2)) - 1)
789
733
_OpenToLine(fname, eline, mainw)
791
ifile, line = _FindFileLine(outbuffer, line, fname,
792
PythonHandler.RE_PY_ERROR)
793
_OpenToLine(ifile, line, mainw)
795
def StyleText(self, stc, start, txt):
796
"""Style python Information and Error messages from script
801
err, more = _StyleError(stc, start, txt, PythonHandler.RE_PY_ERROR)
803
sty, more = _StyleError(stc, start, txt, PythonHandler.RE_PL_ERR)
811
sty = super(PythonHandler, self).StyleText(stc, start, txt)[0]
735
super(PythonHandler, cls).HandleHotSpot(mainw, outbuffer, line, fname)
814
737
#-----------------------------------------------------------------------------#
816
739
class RHandler(FileTypeHandler):
817
740
"""FileTypeHandler for R"""
819
FileTypeHandler.__init__(self)
820
self.commands = {'r' : 'R',
823
'Rscript' : 'Rscript'}
824
self.default = 'Rscript'
742
typeid = synglob.ID_LANG_R
743
commands = {'r' : 'R', 'Rterm' : 'Rterm',
744
'Rgui' : 'Rgui', 'Rscript' : 'Rscript'}
828
747
#-----------------------------------------------------------------------------#
830
749
class RubyHandler(FileTypeHandler):
831
750
"""FileTypeHandler for Ruby scripts"""
832
RE_RUBY_ERROR = re.compile('(.+):([0-9]+)[:]{0,1}.*')
835
FileTypeHandler.__init__(self)
836
self.commands = dict(ruby='ruby')
837
self.default = 'ruby'
841
def HandleHotSpot(self, mainw, outbuffer, line, fname):
842
"""Hotspots are error messages, find the file/line of the
843
error in question and open the file to that point in the buffer.
846
ifile, line = _FindFileLine(outbuffer, line, fname,
847
RubyHandler.RE_RUBY_ERROR)
848
_OpenToLine(ifile, line, mainw)
850
def StyleText(self, stc, start, txt):
851
"""Style NSIS output messages"""
853
err, more = _StyleError(stc, start, txt, RubyHandler.RE_RUBY_ERROR)
857
sty = super(RubyHandler, self).StyleText(stc, start, txt)[0]
752
typeid = synglob.ID_LANG_RUBY
753
commands = dict(ruby='ruby')
755
error = re.compile('(.+):([0-9]+)[:]{0,1}.*')
756
hotspot = re.compile('(.+):([0-9]+)[:]{0,1}.*')
860
758
#-----------------------------------------------------------------------------#
862
760
class TCLHandler(FileTypeHandler):
863
761
"""FileTypeHandler for TCL/TK"""
864
RE_TCL_ERROR = re.compile('\(file "(.+)" line ([0-9]+)\)')
867
FileTypeHandler.__init__(self)
868
self.commands = dict(wish='wish')
869
self.default = 'wish'
873
def HandleHotSpot(self, mainw, outbuffer, line, fname):
763
typeid = synglob.ID_LANG_TCL
764
commands = dict(wish='wish')
766
error = re.compile('\(file "(.+)" line ([0-9]+)\)')
767
hotspot = re.compile('\(file "(.+)" line ([0-9]+)\)')
770
def HandleHotSpot(cls, mainw, outbuffer, line, fname):
874
771
"""Hotspots are error messages, find the file/line of the
875
772
error in question and open the file to that point in the buffer.
878
775
txt = outbuffer.GetLine(line)
879
match = TCLHandler.RE_TCL_ERROR.findall(txt)
776
match = cls.meta.hotspot.findall(txt)
882
779
ifile = match[0][0]
893
790
_OpenToLine(ifile, line, mainw)
895
def StyleText(self, stc, start, txt):
896
"""Style TCL output messages"""
898
err, more = _StyleError(stc, start, txt, TCLHandler.RE_TCL_ERROR)
902
sty = super(TCLHandler, self).StyleText(stc, start, txt)[0]
905
792
#-----------------------------------------------------------------------------#
907
794
class VBScriptHandler(FileTypeHandler):
908
795
"""FileTypeHandler for VBScript"""
909
RE_VBS_ERROR = re.compile('(.+)\(([0-9]+).*' + os.linesep)
912
FileTypeHandler.__init__(self)
913
self.commands = dict(cscript='CSCRIPT.exe', wscript='WSCRIPT.exe')
914
self.default = 'cscript'
916
__name__ = 'VBScript'
918
def HandleHotSpot(self, mainw, outbuffer, line, fname):
919
"""Hotspots are error messages, find the file/line of the
920
error in question and open the file to that point in the
924
ifile, line = _FindFileLine(outbuffer, line, fname,
925
VBScriptHandler.RE_VBS_ERROR)
926
_OpenToLine(ifile, line, mainw)
928
def StyleText(self, stc, start, txt):
929
"""Style VBScript Information and Error messages from script output."""
931
err, more = _StyleError(stc, start, txt, VBScriptHandler.RE_VBS_ERROR)
935
sty = super(VBScriptHandler, self).StyleText(stc, start, txt)[0]
797
typeid = synglob.ID_LANG_VBSCRIPT
798
commands = dict(cscript='CSCRIPT.exe', wscript='WSCRIPT.exe')
800
error = re.compile('(.+)\(([0-9]+).*' + os.linesep)
801
hotspot = re.compile('(.+)\(([0-9]+).*' + os.linesep)
938
803
#-----------------------------------------------------------------------------#
940
class XmlHandlerDelegate(FileTypeHandler):
941
"""Delegate class for creating new filetype handlers from a Launch
805
def XmlHandlerDelegate(xmlobj):
806
"""Create delegate class for creating new filetype handlers from a Launch
808
@param xmlobj: launchxml.Handler
945
def __init__(self, xmlobj):
946
"""Create the object from the Launch XML Object"""
947
FileTypeHandler.__init__(self)
951
self._errpat = self._xml.GetErrorPattern()
952
self._hotspot = self._xml.GetHotSpotPattern()
954
# FileTypeHandler implementation
955
self.commands = self._xml.GetCommands()
956
self.default = self._xml.GetDefaultCommand()
957
self._name = self._xml.GetLang()
963
def HandleHotSpot(self, mainw, outbuffer, line, fname):
964
"""Handle hotspot navigation if it has been defined by the custom
968
if self._hotspot is not None:
969
ifile, line = _FindFileLine(outbuffer, line, fname, self._hotspot)
970
_OpenToLine(ifile, line, mainw)
974
def StyleText(self, stc, start, txt):
975
"""Highlight text if an error pattern was defined."""
978
if self._errpat is not None:
979
err, more = _StyleError(stc, start, txt, self._errpat)
983
sty = super(XmlHandlerDelegate, self).StyleText(stc, start, txt)[0]
986
#-----------------------------------------------------------------------------#
987
# Handler Object Dictionary
988
# Create an instance of each Handler to use as a persistent object
989
HANDLERS = { 0 : FileTypeHandler(), # Null Handler
990
synglob.ID_LANG_ADA : AdaHandler(),
991
synglob.ID_LANG_BASH : BashHandler(),
992
synglob.ID_LANG_BATCH : BatchHandler(),
993
synglob.ID_LANG_BOO : BooHandler(),
994
synglob.ID_LANG_CAML : CamlHandler(),
995
synglob.ID_LANG_CSH : CSHHandler(),
996
synglob.ID_LANG_D : DHandler(),
997
synglob.ID_LANG_FERITE : FeriteHandler(),
998
synglob.ID_LANG_KSH : KornHandler(),
999
synglob.ID_LANG_HASKELL : HaskellHandler(),
1000
synglob.ID_LANG_HAXE : HaxeHandler(),
1001
synglob.ID_LANG_HTML : HTMLHandler(),
1002
synglob.ID_LANG_INNO : InnoSetupHandler(),
1003
synglob.ID_LANG_LATEX : LatexHandler(),
1004
synglob.ID_LANG_STATA : STATAHandler(),
1005
synglob.ID_LANG_LUA : LuaHandler(),
1006
synglob.ID_LANG_NEWLISP : NewLispHandler(),
1007
synglob.ID_LANG_NSIS : NSISHandler(),
1008
synglob.ID_LANG_PERL : PerlHandler(),
1009
synglob.ID_LANG_PHP : PhpHandler(),
1010
synglob.ID_LANG_PIKE : PikeHandler(),
1011
synglob.ID_LANG_PS : PostScriptHandler(),
1012
synglob.ID_LANG_PYTHON : PythonHandler(),
1013
synglob.ID_LANG_R : RHandler(),
1014
synglob.ID_LANG_RUBY : RubyHandler(),
1015
synglob.ID_LANG_TCL : TCLHandler(),
1016
synglob.ID_LANG_VBSCRIPT : VBScriptHandler() }
811
class XmlDelegateClass(FileTypeHandler):
813
typeid = getattr(synglob, xmlobj.id, -1)
815
commands = xmlobj.GetCommands()
816
default = xmlobj.GetDefaultCommand()
817
error = xmlobj.GetErrorPattern()
818
hotspot = xmlobj.GetHotspotPattern()
820
return XmlDelegateClass
1018
822
#-----------------------------------------------------------------------------#
1019
823
# Local utility functions