Ejemplo n.º 1
0
 def _render(self, *args):
     if self._client.is_connected.value:
         self._dom_disconnected_container.set_style(DOMStyle(display=Display.NONE))
         self._dom_telemetry_container.set_style(DOMStyle(display=Display.BLOCK))
     else:
         self._dom_disconnected_container.set_style(DOMStyle(display=Display.BLOCK))
         self._dom_telemetry_container.set_style(DOMStyle(display=Display.NONE))
Ejemplo n.º 2
0
    def __init__(
            self,
            id: str = None,
            classnames: Set[str] = None,
            style: DOMStyle = DOMStyle(),
    ):
        self._cwd = os.path.abspath(os.getcwd())
        self._prev_cwd = self._cwd
        self._history = [""]
        self._history_position = 0
        self._dom_stdout = DOMShellStdout(self)
        self._dom_stderr = DOMShellStderr(self)
        self._active_task: Optional[SubprocessShellTask] = None
        self._sigint_handler = None

        self._output_log = DOMShellLog(id=f"{id}.log" if id else None,
                                       style=DOMStyle(size=(FULL_WIDTH,
                                                            GROW_HEIGHT)))
        self._input = DOMShellInput(
            self._cwd,
            id=f"{id}.input" if id else None,
        )
        super().__init__(
            id=id,
            classnames=classnames,
            orientation=VERTICAL,
            style=DOMStyle.merge(style, DOMStyle(scroll=Scroll.LINE)),
            children=[
                # Push everythign down
                self._output_log,
                self._input
            ])
Ejemplo n.º 3
0
 def __init__(self,
              value: str = "",
              style: DOMStyle = DOMStyle(),
              terminated: bool = False):
     super().__init__(value, style=style)
     # Indicate that the log item is terminated with a new line
     self.terminated = terminated
Ejemplo n.º 4
0
 def __init__(self, cwd: str, value: str):
     super().__init__(
         value,
         style=DOMStyle(size=(FULL_WIDTH, GROW_HEIGHT)),
         terminated=True,
     )
     self._dirname = os.path.basename(cwd)
     self._static_prefix_length = 3 + len(self._dirname)
Ejemplo n.º 5
0
 def __init__(
         self,
         char: str = " ",
         id: str = None,
         classnames: Set[str] = None,
         style: DOMStyle = DOMStyle(),
 ):
     super().__init__(id=id, style=style, classnames=classnames)
     self.character = char
Ejemplo n.º 6
0
async def main():
    """
    Run a hello world TUI via the DOM.
    """
    # Create a DOM window to contain the DOMLayouts
    window = DOMWindow()
    # Create a layout to contain DOMElements
    dom_layout = DOMStackLayout(id="window",
                                style=DOMStyle(background_color=Color.BLACK),
                                children=[
                                    DOMText("Hello world!",
                                            style=DOMStyle(
                                                size=FULL_SIZE,
                                                text_align=Alignment.CENTER)),
                                ])
    await asyncio.gather(
        window.run(dom_layout),
        asyncio.sleep(3),
    )
Ejemplo n.º 7
0
 def __init__(
     self,
     value: Union[List[str], str] = "",
     id: str = None,
     classnames: Set[str] = None,
     style: DOMStyle=DOMStyle(),
 ):
     self.values: List[str] = value if isinstance(value, list) else [value]
     self._render_values = None
     super().__init__(id=id, style=style, classnames=classnames)
Ejemplo n.º 8
0
 def __init__(
         self,
         value: str = "",
         id: str = None,
         classnames: Set[str] = None,
         style: DOMStyle = DOMStyle(),
 ):
     super().__init__(id=id, style=style, classnames=classnames)
     self._value = strip_ansi(value)
     self._render_value: Optional[str] = None
     self._static_prefix_length = 0
Ejemplo n.º 9
0
 def __init__(
         self,
         cwd: str,
         id: str = None,
         classnames: Set[str] = None,
         style: DOMStyle = DOMStyle(),
 ):
     super().__init__(id, classnames, style)
     self._dirname = os.path.basename(cwd)
     self._static_prefix_length = 2 + len(self._dirname) + 1
     self._task_mode = False
     self._task_prefix = ""
Ejemplo n.º 10
0
 def __init__(
         self,
         id: str = None,
         classnames: Set[str] = None,
         style: DOMStyle = DOMStyle(),
 ):
     super().__init__(id=id, style=style, classnames=classnames)
     self._cursor_position: int = 0
     self._render_cursor_position: int = 0
     self._value: str = ""
     self._render_value: str = ""
     # This dictates where the value starts to be rendered when it doesn't fully fit
     self._value_offset = 0
     self._static_prefix_length = 0