add initial (buggy :/ ) prev,curr,next word commands

This commit is contained in:
chrys 2016-07-19 01:19:21 +02:00
parent bf5cd96a18
commit 513d4a4ddf
9 changed files with 167 additions and 21 deletions

View File

@ -2,4 +2,7 @@
1-KEY_KP8=curr_line 1-KEY_KP8=curr_line
1-KEY_KP7=prev_line 1-KEY_KP7=prev_line
1-KEY_KP9=next_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 1-KEY_KPDOT=exit_review

View File

@ -7,11 +7,11 @@ class command():
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview']
if environment['screenData']['newCursorReview']['y'] == -1: if environment['screenData']['newCursorReview']['y'] == -1:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
wrappedLines = environment['screenData']['newContentText'].split('\n')
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']].replace(" ","").replace("\n","").replace("\t","") == '': if wrappedLines[environment['screenData']['newCursorReview']['y']].strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank") environment['runtime']['outputManager'].presentText(environment, "blank")
else: 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 return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View 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

View File

@ -9,11 +9,11 @@ class command():
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
if environment['screenData']['newCursorReview']['y'] + 1 < environment['screenData']['lines']: if environment['screenData']['newCursorReview']['y'] + 1 < environment['screenData']['lines']:
environment['screenData']['newCursorReview']['y'] = environment['screenData']['newCursorReview']['y'] + 1 environment['screenData']['newCursorReview']['y'] = environment['screenData']['newCursorReview']['y'] + 1
wrappedLines = environment['screenData']['newContentText'].split('\n')
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']].replace(" ","").replace("\n","").replace("\t","") == '': if wrappedLines[environment['screenData']['newCursorReview']['y']].strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank") environment['runtime']['outputManager'].presentText(environment, "blank")
else: 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 return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View 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

View File

@ -9,10 +9,11 @@ class command():
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy()
if environment['screenData']['newCursorReview']['y'] - 1 >= 0: if environment['screenData']['newCursorReview']['y'] - 1 >= 0:
environment['screenData']['newCursorReview']['y'] = environment['screenData']['newCursorReview']['y'] - 1 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") environment['runtime']['outputManager'].presentText(environment, "blank")
else: 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 return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View 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

View File

@ -7,7 +7,7 @@ class command():
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y'] or\ if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y'] or\
environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
return environment 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 pass
#environment['runtime']['outputManager'].presentText(environment, "blank",True) #environment['runtime']['outputManager'].presentText(environment, "blank",True)
else: else:

View File

@ -12,18 +12,18 @@ class commandManager():
commandFolder = "commands/" + section +"/" commandFolder = "commands/" + section +"/"
commandList = glob.glob(commandFolder+'*') commandList = glob.glob(commandFolder+'*')
for currCommand in commandList: for currCommand in commandList:
try: #try:
fileName, fileExtension = os.path.splitext(currCommand) fileName, fileExtension = os.path.splitext(currCommand)
fileName = fileName.split('/')[-1] fileName = fileName.split('/')[-1]
if fileName in ['__init__','__pycache__']: if fileName in ['__init__','__pycache__']:
continue
if fileExtension.lower() == '.py':
spec = importlib.util.spec_from_file_location(fileName, currCommand)
command_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(command_mod)
environment['commands'][section][fileName] = command_mod.command()
except:
continue continue
if fileExtension.lower() == '.py':
spec = importlib.util.spec_from_file_location(fileName, currCommand)
command_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(command_mod)
environment['commands'][section][fileName] = command_mod.command()
#except:
# continue
return environment return environment
def executeTriggerCommands(self, environment, trigger): def executeTriggerCommands(self, environment, trigger):
for cmd in sorted(environment['commands'][trigger]): for cmd in sorted(environment['commands'][trigger]):