diff --git a/src/fenrir-package/commands/onInput/10000-shut_up.py b/src/fenrir-package/commands/onInput/10000-shut_up.py index 11e786ef..c6d5ba18 100644 --- a/src/fenrir-package/commands/onInput/10000-shut_up.py +++ b/src/fenrir-package/commands/onInput/10000-shut_up.py @@ -17,11 +17,13 @@ class command(): return '' def run(self): + if self.env['runtime']['inputManager'].noKeyPressed(): + return if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'interruptOnKeyPress'): return if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: return - + print(self.environment['input']['currInput']) self.env['runtime']['outputManager'].interruptOutput() def setCallback(self, callback): diff --git a/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py b/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py index b83246af..0f395316 100644 --- a/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py +++ b/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py @@ -17,7 +17,7 @@ class command(): return '' def run(self): - if self.env['runtime']['inputManager'].noKeyPressed(): + if not self.env['runtime']['inputManager'].noKeyPressed(): return if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: return diff --git a/src/fenrir-package/commands/onInput/50000-char_echo.py b/src/fenrir-package/commands/onScreenUpdate/50000-char_echo.py similarity index 90% rename from src/fenrir-package/commands/onInput/50000-char_echo.py rename to src/fenrir-package/commands/onScreenUpdate/50000-char_echo.py index 0c20e4ca..9ed4232f 100644 --- a/src/fenrir-package/commands/onInput/50000-char_echo.py +++ b/src/fenrir-package/commands/onScreenUpdate/50000-char_echo.py @@ -17,8 +17,6 @@ class command(): return 'No Description found' def run(self): - if self.env['runtime']['inputManager'].noKeyPressed(): - return if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'): return # detect deletion or chilling diff --git a/src/fenrir-package/commands/onInput/60000-word_echo.py b/src/fenrir-package/commands/onScreenUpdate/60000-word_echo.py similarity index 93% rename from src/fenrir-package/commands/onInput/60000-word_echo.py rename to src/fenrir-package/commands/onScreenUpdate/60000-word_echo.py index 3526352a..46e17c9e 100644 --- a/src/fenrir-package/commands/onInput/60000-word_echo.py +++ b/src/fenrir-package/commands/onScreenUpdate/60000-word_echo.py @@ -18,8 +18,6 @@ class command(): return 'No Description found' def run(self): - if self.env['runtime']['inputManager'].noKeyPressed(): - return if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'): return diff --git a/src/fenrir-package/commands/onInput/62000-spell_check.py b/src/fenrir-package/commands/onScreenUpdate/62000-spell_check.py similarity index 95% rename from src/fenrir-package/commands/onInput/62000-spell_check.py rename to src/fenrir-package/commands/onScreenUpdate/62000-spell_check.py index 40d561a2..d8fd5840 100644 --- a/src/fenrir-package/commands/onInput/62000-spell_check.py +++ b/src/fenrir-package/commands/onScreenUpdate/62000-spell_check.py @@ -30,8 +30,6 @@ class command(): self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') def run(self): - if self.env['runtime']['inputManager'].noKeyPressed(): - return if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'): return @@ -71,7 +69,7 @@ class command(): if currWord != '': if not self.spellChecker.check(currWord): - self.env['runtime']['outputManager'].presentText('misspelled',soundIcon='mispell', interrupt=True) + self.env['runtime']['outputManager'].presentText('misspelled',soundIcon='mispell', interrupt=False) def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/onInput/65000-char_delete_echo.py b/src/fenrir-package/commands/onScreenUpdate/65000-char_delete_echo.py similarity index 91% rename from src/fenrir-package/commands/onInput/65000-char_delete_echo.py rename to src/fenrir-package/commands/onScreenUpdate/65000-char_delete_echo.py index 72250f48..8fada66f 100644 --- a/src/fenrir-package/commands/onInput/65000-char_delete_echo.py +++ b/src/fenrir-package/commands/onScreenUpdate/65000-char_delete_echo.py @@ -17,8 +17,6 @@ class command(): return 'No Description found' def run(self): - if self.env['runtime']['inputManager'].noKeyPressed(): - return if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'): return diff --git a/src/fenrir-package/core/screenManager.py b/src/fenrir-package/core/screenManager.py index b75f10ed..c96fa4e0 100644 --- a/src/fenrir-package/core/screenManager.py +++ b/src/fenrir-package/core/screenManager.py @@ -21,26 +21,29 @@ class screenManager(): def shutdown(self): self.env['runtime']['settingsManager'].shutdownDriver('screenDriver') - def update(self): + def update(self, trigger = 'onUpdate'): + self.env['screenData']['newTTY'] = self.env['runtime']['screenDriver'].getCurrScreen() + if trigger == 'onUpdate': + self.env['runtime']['applicationManager'].getCurrentApplication() if not self.isSuspendingScreen(): - self.env['runtime']['screenDriver'].update() + self.env['runtime']['screenDriver'].update(trigger) self.env['screenData']['lastScreenUpdate'] = time.time() def isSuspendingScreen(self): - currScreen = self.env['runtime']['screenDriver'].getCurrScreen() - return ((currScreen in \ + return ((self.env['screenData']['newTTY'] in \ self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or - (currScreen in self.autoIgnoreScreens)) + (self.env['screenData']['newTTY'] in self.autoIgnoreScreens)) + def isScreenChange(self): return self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY'] + def getWindowAreaInText(self, text): if not self.env['runtime']['cursorManager'].isApplicationWindowSet(): return text - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() windowText = '' windowList = text.split('\n') - windowList = windowList[self.env['commandBuffer']['windowArea'][currApp]['1']['y']:self.env['commandBuffer']['windowArea'][currApp]['2']['y'] + 1] + windowList = windowList[self.env['commandBuffer']['windowArea'][self.env['screenData']['newApplication']]['1']['y']:self.env['commandBuffer']['windowArea'][currApp]['2']['y'] + 1] for line in windowList: - windowText += line[self.env['commandBuffer']['windowArea'][currApp]['1']['x']:self.env['commandBuffer']['windowArea'][currApp]['2']['x'] + 1] + '\n' + windowText += line[self.env['commandBuffer']['windowArea'][self.env['screenData']['newApplication']]['1']['x']:self.env['commandBuffer']['windowArea'][currApp]['2']['x'] + 1] + '\n' return windowText diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index 42c08ca2..76aed7dc 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -51,11 +51,11 @@ class fenrir(): if self.environment['input']['keyForeward'] > 0: self.environment['input']['keyForeward'] -=1 else: - self.environment['runtime']['screenManager'].update() - self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') + self.environment['runtime']['screenManager'].update('onInput') + self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') else: - self.environment['runtime']['screenManager'].update() + self.environment['runtime']['screenManager'].update('onUpdate') if self.environment['runtime']['applicationManager'].isApplicationChange(): self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange') self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \ diff --git a/src/fenrir-package/screenDriver/linux.py b/src/fenrir-package/screenDriver/linux.py index e8ac84cf..7daef844 100644 --- a/src/fenrir-package/screenDriver/linux.py +++ b/src/fenrir-package/screenDriver/linux.py @@ -19,7 +19,7 @@ class driver(): return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) def getCurrScreen(self): - currScreen = -1 + currScreen = '' try: currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r') currScreen = currScreenFile.read()[3:-1] @@ -28,10 +28,10 @@ class driver(): self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) return currScreen - def getCurrApplication(self, screen): + def getCurrApplication(self): apps = [] try: - currScreen = str(screen) + currScreen = str(self.env['screenData']['newTTY']) apps = subprocess.Popen('ps -t tty' + currScreen + ' -o comm,tty,stat', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n') except Exception as e: print(e) @@ -49,7 +49,10 @@ class driver(): not "SH" == i[0] and \ not "PS" == i[0]: if "TTY"+currScreen in i[1]: - return i[0] + if self.env['runtime']['applicationManager'].isApplicationChange(): + self.env['screenData']['oldApplication'] = self.env['screenData']['newApplication'] + self.env['screenData']['newApplication'] = i[0] + return except: return '' return '' @@ -74,7 +77,6 @@ class driver(): newContentBytes = b'' try: # read screen - newTTY = self.getCurrScreen() vcsa = open(self.vcsaDevicePath + newTTY,'rb',0) newContentBytes = vcsa.read() vcsa.close() @@ -91,20 +93,17 @@ class driver(): self.env['screenData']['oldCursor']['x'] = self.env['screenData']['newCursor']['x'] self.env['screenData']['oldCursor']['y'] = self.env['screenData']['newCursor']['y'] if self.env['screenData']['oldTTY'] == '-1': - self.env['screenData']['oldTTY'] = newTTY # dont recognice starting fenrir as change + self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] else: self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta'] self.env['screenData']['oldNegativeDelta'] = self.env['screenData']['newNegativeDelta'] - self.env['screenData']['oldApplication'] = self.env['screenData']['newApplication'] - self.env['screenData']['newTTY'] = newTTY self.env['screenData']['newContentBytes'] = newContentBytes # get metadata like cursor or screensize self.env['screenData']['lines'] = int( self.env['screenData']['newContentBytes'][0]) self.env['screenData']['columns'] = int( self.env['screenData']['newContentBytes'][1]) self.env['screenData']['newCursor']['x'] = int( self.env['screenData']['newContentBytes'][2]) self.env['screenData']['newCursor']['y'] = int( self.env['screenData']['newContentBytes'][3]) - self.env['screenData']['newApplication'] = self.getCurrApplication(newTTY) # analyze content self.env['screenData']['newContentText'] = self.env['screenData']['newContentBytes'][4:][::2].decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') self.env['screenData']['newContentAttrib'] = self.env['screenData']['newContentBytes'][5:][::2]