Initialize the layout of UI components. Initialize the location and size of UI components such as command textbox and output region according to the terminal size.
(self)
| 334 | prefix_aliases=["m"]) |
| 335 | |
| 336 | def _init_layout(self): |
| 337 | """Initialize the layout of UI components. |
| 338 | |
| 339 | Initialize the location and size of UI components such as command textbox |
| 340 | and output region according to the terminal size. |
| 341 | """ |
| 342 | |
| 343 | # NamedTuple for rectangular locations on screen |
| 344 | self.rectangle = collections.namedtuple("rectangle", |
| 345 | "top left bottom right") |
| 346 | |
| 347 | # Height of command text box |
| 348 | self._command_textbox_height = 2 |
| 349 | |
| 350 | self._title_row = 0 |
| 351 | |
| 352 | # Row index of the Navigation Bar (i.e., the bar that contains forward and |
| 353 | # backward buttons and displays the current command line). |
| 354 | self._nav_bar_row = 1 |
| 355 | |
| 356 | # Top row index of the output pad. |
| 357 | # A "pad" is a curses object that holds lines of text and not limited to |
| 358 | # screen size. It can be rendered on the screen partially with scroll |
| 359 | # parameters specified. |
| 360 | self._output_top_row = 2 |
| 361 | |
| 362 | # Number of rows that the output pad has. |
| 363 | self._output_num_rows = ( |
| 364 | self._max_y - self._output_top_row - self._command_textbox_height - 1) |
| 365 | |
| 366 | # Row index of scroll information line: Taking into account the zero-based |
| 367 | # row indexing and the command textbox area under the scroll information |
| 368 | # row. |
| 369 | self._output_scroll_row = self._max_y - 1 - self._command_textbox_height |
| 370 | |
| 371 | # Tab completion bottom row. |
| 372 | self._candidates_top_row = self._output_scroll_row - 4 |
| 373 | self._candidates_bottom_row = self._output_scroll_row - 1 |
| 374 | |
| 375 | # Maximum number of lines the candidates display can have. |
| 376 | self._candidates_max_lines = int(self._output_num_rows / 2) |
| 377 | |
| 378 | self.max_output_lines = 10000 |
| 379 | |
| 380 | # Regex search state. |
| 381 | self._curr_search_regex = None |
| 382 | self._unwrapped_regex_match_lines = [] |
| 383 | |
| 384 | # Size of view port on screen, which is always smaller or equal to the |
| 385 | # screen size. |
| 386 | self._output_pad_screen_height = self._output_num_rows - 1 |
| 387 | self._output_pad_screen_width = self._max_x - 2 |
| 388 | self._output_pad_screen_location = self.rectangle( |
| 389 | top=self._output_top_row, |
| 390 | left=0, |
| 391 | bottom=self._output_top_row + self._output_num_rows, |
| 392 | right=self._output_pad_screen_width) |
| 393 |
no outgoing calls
no test coverage detected