add review_up and review_donw commands

This commit is contained in:
chrys
2016-10-02 19:53:58 +02:00
parent 0d2c095b62
commit 1d7ba49e92
6 changed files with 88 additions and 2 deletions

View 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

View 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

View File

@ -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, ''