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)
b = self.data_buffer("*Completions*", data, switch_to=False)
b._completion = s
b._opened = opened
b._previous = previous

View File

@ -490,6 +490,11 @@ class InsertTab(Method):
# if no lvl, insert a literal tab
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)
return
@ -497,7 +502,13 @@ class InsertTab(Method):
ws = w.buffer.count_leading_whitespace(y)
if lvl != ws:
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)
if w.logical_cursor().x < x2:
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
import math, os, string
import color, method
from lex import Lexer
from point import Point
@ -458,7 +462,10 @@ class Fundamental(Handler):
except Exception, e:
if DEBUG:
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))
def region_added(self, p, newlines):

View File

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