From 520e6e1e529f6c59a98ba797b77ca6225842923e Mon Sep 17 00:00:00 2001 From: moculus Date: Sun, 24 Jun 2007 04:44:09 +0000 Subject: [PATCH] --HG-- branch : pmacs2 --- application.py | 4 ++-- buffer.py | 2 +- mode_diff.py | 36 +++++++++++++++++++++++------------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/application.py b/application.py index ac2abd4..e82d737 100755 --- a/application.py +++ b/application.py @@ -9,7 +9,7 @@ from point2 import Point # modes # TODO: mode_c mode_nasm mode_console mode_sh mode_sql mode_javascript mode_diff mode_tt import mode2 -import mode_mini, mode_search, mode_replace, mode_blame, mode_which +import mode_mini, mode_search, mode_replace, mode_blame, mode_which, mode_diff import mode_python, mode_perl, mode_xml import mode_life, mode_text, mode_mutt @@ -82,7 +82,7 @@ class Application(object): 'blame': mode_blame.Blame, # 'c': mode_c.C, # 'console': mode_console.Console, -# 'diff': mode_diff.Diff, + 'diff': mode_diff.Diff, 'fundamental': mode2.Fundamental, 'mini': mode_mini.Mini, # 'nasm': mode_nasm.Nasm, diff --git a/buffer.py b/buffer.py index b5827e3..a70523a 100644 --- a/buffer.py +++ b/buffer.py @@ -1,5 +1,5 @@ import md5, os, sets, shutil -import aes, point, method, regex +import aes, point, method, regexjgejgew # set this to 0 or less to have infinite undo/redo REDO_STACK_LIMIT = 1024 diff --git a/mode_diff.py b/mode_diff.py index 0b59810..f28c5c5 100644 --- a/mode_diff.py +++ b/mode_diff.py @@ -1,24 +1,34 @@ -import color, method, mode, lex, lex_diff, re +import color, method, mode2, re +from lex2 import Grammar, PatternRule, RegionRule -class Diff(mode.Fundamental): +class MetadataGrammar(Grammar): + rules = [ + PatternRule(name=r'line', pattern=r'^.*$'), + ] + +class DiffGrammar(Grammar): + rules = [ + PatternRule(name=r'left', pattern=r"^\-.*$"), + PatternRule(name=r'right', pattern=r"^\+.*$"), + PatternRule(name=r'metadata', pattern=r'^[A-Za-z].*$'), + PatternRule(name=r'seperator', pattern=r'^={67}$'), + PatternRule(name=r'location', pattern=r"(?:^|(?<=\n))@@ [-+0-9a-z, ]* @@(?:$|\n)"), + PatternRule(name=r'common', pattern=r"(?:^|(?<=\n)).*(?:$|\n)"), + ] + +class Diff(mode2.Fundamental): + grammar = DiffGrammar() def __init__(self, w): - mode.Fundamental.__init__(self, w) - - self.grammar = lex_diff.DiffGrammar() - self.lexer = lex.Lexer(self.grammar) - - self.add_action_and_bindings(DiffNextSection(), ('M-n', 'M-D_ARROW',)) - self.add_action_and_bindings(DiffPreviousSection(), ('M-p', 'M-U_ARROW',)) - + mode2.Fundamental.__init__(self, w) + #self.add_action_and_bindings(DiffNextSection(), ('M-n', 'M-D_ARROW',)) + #self.add_action_and_bindings(DiffPreviousSection(), ('M-p', 'M-U_ARROW',)) self.colors = { 'left': color.build('red', 'default', 'bold'), 'right': color.build('blue', 'default', 'bold'), 'seperator': color.build('magenta', 'default', 'bold'), - 'cvs metadata': color.build('magenta', 'default', 'bold'), - 'svn metadata': color.build('magenta', 'default', 'bold'), + 'metadata': color.build('magenta', 'default', 'bold'), 'location': color.build('magenta', 'default', 'bold'), } - def name(self): return "Diff"