added Application.run_external() and added latex spell checking
--HG-- branch : pmacs2
This commit is contained in:
parent
3cb04bfb18
commit
d74ff84fa3
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import curses, curses.ascii, getpass, os, re, string, sets, sys, termios, time
|
import curses, curses.ascii, getpass, os, re, string, sets, sys, termios, time
|
||||||
import traceback
|
import traceback
|
||||||
|
from subprocess import Popen, PIPE, STDOUT
|
||||||
|
|
||||||
import buffer, bufferlist, color, completer, keyinput, method, minibuffer, mode
|
import buffer, bufferlist, color, completer, keyinput, method, minibuffer, mode
|
||||||
import util, window
|
import util, window
|
||||||
|
@ -22,6 +23,7 @@ def run(buffers, jump_to_line=None, init_mode=None):
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
def run_app(stdscr, buffers, jump_to_line=None, init_mode=None):
|
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 = Application(stdscr, buffers, jump_to_line, init_mode)
|
||||||
a.run()
|
a.run()
|
||||||
|
|
||||||
|
@ -200,6 +202,7 @@ class Application(object):
|
||||||
#curses.halfdelay(5)
|
#curses.halfdelay(5)
|
||||||
curses.noecho()
|
curses.noecho()
|
||||||
curses.nonl()
|
curses.nonl()
|
||||||
|
curses.def_prog_mode()
|
||||||
|
|
||||||
# this sets up a mode, as well as optionally adding information on when to
|
# this sets up a mode, as well as optionally adding information on when to
|
||||||
# auto-load the mode
|
# auto-load the mode
|
||||||
|
@ -504,14 +507,23 @@ class Application(object):
|
||||||
def clear_highlighted_ranges(self):
|
def clear_highlighted_ranges(self):
|
||||||
self.highlighted_ranges = []
|
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
|
# full screen drawer
|
||||||
def draw(self, err=""):
|
def draw(self, err=""):
|
||||||
try:
|
try:
|
||||||
self.draw_slots()
|
self.draw_slots()
|
||||||
self.draw_input_bar()
|
self.draw_input_bar()
|
||||||
self.draw_cursor()
|
self.draw_cursor()
|
||||||
self.win.noutrefresh()
|
#self.win.noutrefresh()
|
||||||
curses.doupdate()
|
#curses.doupdate()
|
||||||
|
curses.refresh()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
# ok, so there was a problem...
|
# ok, so there was a problem...
|
||||||
# let's see if the screen changed sizes and if so, resize our slots
|
# let's see if the screen changed sizes and if so, resize our slots
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import commands, os
|
import commands, curses, os
|
||||||
import color, method, mode
|
import color, method, mode
|
||||||
from lex import Grammar, PatternRule, RegionRule
|
from lex import Grammar, PatternRule, RegionRule
|
||||||
from mode.text import TextInsertSpace
|
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(LatexInsertSpace(), ('SPACE',))
|
||||||
self.add_action_and_bindings(LatexBuildPdf(), ("C-c C-p",))
|
self.add_action_and_bindings(LatexBuildPdf(), ("C-c C-p",))
|
||||||
self.add_action_and_bindings(LatexViewPdf(), ('C-c C-v',))
|
self.add_action_and_bindings(LatexViewPdf(), ('C-c C-v',))
|
||||||
|
self.add_action(LatexCheckSpelling())
|
||||||
|
|
||||||
class LatexBuild(method.Method):
|
class LatexBuild(method.Method):
|
||||||
'''Insert a pair of LaTeX-style single-quotes into the buffer'''
|
'''Insert a pair of LaTeX-style single-quotes into the buffer'''
|
||||||
|
@ -109,4 +110,9 @@ class LatexInsertBraces(method.Method):
|
||||||
class LatexInsertSpace(TextInsertSpace):
|
class LatexInsertSpace(TextInsertSpace):
|
||||||
pass
|
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
|
install = Latex.install
|
||||||
|
|
Loading…
Reference in New Issue