-
Notifications
You must be signed in to change notification settings - Fork 0
/
handlers.h
158 lines (118 loc) · 3.32 KB
/
handlers.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 1000
#endif
#ifndef HANDLERS_H
#define HANDLERS_H
#include "instance.h"
#include "parser.h"
#include "help.h"
#include <stdio.h>
#include <wchar.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
extern char isatty_stdout;
extern char isatty_stderr;
extern char changes_made;
extern char *association;
extern char config_use_cls;
#define ANSI_CLEAR_SCREEN L"\033[2J"
#define ANSI_COLOR_RED L"\x1b[31m"
#define ANSI_COLOR_GREEN L"\x1b[32m"
#define ANSI_COLOR_YELLOW L"\x1b[33m"
#define ANSI_COLOR_BLUE L"\x1b[34m"
#define ANSI_COLOR_MAGENTA L"\x1b[35m"
#define ANSI_COLOR_CYAN L"\x1b[36m"
#define ANSI_COLOR_RESET L"\x1b[0m"
#define INVITE_TAG L"editor:"
#define ERROR_TAG L"error:"
#define SUCCESS_TAG L"success:"
#define CHECK_WEOS_MISSING \
if (buffer[buffer_position] == WEOS)\
{\
show_message(L"missing arguments", MSG_ERROR);\
return;\
}
#define CHECK_WEOS_UNEXPECTED \
if (buffer[buffer_position] != WEOS)\
{\
show_message(L"unexpected arguments found", MSG_ERROR);\
return;\
}
#define CHECK_WEOS_ESCAPE \
if (buffer[buffer_position] == WEOS)\
{\
show_message(L"escape character \\ must have succeeding character", MSG_ERROR);\
return;\
}
#define CHECK_PARSE_UINT(x) \
if (parse_uint(x) == -1)\
{\
show_message(L"unsigned integers expected as argument", MSG_ERROR);\
return;\
}
void swap_uint(uint *x, uint *y);
uint uint_len(uint x);
#define MSG_NOMODE 0
#define MSG_ERROR 1
#define MSG_SUCCESS 2
void show_message(const wchar_t *msg, int mode);
/*
* for interactive mode
*/
struct termios old_termios;
void set_noncanon_nonecho();
void unset_noncanon_nonecho();
#define KEY_LEFTARROW 1
#define KEY_RIGHTARROW 2
#define KEY_UPARROW 3
#define KEY_DOWNARROW 4
#define KEY_SPACE 5
#define KEY_Q 6
#define KEY_OTHER 7
int read_interactive_keypress();
#define BE_SUCCESS 0
#define BE_WRONGBALANCE 1
int bracets_eraser(line *from, uint range, line **res, uint *res_size, line **res_end);
int print_line_interactive(wchar_t *wstring, uint start_position, uint symbols_limit,
uint offset,
char wrapped,
uint number);
/*
* non-wrap version
* with < > ^ v SPACE
*/
void print_range_interactive_nonwrap(instance *inst, const uint from, const uint to);
void print_range_interactive_wrap(instance *inst, const uint from, const uint to);
/*
* Commands for text viewing
*/
void set_tabwidth_handler(instance *inst);
void set_numbers_handler(instance *inst);
void print_range_handler(instance *inst);
void set_wrap_handler(instance *inst);
/*
* Commands for pasting strings
*/
void insert_after_handler(instance *inst);
/*
* Commands for editing strings
*/
void edit_string_handler(instance *inst);
void insert_symbol_handler(instance *inst);
void replace_substring_handler(instance *inst);
void delete_range_handler(instance *inst);
void delete_braces_handler(instance *inst);
/*
* etc
*/
int exit_handler(instance *inst);
void read_open_handler(instance **inst, const char remember_association);
void write_handler(instance *inst);
void set_name_handler(instance *inst);
#endif