LCOV - code coverage report
Current view: top level - dashql-core-shell/src - vt100.rs Coverage Total Hit
Test: DashQL 6e74948 Lines: 100.0 % 10 10
Test Date: 2026-11-06 17:46:50

            Line data    Source code
       1              : //! VT100 control sequences of the shell.
       2              : 
       3              : pub const CONTROL_SEQUENCE_INTRODUCER: &str = "\x1b[";
       4              : pub const CARRIAGE_RETURN: &str = "\r";
       5              : pub const NEW_LINE: &str = "\r\n";
       6              : 
       7              : /// Parameterized CSI commands
       8              : #[derive(Clone, Copy, Debug, PartialEq, Eq)]
       9              : #[repr(u8)]
      10              : pub enum Command {
      11              :     InsertCharacter = b'@',
      12              :     CursorUp = b'A',
      13              :     CursorDown = b'B',
      14              :     CursorForward = b'C',
      15              :     CursorBackward = b'D',
      16              :     InsertLine = b'L',
      17              :     DeleteLine = b'M',
      18              :     DeleteCharacter = b'P',
      19              : }
      20              : 
      21              : /// Append a parameterized CSI command
      22         4227 : pub fn append_sequence(output: &mut Vec<u8>, count: usize, command: Command) {
      23         4227 :     output.extend_from_slice(CONTROL_SEQUENCE_INTRODUCER.as_bytes());
      24         4227 :     output.extend_from_slice(count.to_string().as_bytes());
      25         4227 :     output.push(command as u8);
      26         4227 : }
      27              : 
      28              : /// A parameterized CSI command
      29           20 : pub fn sequence(count: usize, command: Command) -> String {
      30           20 :     let mut output = Vec::new();
      31           20 :     append_sequence(&mut output, count, command);
      32           20 :     String::from_utf8(output).unwrap()
      33           20 : }
      34              : 
      35              : pub const CURSOR_UP_ONE: &str = "\x1b[1A";
      36              : pub const ERASE_ENTIRE_LINE: &str = "\x1b[2K";
      37              : pub const ERASE_LINE_FROM_CURSOR: &str = "\x1b[0K";
      38              : pub const SAVE_CURSOR: &str = "\x1b[s";
      39              : pub const RESTORE_CURSOR: &str = "\x1b[u";
      40              : pub const ENABLE_AUTO_WRAP: &str = "\x1b[?7h";
      41              : pub const DISABLE_AUTO_WRAP: &str = "\x1b[?7l";
      42              : pub const CLEAR_SCREEN: &str = "\x1b[2J\x1b[H";
      43              : 
      44              : pub const RESET_ATTRIBUTES: &str = "\x1b[0m";
      45              : pub const BOLD: &str = "\x1b[1m";
      46              : pub const REVERSE_VIDEO: &str = "\x1b[7m";
      47              : pub const FOREGROUND_RED: &str = "\x1b[31m";
      48              : pub const FOREGROUND_BRIGHT_BLACK: &str = "\x1b[90m";
      49              : pub const BOLD_FOREGROUND_PINK: &str = "\x1b[1;38;2;255;122;178m";
      50              : pub const ITALIC_FOREGROUND_SILVER: &str = "\x1b[3;38;2;201;209;217m";
      51              : pub const FOREGROUND_PURPLE: &str = "\x1b[38;2;218;186;255m";
      52              : pub const FOREGROUND_CORAL: &str = "\x1b[38;2;255;129;112m";
      53              : pub const FOREGROUND_PINK: &str = "\x1b[38;2;255;122;178m";
      54              : pub const FOREGROUND_SILVER: &str = "\x1b[38;2;201;209;217m";
      55              : pub const FOREGROUND_GRAY: &str = "\x1b[38;2;127;140;152m";
        

Generated by: LCOV version 2.0-1