parent
55c55aeca9
commit
6f8a79a451
|
@ -11,7 +11,7 @@ import mode2
|
||||||
import mode.mini, mode.search, mode.replace, mode.which
|
import mode.mini, mode.search, mode.replace, mode.which
|
||||||
import mode.console, mode.consolemini
|
import mode.console, mode.consolemini
|
||||||
import mode.c, mode.python, mode.perl, mode.nasm, mode.sh, mode.sql, mode.java
|
import mode.c, mode.python, mode.perl, mode.nasm, mode.sh, mode.sql, mode.java
|
||||||
import mode.elisp, mode.scheme
|
import mode.lisp, mode.elisp, mode.scheme
|
||||||
import mode.blame, mode.diff, mode.dir
|
import mode.blame, mode.diff, mode.dir
|
||||||
import mode.xml, mode.tt, mode.css, mode.javascript, mode.html
|
import mode.xml, mode.tt, mode.css, mode.javascript, mode.html
|
||||||
import mode.text, mode.mutt
|
import mode.text, mode.mutt
|
||||||
|
@ -108,8 +108,11 @@ class Application(object):
|
||||||
'bds': mode.bds.BDS,
|
'bds': mode.bds.BDS,
|
||||||
'rst': mode.rst.RST,
|
'rst': mode.rst.RST,
|
||||||
'java': mode.java.Java,
|
'java': mode.java.Java,
|
||||||
'elisp': mode.elisp.ELisp,
|
|
||||||
|
# lisp dialects
|
||||||
|
'lisp': mode.lisp.Lisp,
|
||||||
'scheme': mode.scheme.Scheme,
|
'scheme': mode.scheme.Scheme,
|
||||||
|
'elisp': mode.elisp.ELisp,
|
||||||
}
|
}
|
||||||
|
|
||||||
# these are used in this order to determine which mode to open certain
|
# these are used in this order to determine which mode to open certain
|
||||||
|
|
17
method.py
17
method.py
|
@ -399,11 +399,11 @@ class PopKill(Method):
|
||||||
class DeleteLeft(Method):
|
class DeleteLeft(Method):
|
||||||
'''Delete the character to the left of the cursor'''
|
'''Delete the character to the left of the cursor'''
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
cursor = w.logical_cursor()
|
(x, y) = w.logical_cursor().xy()
|
||||||
line = w.buffer.lines[cursor.y]
|
line = w.buffer.lines[y]
|
||||||
if cursor.x >= 4 and line[0:cursor.x].isspace():
|
tabwidth = w.mode.tabwidth
|
||||||
w.kill(Point(cursor.x-4, cursor.y),
|
if x >= tabwidth and x % tabwidth == 0 and line[0:x].isspace():
|
||||||
Point(cursor.x, cursor.y))
|
w.kill(Point(x - tabwidth, y), Point(x, y))
|
||||||
else:
|
else:
|
||||||
w.left_delete()
|
w.left_delete()
|
||||||
class DeleteRight(Method):
|
class DeleteRight(Method):
|
||||||
|
@ -558,8 +558,8 @@ class InsertTab(Method):
|
||||||
i = None
|
i = None
|
||||||
|
|
||||||
if i is None:
|
if i is None:
|
||||||
#raise Exception, repr(w.mode.tabber.lines)
|
#w.insert_string_at_cursor(' ')
|
||||||
w.insert_string_at_cursor(' ')
|
w.insert_string_at_cursor(' ' * w.mode.tabwidth)
|
||||||
else:
|
else:
|
||||||
j = w.buffer.count_leading_whitespace(cursor.y)
|
j = w.buffer.count_leading_whitespace(cursor.y)
|
||||||
if i != j:
|
if i != j:
|
||||||
|
@ -842,8 +842,9 @@ class IndentBlock(Method):
|
||||||
w.input_line = "Empty kill region"
|
w.input_line = "Empty kill region"
|
||||||
return
|
return
|
||||||
lines = w.buffer.lines[p1.y:p2.y]
|
lines = w.buffer.lines[p1.y:p2.y]
|
||||||
|
tstr = ' ' * w.mode.tabwidth
|
||||||
for i in range(0, len(lines)):
|
for i in range(0, len(lines)):
|
||||||
lines[i] = ' ' + lines[i]
|
lines[i] = tstr + lines[i]
|
||||||
w.buffer.delete(Point(0, p1.y), Point(0, p2.y))
|
w.buffer.delete(Point(0, p1.y), Point(0, p2.y))
|
||||||
w.buffer.insert_string(Point(0, p1.y), '\n'.join(lines) + '\n')
|
w.buffer.insert_string(Point(0, p1.y), '\n'.join(lines) + '\n')
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,13 @@ import commands, os.path, sets, string, sys, traceback
|
||||||
import color, completer, default, mode2, method, regex, tab2
|
import color, completer, default, mode2, method, regex, tab2
|
||||||
from point2 import Point
|
from point2 import Point
|
||||||
from lex3 import Grammar, PatternRule, RegionRule, OverridePatternRule
|
from lex3 import Grammar, PatternRule, RegionRule, OverridePatternRule
|
||||||
|
import mode.lisp
|
||||||
class StringGrammar(Grammar):
|
|
||||||
rules = [
|
|
||||||
PatternRule(r'octal', r'\\[0-7]{3}'),
|
|
||||||
PatternRule(r'escaped', r'\\.'),
|
|
||||||
]
|
|
||||||
|
|
||||||
class SchemeGrammar(Grammar):
|
class SchemeGrammar(Grammar):
|
||||||
rules = [
|
rules = [
|
||||||
PatternRule(r'comment', r';.*$'),
|
PatternRule(r'comment', r';.*$'),
|
||||||
PatternRule(r'delimiter', r'[()]'),
|
PatternRule(r'delimiter', r'[()]'),
|
||||||
RegionRule(r'string', r'"', StringGrammar, r'"'),
|
RegionRule(r'string', r'"', mode.lisp.StringGrammar, r'"'),
|
||||||
PatternRule(r'spaces', r' +'),
|
PatternRule(r'spaces', r' +'),
|
||||||
PatternRule(r'eol', r'\n'),
|
PatternRule(r'eol', r'\n'),
|
||||||
PatternRule(r'abbrev', r"'|`|,\@|,"),
|
PatternRule(r'abbrev', r"'|`|,\@|,"),
|
||||||
|
@ -35,15 +30,8 @@ class SchemeGrammar(Grammar):
|
||||||
PatternRule(r'variable', r'[a-zA-Z!$%&*/:<=>?\^_~][a-zA-Z0-9!$%&*/:<=>?^_~+-.@]*|\+|-|...'),
|
PatternRule(r'variable', r'[a-zA-Z!$%&*/:<=>?\^_~][a-zA-Z0-9!$%&*/:<=>?^_~+-.@]*|\+|-|...'),
|
||||||
]
|
]
|
||||||
|
|
||||||
class SchemeTabber(tab2.StackTabber):
|
|
||||||
def _handle_open_token(self, currlvl, y, i):
|
|
||||||
level = self.get_curr_level() + 4
|
|
||||||
token = self.get_token(y, i)
|
|
||||||
self._append(token.string, level)
|
|
||||||
return currlvl
|
|
||||||
|
|
||||||
class Scheme(mode2.Fundamental):
|
class Scheme(mode2.Fundamental):
|
||||||
tabbercls = SchemeTabber
|
tabbercls = mode.lisp.LispTabber
|
||||||
grammar = SchemeGrammar
|
grammar = SchemeGrammar
|
||||||
opentokens = ('delimiter',)
|
opentokens = ('delimiter',)
|
||||||
opentags = {'(': ')'}
|
opentags = {'(': ')'}
|
||||||
|
|
1
mode2.py
1
mode2.py
|
@ -72,6 +72,7 @@ class Handler(object):
|
||||||
|
|
||||||
class Fundamental(Handler):
|
class Fundamental(Handler):
|
||||||
'''This is the default mode'''
|
'''This is the default mode'''
|
||||||
|
tabwidth = 4
|
||||||
tabbercls = None
|
tabbercls = None
|
||||||
grammar = None
|
grammar = None
|
||||||
lexer = None
|
lexer = None
|
||||||
|
|
|
@ -11,6 +11,8 @@ WORD_LETTERS = list(string.letters + string.digits)
|
||||||
# error. both buffer and window need to be aware of this possibility for points.
|
# error. both buffer and window need to be aware of this possibility for points.
|
||||||
|
|
||||||
class Window(object):
|
class Window(object):
|
||||||
|
margins = ((80, 'blue'),)
|
||||||
|
margins_visible = False
|
||||||
def __init__(self, b, a, height=24, width=80, mode_name=None):
|
def __init__(self, b, a, height=24, width=80, mode_name=None):
|
||||||
self.buffer = b
|
self.buffer = b
|
||||||
self.application = a
|
self.application = a
|
||||||
|
@ -25,8 +27,6 @@ class Window(object):
|
||||||
self.width = width
|
self.width = width
|
||||||
|
|
||||||
self.input_line = ""
|
self.input_line = ""
|
||||||
self.margins = [(80, 'blue')]
|
|
||||||
self.margins_visible = False
|
|
||||||
|
|
||||||
if mode_name is not None:
|
if mode_name is not None:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue