From 0080e1aeb87a480239563d988a43b2aebc3d4e5d Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 28 Aug 2016 19:19:55 +0200 Subject: [PATCH] add new command cursor_position --- config/keyboard/desktop.conf | 1 + config/keyboard/laptop.conf | 1 + config/keyboard/test.conf | 1 + .../commands/curr_screen_after_cursor.py | 2 +- .../commands/curr_screen_before_cursor.py | 2 +- .../commands/commands/cursor_position.py | 20 +++++++++++++++++++ .../commands/commands/remove_marks.py | 2 +- src/fenrir-package/core/commandManager.py | 1 + 8 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/fenrir-package/commands/commands/cursor_position.py diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 0d5424f1..398ccc26 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -9,6 +9,7 @@ 1-KEY_KP2=curr_char 1-KEY_KP1=prev_char 1-KEY_KP3=next_char +#=cursor_position 1-KEY_KPDOT=exit_review #=curr_screen #=curr_screen_before_cursor diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 1d9d36d4..5857ddf7 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -10,6 +10,7 @@ 1-KEY_m=prev_char 1-KEY_DOT=next_char 1-KEY_SLASH=exit_review +#=cursor_position #=curr_screen #=curr_screen_before_cursor #=curr_screen_after_cursor diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index 04388322..a4801d48 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -10,6 +10,7 @@ 1-FENRIR,1-KEY_KP1=prev_char 1-FENRIR,1-KEY_KP3=next_char 1-FENRIR,1-KEY_KPDOT=exit_review +1-FENRIR,1-KEY_J=cursor_position #=curr_screen #=curr_screen_before_cursor #=curr_screen_after_cursor diff --git a/src/fenrir-package/commands/commands/curr_screen_after_cursor.py b/src/fenrir-package/commands/commands/curr_screen_after_cursor.py index 9dc3f779..957ee298 100644 --- a/src/fenrir-package/commands/commands/curr_screen_after_cursor.py +++ b/src/fenrir-package/commands/commands/curr_screen_after_cursor.py @@ -7,7 +7,7 @@ class command(): pass def run(self, environment): # Prefer review cursor over text cursor - if (environment['screenData']['newCursorReview'] != None) + if (environment['screenData']['newCursorReview'] != None): cursorPos = environment['screenData']['newCursorReview'].copy() else: cursorPos = environment['screenData']['newCursor'].copy() diff --git a/src/fenrir-package/commands/commands/curr_screen_before_cursor.py b/src/fenrir-package/commands/commands/curr_screen_before_cursor.py index 2d7d62e3..dab8db4b 100644 --- a/src/fenrir-package/commands/commands/curr_screen_before_cursor.py +++ b/src/fenrir-package/commands/commands/curr_screen_before_cursor.py @@ -7,7 +7,7 @@ class command(): pass def run(self, environment): # Prefer review cursor over text cursor - if (environment['screenData']['newCursorReview'] != None) + if (environment['screenData']['newCursorReview'] != None): cursorPos = environment['screenData']['newCursorReview'].copy() else: cursorPos = environment['screenData']['newCursor'].copy() diff --git a/src/fenrir-package/commands/commands/cursor_position.py b/src/fenrir-package/commands/commands/cursor_position.py new file mode 100644 index 00000000..f26cb70d --- /dev/null +++ b/src/fenrir-package/commands/commands/cursor_position.py @@ -0,0 +1,20 @@ +#!/bin/python + + +class command(): + def __init__(self): + pass + def run(self, environment): + # Prefer review cursor over text cursor + + if (environment['screenData']['newCursorReview'] != None): + cursorPos = environment['screenData']['newCursorReview'].copy() + else: + cursorPos = environment['screenData']['newCursor'].copy() + + environment['runtime']['outputManager'].presentText(environment, "line "+ str(cursorPos['y']+1) + " column "+ str(cursorPos['x']+1), interrupt=True) + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass diff --git a/src/fenrir-package/commands/commands/remove_marks.py b/src/fenrir-package/commands/commands/remove_marks.py index 516aca33..cd35b41a 100644 --- a/src/fenrir-package/commands/commands/remove_marks.py +++ b/src/fenrir-package/commands/commands/remove_marks.py @@ -12,4 +12,4 @@ class command(): def setCallback(self, callback): pass def shutdown(self): -pass + pass diff --git a/src/fenrir-package/core/commandManager.py b/src/fenrir-package/core/commandManager.py index c5e27e7d..f71c3222 100644 --- a/src/fenrir-package/core/commandManager.py +++ b/src/fenrir-package/core/commandManager.py @@ -24,6 +24,7 @@ class commandManager(): spec.loader.exec_module(command_mod) environment['commands'][section][fileName] = command_mod.command() except Exception as e: + print(e) environment['runtime']['debug'].writeDebugOut(environment,"Error while loading command:" + currCommand ,debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) continue