|
None | __init__ (self, ComponentsStructure data_structure, int width, int height, int start_x=0) |
|
None | initialize_styles (self) |
|
None | reload_data (self, ComponentsStructure data_structure) |
|
None | initialize_cursor (self) |
|
int | draw_structure (self, Element structure, int start_y) |
|
None | draw_all_structures (self, start_y=0) |
|
None | refresh (self) |
|
bool | lines_empty (self) |
|
None | clear (self) |
|
None | redraw (self, bool reinit_cursor=False) |
|
None | filter (self, str text) |
|
None | show_all (self) |
|
str | get_character (self, int y, int x) |
|
None | move_cursor (self, int number) |
|
Tuple[int, int] | hide_cursor (self) |
|
None | show_cursor (self) |
|
None | set_cursor (self, int y, int x) |
|
None | scroll (self, int number) |
|
None | scroll_to_element (self, int new_y) |
|
int | get_index_by_name (self, str name) |
|
None | move_down (self) |
|
None | move_up (self) |
|
None | expand (self) |
|
None | expand_all (self, filter_comps=False) |
|
None | expand_children (self, Element element, filter_comps) |
|
None | collapse (self) |
|
def | collapse_all (self) |
|
None | collapse_children (self, Element element) |
|
None | set_as_checked (self) |
|
None | handle_event (self, int event) |
|
Definition at line 24 of file pad.py.
◆ __init__()
None python.iconfTool.gui.pad.Pad.__init__ |
( |
|
self, |
|
|
ComponentsStructure |
data_structure, |
|
|
int |
width, |
|
|
int |
height, |
|
|
int |
start_x = 0 |
|
) |
| |
Definition at line 25 of file pad.py.
27 data_structure: ComponentsStructure,
32 self.structure: ComponentsStructure = data_structure
33 self.structure_list: List[Element] = self.structure.get_list()
34 self.root_items_names: Set = {
35 element.name
for element
in self.structure_list
37 self.width: int = width
38 self.start_x: int = start_x
39 self.MAX_PAD_HEIGHT: int = 32000
40 self.pad = curses.newpad(self.MAX_PAD_HEIGHT, width)
41 self.actual_offset: int = 0
42 self.pad_height: int = height - 1
44 self.mark_character: str =
" "
46 self.lines: List[Element] = []
47 self.search_text: str =
""
49 self.initialize_styles()
52 self.draw_all_structures()
53 self.actual_y: int = 0
55 self.initialize_cursor()
◆ clear()
None python.iconfTool.gui.pad.Pad.clear |
( |
|
self | ) |
|
◆ collapse()
None python.iconfTool.gui.pad.Pad.collapse |
( |
|
self | ) |
|
Definition at line 327 of file pad.py.
327 def collapse(self) -> None:
328 if self.actual_y >= len(self.lines):
330 element = self.lines[self.actual_y]
331 if isinstance(element, GroupingElement):
332 element.show_children =
False
◆ collapse_all()
def python.iconfTool.gui.pad.Pad.collapse_all |
( |
|
self | ) |
|
Definition at line 335 of file pad.py.
335 def collapse_all(self):
336 for element
in self.structure_list:
337 self.collapse_children(element)
◆ collapse_children()
None python.iconfTool.gui.pad.Pad.collapse_children |
( |
|
self, |
|
|
Element |
element |
|
) |
| |
Definition at line 341 of file pad.py.
341 def collapse_children(self, element: Element) ->
None:
342 if isinstance(element, GroupingElement):
343 element.show_children =
False
344 for child
in element.children:
345 self.collapse_children(child)
◆ draw_all_structures()
None python.iconfTool.gui.pad.Pad.draw_all_structures |
( |
|
self, |
|
|
|
start_y = 0 |
|
) |
| |
Definition at line 130 of file pad.py.
130 def draw_all_structures(self, start_y=0) -> None:
133 for i
in self.structure_list:
134 if start_y >= self.MAX_PAD_HEIGHT:
136 start_y = self.draw_structure(i, start_y)
◆ draw_structure()
int python.iconfTool.gui.pad.Pad.draw_structure |
( |
|
self, |
|
|
Element |
structure, |
|
|
int |
start_y |
|
) |
| |
start_y - starting vertical position where elements will be drawn
Definition at line 101 of file pad.py.
101 def draw_structure(self, structure: Element, start_y: int) -> int:
102 """start_y - starting vertical position where elements will be drawn"""
103 style = self.styles[
"marked" if structure.is_marked()
else "normal"]
105 f
"Adding str: x:{structure.x_pos}, y:{start_y}/{self.MAX_PAD_HEIGHT}"
111 structure.get_line(),
114 except Exception
as e:
116 f
"Error {e} loading str y:{start_y}, x: {structure.x_pos}"
118 self.lines.insert(start_y, structure)
120 if isinstance(structure, GroupingElement)
and structure.show_children:
121 for child
in structure.children:
122 if start_y < self.MAX_PAD_HEIGHT:
123 start_y = self.draw_structure(child, start_y)
126 f
"Too many structures: {start_y}. Max count: {self.MAX_PAD_HEIGHT}"
◆ expand()
None python.iconfTool.gui.pad.Pad.expand |
( |
|
self | ) |
|
Definition at line 295 of file pad.py.
296 if self.actual_y >= len(self.lines):
298 element = self.lines[self.actual_y]
299 if isinstance(element, GroupingElement):
300 self.structure.replace_references(element)
301 element.show_children =
True
◆ expand_all()
None python.iconfTool.gui.pad.Pad.expand_all |
( |
|
self, |
|
|
|
filter_comps = False |
|
) |
| |
Definition at line 304 of file pad.py.
304 def expand_all(self, filter_comps=False) -> None:
305 for element
in self.structure_list:
306 self.expand_children(element, filter_comps)
307 self.structure.filter.comps_to_save = []
◆ expand_children()
None python.iconfTool.gui.pad.Pad.expand_children |
( |
|
self, |
|
|
Element |
element, |
|
|
|
filter_comps |
|
) |
| |
Definition at line 310 of file pad.py.
310 def expand_children(self, element: Element, filter_comps) ->
None:
313 and element.get_reference_name()
314 not in self.structure.filter.comps_to_save
315 and element.get_reference_name()
in self.structure.roots_dict
318 f
"Skipped expanding for: {element.get_reference_name()}"
321 if isinstance(element, GroupingElement):
322 self.structure.replace_references(element)
323 element.show_children =
True
324 for child
in element.children:
325 self.expand_children(child, filter_comps)
◆ filter()
None python.iconfTool.gui.pad.Pad.filter |
( |
|
self, |
|
|
str |
text |
|
) |
| |
Definition at line 182 of file pad.py.
182 def filter(self, text: str) ->
None:
183 self.search_text = text
if text
else ""
186 if len(self.search_text) > 0:
187 self.structure.filter_by_text(text)
188 if self.structure.filter.comps_to_save:
189 self.expand_all(filter_comps=
True)
190 for element
in self.lines:
191 if text
in element.get_name()
and not element.is_checked():
192 element.set_as_checked()
◆ get_character()
str python.iconfTool.gui.pad.Pad.get_character |
( |
|
self, |
|
|
int |
y, |
|
|
int |
x |
|
) |
| |
Definition at line 199 of file pad.py.
199 def get_character(self, y: int, x: int) -> str:
200 current_character = chr(
201 int(self.pad.inch(y, x)) & 0xFF
203 return current_character
◆ get_index_by_name()
int python.iconfTool.gui.pad.Pad.get_index_by_name |
( |
|
self, |
|
|
str |
name |
|
) |
| |
Definition at line 273 of file pad.py.
273 def get_index_by_name(self, name: str) -> int:
274 for index, element
in enumerate(self.lines):
275 if element.parent
is None and element.name == name:
◆ handle_event()
None python.iconfTool.gui.pad.Pad.handle_event |
( |
|
self, |
|
|
int |
event |
|
) |
| |
Definition at line 357 of file pad.py.
357 def handle_event(self, event: int) ->
None:
358 if event == curses.KEY_DOWN:
360 elif event == curses.KEY_UP:
362 elif event == curses.KEY_RIGHT:
364 elif event == curses.KEY_LEFT:
366 elif event == ord(
" "):
367 self.set_as_checked()
◆ hide_cursor()
Tuple[int, int] python.iconfTool.gui.pad.Pad.hide_cursor |
( |
|
self | ) |
|
Definition at line 213 of file pad.py.
213 def hide_cursor(self) -> Tuple[int, int]:
214 cursor_pos = curses.getsyx()
215 current_character = self.get_character(
216 cursor_pos[0] + self.actual_offset, cursor_pos[1] - 1
219 cursor_pos[0] + self.actual_offset,
222 self.styles[
"normal"],
◆ initialize_cursor()
None python.iconfTool.gui.pad.Pad.initialize_cursor |
( |
|
self | ) |
|
Definition at line 81 of file pad.py.
81 def initialize_cursor(self) -> None:
83 if self.lines_empty():
86 if self.actual_y >= len(self.lines):
88 element = self.lines[self.actual_y]
89 curses.setsyx(self.actual_y, element.x_pos + 1)
93 element.get_mark_character(),
94 self.styles[
"highlighted"],
◆ initialize_styles()
None python.iconfTool.gui.pad.Pad.initialize_styles |
( |
|
self | ) |
|
Definition at line 60 of file pad.py.
60 def initialize_styles(self) -> None:
62 1, curses.COLOR_BLACK, curses.COLOR_WHITE
64 highlighted = curses.color_pair(1)
65 normal = curses.A_NORMAL
66 curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
67 marked = curses.color_pair(3)
70 "highlighted": highlighted,
◆ lines_empty()
bool python.iconfTool.gui.pad.Pad.lines_empty |
( |
|
self | ) |
|
Definition at line 151 of file pad.py.
151 def lines_empty(self) -> bool:
152 return len(self.lines) == 0
◆ move_cursor()
None python.iconfTool.gui.pad.Pad.move_cursor |
( |
|
self, |
|
|
int |
number |
|
) |
| |
Definition at line 205 of file pad.py.
205 def move_cursor(self, number: int) ->
None:
206 cursor_pos = self.hide_cursor()
207 self.actual_y += number
208 if self.actual_y < len(self.lines):
210 cursor_pos[0] + number, self.lines[self.actual_y].x_pos + 1
◆ move_down()
None python.iconfTool.gui.pad.Pad.move_down |
( |
|
self | ) |
|
Definition at line 279 of file pad.py.
279 def move_down(self) -> None:
280 if self.actual_y < len(self.lines) - 1:
282 cursor_pos = curses.getsyx()
283 if cursor_pos[0] > self.pad_height - 4:
◆ move_up()
None python.iconfTool.gui.pad.Pad.move_up |
( |
|
self | ) |
|
Definition at line 286 of file pad.py.
286 def move_up(self) -> None:
287 if len(self.lines) == 0:
289 if self.actual_y >= 1:
291 cursor_pos = curses.getsyx()
292 if cursor_pos[0] < 4
and self.actual_offset > 0:
◆ redraw()
None python.iconfTool.gui.pad.Pad.redraw |
( |
|
self, |
|
|
bool |
reinit_cursor = False |
|
) |
| |
Definition at line 158 of file pad.py.
158 def redraw(self, reinit_cursor: bool =
False) ->
None:
159 cursor_pos = curses.getsyx()
161 self.draw_all_structures()
162 if self.lines_empty():
164 if reinit_cursor
or cursor_pos[1] == 0:
165 self.actual_offset = 0
167 self.initialize_cursor()
170 f
"y: {self.actual_y}, lines length: {len(self.lines)}"
172 element = self.lines[self.actual_y]
173 self.pad.move(self.actual_y, cursor_pos[1])
177 element.get_mark_character(),
178 self.styles[
"highlighted"],
◆ refresh()
None python.iconfTool.gui.pad.Pad.refresh |
( |
|
self | ) |
|
Definition at line 139 of file pad.py.
139 def refresh(self) -> None:
146 self.width + self.start_x - 2,
148 cursor_pos = curses.getsyx()
149 curses.setsyx(cursor_pos[0],
int(cursor_pos[1] - self.start_x))
◆ reload_data()
None python.iconfTool.gui.pad.Pad.reload_data |
( |
|
self, |
|
|
ComponentsStructure |
data_structure |
|
) |
| |
Definition at line 74 of file pad.py.
74 def reload_data(self, data_structure: ComponentsStructure) ->
None:
75 self.structure = data_structure
76 self.structure_list = self.structure.get_list()
77 self.root_items_names = {
78 element.name
for element
in self.structure_list
◆ scroll()
None python.iconfTool.gui.pad.Pad.scroll |
( |
|
self, |
|
|
int |
number |
|
) |
| |
Definition at line 253 of file pad.py.
253 def scroll(self, number: int) ->
None:
254 self.actual_offset += number
◆ scroll_to_element()
None python.iconfTool.gui.pad.Pad.scroll_to_element |
( |
|
self, |
|
|
int |
new_y |
|
) |
| |
Definition at line 257 of file pad.py.
257 def scroll_to_element(self, new_y: int) ->
None:
258 self.actual_y = new_y
261 if new_y < self.actual_offset:
262 self.actual_offset = new_y - 1
263 if self.actual_offset < 0:
264 self.actual_offset = 0
265 elif new_y > self.actual_offset + self.pad_height:
266 self.actual_offset = new_y - 1
267 if self.actual_offset + self.pad_height > len(self.lines):
268 self.actual_offset = len(self.lines) - self.pad_height
270 new_y - self.actual_offset, self.lines[new_y].x_pos + 1
◆ set_as_checked()
None python.iconfTool.gui.pad.Pad.set_as_checked |
( |
|
self | ) |
|
Definition at line 347 of file pad.py.
347 def set_as_checked(self) -> None:
348 element = self.lines[self.actual_y]
350 element.set_as_unchecked()
351 self.structure.remove_from_checked(element)
353 element.set_as_checked()
354 self.structure.add_to_checked(element)
◆ set_cursor()
None python.iconfTool.gui.pad.Pad.set_cursor |
( |
|
self, |
|
|
int |
y, |
|
|
int |
x |
|
) |
| |
Definition at line 239 of file pad.py.
239 def set_cursor(self, y: int, x: int) ->
None:
241 cursor_pos = curses.getsyx()
242 current_character = self.get_character(
243 cursor_pos[0] + self.actual_offset, cursor_pos[1]
246 cursor_pos[0] + self.actual_offset,
249 self.styles[
"highlighted"],
◆ show_all()
None python.iconfTool.gui.pad.Pad.show_all |
( |
|
self | ) |
|
Definition at line 195 of file pad.py.
195 def show_all(self) -> None:
196 self.structure_list = self.structure.get_list()
◆ show_cursor()
None python.iconfTool.gui.pad.Pad.show_cursor |
( |
|
self | ) |
|
Definition at line 226 of file pad.py.
226 def show_cursor(self) -> None:
227 cursor_pos = curses.getsyx()
228 current_character = self.get_character(
229 cursor_pos[0] + self.actual_offset, cursor_pos[1] - 1
232 cursor_pos[0] + self.actual_offset,
235 self.styles[
"highlighted"],
◆ actual_offset
python.iconfTool.gui.pad.Pad.actual_offset |
◆ actual_y
python.iconfTool.gui.pad.Pad.actual_y |
◆ lines
python.iconfTool.gui.pad.Pad.lines |
◆ pad
python.iconfTool.gui.pad.Pad.pad |
◆ root_items_names
python.iconfTool.gui.pad.Pad.root_items_names |
◆ search_text
python.iconfTool.gui.pad.Pad.search_text |
◆ structure
python.iconfTool.gui.pad.Pad.structure |
◆ structure_list
python.iconfTool.gui.pad.Pad.structure_list |
◆ styles
python.iconfTool.gui.pad.Pad.styles |
The documentation for this class was generated from the following file: