add initial set/read/clear bookmark commands
This commit is contained in:
52
src/fenrir-package/commands/commands/bookmark_1.py
Normal file
52
src/fenrir-package/commands/commands/bookmark_1.py
Normal file
@ -0,0 +1,52 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
from utils import mark_utils
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
self.ID = '1'
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return 'read Bookmark ' + self.ID
|
||||
|
||||
def run(self):
|
||||
currApp = ''
|
||||
try:
|
||||
currApp = str(self.env['screenData']['newApplication'][0])
|
||||
except:
|
||||
currApp = 'DEFAULT'
|
||||
if not self.env['commandBuffer']['bookMarks'][self.ID]:
|
||||
self.env['runtime']['outputManager'].presentText("Bookmark " + self.ID + "not found.", interrupt=True)
|
||||
return
|
||||
if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]:
|
||||
self.env['runtime']['outputManager'].presentText("Bookmark for application " + currApp + "not found.", interrupt=True)
|
||||
return
|
||||
if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']:
|
||||
self.env['runtime']['outputManager'].presentText("No valid bookmark position", interrupt=True)
|
||||
return
|
||||
|
||||
# set marks
|
||||
marked = ''
|
||||
startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy()
|
||||
if self.env['commandBuffer']['bookMarks'][self.ID][currApp]]['2']:
|
||||
endMark = self.env['commandBuffer']['Marks']['2'].copy()
|
||||
marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screenData']['newContentText'])
|
||||
else:
|
||||
x, y, marked = \
|
||||
line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screenData']['newContentText'])
|
||||
|
||||
if marked.strip(" \t\n") == '':
|
||||
self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText(marked, interrupt=True)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
30
src/fenrir-package/commands/commands/clear_bookmark_1.py
Normal file
30
src/fenrir-package/commands/commands/clear_bookmark_1.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
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
self.ID = '1'
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return 'remove Bookmark ' + self.ID
|
||||
|
||||
def run(self):
|
||||
currApp = ''
|
||||
try:
|
||||
currApp = str(self.env['screenData']['newApplication'][0])
|
||||
except:
|
||||
currApp = 'DEFAULT'
|
||||
del self.env['commandBuffer']['bookMarks'][self.ID][currApp]
|
||||
|
||||
self.env['runtime']['outputManager'].presentText('Bookmark ' + self.ID + " removed for application " + currApp, interrupt=True)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
39
src/fenrir-package/commands/commands/set_bookmark_1.py
Normal file
39
src/fenrir-package/commands/commands/set_bookmark_1.py
Normal file
@ -0,0 +1,39 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
self.ID = '1'
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
self.env['commandBuffer']['bookMarks'][self.ID] = {}
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getDescription(self):
|
||||
return 'set Bookmark ' + self.ID
|
||||
|
||||
def run(self):
|
||||
if not self.env['commandBuffer']['Marks']['1']:
|
||||
self.env['runtime']['outputManager'].presentText("No Mark found", interrupt=True)
|
||||
return
|
||||
currApp = ''
|
||||
try:
|
||||
currApp = str(self.env['screenData']['newApplication'][0])
|
||||
except Exception as e:
|
||||
print(e)
|
||||
currApp = 'DEFAULT'
|
||||
self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {}
|
||||
|
||||
self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy()
|
||||
if self.env['commandBuffer']['Marks']['2']:
|
||||
self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy()
|
||||
self.env['runtime']['outputManager'].presentText('Bookmark ' + self.ID + " set for application " + currApp, interrupt=True)
|
||||
self.env['commandBuffer']['Marks']['1'] = None
|
||||
self.env['commandBuffer']['Marks']['2'] = None
|
||||
def setCallback(self, callback):
|
||||
pass
|
@ -69,9 +69,9 @@ class commandManager():
|
||||
if len(unLoadScript) == 0:
|
||||
oldScript = 'DEFAULT'
|
||||
else:
|
||||
oldScript = unLoadScript[0].upper()
|
||||
oldScript = unLoadScript[0]
|
||||
elif unLoadScript:
|
||||
oldScript = str(unLoadScript).upper()
|
||||
oldScript = str(unLoadScript)
|
||||
if oldScript == '':
|
||||
oldScript == 'DEFAULT'
|
||||
if self.commandExists(oldScript, trigger):
|
||||
@ -87,9 +87,9 @@ class commandManager():
|
||||
if len(loadScript) == 0:
|
||||
newScript = 'DEFAULT'
|
||||
else:
|
||||
newScript = loadScript[0].upper()
|
||||
newScript = loadScript[0]
|
||||
elif unLoadScript:
|
||||
newScript = str(loadScript).upper()
|
||||
newScript = str(loadScript)
|
||||
if newScript == '':
|
||||
newScript == 'DEFAULT'
|
||||
if self.commandExists(newScript, trigger):
|
||||
|
@ -16,14 +16,15 @@ commandBuffer = {
|
||||
'genericListSelection': 0,
|
||||
'clipboard':[],
|
||||
'currClipboard': 0,
|
||||
'Marks':{'1':None, '2':None}
|
||||
'Marks':{'1':None, '2':None},
|
||||
'bookMarks':{},
|
||||
}
|
||||
|
||||
# used by the commandManager
|
||||
commandInfo = {
|
||||
'currCommand': '',
|
||||
'lastCommandExecutionTime': time.time(),
|
||||
'lastCommandRequestTime': time.time()
|
||||
'lastCommandRequestTime': time.time(),
|
||||
}
|
||||
|
||||
# used by the commandManager
|
||||
|
@ -46,7 +46,7 @@ class driver():
|
||||
not "sh" == i[0] and \
|
||||
not "ps" == i[0]:
|
||||
if "tty"+currScreen in i[1]:
|
||||
appList.append(i[0])
|
||||
appList.append(i[0].upper())
|
||||
return appList
|
||||
|
||||
def getIgnoreScreens(self):
|
||||
|
Reference in New Issue
Block a user