Show candidates (e.g., tab-completion candidates) on multiple lines. Args: candidates: (list of str) candidates.
(self, candidates)
| 1568 | return except_last_word + prefix |
| 1569 | |
| 1570 | def _display_candidates(self, candidates): |
| 1571 | """Show candidates (e.g., tab-completion candidates) on multiple lines. |
| 1572 | |
| 1573 | Args: |
| 1574 | candidates: (list of str) candidates. |
| 1575 | """ |
| 1576 | |
| 1577 | if self._curr_unwrapped_output: |
| 1578 | # Force refresh screen output. |
| 1579 | self._scroll_output(_SCROLL_REFRESH) |
| 1580 | |
| 1581 | if not candidates: |
| 1582 | return |
| 1583 | |
| 1584 | candidates_prefix = "Candidates: " |
| 1585 | candidates_line = candidates_prefix + " ".join(candidates) |
| 1586 | candidates_output = debugger_cli_common.RichTextLines( |
| 1587 | candidates_line, |
| 1588 | font_attr_segs={ |
| 1589 | 0: [(len(candidates_prefix), len(candidates_line), "yellow")] |
| 1590 | }) |
| 1591 | |
| 1592 | candidates_output, _ = debugger_cli_common.wrap_rich_text_lines( |
| 1593 | candidates_output, self._max_x - 3) |
| 1594 | |
| 1595 | # Calculate how many lines the candidate text should occupy. Limit it to |
| 1596 | # a maximum value. |
| 1597 | candidates_num_rows = min( |
| 1598 | len(candidates_output.lines), self._candidates_max_lines) |
| 1599 | self._candidates_top_row = ( |
| 1600 | self._candidates_bottom_row - candidates_num_rows + 1) |
| 1601 | |
| 1602 | # Render the candidate text on screen. |
| 1603 | pad, _, _ = self._display_lines(candidates_output, 0) |
| 1604 | self._screen_scroll_output_pad( |
| 1605 | pad, 0, 0, self._candidates_top_row, 0, |
| 1606 | self._candidates_top_row + candidates_num_rows - 1, self._max_x - 2) |
| 1607 | |
| 1608 | def _toast(self, message, color=None, line_index=None): |
| 1609 | """Display a one-line message on the screen. |
no test coverage detected