add review_line_last_char

This commit is contained in:
chrys
2016-10-02 18:08:21 +02:00
parent 09a4d60e0a
commit 0d2c095b62
5 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,33 @@
#!/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['runtime']['cursorManager'].setReviewCursorPosition(self.env['screenData']['columns']-1 ,cursorPos['y'])
self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], lastChar = \
char_utils.getLastCharInLine(self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if lastChar.strip(" \t\n") == '':
self.env['runtime']['outputManager'].presentText("line is empty" ,interrupt=True)
else:
self.env['runtime']['outputManager'].presentText(lastChar ,interrupt=True, ignorePunctuation=True, announceCapital=True)
self.env['runtime']['outputManager'].presentText("last char in line", interrupt=False)
def setCallback(self, callback):
pass

View File

@ -28,6 +28,16 @@ def getCurrentChar(currX,currY, currText):
currChar = wrappedLines[currY][currX]
return currX, currY, currChar
def getLastCharInLine(currY, currText):
if currText == '':
return -1, -1, ''
wrappedLines = currText.split('\n')
currX = len(wrappedLines[currY].rstrip())-1
if currX < 0:
currX = 0
currChar = wrappedLines[currY][currX]
return currX, currY, currChar
def getNextChar(currX,currY, currText):
if currText == '':
return -1, -1, ''