From 9b3ef0fc3ed8dea7cbbf5e6c11274b8b0772c7f7 Mon Sep 17 00:00:00 2001 From: moculus Date: Mon, 16 Mar 2009 18:35:13 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- method/shell.py | 1 - mode/perl.py | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/method/shell.py b/method/shell.py index 4c88bba..8059fc3 100644 --- a/method/shell.py +++ b/method/shell.py @@ -62,7 +62,6 @@ class Man(Exec): def _execute(self, w, **vargs): name = vargs['name'] cmd = 'man %r' % name - #p = Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT) p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) output = p.stdout.read() result = p.wait() diff --git a/mode/perl.py b/mode/perl.py index dbcac7e..4511f6e 100644 --- a/mode/perl.py +++ b/mode/perl.py @@ -7,6 +7,7 @@ from lex import Grammar, PatternRule, ContextPatternRule, RegionRule, \ from method import Argument, Method, WrapParagraph from tab import StackTabber, StackTabber2 from parse import Any, And, Or, Optional, Name, Match, Matchs +import term class PodDataGrammar(Grammar): rules = [PatternRule(r'data', r'[^\n]+\n$')] @@ -226,6 +227,7 @@ class PerldocModule(PerlBase): '''View documentation about this buffer using perldoc''' bname = '*Perldoc*' prog = 'use Pod::Text; Pod::Text->new()->parse_from_filehandle();'; + #prog = 'use Pod::Text::Termcap; Pod::Text::Termcap->new()->parse_from_filehandle();'; def get_args(self, w, **vargs): return ('perl', '-e', self.prog) def _execute(self, w, **vargs): @@ -258,21 +260,25 @@ class Perldoc(Method): w.set_error('nothing found for %r' % name) def _try(self, w, name, asfunc=False): if asfunc: - cmd = "perldoc -t -T -f '%s'" % name + cmd = "perldoc -f '%s'" % name else: - cmd = "perldoc -t -T '%s'" % name - + cmd = "perldoc '%s'" % name l = w.application.config.get('perl.libs', []) if l: cmd = 'PERL5LIB=%r %s' % (':'.join(['%r' % x for x in l]), cmd) - status, data = commands.getstatusoutput(cmd) + p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) + output = p.stdout.read() + result = p.wait() + status = os.WEXITSTATUS(result) if status == 0: - return data + xterm = term.XTerm(cbuf=True) + output = xterm.term_filter(output) + return output else: return None def _show(self, w, data, name): - w.application.data_buffer("*Perldoc*", data, switch_to=True) + w.application.color_data_buffer("*Perldoc*", data, switch_to=True) w.set_error('displaying perldoc for %r' % name) class PerldocWord(Perldoc):