| 
21 | 21 | #endif  | 
22 | 22 | 
 
  | 
23 | 23 | //| class Terminal:  | 
24 |  | -//|     """Display a character stream with a TileGrid  | 
 | 24 | +//|     """Terminal manages tile indices and cursor position based on VT100 commands. The ``font`` should be  | 
 | 25 | +//|     a `fontio.BuiltinFont` and the ``scroll_area`` TileGrid's bitmap should match the font's bitmap.  | 
 | 26 | +//|  | 
 | 27 | +//|     Display a character stream with a TileGrid  | 
25 | 28 | //|  | 
26 | 29 | //|     ASCII control:  | 
27 | 30 | //|  | 
 | 
75 | 78 | //|     +--------+------------+------------+  | 
76 | 79 | //|     | White  | 37         | 47         |  | 
77 | 80 | //|     +--------+------------+------------+  | 
 | 81 | +//|  | 
 | 82 | +//|     Example Usage:  | 
 | 83 | +//|  | 
 | 84 | +//|     .. code-block:: python  | 
 | 85 | +//|  | 
 | 86 | +//|         import time  | 
 | 87 | +//|         import displayio  | 
 | 88 | +//|         import supervisor  | 
 | 89 | +//|         from displayio import Group, TileGrid  | 
 | 90 | +//|         from terminalio import FONT, Terminal  | 
 | 91 | +//|  | 
 | 92 | +//|         main_group = Group()  | 
 | 93 | +//|         display = supervisor.runtime.display  | 
 | 94 | +//|         font_bb = FONT.get_bounding_box()  | 
 | 95 | +//|         screen_size = (display.width // font_bb[0], display.height // font_bb[1])  | 
 | 96 | +//|         char_size = FONT.get_bounding_box()  | 
 | 97 | +//|  | 
 | 98 | +//|         palette = displayio.Palette(2)  | 
 | 99 | +//|         palette[0] = 0x000000  | 
 | 100 | +//|         palette[1] = 0xffffff  | 
 | 101 | +//|  | 
 | 102 | +//|         tilegrid = TileGrid(  | 
 | 103 | +//|             bitmap=FONT.bitmap, width=screen_size[0], height=screen_size[1],  | 
 | 104 | +//|             tile_width=char_size[0], tile_height=char_size[1], pixel_shader=palette)  | 
 | 105 | +//|  | 
 | 106 | +//|         terminal = Terminal(tilegrid, FONT)  | 
 | 107 | +//|  | 
 | 108 | +//|         main_group.append(tilegrid)  | 
 | 109 | +//|         display.root_group = main_group  | 
 | 110 | +//|  | 
 | 111 | +//|         message = "Hello World\\n"  | 
 | 112 | +//|         terminal.write(message)  | 
 | 113 | +//|  | 
 | 114 | +//|         print(terminal.cursor_x, terminal.cursor_y)  | 
 | 115 | +//|         move_cursor = chr(27) + "[10;10H"  | 
 | 116 | +//|         terminal.write(f"Moving the cursor\\n{move_cursor} To here")  | 
 | 117 | +//|  | 
 | 118 | +//|         cursor_home = chr(27) + f"[{screen_size[1]};0H"  | 
 | 119 | +//|         terminal.write(cursor_home)  | 
 | 120 | +//|         i = 1  | 
 | 121 | +//|         while True:  | 
 | 122 | +//|             terminal.write(f"Writing again {i}\\n")  | 
 | 123 | +//|             i = i + 1  | 
 | 124 | +//|             time.sleep(1)  | 
 | 125 | +//|  | 
 | 126 | +//|  | 
78 | 127 | //|     """  | 
79 | 128 | //|  | 
80 | 129 | //|     def __init__(  | 
 | 
84 | 133 | //|         *,  | 
85 | 134 | //|         status_bar: Optional[displayio.TileGrid] = None,  | 
86 | 135 | //|     ) -> None:  | 
87 |  | -//|         """Terminal manages tile indices and cursor position based on VT100 commands. The font should be  | 
88 |  | -//|         a `fontio.BuiltinFont` and the TileGrid's bitmap should match the font's bitmap."""  | 
89 | 136 | //|         ...  | 
90 | 137 | //|  | 
91 | 138 | 
 
  | 
 | 
0 commit comments