5 from typing
import Any, Tuple
7 from AthenaConfiguration.iconfTool.gui.modals
import (
12 from AthenaConfiguration.iconfTool.gui.pad
import Pad
13 from AthenaConfiguration.iconfTool.models.loaders
import (
14 ComponentsDiffFileLoader,
17 from AthenaConfiguration.iconfTool.models.structure
import ComponentsStructure
19 logger = logging.getLogger(__name__)
23 def __init__(self, data_loader: ComponentsFileLoader) ->
None:
24 self.data_loader: ComponentsFileLoader = data_loader
25 self.
data_structure: ComponentsStructure = self.data_loader.get_data()
30 self.actual_offset: int = 0
49 def search(self, strict: bool =
False) ->
None:
52 b_startx: int = self.
width - search_size - 2
53 b_width: int = search_size
55 cursor_pos: Tuple[int, int] = curses.getsyx()
56 search: SearchModal = SearchModal(
57 b_startx, b_starty, b_width, b_height
59 text: str = search.edit()
60 curses.setsyx(cursor_pos[0], cursor_pos[1])
69 b_width: int = search_size
71 b_starty: int = self.
screen.getmaxyx()[0] - b_height
72 b_startx: int = self.
width - search_size - 2
73 cursor_pos: Tuple[int, int] = curses.getsyx()
74 search: SingleHelpModal = SingleHelpModal(
75 b_startx, b_starty, b_width, b_height
77 curses.setsyx(*cursor_pos)
79 self.
pad.initialize_cursor()
84 event: int = self.
screen.getch()
85 logger.debug(f
"Key pressed: [{event}, {chr(event)}]")
88 elif event == ord(
"m"):
90 elif event == ord(
"h"):
92 elif event == ord(
"r"):
97 self.
pad.handle_event(event)
101 def __init__(self, data_loader: ComponentsDiffFileLoader) ->
None:
102 self.data_loader: ComponentsDiffFileLoader = data_loader
103 self.data_structure: ComponentsStructure
111 self.current_pad: Pad
113 self.actual_offset: int = 0
115 self.show_diff_only: bool =
False
121 self.data_structure,
int(self.
width / 2 - 1), self.height
145 search_size: int = 50
147 b_startx: int = self.
width - search_size - 2
148 b_width: int = search_size
150 cursor_pos: Tuple[int, int] = curses.getsyx()
151 search: SearchModal = SearchModal(
152 b_startx, b_starty, b_width, b_height
154 text: str = search.edit()
155 curses.setsyx(cursor_pos[0], cursor_pos[1])
156 self.current_pad.
filter(text)
161 self.current_pad.refresh()
167 self.current_pad.hide_cursor()
173 self.current_pad.refresh()
174 self.current_pad.show_cursor()
177 search_size: int = 60
178 b_width: int = search_size
180 b_starty: int = self.
screen.getmaxyx()[0] - b_height
181 b_startx: int = self.
width - search_size - 2
182 cursor_pos: Tuple[int, int] = curses.getsyx()
183 search: DoubleHelpModal = DoubleHelpModal(
184 b_startx, b_starty, b_width, b_height
186 curses.setsyx(*cursor_pos)
188 self.current_pad.initialize_cursor()
193 event = self.
screen.getch()
194 logger.debug(f
"Key pressed: [{event}, {chr(event)}]")
195 if event == ord(
"q"):
197 elif event == ord(
"\t"):
199 elif event == ord(
"h"):
201 elif event == ord(
"m"):
203 elif event == ord(
"r"):
209 ) = self.data_loader.get_data()
210 self.
pad.reload_data(self.data_structure)
217 self.current_pad.handle_event(event)