Mercurial > vim
comparison src/register.c @ 18454:b912277e3877 v8.1.2221
patch 8.1.2221: cannot filter :disp output
Commit: https://github.com/vim/vim/commit/8fc42964363087025a27e8c80276c706536fc4e3
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Oct 26 17:33:13 2019 +0200
patch 8.1.2221: cannot filter :disp output
Problem: Cannot filter :disp output.
Solution: Support filtereing :disp output. (Andi Massimino, closes https://github.com/vim/vim/issues/5117)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 26 Oct 2019 17:45:03 +0200 |
parents | 6ec1bfb4690b |
children | 9e6d5a4abb1c |
comparison
equal
deleted
inserted
replaced
18453:043c07d16d60 | 18454:b912277e3877 |
---|---|
2159 yankreg_T *yb; | 2159 yankreg_T *yb; |
2160 int name; | 2160 int name; |
2161 int attr; | 2161 int attr; |
2162 char_u *arg = eap->arg; | 2162 char_u *arg = eap->arg; |
2163 int clen; | 2163 int clen; |
2164 char_u type[2]; | 2164 int type; |
2165 | 2165 |
2166 if (arg != NULL && *arg == NUL) | 2166 if (arg != NULL && *arg == NUL) |
2167 arg = NULL; | 2167 arg = NULL; |
2168 attr = HL_ATTR(HLF_8); | 2168 attr = HL_ATTR(HLF_8); |
2169 | 2169 |
2172 for (i = -1; i < NUM_REGISTERS && !got_int; ++i) | 2172 for (i = -1; i < NUM_REGISTERS && !got_int; ++i) |
2173 { | 2173 { |
2174 name = get_register_name(i); | 2174 name = get_register_name(i); |
2175 switch (get_reg_type(name, NULL)) | 2175 switch (get_reg_type(name, NULL)) |
2176 { | 2176 { |
2177 case MLINE: type[0] = 'l'; break; | 2177 case MLINE: type = 'l'; break; |
2178 case MCHAR: type[0] = 'c'; break; | 2178 case MCHAR: type = 'c'; break; |
2179 default: type[0] = 'b'; break; | 2179 default: type = 'b'; break; |
2180 } | 2180 } |
2181 if (arg != NULL && vim_strchr(arg, name) == NULL | 2181 if (arg != NULL && vim_strchr(arg, name) == NULL |
2182 #ifdef ONE_CLIPBOARD | 2182 #ifdef ONE_CLIPBOARD |
2183 // Star register and plus register contain the same thing. | 2183 // Star register and plus register contain the same thing. |
2184 && (name != '*' || vim_strchr(arg, '+') == NULL) | 2184 && (name != '*' || vim_strchr(arg, '+') == NULL) |
2211 // pointer can be freed | 2211 // pointer can be freed |
2212 #endif | 2212 #endif |
2213 | 2213 |
2214 if (yb->y_array != NULL) | 2214 if (yb->y_array != NULL) |
2215 { | 2215 { |
2216 msg_putchar('\n'); | 2216 int do_show = FALSE; |
2217 msg_puts(" "); | 2217 |
2218 msg_putchar(type[0]); | 2218 for (j = 0; !do_show && j < yb->y_size; ++j) |
2219 msg_puts(" "); | 2219 do_show = !message_filtered(yb->y_array[j]); |
2220 msg_putchar('"'); | 2220 |
2221 msg_putchar(name); | 2221 if (do_show || yb->y_size == 0) |
2222 msg_puts(" "); | |
2223 | |
2224 n = (int)Columns - 11; | |
2225 for (j = 0; j < yb->y_size && n > 1; ++j) | |
2226 { | 2222 { |
2227 if (j) | 2223 msg_putchar('\n'); |
2224 msg_puts(" "); | |
2225 msg_putchar(type); | |
2226 msg_puts(" "); | |
2227 msg_putchar('"'); | |
2228 msg_putchar(name); | |
2229 msg_puts(" "); | |
2230 | |
2231 n = (int)Columns - 11; | |
2232 for (j = 0; j < yb->y_size && n > 1; ++j) | |
2228 { | 2233 { |
2234 if (j) | |
2235 { | |
2236 msg_puts_attr("^J", attr); | |
2237 n -= 2; | |
2238 } | |
2239 for (p = yb->y_array[j]; *p && (n -= ptr2cells(p)) >= 0; | |
2240 ++p) | |
2241 { | |
2242 clen = (*mb_ptr2len)(p); | |
2243 msg_outtrans_len(p, clen); | |
2244 p += clen - 1; | |
2245 } | |
2246 } | |
2247 if (n > 1 && yb->y_type == MLINE) | |
2229 msg_puts_attr("^J", attr); | 2248 msg_puts_attr("^J", attr); |
2230 n -= 2; | 2249 out_flush(); // show one line at a time |
2231 } | |
2232 for (p = yb->y_array[j]; *p && (n -= ptr2cells(p)) >= 0; ++p) | |
2233 { | |
2234 clen = (*mb_ptr2len)(p); | |
2235 msg_outtrans_len(p, clen); | |
2236 p += clen - 1; | |
2237 } | |
2238 } | 2250 } |
2239 if (n > 1 && yb->y_type == MLINE) | 2251 ui_breakcheck(); |
2240 msg_puts_attr("^J", attr); | 2252 } |
2241 out_flush(); // show one line at a time | |
2242 } | |
2243 ui_breakcheck(); | |
2244 } | 2253 } |
2245 | 2254 |
2246 // display last inserted text | 2255 // display last inserted text |
2247 if ((p = get_last_insert()) != NULL | 2256 if ((p = get_last_insert()) != NULL |
2248 && (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int) | 2257 && (arg == NULL || vim_strchr(arg, '.') != NULL) && !got_int |
2258 && !message_filtered(p)) | |
2249 { | 2259 { |
2250 msg_puts("\n c \". "); | 2260 msg_puts("\n c \". "); |
2251 dis_msg(p, TRUE); | 2261 dis_msg(p, TRUE); |
2252 } | 2262 } |
2253 | 2263 |
2254 // display last command line | 2264 // display last command line |
2255 if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL) | 2265 if (last_cmdline != NULL && (arg == NULL || vim_strchr(arg, ':') != NULL) |
2256 && !got_int) | 2266 && !got_int && !message_filtered(last_cmdline)) |
2257 { | 2267 { |
2258 msg_puts("\n c \": "); | 2268 msg_puts("\n c \": "); |
2259 dis_msg(last_cmdline, FALSE); | 2269 dis_msg(last_cmdline, FALSE); |
2260 } | 2270 } |
2261 | 2271 |
2262 // display current file name | 2272 // display current file name |
2263 if (curbuf->b_fname != NULL | 2273 if (curbuf->b_fname != NULL |
2264 && (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int) | 2274 && (arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int |
2275 && !message_filtered(curbuf->b_fname)) | |
2265 { | 2276 { |
2266 msg_puts("\n c \"% "); | 2277 msg_puts("\n c \"% "); |
2267 dis_msg(curbuf->b_fname, FALSE); | 2278 dis_msg(curbuf->b_fname, FALSE); |
2268 } | 2279 } |
2269 | 2280 |
2271 if ((arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int) | 2282 if ((arg == NULL || vim_strchr(arg, '%') != NULL) && !got_int) |
2272 { | 2283 { |
2273 char_u *fname; | 2284 char_u *fname; |
2274 linenr_T dummy; | 2285 linenr_T dummy; |
2275 | 2286 |
2276 if (buflist_name_nr(0, &fname, &dummy) != FAIL) | 2287 if (buflist_name_nr(0, &fname, &dummy) != FAIL |
2288 && !message_filtered(fname)) | |
2277 { | 2289 { |
2278 msg_puts("\n c \"# "); | 2290 msg_puts("\n c \"# "); |
2279 dis_msg(fname, FALSE); | 2291 dis_msg(fname, FALSE); |
2280 } | 2292 } |
2281 } | 2293 } |
2282 | 2294 |
2283 // display last search pattern | 2295 // display last search pattern |
2284 if (last_search_pat() != NULL | 2296 if (last_search_pat() != NULL |
2285 && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int) | 2297 && (arg == NULL || vim_strchr(arg, '/') != NULL) && !got_int |
2298 && !message_filtered(last_search_pat())) | |
2286 { | 2299 { |
2287 msg_puts("\n c \"/ "); | 2300 msg_puts("\n c \"/ "); |
2288 dis_msg(last_search_pat(), FALSE); | 2301 dis_msg(last_search_pat(), FALSE); |
2289 } | 2302 } |
2290 | 2303 |
2291 #ifdef FEAT_EVAL | 2304 #ifdef FEAT_EVAL |
2292 // display last used expression | 2305 // display last used expression |
2293 if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL) | 2306 if (expr_line != NULL && (arg == NULL || vim_strchr(arg, '=') != NULL) |
2294 && !got_int) | 2307 && !got_int && !message_filtered(expr_line)) |
2295 { | 2308 { |
2296 msg_puts("\n c \"= "); | 2309 msg_puts("\n c \"= "); |
2297 dis_msg(expr_line, FALSE); | 2310 dis_msg(expr_line, FALSE); |
2298 } | 2311 } |
2299 #endif | 2312 #endif |