add widow

This commit is contained in:
chrys 2018-09-07 17:09:11 +02:00
parent 59f68e39ff
commit c1e09f0e58
2 changed files with 82 additions and 26 deletions

View File

@ -82,21 +82,36 @@ class cursorManager():
except:
pass
return False
def setWindowForApplication(self):
def setWindowForApplication(self, start = None, end = None):
if start == None:
if not self.env['commandBuffer']['Marks']['1']:
return False
else:
x1 = self.env['commandBuffer']['Marks']['1']['x']
y1 = self.env['commandBuffer']['Marks']['1']['y']
else:
x1 = start['x']
y1 = start['y']
if end == None:
if not self.env['commandBuffer']['Marks']['2']:
return False
else:
x1 = self.env['commandBuffer']['Marks']['2']['x']
y1 = self.env['commandBuffer']['Marks']['2']['y']
else:
x1 = start['x']
y1 = start['y']
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
self.env['commandBuffer']['windowArea'][currApp] = {}
if self.env['commandBuffer']['Marks']['1']['x'] * self.env['commandBuffer']['Marks']['1']['y'] <= \
self.env['commandBuffer']['Marks']['2']['x'] * self.env['commandBuffer']['Marks']['2']['y']:
self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy()
self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy()
if x1 * y1 <= \
x2 * y2:
self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x1, 'y':y1}
self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x2, 'y':y2}
else:
self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['2'].copy()
self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['1'].copy()
self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x2, 'y':y2}
self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x1, 'y':y1}
return True
def clearWindowForApplication(self):
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()

View File

@ -34,7 +34,16 @@ import os, os.path
class remoteManager():
def __init__(self):
pass
# command controll
self.commandConst = 'COMMAND '
self.sayConst = 'SAY '
self.interruptConst = 'INTERRUPT'
self.defineWindowConst = 'WINDOW '
self.resetWindowConst = 'RESETWINDOW'
# setting controll
self.settingConst = 'SETTING '
self.setSettingConst = 'SET '
self.resetSettingConst = 'RESET'
def initialize(self, environment):
self.env = environment
@ -112,22 +121,53 @@ class remoteManager():
def handleSettingsChange(self, settingsText):
if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableSettingsRemote'):
return
if settingsText.startswith('set '):
parameterText = settingsText[len('set '):]
upperSettingsText = settingsText.upper()
# set setting
if upperSettingsText.startswith(self.setSettingConst):
parameterText = settingsText[len(self.setSettingConst):]
self.setSettings(parameterText)
if settingsText.startswith('reset'):
# reset setting
if upperSettingsText.startswith(self.resetSettingConst):
self.resetSettings()
def handleCommandExecution(self, commandText):
if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableCommandRemote'):
return
if commandText.startswith('say '):
parameterText = commandText[len('say '):]
self.execSay(parameterText)
if commandText.startswith('interrupt'):
self.execInterruptSpeech()
def execSay(self, text):
upperCommandText = commandText.upper()
# say
if upperCommandText.startswith(self.sayConst):
parameterText = commandText[len(self.sayConst):]
self.say(parameterText)
# interrupt
if upperCommandText.startswith(self.interruptConst):
self.interruptSpeech()
# define window
if upperCommandText.startswith(self.defineWindowConst):
parameterText = commandText[len(self.defineWindowConst):]
self.defineWindow(parameterText)
# reset window
if upperCommandText.startswith(self.resetWindowConst):
self.resetWindow()
def defineWindow(self, windowText):
start = {}
end = {}
try:
windowList = windowText.split(' ')
if len(windowList) < 4:
return
print(windowList)
start['x'] = int(windowList[0])
start['y'] = int(windowList[1])
end['x'] = int(windowList[2])
end['y'] = int(windowList[3])
self.env['runtime']['cursorManager'].setWindowForApplication(start, end)
except:
pass
def resetWindow(self):
self.env['runtime']['cursorManager'].clearWindowForApplication()
def say(self, text):
self.env['runtime']['outputManager'].speakText(text)
def execInterruptSpeech(self):
def interruptSpeech(self):
self.env['runtime']['outputManager'].interruptOutput()
def resetSettings(self):
self.env['runtime']['settingsManager'].resetSettingArgDict()
@ -136,9 +176,10 @@ class remoteManager():
def handleRemoteIncomming(self, eventData):
if not eventData:
return
if eventData.startswith('setting '):
settingsText = eventData[len('setting '):]
upperEventData = eventData.upper()
if upperEventData.startswith(self.settingConst):
settingsText = eventData[len(self.settingConst):]
self.handleSettingsChange(settingsText)
elif eventData.startswith('command '):
commandText = eventData[len('command '):]
elif upperEventData.startswith(self.commandConst):
commandText = eventData[len(self.commandConst):]
self.handleCommandExecution(commandText)