From d74ff84fa311fb170d4b75022cad8053c28dfce7 Mon Sep 17 00:00:00 2001 From: moculus Date: Fri, 4 Apr 2008 20:12:31 +0000 Subject: [PATCH] added Application.run_external() and added latex spell checking --HG-- branch : pmacs2 --- application.py | 16 ++++++++++++++-- mode/latex.py | 8 +++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/application.py b/application.py index b9e37d7..d439fe3 100755 --- a/application.py +++ b/application.py @@ -1,6 +1,7 @@ #!/usr/bin/env python import curses, curses.ascii, getpass, os, re, string, sets, sys, termios, time import traceback +from subprocess import Popen, PIPE, STDOUT import buffer, bufferlist, color, completer, keyinput, method, minibuffer, mode import util, window @@ -22,6 +23,7 @@ def run(buffers, jump_to_line=None, init_mode=None): return retval def run_app(stdscr, buffers, jump_to_line=None, init_mode=None): + curses.def_shell_mode() a = Application(stdscr, buffers, jump_to_line, init_mode) a.run() @@ -200,6 +202,7 @@ class Application(object): #curses.halfdelay(5) curses.noecho() curses.nonl() + curses.def_prog_mode() # this sets up a mode, as well as optionally adding information on when to # auto-load the mode @@ -504,14 +507,23 @@ class Application(object): def clear_highlighted_ranges(self): self.highlighted_ranges = [] + def run_external(self, *args): + curses.reset_shell_mode() + pipe = Popen(args) + pipe.wait() + curses.reset_prog_mode() + self.win.redrawwin() + self.draw() + # full screen drawer def draw(self, err=""): try: self.draw_slots() self.draw_input_bar() self.draw_cursor() - self.win.noutrefresh() - curses.doupdate() + #self.win.noutrefresh() + #curses.doupdate() + curses.refresh() except Exception, e: # ok, so there was a problem... # let's see if the screen changed sizes and if so, resize our slots diff --git a/mode/latex.py b/mode/latex.py index e2f5ea9..93f6eb0 100644 --- a/mode/latex.py +++ b/mode/latex.py @@ -1,4 +1,4 @@ -import commands, os +import commands, curses, os import color, method, mode from lex import Grammar, PatternRule, RegionRule from mode.text import TextInsertSpace @@ -38,6 +38,7 @@ class Latex(mode.Fundamental): self.add_action_and_bindings(LatexInsertSpace(), ('SPACE',)) self.add_action_and_bindings(LatexBuildPdf(), ("C-c C-p",)) self.add_action_and_bindings(LatexViewPdf(), ('C-c C-v',)) + self.add_action(LatexCheckSpelling()) class LatexBuild(method.Method): '''Insert a pair of LaTeX-style single-quotes into the buffer''' @@ -109,4 +110,9 @@ class LatexInsertBraces(method.Method): class LatexInsertSpace(TextInsertSpace): pass +class LatexCheckSpelling(method.Method): + """Check the spelling of the document via ispell -t""" + def _execute(self, w, **vargs): + w.application.run_external('ispell', '-t', w.buffer.path) + install = Latex.install