From d2fca5279c74099f48366d1ffc7a7fe91653e349 Mon Sep 17 00:00:00 2001 From: moculus Date: Tue, 1 Apr 2008 18:35:09 +0000 Subject: [PATCH] improvements and whatnot --HG-- branch : pmacs2 --- method/__init__.py | 21 +++++++++++++-------- mode/__init__.py | 2 -- mode/python.py | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/method/__init__.py b/method/__init__.py index add9c9e..3e2102f 100644 --- a/method/__init__.py +++ b/method/__init__.py @@ -182,6 +182,19 @@ class OverwriteChar(Method): self.char = c def _execute(self, w, **vargs): w.overwrite_char_at_cursor(self.char) +class InsertText(Method): + '''Insert literal text into the buffer''' + args = [arg('text', t="string", p="Literal: ", h='Literal text to insert')] + def _execute(self, w, **vargs): + w.insert_string_at_cursor(vargs['text']) +class InsertText2(Method): + '''Insert escaped text into the buffer''' + args = [arg('text', t="string", p="Text: ", h='Text to insert')] + def _execute(self, w, **vargs): + text = vargs['text'].replace('\\n', '\n') + text = text.replace('\\t', ' ') + text = text.replace('\\\\', '\\') + w.insert_string_at_cursor(text) # killing/copying/etc. class Kill(Method): @@ -388,14 +401,6 @@ class InsertDquotes(Method): def _execute(self, w, **vargs): w.insert_string_at_cursor('""') w.backward() -class InsertEscapedSquote(Method): - '''Insert an escaped single-quote''' - def _execute(self, w, **vargs): - w.insert_string_at_cursor("\\'") -class InsertEscapedDquote(Method): - '''Insert an escaped double-quote''' - def _execute(self, w, **vargs): - w.insert_string_at_cursor('\\"') class InsertTab(Method): '''Insert tab into buffer, or tabbify line, depending on mode''' diff --git a/mode/__init__.py b/mode/__init__.py index 9fc880f..c6673ae 100644 --- a/mode/__init__.py +++ b/mode/__init__.py @@ -187,8 +187,6 @@ class Fundamental(Handler): self.add_bindings('view-buffer-parent', ('C-c .',)) self.add_bindings('insert-squotes', ('M-\'',)) self.add_bindings('insert-dquotes', ('M-"',)) - self.add_bindings('insert-escaped-squote', ('C-c M-\'',)) - self.add_bindings('insert-escaped-dquote', ('C-c M-"',)) self.add_bindings('get-token', ('C-c t',)) # create all the insert actions for the basic text input diff --git a/mode/python.py b/mode/python.py index 494b3c4..1f35971 100644 --- a/mode/python.py +++ b/mode/python.py @@ -215,6 +215,8 @@ class Python(mode.Fundamental): self.add_action_and_bindings(PythonGotoFunction(), ('C-c M-g',)) self.add_action_and_bindings(PythonCheckSyntax(), ('C-c s',)) self.add_action_and_bindings(PythonDictCleanup(), ('C-c h',)) + self.add_action_and_bindings(PythonInsertTripleSquotes(), ('C-c M-\'',)) + self.add_action_and_bindings(PythonInsertTripleDquotes(), ('C-c M-"',)) # other python self.functions = None def build_function_map(self): @@ -373,4 +375,18 @@ class PythonDictCleanup(method.Method): w.kill(start_p, end_p) w.insert_string(start_p, data) +class PythonInsertTripleSquotes(method.Method): + '''Insert a triple-quoted string using single-quotes''' + def _execute(self, w, **vargs): + w.insert_string_at_cursor("''''''") + for i in range(0, 3): + w.backward() + +class PythonInsertTripleDquotes(method.Method): + '''Insert a triple-quoted string using double-quotes''' + def _execute(self, w, **vargs): + w.insert_string_at_cursor('""""""') + for i in range(0, 3): + w.backward() + install = Python.install