add initial clipboard management for pasting

This commit is contained in:
chrys
2016-08-23 00:51:39 +02:00
parent 0c7a103eab
commit 57f61e80f5
16 changed files with 246 additions and 15 deletions

View File

@ -0,0 +1,18 @@
#!/bin/python
import fcntl
import sys
import termios
class command():
def __init__(self):
pass
def run(self, environment):
environment['commandBuffer']['currClipboard'] = -1
del environment['commandBuffer']['clipboard'][:]
environment['runtime']['outputManager'].presentText(environment, 'clipboard cleared', interrupt=True)
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -0,0 +1,19 @@
#!/bin/python
import fcntl
import sys
import termios
class command():
def __init__(self):
pass
def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
return environment
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True)
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -0,0 +1,20 @@
#!/bin/python
import fcntl
import sys
import termios
class command():
def __init__(self):
pass
def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
return environment
environment['commandBuffer']['currClipboard'] = 0
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True)
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -0,0 +1,20 @@
#!/bin/python
import fcntl
import sys
import termios
class command():
def __init__(self):
pass
def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
return environment
environment['commandBuffer']['currClipboard'] = len(environment['commandBuffer']['clipboard']) -1
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True)
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -0,0 +1,23 @@
#!/bin/python
import fcntl
import sys
import termios
import time
class command():
def __init__(self):
pass
def run(self, environment):
currClipboard = environment['commandBuffer']['currClipboard']
if currClipboard < 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
return environment
with open("/dev/tty" + environment['screenData']['newTTY'], 'w') as fd:
for c in environment['commandBuffer']['clipboard'][currClipboard]:
fcntl.ioctl(fd, termios.TIOCSTI, c)
time.sleep(0.01)
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -0,0 +1,25 @@
#!/bin/python
import fcntl
import sys
import termios
class command():
def __init__(self):
pass
def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
return environment
environment['commandBuffer']['currClipboard'] += 1
if environment['commandBuffer']['currClipboard'] > len(environment['commandBuffer']['clipboard']) -1:
environment['commandBuffer']['currClipboard'] = 0
environment['runtime']['outputManager'].presentText(environment, 'First clipboard ', interrupt=True)
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=False)
else:
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True)
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -0,0 +1,25 @@
#!/bin/python
import fcntl
import sys
import termios
class command():
def __init__(self):
pass
def run(self, environment):
if len(environment['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True)
return environment
environment['commandBuffer']['currClipboard'] -= 1
if environment['commandBuffer']['currClipboard'] < 0:
environment['commandBuffer']['currClipboard'] = len(environment['commandBuffer']['clipboard']) -1
environment['runtime']['outputManager'].presentText(environment, 'Last clipboard ', interrupt=True)
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=False)
else:
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True)
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -1,4 +0,0 @@
#!/bin/python
bindings = {
}

View File

@ -1,12 +1,22 @@
#!/bin/python
import time
# used as shared memory between commands
# use this in your own commands
commandBuffer = {
'clipboard':['chrys\n', 'test', 'ls\n'],
'currClipboard': 0,
'clipboardMark':{'1':None, '2':None}
}
# used by the commandManager
commandInfo = {
'currCommand': '',
'commandCueue':[],
'lastCommandTime': time.time()
}
# used by the commandManager
commands = {
'onInput':{
},

View File

@ -1,8 +1,6 @@
#!/bin/python
from core import settings
from core import soundIcons
from core import bindings
from core import runtime
from core import screenData
from core import generalInformation
@ -14,9 +12,10 @@ environment = {
'runtime': runtime.runtime,
'generalInformation': generalInformation.generalInformation,
'settings': settings.settings,
'bindings': bindings.bindings,
'commands': commands.commands,
'input': input.input,
'commandInfo': commands.commandInfo,
'soundIcons': soundIcons.soundIcons,
'commandBuffer': commands.commandBuffer,
'input': input.input,
'soundIcons': {},
'bindings': {},
}

View File

@ -1,4 +0,0 @@
#!/bin/python
soundIcons = {
}