()
| 102 | """ |
| 103 | |
| 104 | def get_text_fragments() -> StyleAndTextTuples: |
| 105 | tokens: StyleAndTextTuples = [] |
| 106 | |
| 107 | def append_category(category: OptionCategory[Any]) -> None: |
| 108 | tokens.extend( |
| 109 | [ |
| 110 | ("class:sidebar", " "), |
| 111 | ("class:sidebar.title", f" {category.title:36}"), |
| 112 | ("class:sidebar", "\n"), |
| 113 | ] |
| 114 | ) |
| 115 | |
| 116 | def append(index: int, label: str, status: str) -> None: |
| 117 | selected = index == python_input.selected_option_index |
| 118 | |
| 119 | @if_mousedown |
| 120 | def select_item(mouse_event: MouseEvent) -> None: |
| 121 | python_input.selected_option_index = index |
| 122 | |
| 123 | @if_mousedown |
| 124 | def goto_next(mouse_event: MouseEvent) -> None: |
| 125 | "Select item and go to next value." |
| 126 | python_input.selected_option_index = index |
| 127 | option = python_input.selected_option |
| 128 | option.activate_next() |
| 129 | |
| 130 | sel = ",selected" if selected else "" |
| 131 | |
| 132 | tokens.append(("class:sidebar" + sel, " >" if selected else " ")) |
| 133 | tokens.append(("class:sidebar.label" + sel, f"{label:24}", select_item)) |
| 134 | tokens.append(("class:sidebar.status" + sel, " ", select_item)) |
| 135 | tokens.append(("class:sidebar.status" + sel, f"{status}", goto_next)) |
| 136 | |
| 137 | if selected: |
| 138 | tokens.append(("[SetCursorPosition]", "")) |
| 139 | |
| 140 | tokens.append( |
| 141 | ("class:sidebar.status" + sel, " " * (13 - len(status)), goto_next) |
| 142 | ) |
| 143 | tokens.append(("class:sidebar", "<" if selected else "")) |
| 144 | tokens.append(("class:sidebar", "\n")) |
| 145 | |
| 146 | i = 0 |
| 147 | for category in python_input.options: |
| 148 | append_category(category) |
| 149 | |
| 150 | for option in category.options: |
| 151 | append(i, option.title, str(option.get_current_value())) |
| 152 | i += 1 |
| 153 | |
| 154 | tokens.pop() # Remove last newline. |
| 155 | |
| 156 | return tokens |
| 157 | |
| 158 | class Control(FormattedTextControl): |
| 159 | def move_cursor_down(self) -> None: |
nothing calls this directly
no test coverage detected