searcher - updated timings

This commit is contained in:
2022-10-04 22:58:27 -05:00
parent 0dece2cec9
commit e929e9b742
7 changed files with 75 additions and 71 deletions

View File

@@ -29,6 +29,7 @@ class FileSearchMixin:
def _handle_find_file_query(self, widget=None, eve=None, query=None):
# NOTE: Freeze IPC consumption
self.pause_fifo_update = True
self.search_query = ""
# NOTE: Kill the former process
if self._list_proc:
@@ -41,15 +42,13 @@ class FileSearchMixin:
else:
self._list_proc = None
# NOTE: Clear children from ui and make sure ui thread redraws
GLib.idle_add(self.clear_children, self._file_list)
while len(self._file_list.get_children()) > 0:
...
# NOTE: Make sure ui thread redraws
time.sleep(0.5)
self.pause_fifo_update = False
time.sleep(0.2)
# NOTE: If query create new process and do all new loop.
self.pause_fifo_update = False
if query:
GLib.idle_add(self._exec_find_file_query, query)
@@ -57,12 +56,16 @@ class FileSearchMixin:
query = widget.get_text()
if not query in ("", None):
self.search_query = query
target_dir = shlex.quote( self._fm_state.tab.get_current_directory() )
command = ["python", f"{self.path}/utils/search.py", "-t", "file_search", "-d", f"{target_dir}", "-q", f"{query}"]
self._list_proc = subprocess.Popen(command, cwd=self.path, stdin=None, stdout=None, stderr=None)
def _load_file_ui(self, data):
if not data in ("", None) and not self.pause_fifo_update:
if self.pause_fifo_update:
return
if not data in ("", None):
jdata = json.loads( data )
target = jdata[0]
file = jdata[1]

View File

@@ -29,6 +29,7 @@ class GrepSearchMixin:
def _handle_grep_query(self, widget=None, eve=None, query=None):
# NOTE: Freeze IPC consumption
self.pause_fifo_update = True
self.grep_query = ""
# NOTE: Kill the former process
if self._grep_proc:
@@ -41,34 +42,35 @@ class GrepSearchMixin:
else:
self._grep_proc = None
# NOTE: Clear children from ui
# NOTE: Clear children from ui and make sure ui thread redraws
GLib.idle_add(self.clear_children, self._grep_list)
while len(self._grep_list.get_children()) > 0:
...
# NOTE: Make sure ui thread redraws
time.sleep(0.5)
self.pause_fifo_update = False
time.sleep(0.2)
# NOTE: If query create new process and do all new loop.
self.pause_fifo_update = False
if query:
GLib.idle_add(self._exec_grep_query, query)
def _exec_grep_query(self, widget=None, eve=None):
query = widget.get_text()
if not query in ("", None):
self.grep_query = query
target_dir = shlex.quote( self._fm_state.tab.get_current_directory() )
command = ["python", f"{self.path}/utils/search.py", "-t", "grep_search", "-d", f"{target_dir}", "-q", f"{query}"]
self._grep_proc = subprocess.Popen(command, cwd=self.path, stdin=None, stdout=None, stderr=None)
def _load_grep_ui(self, data):
if not data in ("", None) and not self.pause_fifo_update:
if self.pause_fifo_update:
return
if not data in ("", None):
jdata = json.loads( data )
jkeys = jdata.keys()
for key in jkeys:
sub_keys = jdata[key].keys()
grep_result = jdata[key]
widget = GrepPreviewWidget(key, sub_keys, grep_result)
GLib.idle_add(self._grep_list.add, widget)
# self._grep_list.add(widget)
widget = GrepPreviewWidget(key, sub_keys, grep_result, self.grep_query)
self._grep_list.add(widget)