Espresso 0.0.2c
This commit is contained in:
73
include/new_tty.h
Normal file
73
include/new_tty.h
Normal file
@ -0,0 +1,73 @@
|
||||
#ifndef _TTY_H
|
||||
#define _TTY_H
|
||||
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include <processes.h>
|
||||
#include <sync.h>
|
||||
|
||||
|
||||
#define TTY_BUFFER_SIZE 4096
|
||||
#define MAX_TTYS 8 /* to make things easy, might change later */
|
||||
|
||||
#define TTY_ECHO 0x10 /* 0b00010000 */
|
||||
#define TTY_PASSWORD 0x20 /* 0b00100000 */
|
||||
#define TTY_ACTIVE 0x01 /* 0b00000001 */
|
||||
|
||||
#define TTY_CANONICAL 0x40 /* 0b01000000 */
|
||||
|
||||
|
||||
#define TTY_NULL 0x80 /* 0b10000000 --- used to end the list of tty_t structs in the ttys array */
|
||||
|
||||
#define TTY_NORMAL TTY_ECHO | TTY_ACTIVE | TTY_CANONICAL
|
||||
|
||||
#define MODIFIER_CAPS 0x01 /* 0b00000001 */
|
||||
#define MODIFIER_CAPS_DESTROY 0b11111110
|
||||
#define MODIFIER_SHIFT 0x02 /* 0b00000010 */
|
||||
#define MODIFIER_SHIFT_DESTROY 0b11111101
|
||||
#define MODIFIER_ALT 0x04 /* 0b00000100 */
|
||||
#define MODIFIER_ALT_DESTROY 0b11111011
|
||||
#define MODIFIER_LCTRL 0x10 /* 0b00010000 */
|
||||
#define MODIFIER_LCTRL_DESTROY 0b11101111
|
||||
#define MODIFIER_RCTRL 0x0 /* 0b00100000*/
|
||||
#define MODIFIER_RCTRL_DESTROY 0b11011111
|
||||
|
||||
|
||||
typedef struct tty_t {
|
||||
char input_buffer[TTY_BUFFER_SIZE];
|
||||
size_t head;
|
||||
size_t tail;
|
||||
|
||||
uint32_t flags;
|
||||
|
||||
bool canonical;
|
||||
bool line_ready;
|
||||
|
||||
spinlock_t lock;
|
||||
|
||||
pid_t foreground_pgid; /* not used yet */
|
||||
} tty_t;
|
||||
|
||||
/* essentially, key is non-zero if a key like the up arrow is pressed, otherwise c is the char that was entered */
|
||||
struct keyevent {
|
||||
uint8_t key;
|
||||
char c;
|
||||
};
|
||||
|
||||
int init_tty(void);
|
||||
|
||||
ssize_t tty_read(tty_t* tty, char* buf, size_t count);
|
||||
ssize_t tty_read_active(char* buf, size_t count);
|
||||
|
||||
tty_t* get_active_tty(void);
|
||||
tty_t* tty_get_active(void);
|
||||
|
||||
tty_t* make_tty(uint32_t flags);
|
||||
|
||||
void tty_receive_char(char c, uint32_t kbd_mod);
|
||||
char tty_translate_char(char c, uint32_t modifiers);
|
||||
|
||||
void tty_input_char(tty_t* tty, char c);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user