From 4e254d71156a587bddd58f0862d5b25e82236790 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 8 Feb 2019 13:39:42 +0100 Subject: [PATCH] Update vmenuManager.py --- src/fenrirscreenreader/core/vmenuManager.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/fenrirscreenreader/core/vmenuManager.py b/src/fenrirscreenreader/core/vmenuManager.py index 5dcd8b12..b6661398 100755 --- a/src/fenrirscreenreader/core/vmenuManager.py +++ b/src/fenrirscreenreader/core/vmenuManager.py @@ -6,7 +6,7 @@ from fenrirscreenreader.core import debug from fenrirscreenreader.utils import module_utils -import os, inspect +import os, inspect, time currentdir = os.path.dirname(os.path.realpath(os.path.abspath(inspect.getfile(inspect.currentframe())))) fenrirPath = os.path.dirname(currentdir) @@ -17,6 +17,8 @@ class vmenuManager(): self.currIndex = None self.currMenu = '' self.active = False + self.searchText = '' + self.lastSearchTime = time.time() def initialize(self, environment): self.env = environment self.defaultVMenuPath = fenrirPath+ "/commands/vmenu-profiles/" + self.env['runtime']['inputManager'].getShortcutType() @@ -24,6 +26,21 @@ class vmenuManager(): self.closeAfterAction = False def shutdown(self): pass + def searchEntry(self, value): + if self.currIndex == None: + return False + if time.time() - self.lastSearchTime > 1: + self.searchText = '' + self.searchText += value + self.lastSearchTime = time.time() + startIndex = 0 + while True: + entry = self.getCurrentEntry() + if entry.startswith(self.searchText): + return True + if not self.nextIndex(): + return False + if def setCurrMenu(self, currMenu = ''): self.currIndex = None self.currMenu = ''