add review_up and review_donw commands
This commit is contained in:
30
src/fenrir-package/commands/commands/review_down.py
Normal file
30
src/fenrir-package/commands/commands/review_down.py
Normal file
@ -0,0 +1,30 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
from utils import char_utils
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return 'set review cursor to end of current line and display the content'
|
||||
|
||||
def run(self):
|
||||
cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor()
|
||||
self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], downChar = \
|
||||
char_utils.getDownChar(self.env['screenData']['newCursorReview']['x'],self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
|
||||
if downChar.strip(" \t\n") == '':
|
||||
self.env['runtime']['outputManager'].presentText("line is empty" ,interrupt=True)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText(downChar ,interrupt=True, ignorePunctuation=True, announceCapital=True)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
30
src/fenrir-package/commands/commands/review_up.py
Normal file
30
src/fenrir-package/commands/commands/review_up.py
Normal file
@ -0,0 +1,30 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
from utils import char_utils
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return 'set review cursor to end of current line and display the content'
|
||||
|
||||
def run(self):
|
||||
cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor()
|
||||
self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], upChar = \
|
||||
char_utils.getUpChar(self.env['screenData']['newCursorReview']['x'],self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
|
||||
if upChar.strip(" \t\n") == '':
|
||||
self.env['runtime']['outputManager'].presentText("line is empty" ,interrupt=True)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText(upChar ,interrupt=True, ignorePunctuation=True, announceCapital=True)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
@ -28,6 +28,26 @@ def getCurrentChar(currX,currY, currText):
|
||||
currChar = wrappedLines[currY][currX]
|
||||
return currX, currY, currChar
|
||||
|
||||
def getUpChar(currX,currY, currText):
|
||||
if currText == '':
|
||||
return -1, -1, ''
|
||||
wrappedLines = currText.split('\n')
|
||||
currY -= 1
|
||||
if currY < 0:
|
||||
currY = 0
|
||||
currChar = wrappedLines[currY][currX]
|
||||
return currX, currY, currChar
|
||||
|
||||
def getDownChar(currX,currY, currText):
|
||||
if currText == '':
|
||||
return -1, -1, ''
|
||||
wrappedLines = currText.split('\n')
|
||||
currY += 1
|
||||
if currY >= len(wrappedLines):
|
||||
currY = len(wrappedLines) -1
|
||||
currChar = wrappedLines[currY][currX]
|
||||
return currX, currY, currChar
|
||||
|
||||
def getLastCharInLine(currY, currText):
|
||||
if currText == '':
|
||||
return -1, -1, ''
|
||||
|
Reference in New Issue
Block a user