From 0d749e9238722dedfbc1e9882a22feea69999cd2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 9 Sep 2013 05:19:55 +0200 Subject: derp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/editor.py | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/editor.py b/src/editor.py index 5fd896a..83a964c 100644 --- a/src/editor.py +++ b/src/editor.py @@ -22,6 +22,27 @@ import sys from subprocess import Popen, PIPE +def limit(min_value, value, max_value): + ''' + Limit a value to a closed set + + @param min_value Minimum value + @param value Preferred value + @param max_value Maximum value + ''' + return min(max(min_value, value), max_value) + + +def ctrl(key): + ''' + Return the symbol for a specific letter pressed in combination with Ctrl + + @param key Without Ctrl + @return With Ctrl + ''' + return chr(ord(key) - ord('@')) + + class TextArea(): ''' GNU Emacs alike text area @@ -47,28 +68,6 @@ class TextArea(): self.last_alert, self.last_status, self.alerted = None, None, False - @staticmethod - def limit(min_value, value, max_value): - ''' - Limit a value to a closed set - - @param min_value Minimum value - @param value Preferred value - @param max_value Maximum value - ''' - return min(max(min_value, value), max_value) - - - @staticmethod - def ctrl(key): - ''' - Return the symbol for a specific letter pressed in combination with Ctrl - - @param key Without Ctrl - @return With Ctrl - ''' - return chr(ord(key) - ord('@')) - def get_selection(self, for_display = False): a = min(self.mark, self.x) @@ -427,7 +426,7 @@ class TextArea(): if d == '[': d = sys.stdin.read(1) if d == 'A': - stored = ctrl('P'): + stored = ctrl('P') elif d == 'B': if self.y == len(self.lines) - 1: self.alert('At last line') -- cgit v1.2.3-70-g09d2