blob: a420f0088de2f095cae50135defd90850f402e93 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
#ifndef ECEX_APP_H
#define ECEX_APP_H
#include "ecex.h"
#include "font.h"
#include <GLFW/glfw3.h>
#include <stddef.h>
#define ECEX_MINIBUFFER_SIZE 256
#define ECEX_PREFIX_SIZE 128
typedef enum app_mode {
APP_MODE_EDIT = 0,
APP_MODE_MX = 1,
APP_MODE_PREFIX = 2,
APP_MODE_PROMPT = 3,
APP_MODE_ISEARCH = 4,
} app_mode_t;
typedef struct app {
ecex_t *ed;
GLFWwindow *window;
int width;
int height;
int dirty;
app_mode_t mode;
char minibuffer[ECEX_MINIBUFFER_SIZE];
size_t minibuffer_len;
char message[ECEX_MINIBUFFER_SIZE];
ecex_prompt_request_t prompt_kind;
int isearch_backward;
char isearch_query[ECEX_MINIBUFFER_SIZE];
size_t isearch_len;
size_t isearch_origin;
size_t isearch_match;
int isearch_has_match;
char last_search_query[ECEX_MINIBUFFER_SIZE];
char prompt_label[128];
char prompt_input[1024];
size_t prompt_input_len;
/*
* Prompt completion state for path prompts and buffer prompts.
* prompt_completion_query stores the original typed query while
* prompt_input is temporarily replaced with the selected candidate.
*/
int prompt_completion_active;
char prompt_completion_query[1024];
size_t prompt_completion_index;
size_t prompt_completion_count;
char prompt_completion_preview[8][1024];
size_t prompt_completion_preview_start;
size_t prompt_completion_preview_count;
/*
* M-x completion state.
* completion_query is the original user query used to build the candidate
* list. This lets the UI replace the minibuffer with a candidate while
* Up/Down still cycle through matches for the original query, e.g.
* "-buffer" -> next-buffer / previous-buffer / end-of-buffer / ...
*/
int completion_active;
char completion_query[ECEX_MINIBUFFER_SIZE];
size_t completion_index;
size_t completion_count;
char prefix[ECEX_PREFIX_SIZE];
size_t prefix_len;
int current_mods;
buffer_t *mouse_capture_buffer;
int mouse_capture_button;
int mouse_capture_active;
/*
* GLFW sends key events and text events separately. When a printable
* key is consumed as part of a command sequence, suppress the matching
* char_callback so it does not insert into the buffer after the command
* returns to edit mode.
*/
int suppress_next_char;
font_t font;
char font_path[4096];
} app_t;
void app_init(app_t *app, ecex_t *ed);
void app_set_window(app_t *app, GLFWwindow *window);
void app_install_callbacks(app_t *app);
void app_message(app_t *app, const char *msg);
#endif
|