-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.h
105 lines (90 loc) · 3.24 KB
/
actions.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
#ifndef ACTIONS_H
#define ACTIONS_H
#include "macro.h"
// All actions and movements
enum { DELETE = 1, INSERT, YANK, PASTE, PASTE_BACKWARD };
enum { FORWARD = 1, BACKWARD, WORD_FORWARD, WORD_BACKWARD,
FIND, FIND_BACKWARD, TILL, TILL_BACKWARD, LINE_START,
LINE_END, SEARCH_FORWARD, SEARCH_BACKWARD, MATCH };
#define MAX_SEARCH_LEN 100
typedef struct {
char text[MAX_SEARCH_LEN];
size_t len;
} SearchText;
typedef struct {
char identifier;
int command;
char arg;
size_t count;
SearchText s_text;
} Movement;
#define MAX_INSERT_LEN 50
typedef struct {
char text[MAX_INSERT_LEN];
size_t len;
} Insert;
typedef struct {
char identifier;
int command;
Movement mov;
Insert ins;
} Action;
// Structure to hold the copied text
// There sould be one yank buffer
#define YANK_BUF_MAX 200
typedef struct {
char buf[YANK_BUF_MAX];
size_t len;
} YankBuffer;
Action process_actions(char *action_str, size_t len);
Line *eval_action_on_line(Line *l, Action *a);
void movement_forward(Line *l, Action *a);
void movement_backward(Line *l, Action *a);
void movement_word_forward(Line *l, Action *a);
void movement_word_backward(Line *l, Action *a);
void movement_line_start(Line *l, Action *a);
void movement_line_end(Line *l, Action *a);
void movement_find(Line *l, Action *a);
void movement_find_backward(Line *l, Action *a);
void movement_till(Line *l, Action *a);
void movement_till_backward(Line *l, Action *a);
void movement_search(Line *l, Action *a);
void movement_search_backward(Line *l, Action *a);
void movement_match_pair(Line *l, Action *a);
void action_delete_word_forward(Line *l, Action *a);
void action_delete_word_backward(Line *l, Action *a);
void action_delete_forward(Line *l, Action *a);
void action_delete_backward(Line *l, Action *a);
void action_delete_to_line_end(Line *l, Action *a);
void action_delete_to_line_start(Line *l, Action *a);
void action_delete_to_find(Line *l, Action *a);
void action_delete_to_find_backward(Line *l, Action *a);
void action_delete_till(Line *l, Action *a);
void action_delete_till_backward(Line *l, Action *a);
void action_delete_search(Line *l, Action *a);
void action_delete_search_backward(Line *l, Action *a);
void action_delete_match_pair(Line *l, Action *a);
void action_insert_at_cursor(Line *l, Action *a);
void action_yank_forward(Line *l, Action *a);
void action_yank_backward(Line *l, Action *a);
void action_yank_word_forward(Line *l, Action *a);
void action_yank_word_backward(Line *l, Action *a);
void action_yank_to_line_start(Line *l, Action *a);
void action_yank_to_line_end(Line *l, Action *a);
void action_yank_to_find(Line *l, Action *a);
void action_yank_to_find_backward(Line *l, Action *a);
void action_yank_till(Line *l, Action *a);
void action_yank_till_backward(Line *l, Action *a);
void action_yank_search(Line *l, Action *a);
void action_yank_search_backward(Line *l, Action *a);
void action_yank_match_pair(Line *l, Action *a);
void action_paste_at_cursor(Line *l, Action *a);
void action_paste_backward_at_cursor(Line *l, Action *a);
bool is_action(char c);
bool is_movement(char c);
int movement_get_value_for_key(char key);
void clear_yank_buffer();
int action_get_value_for_key(char key);
char get_matching_char(char c);
bool is_opening(char c);
#endif