Change of vterm handling logic on backend chardev input event (#40)
[lunaix-os.git] / lunaix-os / hal / term / lcntls / ansi_cntl.c
1 /**
2  * @file ansi_cntl.c
3  * @author Lunaixsky (lunaxisky@qq.com)
4  * @brief Line controller slave that handle all non-POSIX control code or ANSI
5  * escape sequence
6  * @version 0.1
7  * @date 2023-11-25
8  *
9  * @copyright Copyright (c) 2023
10  *
11  */
12 #include "lcntl.h"
13 #include <usr/lunaix/term.h>
14
15 #define CTRL_MNEMO(chr) (chr - 'A' + 1)
16
17 int
18 __ansi_actcontrol(struct lcntl_state* state, char chr)
19 {
20     if (chr < 32 && chr != '\n') {
21         lcntl_put_char(state, '^');
22         return lcntl_put_char(state, chr += 64);
23     }
24
25     return lcntl_put_char(state, chr);
26 }