polish clipboard stuff
This commit is contained in:
@ -5,14 +5,16 @@ class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def run(self, environment):
|
||||
print('run')
|
||||
if (environment['commandBuffer']['Marks']['1'] == None) or \
|
||||
(environment['commandBuffer']['Marks']['2'] == None):
|
||||
environment['runtime']['outputManager'].presentText(environment, "two marks needed", interrupt=True)
|
||||
return environment
|
||||
|
||||
|
||||
marked = mark_utils.getTextBetweenMarks(environment['commandBuffer']['Marks']['1'], environment['commandBuffer']['Marks']['2'], environment['screenData']['newContentText'].split('\n'))
|
||||
|
||||
environment['commandBuffer']['clipboard'] = [marked] + environment['commandBuffer']['clipboard'][:9]
|
||||
environment['commandBuffer']['clipboard'] = 0
|
||||
environment['commandBuffer']['currClipboard'] = 0
|
||||
|
||||
if marked.strip(" \t\n") == '':
|
||||
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True)
|
||||
|
@ -11,7 +11,7 @@ class command():
|
||||
return environment
|
||||
|
||||
marked = mark_utils.getTextBetweenMarks(environment['commandBuffer']['Marks']['1'], environment['commandBuffer']['Marks']['2'], environment['screenData']['newContentText'].split('\n'))
|
||||
|
||||
print(marked)
|
||||
if marked.strip(" \t\n") == '':
|
||||
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True)
|
||||
else:
|
||||
|
@ -6,14 +6,16 @@ class command():
|
||||
def run(self, environment):
|
||||
if environment['screenData']['newCursorReview'] == None:
|
||||
environment['runtime']['outputManager'].presentText(environment, 'no review cursor', interrupt=True)
|
||||
return environment
|
||||
|
||||
if environment['commandBuffer']['Marks']['1'] == None:
|
||||
environment['commandBuffer']['Marks']['1'] = environment['screenData']['newCursorReview']
|
||||
environment['commandBuffer']['Marks']['1'] = environment['screenData']['newCursorReview'].copy()
|
||||
else:
|
||||
environment['commandBuffer']['Marks']['2'] = environment['screenData']['newCursorReview']
|
||||
environment['commandBuffer']['Marks']['2'] = environment['screenData']['newCursorReview'].copy()
|
||||
|
||||
environment['runtime']['outputManager'].presentText(environment, 'set mark', interrupt=True)
|
||||
return environment
|
||||
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
def shutdown(self):
|
||||
|
@ -3,6 +3,7 @@ import importlib.util
|
||||
import glob
|
||||
import os
|
||||
import time
|
||||
from utils import debug
|
||||
|
||||
class commandManager():
|
||||
def __init__(self):
|
||||
@ -27,6 +28,7 @@ class commandManager():
|
||||
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR)
|
||||
continue
|
||||
return environment
|
||||
|
||||
def executeTriggerCommands(self, environment, trigger):
|
||||
for cmd in sorted(environment['commands'][trigger]):
|
||||
try:
|
||||
|
@ -5,7 +5,7 @@ import time
|
||||
# used as shared memory between commands
|
||||
# use this in your own commands
|
||||
commandBuffer = {
|
||||
'clipboard':['chrys\n', 'test', 'ls\n'],
|
||||
'clipboard':[],
|
||||
'currClipboard': 0,
|
||||
'Marks':{'1':None, '2':None}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import evdev
|
||||
from evdev import InputDevice, UInput
|
||||
from select import select
|
||||
import time
|
||||
from utils import debug
|
||||
|
||||
class inputManager():
|
||||
def __init__(self):
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/bin/python
|
||||
from utils import debug
|
||||
|
||||
class outputManager():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
@ -15,12 +15,15 @@ def getTextBetweenMarks(firstMark, secondMark, inText):
|
||||
startY = startMark['y']
|
||||
textPart = ''
|
||||
while startY <= endMark['y']:
|
||||
if startY < endMark['y']:
|
||||
textPart += inText[startY][startX:]
|
||||
if len(textPart) - len(textPart[::-1].strip()) > 0:
|
||||
textPart = textPart[:len(textPart[::-1].strip())] + "\n"
|
||||
if startMark['y'] == endMark['y']:
|
||||
textPart += inText[startY][startX:endMark['x'] + 1]
|
||||
else:
|
||||
textPart += inText[startY][:startX + 1]
|
||||
if startY < endMark['y']:
|
||||
textPart += inText[startY][startX:]
|
||||
if len(textPart) - len(textPart[::-1].strip()) > 0:
|
||||
textPart = textPart[:len(textPart[::-1].strip())] + "\n"
|
||||
else:
|
||||
textPart += inText[startY][:startX + 1]
|
||||
startX = 0
|
||||
startY += 1
|
||||
return textPart
|
||||
|
Reference in New Issue
Block a user