link result view and source view
This commit is contained in:
21
filterviewsyncer.py
Normal file
21
filterviewsyncer.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from bigtext import BigText
|
||||
|
||||
|
||||
class FilterViewSyncer:
|
||||
|
||||
def __init__(self, sync_view: BigText):
|
||||
self._matches = {}
|
||||
self._sync_view = sync_view
|
||||
|
||||
def click_listener(self, byte_offset: int):
|
||||
source_byte_offset = self._matches[byte_offset] if byte_offset in self._matches else None
|
||||
# print("click %d -> %d (total hits %d)" % (byte_offset, source_byte_offset, len(self._matches)))
|
||||
if source_byte_offset is not None:
|
||||
self._sync_view.scroll_to_byte(source_byte_offset)
|
||||
|
||||
def match_found(self, match_byte_offset: int, source_byte_offset: int):
|
||||
# print("match %d" % match_byte_offset)
|
||||
if match_byte_offset >= 0:
|
||||
self._matches[match_byte_offset] = source_byte_offset
|
||||
else:
|
||||
self._matches = {}
|
||||
Reference in New Issue
Block a user