slightly improve tab support (as well as adding an *Exception* buffer for app exception)

--HG--
branch : pmacs2
This commit is contained in:
Erik Osheim 2010-04-19 22:58:27 -04:00
parent 479e64d1e0
commit 20c095b6c6
4 changed files with 31 additions and 11 deletions

View File

@ -319,6 +319,7 @@ class Application(object):
data = '\n'.join(lines) data = '\n'.join(lines)
b = self.data_buffer("*Completions*", data, switch_to=False) b = self.data_buffer("*Completions*", data, switch_to=False)
b._completion = s b._completion = s
b._opened = opened b._opened = opened
b._previous = previous b._previous = previous

View File

@ -490,6 +490,11 @@ class InsertTab(Method):
# if no lvl, insert a literal tab # if no lvl, insert a literal tab
if lvl is None: if lvl is None:
#w.insert_string_at_cursor(' ' * w.mode.tabwidth)
if w.buffer.usetabs:
# see HACK in buffer
w.insert_string_at_cursor('\t \t')
else:
w.insert_string_at_cursor(' ' * w.mode.tabwidth) w.insert_string_at_cursor(' ' * w.mode.tabwidth)
return return
@ -497,7 +502,13 @@ class InsertTab(Method):
ws = w.buffer.count_leading_whitespace(y) ws = w.buffer.count_leading_whitespace(y)
if lvl != ws: if lvl != ws:
w.delete(Point(0, y), Point(ws, y)) w.delete(Point(0, y), Point(ws, y))
w.insert_string(Point(0, y), ' ' * lvl) if w.buffer.usetabs:
nt = lvl // w.mode.tabwidth
ns = lvl % w.mode.tabwidth
s = ('\t \t' * nt) + (' ' * ns)
else:
s = ' ' * lvl
w.insert_string(Point(0, y), s)
x2 = max(x, lvl) x2 = max(x, lvl)
if w.logical_cursor().x < x2: if w.logical_cursor().x < x2:
w.goto(Point(x2, y)) w.goto(Point(x2, y))

View File

@ -1,5 +1,9 @@
import math
import os
import string
import sys
import traceback
from util import defaultdict from util import defaultdict
import math, os, string
import color, method import color, method
from lex import Lexer from lex import Lexer
from point import Point from point import Point
@ -458,7 +462,10 @@ class Fundamental(Handler):
except Exception, e: except Exception, e:
if DEBUG: if DEBUG:
raise raise
else: exc_type, exc_value, exc_traceback = sys.exc_info()
data = ''.join(traceback.format_tb(exc_traceback))
self.window.application.data_buffer("*Exception*", data,
switch_to=False)
self.window.set_error(str(e)) self.window.set_error(str(e))
def region_added(self, p, newlines): def region_added(self, p, newlines):

View File

@ -20,6 +20,7 @@ class ErrorGrammar(Grammar):
chr1 = '[a-zA-Z_]' chr1 = '[a-zA-Z_]'
chr2 = '[a-zA-Z0-9_]' chr2 = '[a-zA-Z0-9_]'
word = chr1 + chr2 + '*' word = chr1 + chr2 + '*'
spaces = r'[\t ]+'
class MacroGrammar(Grammar): class MacroGrammar(Grammar):
rules = [ rules = [
@ -36,7 +37,7 @@ class MacroGrammar(Grammar):
class CGrammar(Grammar): class CGrammar(Grammar):
rules = [ rules = [
PatternRule('spaces', r' +'), PatternRule('spaces', spaces),
PatternMatchRule('x', r'(\()( *)(' + word + r')(\**)( *)(\))( *)(?=[a-zA-Z0-9_\(])', PatternMatchRule('x', r'(\()( *)(' + word + r')(\**)( *)(\))( *)(?=[a-zA-Z0-9_\(])',
'delimiter', 'spaces', 'c.type', 'c.operator', 'delimiter', 'spaces', 'c.type', 'c.operator',