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: except:
pass pass
return False return False
def setWindowForApplication(self): def setWindowForApplication(self, start = None, end = None):
if not self.env['commandBuffer']['Marks']['1']: if start == None:
return False if not self.env['commandBuffer']['Marks']['1']:
if not self.env['commandBuffer']['Marks']['2']: return False
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() currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
self.env['commandBuffer']['windowArea'][currApp] = {} self.env['commandBuffer']['windowArea'][currApp] = {}
if self.env['commandBuffer']['Marks']['1']['x'] * self.env['commandBuffer']['Marks']['1']['y'] <= \ if x1 * y1 <= \
self.env['commandBuffer']['Marks']['2']['x'] * self.env['commandBuffer']['Marks']['2']['y']: x2 * y2:
self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x1, 'y':y1}
self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x2, 'y':y2}
else: else:
self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['2'].copy() self.env['commandBuffer']['windowArea'][currApp]['1'] = {'x':x2, 'y':y2}
self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['1'].copy() self.env['commandBuffer']['windowArea'][currApp]['2'] = {'x':x1, 'y':y1}
return True return True
def clearWindowForApplication(self): def clearWindowForApplication(self):
currApp = self.env['runtime']['applicationManager'].getCurrentApplication() currApp = self.env['runtime']['applicationManager'].getCurrentApplication()

View File

@ -34,7 +34,16 @@ import os, os.path
class remoteManager(): class remoteManager():
def __init__(self): 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): def initialize(self, environment):
self.env = environment self.env = environment
@ -112,22 +121,53 @@ class remoteManager():
def handleSettingsChange(self, settingsText): def handleSettingsChange(self, settingsText):
if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableSettingsRemote'): if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableSettingsRemote'):
return return
if settingsText.startswith('set '): upperSettingsText = settingsText.upper()
parameterText = settingsText[len('set '):] # set setting
if upperSettingsText.startswith(self.setSettingConst):
parameterText = settingsText[len(self.setSettingConst):]
self.setSettings(parameterText) self.setSettings(parameterText)
if settingsText.startswith('reset'): # reset setting
if upperSettingsText.startswith(self.resetSettingConst):
self.resetSettings() self.resetSettings()
def handleCommandExecution(self, commandText): def handleCommandExecution(self, commandText):
if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableCommandRemote'): if not self.env['runtime']['settingsManager'].getSettingAsBool('remote', 'enableCommandRemote'):
return return
if commandText.startswith('say '): upperCommandText = commandText.upper()
parameterText = commandText[len('say '):] # say
self.execSay(parameterText) if upperCommandText.startswith(self.sayConst):
if commandText.startswith('interrupt'): parameterText = commandText[len(self.sayConst):]
self.execInterruptSpeech() self.say(parameterText)
def execSay(self, text): # 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) self.env['runtime']['outputManager'].speakText(text)
def execInterruptSpeech(self): def interruptSpeech(self):
self.env['runtime']['outputManager'].interruptOutput() self.env['runtime']['outputManager'].interruptOutput()
def resetSettings(self): def resetSettings(self):
self.env['runtime']['settingsManager'].resetSettingArgDict() self.env['runtime']['settingsManager'].resetSettingArgDict()
@ -136,9 +176,10 @@ class remoteManager():
def handleRemoteIncomming(self, eventData): def handleRemoteIncomming(self, eventData):
if not eventData: if not eventData:
return return
if eventData.startswith('setting '): upperEventData = eventData.upper()
settingsText = eventData[len('setting '):] if upperEventData.startswith(self.settingConst):
settingsText = eventData[len(self.settingConst):]
self.handleSettingsChange(settingsText) self.handleSettingsChange(settingsText)
elif eventData.startswith('command '): elif upperEventData.startswith(self.commandConst):
commandText = eventData[len('command '):] commandText = eventData[len(self.commandConst):]
self.handleCommandExecution(commandText) self.handleCommandExecution(commandText)