add initial (buggy :/ ) prev,curr,next word commands
This commit is contained in:
parent
bf5cd96a18
commit
513d4a4ddf
@ -2,4 +2,7 @@
|
||||
1-KEY_KP8=curr_line
|
||||
1-KEY_KP7=prev_line
|
||||
1-KEY_KP9=next_line
|
||||
1-KEY_KP5=curr_word
|
||||
1-KEY_KP4=prev_word
|
||||
1-KEY_KP6=next_word
|
||||
1-KEY_KPDOT=exit_review
|
||||
|
@ -7,11 +7,11 @@ class command():
|
||||
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
|
||||
if environment['screenData']['newCursorReview']['y'] == -1:
|
||||
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
|
||||
|
||||
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']].replace(" ","").replace("\n","").replace("\t","") == '':
|
||||
wrappedLines = environment['screenData']['newContentText'].split('\n')
|
||||
if wrappedLines[environment['screenData']['newCursorReview']['y']].strip(" \t\n") == '':
|
||||
environment['runtime']['outputManager'].presentText(environment, "blank")
|
||||
else:
|
||||
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']])
|
||||
environment['runtime']['outputManager'].presentText(environment, wrappedLines[environment['screenData']['newCursorReview']['y']])
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
45
src/fenrir-package/commands/commands/curr_word.py
Normal file
45
src/fenrir-package/commands/commands/curr_word.py
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/python
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def run(self, environment):
|
||||
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
|
||||
if environment['screenData']['newCursorReview']['y'] == -1:
|
||||
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
|
||||
wrappedLines = environment['screenData']['newContentText'].split('\n')
|
||||
currWord = ''
|
||||
currY = environment['screenData']['newCursorReview']['y']
|
||||
currX = environment['screenData']['newCursorReview']['x']
|
||||
wordFound = False
|
||||
while not wordFound:
|
||||
currLine = wrappedLines[currY].replace("\t"," ")
|
||||
currX = currLine[:currX + 1].rfind(" ") + 1
|
||||
if currX == -1:
|
||||
currX = 0
|
||||
wordEnd = currLine[currX + 1:].find(" ") + currX + 1
|
||||
if wordEnd == -1:
|
||||
wordEnd = len(currLine) -1
|
||||
currWord = currLine[currX:wordEnd]
|
||||
wordFound = currWord.strip(" \t\n") != ''
|
||||
if not wordFound:
|
||||
if currX == 0:
|
||||
if currY != 0:
|
||||
currY -= 1
|
||||
else:
|
||||
break
|
||||
currX = len(wrappedLines[currY]) - 1
|
||||
else:
|
||||
currX -= 1
|
||||
environment['screenData']['newCursorReview']['y'] = currY
|
||||
environment['screenData']['newCursorReview']['x'] = currX
|
||||
|
||||
if not wordFound:
|
||||
environment['runtime']['outputManager'].presentText(environment, "blank")
|
||||
else:
|
||||
environment['runtime']['outputManager'].presentText(environment, currWord)
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
def shutdown(self):
|
||||
pass
|
@ -9,11 +9,11 @@ class command():
|
||||
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
|
||||
if environment['screenData']['newCursorReview']['y'] + 1 < environment['screenData']['lines']:
|
||||
environment['screenData']['newCursorReview']['y'] = environment['screenData']['newCursorReview']['y'] + 1
|
||||
|
||||
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']].replace(" ","").replace("\n","").replace("\t","") == '':
|
||||
wrappedLines = environment['screenData']['newContentText'].split('\n')
|
||||
if wrappedLines[environment['screenData']['newCursorReview']['y']].strip(" \t\n") == '':
|
||||
environment['runtime']['outputManager'].presentText(environment, "blank")
|
||||
else:
|
||||
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']])
|
||||
environment['runtime']['outputManager'].presentText(environment, wrappedLines[environment['screenData']['newCursorReview']['y']])
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
53
src/fenrir-package/commands/commands/next_word.py
Normal file
53
src/fenrir-package/commands/commands/next_word.py
Normal file
@ -0,0 +1,53 @@
|
||||
#!/bin/python
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def run(self, environment):
|
||||
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
|
||||
if environment['screenData']['newCursorReview']['y'] == -1:
|
||||
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
|
||||
wrappedLines = environment['screenData']['newContentText'].split('\n')
|
||||
currWord = ''
|
||||
currY = environment['screenData']['newCursorReview']['y']
|
||||
currX = environment['screenData']['newCursorReview']['x']
|
||||
wordFound = False
|
||||
currLine = wrappedLines[currY].replace("\t"," ")
|
||||
while not wordFound:
|
||||
print(currX)
|
||||
currX = currLine[currX:].find(" ") + currX
|
||||
print(currX)
|
||||
if currX == - 1:
|
||||
if currY < environment['screenData']['lines']:
|
||||
currY += 1
|
||||
currLine = wrappedLines[currY].replace("\t"," ")
|
||||
print('erhöhung')
|
||||
else:
|
||||
break
|
||||
currX = 0
|
||||
print('hmm')
|
||||
print(currX)
|
||||
wordEnd = currLine[currX + 1:].find(" ")
|
||||
print(currX)
|
||||
if wordEnd == -1:
|
||||
wordEnd = len(currLine)
|
||||
else:
|
||||
wordEnd += currX + 2
|
||||
print(currX)
|
||||
currWord = currLine[currX:wordEnd]
|
||||
print(currX)
|
||||
print(currWord)
|
||||
wordFound = currWord.strip(" \t\n") != ''
|
||||
print(wordFound)
|
||||
environment['screenData']['newCursorReview']['y'] = currY
|
||||
environment['screenData']['newCursorReview']['x'] = currX
|
||||
|
||||
if not wordFound:
|
||||
environment['runtime']['outputManager'].presentText(environment, "blank")
|
||||
else:
|
||||
environment['runtime']['outputManager'].presentText(environment, currWord)
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
def shutdown(self):
|
||||
pass
|
@ -9,10 +9,11 @@ class command():
|
||||
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
|
||||
if environment['screenData']['newCursorReview']['y'] - 1 >= 0:
|
||||
environment['screenData']['newCursorReview']['y'] = environment['screenData']['newCursorReview']['y'] - 1
|
||||
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']].replace(" ","").replace("\n","").replace("\t","") == '':
|
||||
wrappedLines = environment['screenData']['newContentText'].split('\n')
|
||||
if wrappedLines[environment['screenData']['newCursorReview']['y']].strip(" \t\n") == '':
|
||||
environment['runtime']['outputManager'].presentText(environment, "blank")
|
||||
else:
|
||||
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']])
|
||||
environment['runtime']['outputManager'].presentText(environment, wrappedLines[environment['screenData']['newCursorReview']['y']])
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
44
src/fenrir-package/commands/commands/prev_word.py
Normal file
44
src/fenrir-package/commands/commands/prev_word.py
Normal file
@ -0,0 +1,44 @@
|
||||
#!/bin/python
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def run(self, environment):
|
||||
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
|
||||
if environment['screenData']['newCursorReview']['y'] == -1:
|
||||
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
|
||||
wrappedLines = environment['screenData']['newContentText'].split('\n')
|
||||
currWord = ''
|
||||
currY = environment['screenData']['newCursorReview']['y']
|
||||
currX = environment['screenData']['newCursorReview']['x']
|
||||
wordFound = False
|
||||
while not wordFound:
|
||||
if currX == 0:
|
||||
if currY != 0:
|
||||
currY -= 1
|
||||
else:
|
||||
break
|
||||
currX = len(wrappedLines[currY]) - 1
|
||||
else:
|
||||
currX -= 1
|
||||
currLine = wrappedLines[currY].replace("\t"," ")
|
||||
currX = currLine[:currX].rfind(" ") + 1
|
||||
if currX == -1:
|
||||
currX = 0
|
||||
wordEnd = currLine[currX:].find(" ") + currX
|
||||
if wordEnd == -1:
|
||||
wordEnd = len(currLine) -1
|
||||
currWord = currLine[currX:wordEnd]
|
||||
wordFound = currWord.strip(" \t\n") != ''
|
||||
environment['screenData']['newCursorReview']['y'] = currY
|
||||
environment['screenData']['newCursorReview']['x'] = currX
|
||||
|
||||
if not wordFound:
|
||||
environment['runtime']['outputManager'].presentText(environment, "blank")
|
||||
else:
|
||||
environment['runtime']['outputManager'].presentText(environment, currWord)
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
def shutdown(self):
|
||||
pass
|
@ -7,7 +7,7 @@ class command():
|
||||
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y'] or\
|
||||
environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
|
||||
return environment
|
||||
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']].strip(" \n\t") == '':
|
||||
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']].strip(" \t\n") == '':
|
||||
pass
|
||||
#environment['runtime']['outputManager'].presentText(environment, "blank",True)
|
||||
else:
|
||||
|
@ -12,7 +12,7 @@ class commandManager():
|
||||
commandFolder = "commands/" + section +"/"
|
||||
commandList = glob.glob(commandFolder+'*')
|
||||
for currCommand in commandList:
|
||||
try:
|
||||
#try:
|
||||
fileName, fileExtension = os.path.splitext(currCommand)
|
||||
fileName = fileName.split('/')[-1]
|
||||
if fileName in ['__init__','__pycache__']:
|
||||
@ -22,8 +22,8 @@ class commandManager():
|
||||
command_mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(command_mod)
|
||||
environment['commands'][section][fileName] = command_mod.command()
|
||||
except:
|
||||
continue
|
||||
#except:
|
||||
# continue
|
||||
return environment
|
||||
def executeTriggerCommands(self, environment, trigger):
|
||||
for cmd in sorted(environment['commands'][trigger]):
|
||||
|
Loading…
Reference in New Issue
Block a user