Mercurial > vim
comparison src/ops.c @ 14019:dc67449d648c v8.1.0027
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
commit https://github.com/vim/vim/commit/f273245f6433d5d43a5671306b520a3230c35787
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 3 14:47:35 2018 +0200
patch 8.1.0027: difficult to make a plugin that feeds a line to a job
Problem: Difficult to make a plugin that feeds a line to a job.
Solution: Add the nitial code for the "prompt" buftype.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 03 Jun 2018 15:00:07 +0200 |
parents | e124262d435e |
children | 2ad722003b36 |
comparison
equal
deleted
inserted
replaced
14018:c3064aaf53fb | 14019:dc67449d648c |
---|---|
124 static int fmt_check_par(linenr_T, int *, char_u **, int do_comments); | 124 static int fmt_check_par(linenr_T, int *, char_u **, int do_comments); |
125 #else | 125 #else |
126 static int fmt_check_par(linenr_T); | 126 static int fmt_check_par(linenr_T); |
127 #endif | 127 #endif |
128 | 128 |
129 // Flags for third item in "opchars". | |
130 #define OPF_LINES 1 // operator always works on lines | |
131 #define OPF_CHANGE 2 // operator changes text | |
132 | |
129 /* | 133 /* |
130 * The names of operators. | 134 * The names of operators. |
131 * IMPORTANT: Index must correspond with defines in vim.h!!! | 135 * IMPORTANT: Index must correspond with defines in vim.h!!! |
132 * The third field indicates whether the operator always works on lines. | 136 * The third field holds OPF_ flags. |
133 */ | 137 */ |
134 static char opchars[][3] = | 138 static char opchars[][3] = |
135 { | 139 { |
136 {NUL, NUL, FALSE}, /* OP_NOP */ | 140 {NUL, NUL, 0}, // OP_NOP |
137 {'d', NUL, FALSE}, /* OP_DELETE */ | 141 {'d', NUL, OPF_CHANGE}, // OP_DELETE |
138 {'y', NUL, FALSE}, /* OP_YANK */ | 142 {'y', NUL, 0}, // OP_YANK |
139 {'c', NUL, FALSE}, /* OP_CHANGE */ | 143 {'c', NUL, OPF_CHANGE}, // OP_CHANGE |
140 {'<', NUL, TRUE}, /* OP_LSHIFT */ | 144 {'<', NUL, OPF_LINES | OPF_CHANGE}, // OP_LSHIFT |
141 {'>', NUL, TRUE}, /* OP_RSHIFT */ | 145 {'>', NUL, OPF_LINES | OPF_CHANGE}, // OP_RSHIFT |
142 {'!', NUL, TRUE}, /* OP_FILTER */ | 146 {'!', NUL, OPF_LINES | OPF_CHANGE}, // OP_FILTER |
143 {'g', '~', FALSE}, /* OP_TILDE */ | 147 {'g', '~', OPF_CHANGE}, // OP_TILDE |
144 {'=', NUL, TRUE}, /* OP_INDENT */ | 148 {'=', NUL, OPF_LINES | OPF_CHANGE}, // OP_INDENT |
145 {'g', 'q', TRUE}, /* OP_FORMAT */ | 149 {'g', 'q', OPF_LINES | OPF_CHANGE}, // OP_FORMAT |
146 {':', NUL, TRUE}, /* OP_COLON */ | 150 {':', NUL, OPF_LINES}, // OP_COLON |
147 {'g', 'U', FALSE}, /* OP_UPPER */ | 151 {'g', 'U', OPF_CHANGE}, // OP_UPPER |
148 {'g', 'u', FALSE}, /* OP_LOWER */ | 152 {'g', 'u', OPF_CHANGE}, // OP_LOWER |
149 {'J', NUL, TRUE}, /* DO_JOIN */ | 153 {'J', NUL, OPF_LINES | OPF_CHANGE}, // DO_JOIN |
150 {'g', 'J', TRUE}, /* DO_JOIN_NS */ | 154 {'g', 'J', OPF_LINES | OPF_CHANGE}, // DO_JOIN_NS |
151 {'g', '?', FALSE}, /* OP_ROT13 */ | 155 {'g', '?', OPF_CHANGE}, // OP_ROT13 |
152 {'r', NUL, FALSE}, /* OP_REPLACE */ | 156 {'r', NUL, OPF_CHANGE}, // OP_REPLACE |
153 {'I', NUL, FALSE}, /* OP_INSERT */ | 157 {'I', NUL, OPF_CHANGE}, // OP_INSERT |
154 {'A', NUL, FALSE}, /* OP_APPEND */ | 158 {'A', NUL, OPF_CHANGE}, // OP_APPEND |
155 {'z', 'f', TRUE}, /* OP_FOLD */ | 159 {'z', 'f', OPF_LINES}, // OP_FOLD |
156 {'z', 'o', TRUE}, /* OP_FOLDOPEN */ | 160 {'z', 'o', OPF_LINES}, // OP_FOLDOPEN |
157 {'z', 'O', TRUE}, /* OP_FOLDOPENREC */ | 161 {'z', 'O', OPF_LINES}, // OP_FOLDOPENREC |
158 {'z', 'c', TRUE}, /* OP_FOLDCLOSE */ | 162 {'z', 'c', OPF_LINES}, // OP_FOLDCLOSE |
159 {'z', 'C', TRUE}, /* OP_FOLDCLOSEREC */ | 163 {'z', 'C', OPF_LINES}, // OP_FOLDCLOSEREC |
160 {'z', 'd', TRUE}, /* OP_FOLDDEL */ | 164 {'z', 'd', OPF_LINES}, // OP_FOLDDEL |
161 {'z', 'D', TRUE}, /* OP_FOLDDELREC */ | 165 {'z', 'D', OPF_LINES}, // OP_FOLDDELREC |
162 {'g', 'w', TRUE}, /* OP_FORMAT2 */ | 166 {'g', 'w', OPF_LINES | OPF_CHANGE}, // OP_FORMAT2 |
163 {'g', '@', FALSE}, /* OP_FUNCTION */ | 167 {'g', '@', OPF_CHANGE}, // OP_FUNCTION |
164 {Ctrl_A, NUL, FALSE}, /* OP_NR_ADD */ | 168 {Ctrl_A, NUL, OPF_CHANGE}, // OP_NR_ADD |
165 {Ctrl_X, NUL, FALSE}, /* OP_NR_SUB */ | 169 {Ctrl_X, NUL, OPF_CHANGE}, // OP_NR_SUB |
166 }; | 170 }; |
167 | 171 |
168 /* | 172 /* |
169 * Translate a command name into an operator type. | 173 * Translate a command name into an operator type. |
170 * Must only be called with a valid operator name! | 174 * Must only be called with a valid operator name! |
199 * Return TRUE if operator "op" always works on whole lines. | 203 * Return TRUE if operator "op" always works on whole lines. |
200 */ | 204 */ |
201 int | 205 int |
202 op_on_lines(int op) | 206 op_on_lines(int op) |
203 { | 207 { |
204 return opchars[op][2]; | 208 return opchars[op][2] & OPF_LINES; |
209 } | |
210 | |
211 /* | |
212 * Return TRUE if operator "op" changes text. | |
213 */ | |
214 int | |
215 op_is_change(int op) | |
216 { | |
217 return opchars[op][2] & OPF_CHANGE; | |
205 } | 218 } |
206 | 219 |
207 /* | 220 /* |
208 * Get first operator command character. | 221 * Get first operator command character. |
209 * Returns 'g' or 'z' if there is another command character. | 222 * Returns 'g' or 'z' if there is another command character. |