-
Notifications
You must be signed in to change notification settings - Fork 0
/
editor.h
57 lines (52 loc) · 1.99 KB
/
editor.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <fontlibc.h>
void init_history(void);
void free_history(void);
void add_history(char* string);
char* get_history_item(unsigned char n);
typedef struct
{
/* Physical layout */
unsigned int base_x;
unsigned char base_y;
unsigned int width;
unsigned char font_height;
/* Style */
fontlib_font_t* font;
unsigned char fg_color;
unsigned char bg_color;
char cursor_glyph;
bool cursor_shown;
/* Edit buffer */
char* str;
unsigned char max_length;
unsigned char current_length;
unsigned char cursor_index;
unsigned int cursor_x;
} editor_context_t;
typedef enum
{
shift_none,
shift_alpha,
shift_lower_alpha
} edit_shift_options_t;
void editor_redraw_from_cursor(editor_context_t* context);
void editor_redraw(editor_context_t* context);
void editor_show_cursor(editor_context_t* context);
void editor_hide_cursor(editor_context_t* context);
void editor_toggle_cursor(editor_context_t* context);
editor_context_t* editor_start(unsigned int x_loc, unsigned char y_loc, unsigned int box_width, unsigned char text_max_length, fontlib_font_t* editor_font);
void editor_close(editor_context_t* context);
char* editor_get_string_close(editor_context_t* context);
char* get_string(unsigned int x_loc, unsigned char y_loc, unsigned int box_width, unsigned char text_max_length, fontlib_font_t* editor_font, char* default_text);
void editor_right(editor_context_t* context);
void editor_left(editor_context_t* context);
void editor_cursor_set(editor_context_t* context, unsigned char index);
void editor_insert(editor_context_t* context, char character);
/*void editor_insert_str(editor_context_t* context, char* str);*/
void editor_set_str(editor_context_t* context, char* str);
void editor_delete(editor_context_t* context, unsigned char n);
void editor_flush(editor_context_t* context);
char editor_translate_key(char key, unsigned char shift);