add get first char in line, fix cycle punctuation
This commit is contained in:
37
src/fenrir/commands/commands/review_line_first_char.py
Normal file
37
src/fenrir/commands/commands/review_line_first_char.py
Normal file
@ -0,0 +1,37 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
from utils import line_utils
|
||||
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()
|
||||
x, y, currLine = \
|
||||
line_utils.getCurrentLine(cursorPos['x'], cursorPos['y'], self.env['screenData']['newContentText'])
|
||||
|
||||
self.env['runtime']['cursorManager'].setReviewCursorPosition((len(currLine) - len(currLine.lstrip()))
|
||||
,cursorPos['y'])
|
||||
self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currChar = \
|
||||
char_utils.getCurrentChar(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
|
||||
if currChar.isspace():
|
||||
self.env['runtime']['outputManager'].presentText("line is empty" ,interrupt=True)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText(currChar ,interrupt=True, ignorePunctuation=True, announceCapital=True)
|
||||
self.env['runtime']['outputManager'].presentText("first char in line indent " + str(len(currLine) - len(currLine.lstrip())), interrupt=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
@ -17,7 +17,10 @@ class command():
|
||||
return ''
|
||||
|
||||
def run(self):
|
||||
self.env['runtime']['punctuationManager'].cyclePunctuation()
|
||||
self.env['runtime']['outputManager'].presentText(self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel'), interrupt=True, ignorePunctuation=True)
|
||||
if self.env['runtime']['punctuationManager'].cyclePunctuation():
|
||||
self.env['runtime']['outputManager'].presentText(self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel'), interrupt=True, ignorePunctuation=True)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText('No punctuation found.', interrupt=True, ignorePunctuation=True)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -102,9 +102,10 @@ class punctuationManager():
|
||||
try:
|
||||
currIndex = punctList.index(self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').lower()) # curr punctuation
|
||||
except:
|
||||
return
|
||||
return False
|
||||
currIndex += 1
|
||||
if currIndex >= len(punctList):
|
||||
currIndex = 0
|
||||
currLevel = punctList[currIndex]
|
||||
self.env['runtime']['settingsManager'].setSetting('general', currLevel.lower())
|
||||
self.env['runtime']['settingsManager'].setSetting('general', 'punctuationLevel', currLevel.lower())
|
||||
return True
|
||||
|
Reference in New Issue
Block a user