pub fn enable_custom_mode() {
    check_statics!();

    // Enable raw mode settings, but still send signals. c_flag | ISIG
    let termios = unsafe {
        Termios {
            c_iflag: TTYTERMIOS.c_iflag & !(IGNBRK | BRKINT | PARMRK | ISTRIP
                    | INLCR | IGNCR | ICRNL | IXON),
            c_oflag: TTYTERMIOS.c_oflag & !OPOST,
            c_lflag: TTYTERMIOS.c_lflag & !(ECHO | ECHONL | ICANON | IEXTEN),
            c_cflag: TTYTERMIOS.c_cflag & !(CSIZE | PARENB) | CS8,
            c_line: TTYTERMIOS.c_line,
            c_cc: TTYTERMIOS.c_cc,
        }
    };

    // Set tty with our new settings
    let ret: i32;
    unsafe {
        asm!("syscall",
            in("rax") 16, // SYS_IOCTL
            in("rdi") TTYFD,
            in("rsi") TCSETS,
            in("rdx") &termios as *const Termios,
            out("rcx") _,
            out("r11") _,
            lateout("rax") ret,
        );
    }

    assert!(!ret.is_negative(), "SYS_IOCTL TCSETS returned an error: {}", ret);

    let data = "\x1b[?1049h\x1b[2J\x1b[?25l";
    unsafe {
        asm!("syscall",
            in("rax") 1, // SYS_WRITE
            in("rdi") 1,
            in("rsi") data.as_ptr(),
            in("rdx") data.len(),
            out("rcx") _,
            out("r11") _,
            lateout("rax") _,
        );
    }
}
// Enable raw mode and enable alternate screen and hide cursor
Enable raw mode and enable alternate screen and hide cursor
Enable raw mode and enable alternate screen and hide cursor
pub fn enable_custom_mode() {
    check_statics!();
    // Enable raw mode settings, but still send signals. c_flag | ISIG
    let termios = unsafe {
        Termios {
            c_iflag: TTYTERMIOS.c_iflag & !(IGNBRK | BRKINT | PARMRK | ISTRIP
                    | INLCR | IGNCR | ICRNL | IXON),
            c_oflag: TTYTERMIOS.c_oflag & !OPOST,
            c_lflag: TTYTERMIOS.c_lflag & !(ECHO | ECHONL | ICANON | IEXTEN),
            c_cflag: TTYTERMIOS.c_cflag & !(CSIZE | PARENB) | CS8,
            c_line: TTYTERMIOS.c_line,
            c_cc: TTYTERMIOS.c_cc,
        }
    };
    // Set tty with our new settings
    let ret: i32;
    unsafe {
        asm!("syscall",
            in("rax") 16, // SYS_IOCTL
            in("rdi") TTYFD,
            in("rsi") TCSETS,
            in("rdx") &termios as *const Termios,
            out("rcx") _,
            out("r11") _,
            lateout("rax") ret,
        );
    }
    assert!(!ret.is_negative(), "SYS_IOCTL TCSETS returned an error: {}", ret);
    let data = "\x1b[?1049h\x1b[2J\x1b[?25l";
    unsafe {
        asm!("syscall",
            in("rax") 1, // SYS_WRITE
            in("rdi") 1,
            in("rsi") data.as_ptr(),
            in("rdx") data.len(),
            out("rcx") _,
            out("r11") _,
            lateout("rax") _,
        );
    }
}
pub fn enable_custom_mode ( ) { check_statics ! ( ) ; // Enable raw mode settings, but still send signals. c_flag | ISIG let termios = unsafe { Termios { c_iflag : TTYTERMIOS . c_iflag & ! ( IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON ) , c_oflag : TTYTERMIOS . c_oflag & ! OPOST , c_lflag : TTYTERMIOS . c_lflag & ! ( ECHO | ECHONL | ICANON | IEXTEN ) , c_cflag : TTYTERMIOS . c_cflag & ! ( CSIZE | PARENB ) | CS8 , c_line : TTYTERMIOS . c_line , c_cc : TTYTERMIOS . c_cc , } } ; // Set tty with our new settings let ret : i32 ; unsafe { asm ! ( " " in ( " " ) 16 // SYS_IOCTL in ( " " ) TTYFD in ( " " ) TCSETS in ( " " ) termios as const Termios out ( " " ) out ( " " ) lateout ( " " ) ret ) ; } assert ! ( ret is_negative ( ) " " ret ) ; let data = " \x1b \x1b \x1b " ; unsafe { asm ! ( " " in ( " " ) 1 // SYS_WRITE in ( " " ) 1 in ( " " ) data as_ptr ( ) in ( " " ) data len ( ) out ( " " ) out ( " " ) lateout ( " " ) ) ; } }
Enable raw mode and enable alternate screen and hide cursor
Enable raw mode and enable alternate screen and hide cursor