back to scratko.xyz
summaryrefslogtreecommitdiff
path: root/readline.h
blob: b626cae01e28077e140144ccd04e7a7ba3639e1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef READLINE_H_SENTRY
#define READLINE_H_SENTRY

#include "readline.h"

/*
 * ends with these codes in escape sequence
 * for the arrows
 */
enum keys{
    left_arrow      = 'D',
    right_arrow     = 'C',
    up_arrow        = 'A',
    down_arrow      = 'B',
    none            =  0,
    unknown_key     =  -1,
    backspace       =  127
};

struct readline_type {
    char *arr;
    int cursor_pos;
    int considered_index;
    int last_element_index;
    int allocation_size;
};

void readline_create_array(struct readline_type *readline);
void readline_add_char(struct readline_type *readline, int ch);
void readline_reset_array(struct readline_type *readline);
void readline_clear(struct readline_type *readline);
void readline_print(struct readline_type *readline_type);
enum keys readline_detect_arrow_keys(int ch);
void readline_move_along(struct readline_type *readline, enum keys found_key);
void readline_character_deletion(struct readline_type *readline);

#endif