parent
02b2aafb77
commit
6c6dbfdf15
|
@ -101,7 +101,7 @@ class Highlighter:
|
||||||
# tokens ahead of where it needs to be
|
# tokens ahead of where it needs to be
|
||||||
#data = self.mode.window.buffer.make_string()
|
#data = self.mode.window.buffer.make_string()
|
||||||
#self.mode.lexer.lex(data, start_offset)
|
#self.mode.lexer.lex(data, start_offset)
|
||||||
if len(self.tokens) > i:
|
if self.tokens:
|
||||||
buf_index = max(self.tokens[i].start - 100, 0)
|
buf_index = max(self.tokens[i].start - 100, 0)
|
||||||
else:
|
else:
|
||||||
buf_index = 0
|
buf_index = 0
|
||||||
|
|
126
method.py
126
method.py
|
@ -933,6 +933,66 @@ class SvnBlame(Method):
|
||||||
else:
|
else:
|
||||||
w.application.set_error("There was an error (%s)" % (status))
|
w.application.set_error("There was an error (%s)" % (status))
|
||||||
|
|
||||||
|
class CvsStatus(Method):
|
||||||
|
regex1 = re.compile('^File: (.+?) +?\tStatus: (.*?)$')
|
||||||
|
regex2 = re.compile('^ Working revision:\t([0-9\.]+)$')
|
||||||
|
regex3 = re.compile('^ Repository revision:\t([0-9\.]+)\t(.*)$')
|
||||||
|
regex4 = re.compile('^ Sticky Tag:\t\t\((.*)\)$')
|
||||||
|
regex5 = re.compile('^ Sticky Date:\t\t\((.*)\)$')
|
||||||
|
regex6 = re.compile('^ Sticky Options:\t\((.*)\)$')
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.application.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
cwd = os.getcwd() + os.path.sep
|
||||||
|
path = w.buffer.path
|
||||||
|
if path.startswith(cwd):
|
||||||
|
path = path[len(cwd):]
|
||||||
|
|
||||||
|
cmd = "cvs status %r" % path
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
|
if status != 0:
|
||||||
|
w.application.set_error("Problems with CVS status: %d" % status)
|
||||||
|
return
|
||||||
|
|
||||||
|
lines = data.split('\n')
|
||||||
|
|
||||||
|
if lines[0].startswith('cvs status: nothing known about '):
|
||||||
|
w.application.set_error('File is not under CVS control')
|
||||||
|
return
|
||||||
|
|
||||||
|
m = self.regex1.match(lines[1])
|
||||||
|
assert m, "regex1 %r" % lines[1]
|
||||||
|
ffile = m.group(1)
|
||||||
|
fstatus = m.group(2)
|
||||||
|
|
||||||
|
m = self.regex2.match(lines[3])
|
||||||
|
assert m, "regex2 %r" % lines[3]
|
||||||
|
wrev = m.group(1)
|
||||||
|
|
||||||
|
m = self.regex3.match(lines[4])
|
||||||
|
assert m, "regex3 %r" % lines[4]
|
||||||
|
rrev = m.group(1)
|
||||||
|
rpath = m.group(2)
|
||||||
|
|
||||||
|
m = self.regex4.match(lines[5])
|
||||||
|
assert m, "regex4 %r" % lines[5]
|
||||||
|
stag = m.group(1)
|
||||||
|
|
||||||
|
m = self.regex5.match(lines[6])
|
||||||
|
assert m, "regex5 %r" % lines[6]
|
||||||
|
sdate = m.group(1)
|
||||||
|
|
||||||
|
m = self.regex6.match(lines[7])
|
||||||
|
assert m, "regex6 %r" % lines[7]
|
||||||
|
soptions = m.group(1)
|
||||||
|
|
||||||
|
w.application.set_error('%s %s %s/%s [%s|%s|%s]' % \
|
||||||
|
(ffile, fstatus, wrev, rrev, stag, sdate, soptions))
|
||||||
|
|
||||||
class CvsDiff(Method):
|
class CvsDiff(Method):
|
||||||
'''diff the current file with the version in CVS'''
|
'''diff the current file with the version in CVS'''
|
||||||
def _execute(self, w, **vargs):
|
def _execute(self, w, **vargs):
|
||||||
|
@ -949,6 +1009,72 @@ class CvsDiff(Method):
|
||||||
(status, data) = commands.getstatusoutput(cmd)
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
status = status >> 8
|
status = status >> 8
|
||||||
|
|
||||||
|
if status == 0:
|
||||||
|
w.application.set_error("No difference found")
|
||||||
|
else:
|
||||||
|
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
||||||
|
w.application.set_error("Differences were found")
|
||||||
|
class CvsDiff2(Method):
|
||||||
|
'''diff the current file with the version in CVS'''
|
||||||
|
rev_regex = re.compile('^[0-9]+\.[0-9]+$')
|
||||||
|
def _args(self):
|
||||||
|
return [Argument("revision", type=type(""), prompt="Old Revision: ")]
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.application.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
rev = vargs['revision']
|
||||||
|
if not self.rev_regex.match(rev):
|
||||||
|
w.application.set_error("Could not parse revision: %r" % rev)
|
||||||
|
return
|
||||||
|
|
||||||
|
cwd = os.getcwd() + os.path.sep
|
||||||
|
path = w.buffer.path
|
||||||
|
if path.startswith(cwd):
|
||||||
|
path = path[len(cwd):]
|
||||||
|
|
||||||
|
cmd = "cvs diff -r %s -u %r" % (rev, path)
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
|
if status == 0:
|
||||||
|
w.application.set_error("No difference found")
|
||||||
|
else:
|
||||||
|
w.application.data_buffer("*Diff*", data, switch_to=True, modename='diff')
|
||||||
|
w.application.set_error("Differences were found")
|
||||||
|
class CvsDiff3(Method):
|
||||||
|
'''diff the current file with the version in CVS'''
|
||||||
|
rev_regex = re.compile('^[0-9]+\.[0-9]+$')
|
||||||
|
def _args(self):
|
||||||
|
return [Argument("revision1", type=type(""), prompt="Old Revision: "),
|
||||||
|
Argument("revision2", type=type(""), prompt="New Revision: ")]
|
||||||
|
def _execute(self, w, **vargs):
|
||||||
|
if not hasattr(w.buffer, 'path'):
|
||||||
|
w.application.set_error("Buffer has no corresponding file")
|
||||||
|
return
|
||||||
|
|
||||||
|
rev1 = vargs['revision1']
|
||||||
|
if not self.rev_regex.match(rev1):
|
||||||
|
w.application.set_error("Could not parse revision1: %r" % rev)
|
||||||
|
return
|
||||||
|
|
||||||
|
rev2 = vargs['revision2']
|
||||||
|
if not self.rev_regex.match(rev2):
|
||||||
|
w.application.set_error("Could not parse revision2: %r" % rev)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cwd = os.getcwd() + os.path.sep
|
||||||
|
path = w.buffer.path
|
||||||
|
if path.startswith(cwd):
|
||||||
|
path = path[len(cwd):]
|
||||||
|
|
||||||
|
cmd = "cvs diff -r %s -r %s -u %r" % (rev1, rev2, path)
|
||||||
|
(status, data) = commands.getstatusoutput(cmd)
|
||||||
|
status = status >> 8
|
||||||
|
|
||||||
if status == 0:
|
if status == 0:
|
||||||
w.application.set_error("No difference found")
|
w.application.set_error("No difference found")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -16,6 +16,7 @@ class Search(mode.Fundamental):
|
||||||
(EndSearch(), ('RETURN', 'C-n', 'C-p', 'C-a', 'C-e', 'C-f', 'C-b')),
|
(EndSearch(), ('RETURN', 'C-n', 'C-p', 'C-a', 'C-e', 'C-f', 'C-b')),
|
||||||
(CancelSearch(), ('C-]',)),
|
(CancelSearch(), ('C-]',)),
|
||||||
(DeleteLeft(), ('DELETE', 'BACKSPACE',)),
|
(DeleteLeft(), ('DELETE', 'BACKSPACE',)),
|
||||||
|
(DeleteLeftWord(), ('M-DELETE', 'M-BACKSPACE',)),
|
||||||
)
|
)
|
||||||
|
|
||||||
# add the search actions
|
# add the search actions
|
||||||
|
@ -81,6 +82,17 @@ class DeleteLeft(method.Method):
|
||||||
else:
|
else:
|
||||||
_find_previous(old_window, window, move=False)
|
_find_previous(old_window, window, move=False)
|
||||||
|
|
||||||
|
class DeleteLeftWord(method.Method):
|
||||||
|
def execute(self, window, **vargs):
|
||||||
|
window.kill_left_word()
|
||||||
|
old_cursor = window.buffer.method.old_cursor
|
||||||
|
old_window = window.buffer.method.old_window
|
||||||
|
old_window.goto(old_cursor)
|
||||||
|
if window.buffer.method.direction == 'next':
|
||||||
|
_find_next(old_window, window, move=False)
|
||||||
|
else:
|
||||||
|
_find_previous(old_window, window, move=False)
|
||||||
|
|
||||||
class InsertSearchString(method.Method):
|
class InsertSearchString(method.Method):
|
||||||
def __init__(self, s):
|
def __init__(self, s):
|
||||||
self.name = 'insert-search-string-%s' % (s)
|
self.name = 'insert-search-string-%s' % (s)
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import sets, sys
|
import sets, sys
|
||||||
import color, commands, default, lex, lex_xml, method, mode, point, regex, tab_xml
|
import color, commands, default, lex, lex_tt, method, mode, point, regex, tab_xml
|
||||||
|
|
||||||
class Template(mode.Fundamental):
|
class Template(mode.Fundamental):
|
||||||
def __init__(self, w):
|
def __init__(self, w):
|
||||||
mode.Fundamental.__init__(self, w)
|
mode.Fundamental.__init__(self, w)
|
||||||
|
|
||||||
self.grammar = lex_xml.XMLGrammar()
|
#self.grammar = lex_xml.XMLGrammar()
|
||||||
|
self.grammar = lex_tt.TTGrammar()
|
||||||
self.lexer = lex.Lexer(self.grammar)
|
self.lexer = lex.Lexer(self.grammar)
|
||||||
|
|
||||||
self.add_bindings('close-paren', (')',))
|
self.add_bindings('close-paren', (')',))
|
||||||
|
@ -14,6 +15,7 @@ class Template(mode.Fundamental):
|
||||||
|
|
||||||
self.default_color = color.build('default', 'default')
|
self.default_color = color.build('default', 'default')
|
||||||
self.colors = {
|
self.colors = {
|
||||||
|
'template': color.build('magenta', 'default'),
|
||||||
'markup': color.build('red', 'default'),
|
'markup': color.build('red', 'default'),
|
||||||
'namespace': color.build('magenta', 'default'),
|
'namespace': color.build('magenta', 'default'),
|
||||||
'opentag': color.build('blue', 'default'),
|
'opentag': color.build('blue', 'default'),
|
||||||
|
@ -28,4 +30,4 @@ class Template(mode.Fundamental):
|
||||||
self.tabber = tab_xml.XMLTabber(self)
|
self.tabber = tab_xml.XMLTabber(self)
|
||||||
|
|
||||||
def name(self):
|
def name(self):
|
||||||
return "XML"
|
return "Template"
|
||||||
|
|
Loading…
Reference in New Issue