Mercurial > vim
annotate src/evalbuffer.c @ 31253:0257c9dedf56 v9.0.0960
patch 9.0.0960: error when using the "Spelling / Find More Languages" menu
Commit: https://github.com/vim/vim/commit/502e91756e99181d5fe668fad2e868dc7f3f4fea
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 27 16:18:33 2022 +0000
patch 9.0.0960: error when using the "Spelling / Find More Languages" menu
Problem: Error when using the "Tools / Spelling / Find More Languages"
menu.
Solution: Remove "<SID>". Reset "g:menutrans_set_lang_to" when 'encoding'
changes. (closes #11625)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 27 Nov 2022 17:30:03 +0100 |
parents | 7831da568864 |
children | 87ff5e71d3c2 |
rev | line source |
---|---|
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 * See README.txt for an overview of the Vim source code. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 * evalbuffer.c: Buffer related builtin functions |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 #include "vim.h" |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 #if defined(FEAT_EVAL) || defined(PROTO) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 * Mark references in functions of buffers. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 int |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 set_ref_in_buffers(int copyID) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 int abort = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 buf_T *bp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 FOR_ALL_BUFFERS(bp) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 listener_T *lnr; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 for (lnr = bp->b_listener; !abort && lnr != NULL; lnr = lnr->lr_next) |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
31 abort = abort || set_ref_in_callback(&lnr->lr_callback, copyID); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 # ifdef FEAT_JOB_CHANNEL |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
33 if (!abort) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
34 abort = abort || set_ref_in_callback(&bp->b_prompt_callback, copyID); |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
35 if (!abort) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
36 abort = abort || set_ref_in_callback(&bp->b_prompt_interrupt, copyID); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 # endif |
26518
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
38 #ifdef FEAT_COMPL_FUNC |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
39 if (!abort) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
40 abort = abort || set_ref_in_callback(&bp->b_cfu_cb, copyID); |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
41 if (!abort) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
42 abort = abort || set_ref_in_callback(&bp->b_ofu_cb, copyID); |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
43 if (!abort) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
44 abort = abort || set_ref_in_callback(&bp->b_tsrfu_cb, copyID); |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
45 #endif |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
46 if (!abort) |
13ba00ef7687
patch 8.2.3788: lambda for option that is a function may be freed
Bram Moolenaar <Bram@vim.org>
parents:
25431
diff
changeset
|
47 abort = abort || set_ref_in_callback(&bp->b_tfu_cb, copyID); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 if (abort) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 return abort; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 buf_T * |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 buflist_find_by_name(char_u *name, int curtab_only) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 int save_magic; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 char_u *save_cpo; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 // Ignore 'magic' and 'cpoptions' here to make scripts portable |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 save_magic = p_magic; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 p_magic = TRUE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 save_cpo = p_cpo; |
23493
f8382c4e6551
patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents:
23456
diff
changeset
|
65 p_cpo = empty_option; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 buf = buflist_findnr(buflist_findpat(name, name + STRLEN(name), |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 TRUE, FALSE, curtab_only)); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 p_magic = save_magic; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 p_cpo = save_cpo; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 return buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 * Find a buffer by number or exact name. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 buf_T * |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 find_buffer(typval_T *avar) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 buf_T *buf = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 if (avar->v_type == VAR_NUMBER) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 buf = buflist_findnr((int)avar->vval.v_number); |
24248
883d7ceffd97
patch 8.2.2665: test failures
Bram Moolenaar <Bram@vim.org>
parents:
23893
diff
changeset
|
85 else if (in_vim9script() && check_for_string_arg(avar, 0) == FAIL) |
883d7ceffd97
patch 8.2.2665: test failures
Bram Moolenaar <Bram@vim.org>
parents:
23893
diff
changeset
|
86 return NULL; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 else if (avar->v_type == VAR_STRING && avar->vval.v_string != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 buf = buflist_findname_exp(avar->vval.v_string); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 if (buf == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 // No full path name match, try a match with a URL or a "nofile" |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 // buffer, these don't use the full path. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 FOR_ALL_BUFFERS(buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 if (buf->b_fname != NULL |
29849
6c7eddcce52c
patch 9.0.0263: too many #ifdefs
Bram Moolenaar <Bram@vim.org>
parents:
29442
diff
changeset
|
96 && (path_with_url(buf->b_fname) || bt_nofilename(buf)) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 && STRCMP(buf->b_fname, avar->vval.v_string) == 0) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 return buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 * If there is a window for "curbuf", make it the current window. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 static void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 find_win_for_curbuf(void) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 wininfo_T *wip; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19564
diff
changeset
|
112 FOR_ALL_BUF_WININFO(curbuf, wip) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 if (wip->wi_win != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 curwin = wip->wi_win; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 |
31160
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
122 typedef struct { |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
123 win_T *cob_curwin_save; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
124 aco_save_T cob_aco; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
125 int cob_using_aco; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
126 int cob_save_VIsual_active; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
127 } cob_T; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
128 |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
129 /* |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
130 * Used before making a change in "buf", which is not the current one: Make |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
131 * "buf" the current buffer and find a window for this buffer, so that side |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
132 * effects are done correctly (e.g., adjusting marks). |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
133 * |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
134 * Information is saved in "cob" and MUST be restored by calling |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
135 * change_other_buffer_restore(). |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
136 */ |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
137 static void |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
138 change_other_buffer_prepare(cob_T *cob, buf_T *buf) |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
139 { |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
140 CLEAR_POINTER(cob); |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
141 |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
142 // Set "curbuf" to the buffer being changed. Then make sure there is a |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
143 // window for it to handle any side effects. |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
144 cob->cob_save_VIsual_active = VIsual_active; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
145 VIsual_active = FALSE; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
146 cob->cob_curwin_save = curwin; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
147 curbuf = buf; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
148 find_win_for_curbuf(); // simplest: find existing window for "buf" |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
149 |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
150 if (curwin->w_buffer != buf) |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
151 { |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
152 // No existing window for this buffer. It is dangerous to have |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
153 // curwin->w_buffer differ from "curbuf", use the autocmd window. |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
154 curbuf = curwin->w_buffer; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
155 aucmd_prepbuf(&cob->cob_aco, buf); |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
156 cob->cob_using_aco = TRUE; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
157 } |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
158 } |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
159 |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
160 static void |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
161 change_other_buffer_restore(cob_T *cob) |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
162 { |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
163 if (cob->cob_using_aco) |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
164 { |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
165 aucmd_restbuf(&cob->cob_aco); |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
166 } |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
167 else |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
168 { |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
169 curwin = cob->cob_curwin_save; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
170 curbuf = curwin->w_buffer; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
171 } |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
172 VIsual_active = cob->cob_save_VIsual_active; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
173 } |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
174 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 /* |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
176 * Set line or list of lines in buffer "buf" to "lines". |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
177 * Any type is allowed and converted to a string. |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 static void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 set_buffer_lines( |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 buf_T *buf, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 linenr_T lnum_arg, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 int append, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 typval_T *lines, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 linenr_T lnum = lnum_arg + (append ? 1 : 0); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 char_u *line = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 list_T *l = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 listitem_T *li = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 long added = 0; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 linenr_T append_lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 // When using the current buffer ml_mfp will be set if needed. Useful when |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 // setline() is used on startup. For other buffers the buffer must be |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 // loaded. |
31152
ac6f5741b155
patch 9.0.0910: setting lines in another buffer may not work well
Bram Moolenaar <Bram@vim.org>
parents:
31012
diff
changeset
|
197 int is_curbuf = buf == curbuf; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 if (buf == NULL || (!is_curbuf && buf->b_ml.ml_mfp == NULL) || lnum < 1) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 rettv->vval.v_number = 1; // FAIL |
26775
2df40c348c70
patch 8.2.3916: no error for passing an invalid line number to append()
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
201 if (in_vim9script() && lnum < 1) |
2df40c348c70
patch 8.2.3916: no error for passing an invalid line number to append()
Bram Moolenaar <Bram@vim.org>
parents:
26518
diff
changeset
|
202 semsg(_(e_invalid_line_number_nr), lnum_arg); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 |
31160
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
206 // After this don't use "return", goto "cleanup"! |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
207 cob_T cob; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 if (!is_curbuf) |
31160
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
209 // set "curbuf" to "buf" and find a window for this buffer |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
210 change_other_buffer_prepare(&cob, buf); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 if (append) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 // appendbufline() uses the line number below which we insert |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 append_lnum = lnum - 1; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 // setbufline() uses the line number above which we insert, we only |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 // append if it's below the last line |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 append_lnum = curbuf->b_ml.ml_line_count; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 if (lines->v_type == VAR_LIST) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 l = lines->vval.v_list; |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
223 if (l == NULL || list_len(l) == 0) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
224 { |
31004
eb145a4d6bf8
patch 9.0.0837: append() reports failure when not appending anything
Bram Moolenaar <Bram@vim.org>
parents:
30950
diff
changeset
|
225 // not appending anything always succeeds |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
226 goto done; |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
227 } |
20392
4c317d8c1051
patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
228 CHECK_LIST_MATERIALIZE(l); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
229 li = l->lv_first; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 else |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
232 line = typval_tostring(lines, FALSE); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 // default result is zero == OK |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 for (;;) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 if (l != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 // list argument, get next string |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 if (li == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 break; |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
242 vim_free(line); |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
243 line = typval_tostring(&li->li_tv, FALSE); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 li = li->li_next; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 rettv->vval.v_number = 1; // FAIL |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 if (line == NULL || lnum > curbuf->b_ml.ml_line_count + 1) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 // When coming here from Insert mode, sync undo, so that this can be |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 // undone separately from what was previously inserted. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 if (u_sync_once == 2) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 u_sync_once = 1; // notify that u_sync() was called |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 u_sync(TRUE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 if (!append && lnum <= curbuf->b_ml.ml_line_count) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 // Existing line, replace it. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 // Removes any existing text properties. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 if (u_savesub(lnum) == OK && ml_replace_len( |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 lnum, line, (colnr_T)STRLEN(line) + 1, TRUE, TRUE) == OK) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 changed_bytes(lnum, 0); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 if (is_curbuf && lnum == curwin->w_cursor.lnum) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 check_cursor_col(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 rettv->vval.v_number = 0; // OK |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 else if (added > 0 || u_save(lnum - 1, lnum) == OK) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 // append the line |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 ++added; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 if (ml_append(lnum - 1, line, (colnr_T)0, FALSE) == OK) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 rettv->vval.v_number = 0; // OK |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 if (l == NULL) // only one string argument |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 ++lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 } |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
284 vim_free(line); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 if (added > 0) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 win_T *wp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 tabpage_T *tp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 appended_lines_mark(append_lnum, added); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 // Only adjust the cursor for buffers other than the current, unless it |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 // is the current window. For curbuf and other windows it has been |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 // done in mark_adjust_internal(). |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 FOR_ALL_TAB_WINDOWS(tp, wp) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 if (wp->w_buffer == buf |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 && (wp->w_buffer != curbuf || wp == curwin) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 && wp->w_cursor.lnum > append_lnum) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 wp->w_cursor.lnum += added; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 check_cursor_col(); |
30160
fbf6084346cc
patch 9.0.0416: ml_get error when appending lines in popup window
Bram Moolenaar <Bram@vim.org>
parents:
29849
diff
changeset
|
302 |
fbf6084346cc
patch 9.0.0416: ml_get error when appending lines in popup window
Bram Moolenaar <Bram@vim.org>
parents:
29849
diff
changeset
|
303 // Only update the window view if w_buffer matches curbuf, otherwise |
fbf6084346cc
patch 9.0.0416: ml_get error when appending lines in popup window
Bram Moolenaar <Bram@vim.org>
parents:
29849
diff
changeset
|
304 // the computations will be wrong. |
fbf6084346cc
patch 9.0.0416: ml_get error when appending lines in popup window
Bram Moolenaar <Bram@vim.org>
parents:
29849
diff
changeset
|
305 if (curwin->w_buffer == curbuf) |
fbf6084346cc
patch 9.0.0416: ml_get error when appending lines in popup window
Bram Moolenaar <Bram@vim.org>
parents:
29849
diff
changeset
|
306 update_topline(); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
309 done: |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 if (!is_curbuf) |
31160
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
311 change_other_buffer_restore(&cob); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 * "append(lnum, string/list)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 f_append(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
320 linenr_T lnum; |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
321 int did_emsg_before = did_emsg; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
323 if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
324 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
325 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
326 lnum = tv_get_lnum(&argvars[0]); |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
327 if (did_emsg == did_emsg_before) |
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
328 set_buffer_lines(curbuf, lnum, TRUE, &argvars[1], rettv); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 /* |
25431
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
332 * Set or append lines to a buffer. |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 */ |
25431
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
334 static void |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
335 buf_set_append_line(typval_T *argvars, typval_T *rettv, int append) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 linenr_T lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 buf_T *buf; |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
339 int did_emsg_before = did_emsg; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
341 if (in_vim9script() |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
342 && (check_for_buffer_arg(argvars, 0) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
343 || check_for_lnum_arg(argvars, 1) == FAIL |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
344 || check_for_string_or_number_or_list_arg(argvars, 2) == FAIL)) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
345 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
346 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 buf = tv_get_buf(&argvars[0], FALSE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 if (buf == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 rettv->vval.v_number = 1; // FAIL |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 lnum = tv_get_lnum_buf(&argvars[1], buf); |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
353 if (did_emsg == did_emsg_before) |
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
354 set_buffer_lines(buf, lnum, append, &argvars[2], rettv); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 /* |
25431
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
359 * "appendbufline(buf, lnum, string/list)" function |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
360 */ |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
361 void |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
362 f_appendbufline(typval_T *argvars, typval_T *rettv) |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
363 { |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
364 buf_set_append_line(argvars, rettv, TRUE); |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
365 } |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
366 |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
367 /* |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 * "bufadd(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 f_bufadd(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
373 char_u *name; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
375 if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
376 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
377 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
378 name = tv_get_string(&argvars[0]); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 rettv->vval.v_number = buflist_add(*name == NUL ? NULL : name, 0); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 * "bufexists(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 f_bufexists(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
388 if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
389 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
390 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 rettv->vval.v_number = (find_buffer(&argvars[0]) != NULL); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 * "buflisted(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 f_buflisted(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
402 if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
403 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
404 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 buf = find_buffer(&argvars[0]); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 rettv->vval.v_number = (buf != NULL && buf->b_p_bl); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 * "bufload(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 f_bufload(typval_T *argvars, typval_T *rettv UNUSED) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
415 buf_T *buf; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
417 if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
418 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
419 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
420 buf = get_buf_arg(&argvars[0]); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 if (buf != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 buffer_ensure_loaded(buf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 * "bufloaded(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
429 f_bufloaded(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
433 if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
434 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
435 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
436 buf = find_buffer(&argvars[0]); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 rettv->vval.v_number = (buf != NULL && buf->b_ml.ml_mfp != NULL); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
438 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
439 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 * "bufname(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 f_bufname(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 buf_T *buf; |
22002
c9517003821d
patch 8.2.1550: Vim9: bufname('%') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21855
diff
changeset
|
447 typval_T *tv = &argvars[0]; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
449 if (in_vim9script() && check_for_opt_buffer_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
450 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
451 |
22002
c9517003821d
patch 8.2.1550: Vim9: bufname('%') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21855
diff
changeset
|
452 if (tv->v_type == VAR_UNKNOWN) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 buf = curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 else |
22025
71f886a48ef5
patch 8.2.1562: Vim9: error when using "%" where a buffer is expected
Bram Moolenaar <Bram@vim.org>
parents:
22002
diff
changeset
|
455 buf = tv_get_buf_from_arg(tv); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 rettv->v_type = VAR_STRING; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 if (buf != NULL && buf->b_fname != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 rettv->vval.v_string = vim_strsave(buf->b_fname); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 rettv->vval.v_string = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 * "bufnr(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 f_bufnr(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 int error = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 char_u *name; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
473 if (in_vim9script() |
25314
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
474 && (check_for_opt_buffer_arg(argvars, 0) == FAIL |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
475 || (argvars[0].v_type != VAR_UNKNOWN |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
476 && check_for_opt_bool_arg(argvars, 1) == FAIL))) |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
477 return; |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
478 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 if (argvars[0].v_type == VAR_UNKNOWN) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 buf = curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 else |
22025
71f886a48ef5
patch 8.2.1562: Vim9: error when using "%" where a buffer is expected
Bram Moolenaar <Bram@vim.org>
parents:
22002
diff
changeset
|
482 buf = tv_get_buf_from_arg(&argvars[0]); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 // If the buffer isn't found and the second argument is not zero create a |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 // new buffer. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 if (buf == NULL |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 && argvars[1].v_type != VAR_UNKNOWN |
22081
2b9a2bc77b42
patch 8.2.1590: Vim9: bufnr() doesn't take "true" argument
Bram Moolenaar <Bram@vim.org>
parents:
22025
diff
changeset
|
488 && tv_get_bool_chk(&argvars[1], &error) != 0 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 && !error |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 && (name = tv_get_string_chk(&argvars[0])) != NULL |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 && !error) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 buf = buflist_new(name, NULL, (linenr_T)1, 0); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
493 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
494 if (buf != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 rettv->vval.v_number = buf->b_fnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 rettv->vval.v_number = -1; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 static void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 buf_win_common(typval_T *argvars, typval_T *rettv, int get_nr) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
503 win_T *wp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
504 int winnr = 0; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
507 if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
508 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
509 |
22025
71f886a48ef5
patch 8.2.1562: Vim9: error when using "%" where a buffer is expected
Bram Moolenaar <Bram@vim.org>
parents:
22002
diff
changeset
|
510 buf = tv_get_buf_from_arg(&argvars[0]); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 FOR_ALL_WINDOWS(wp) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 ++winnr; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 if (wp->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 rettv->vval.v_number = (wp != NULL ? (get_nr ? winnr : wp->w_id) : -1); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 * "bufwinid(nr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 f_bufwinid(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 buf_win_common(argvars, rettv, FALSE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 * "bufwinnr(nr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 f_bufwinnr(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 buf_win_common(argvars, rettv, TRUE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 * "deletebufline()" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 f_deletebufline(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 linenr_T first, last; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 linenr_T lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 long count; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 int is_curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 tabpage_T *tp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 win_T *wp; |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
551 int did_emsg_before = did_emsg; |
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
552 |
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
553 rettv->vval.v_number = 1; // FAIL by default |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
555 if (in_vim9script() |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
556 && (check_for_buffer_arg(argvars, 0) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
557 || check_for_lnum_arg(argvars, 1) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
558 || check_for_opt_lnum_arg(argvars, 2) == FAIL)) |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
559 return; |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
560 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 buf = tv_get_buf(&argvars[0], FALSE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 if (buf == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 first = tv_get_lnum_buf(&argvars[1], buf); |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
566 if (did_emsg > did_emsg_before) |
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
567 return; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 if (argvars[2].v_type != VAR_UNKNOWN) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 last = tv_get_lnum_buf(&argvars[2], buf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 last = first; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
572 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 if (buf->b_ml.ml_mfp == NULL || first < 1 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 || first > buf->b_ml.ml_line_count || last < first) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 |
31012
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
577 // After this don't use "return", goto "cleanup"! |
31160
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
578 is_curbuf = buf == curbuf; |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
579 cob_T cob; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 if (!is_curbuf) |
31160
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
581 // set "curbuf" to "buf" and find a window for this buffer |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
582 change_other_buffer_prepare(&cob, buf); |
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
583 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 if (last > curbuf->b_ml.ml_line_count) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 last = curbuf->b_ml.ml_line_count; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 count = last - first + 1; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 // When coming here from Insert mode, sync undo, so that this can be |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 // undone separately from what was previously inserted. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 if (u_sync_once == 2) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 u_sync_once = 1; // notify that u_sync() was called |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 u_sync(TRUE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 if (u_save(first - 1, last + 1) == FAIL) |
31012
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
597 goto cleanup; |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
598 |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
599 for (lnum = first; lnum <= last; ++lnum) |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
600 ml_delete_flags(first, ML_DEL_MESSAGE); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 |
31012
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
602 FOR_ALL_TAB_WINDOWS(tp, wp) |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
603 if (wp->w_buffer == buf) |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
604 { |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
605 if (wp->w_cursor.lnum > last) |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
606 wp->w_cursor.lnum -= count; |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
607 else if (wp->w_cursor.lnum > first) |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
608 wp->w_cursor.lnum = first; |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
609 if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count) |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
610 wp->w_cursor.lnum = wp->w_buffer->b_ml.ml_line_count; |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
611 wp->w_valid = 0; |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
612 if (wp->w_cursor.lnum <= wp->w_topline) |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
613 wp->w_topline = 1; |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
614 } |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
615 check_cursor_col(); |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
616 deleted_lines_mark(first, count); |
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
617 rettv->vval.v_number = 0; // OK |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 |
31012
4ba2890de10d
patch 9.0.0841: deletebufline() does not always return 1 on failure
Bram Moolenaar <Bram@vim.org>
parents:
31004
diff
changeset
|
619 cleanup: |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 if (!is_curbuf) |
31160
eff0d98467e3
patch 9.0.0914: deletebufline() may move marks in the wrong window
Bram Moolenaar <Bram@vim.org>
parents:
31152
diff
changeset
|
621 change_other_buffer_restore(&cob); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 * Returns buffer options, variables and other attributes in a dictionary. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 static dict_T * |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 get_buffer_info(buf_T *buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 dict_T *dict; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 tabpage_T *tp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 win_T *wp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 list_T *windows; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 dict = dict_alloc(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 if (dict == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 return NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 dict_add_number(dict, "bufnr", buf->b_fnum); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 dict_add_string(dict, "name", buf->b_ffname); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 dict_add_number(dict, "lnum", buf == curbuf ? curwin->w_cursor.lnum |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 : buflist_findlnum(buf)); |
18916
cf051bdefb3f
patch 8.2.0019: cannot number of lines of another buffer
Bram Moolenaar <Bram@vim.org>
parents:
18777
diff
changeset
|
643 dict_add_number(dict, "linecount", buf->b_ml.ml_line_count); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 dict_add_number(dict, "loaded", buf->b_ml.ml_mfp != NULL); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 dict_add_number(dict, "listed", buf->b_p_bl); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 dict_add_number(dict, "changed", bufIsChanged(buf)); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 dict_add_number(dict, "changedtick", CHANGEDTICK(buf)); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 dict_add_number(dict, "hidden", |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 buf->b_ml.ml_mfp != NULL && buf->b_nwindows == 0); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 // Get a reference to buffer variables |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
652 dict_add_dict(dict, "variables", buf->b_vars); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 // List of windows displaying this buffer |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 windows = list_alloc(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 if (windows != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 FOR_ALL_TAB_WINDOWS(tp, wp) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 if (wp->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 list_append_number(windows, (varnumber_T)wp->w_id); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 dict_add_list(dict, "windows", windows); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
664 #ifdef FEAT_PROP_POPUP |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 // List of popup windows displaying this buffer |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 windows = list_alloc(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 if (windows != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 { |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19564
diff
changeset
|
669 FOR_ALL_POPUPWINS(wp) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 if (wp->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 list_append_number(windows, (varnumber_T)wp->w_id); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 FOR_ALL_TABPAGES(tp) |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19564
diff
changeset
|
673 FOR_ALL_POPUPWINS_IN_TAB(tp, wp) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 if (wp->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 list_append_number(windows, (varnumber_T)wp->w_id); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 dict_add_list(dict, "popups", windows); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 #endif |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 #ifdef FEAT_SIGNS |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 if (buf->b_signlist != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 // List of signs placed in this buffer |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 list_T *signs = list_alloc(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 if (signs != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 get_buffer_signs(buf, signs); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 dict_add_list(dict, "signs", signs); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 #endif |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 |
18463
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
694 #ifdef FEAT_VIMINFO |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
695 dict_add_number(dict, "lastused", buf->b_last_used); |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
696 #endif |
18d7337b6837
patch 8.1.2225: the "last used" info of a buffer is under used
Bram Moolenaar <Bram@vim.org>
parents:
18010
diff
changeset
|
697 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 return dict; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 * "getbufinfo()" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 f_getbufinfo(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 buf_T *buf = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 buf_T *argbuf = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 dict_T *d; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 int filtered = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 int sel_buflisted = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 int sel_bufloaded = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 int sel_bufmodified = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 |
29175
755ab148288b
patch 8.2.5107: some callers of rettv_list_alloc() check for not OK
Bram Moolenaar <Bram@vim.org>
parents:
28960
diff
changeset
|
715 if (rettv_list_alloc(rettv) == FAIL) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 |
25314
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
718 if (in_vim9script() |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
719 && check_for_opt_buffer_or_dict_arg(argvars, 0) == FAIL) |
25314
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
720 return; |
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
721 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 // List of all the buffers or selected buffers |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 if (argvars[0].v_type == VAR_DICT) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 dict_T *sel_d = argvars[0].vval.v_dict; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 if (sel_d != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 filtered = TRUE; |
29442
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
730 sel_buflisted = dict_get_bool(sel_d, "buflisted", FALSE); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
731 sel_bufloaded = dict_get_bool(sel_d, "bufloaded", FALSE); |
827d9f2b7a71
patch 9.0.0063: too many type casts for dict_get functions
Bram Moolenaar <Bram@vim.org>
parents:
29175
diff
changeset
|
732 sel_bufmodified = dict_get_bool(sel_d, "bufmodified", |
22105
bae2a3fa141f
patch 8.2.1602: Vim9: cannot use 'true" with getbufinfo()
Bram Moolenaar <Bram@vim.org>
parents:
22081
diff
changeset
|
733 FALSE); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 else if (argvars[0].v_type != VAR_UNKNOWN) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 // Information about one buffer. Argument specifies the buffer |
22025
71f886a48ef5
patch 8.2.1562: Vim9: error when using "%" where a buffer is expected
Bram Moolenaar <Bram@vim.org>
parents:
22002
diff
changeset
|
739 argbuf = tv_get_buf_from_arg(&argvars[0]); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 if (argbuf == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 // Return information about all the buffers or a specified buffer |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 FOR_ALL_BUFFERS(buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 if (argbuf != NULL && argbuf != buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 continue; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 if (filtered && ((sel_bufloaded && buf->b_ml.ml_mfp == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 || (sel_buflisted && !buf->b_p_bl) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 || (sel_bufmodified && !buf->b_changed))) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
752 continue; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 d = get_buffer_info(buf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 if (d != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 list_append_dict(rettv->vval.v_list, d); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 if (argbuf != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 * Get line or list of lines from buffer "buf" into "rettv". |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 * Return a range (from start to end) of lines in rettv from the specified |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 * buffer. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 * If 'retlist' is TRUE, then the lines are returned as a Vim List. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 static void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 get_buffer_lines( |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 buf_T *buf, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 linenr_T start, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 linenr_T end, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 int retlist, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 char_u *p; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
778 if (retlist) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
779 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
780 if (rettv_list_alloc(rettv) == FAIL) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
781 return; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
782 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
783 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
784 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
785 rettv->v_type = VAR_STRING; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
786 rettv->vval.v_string = NULL; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
787 } |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 if (!retlist) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 if (start >= 1 && start <= buf->b_ml.ml_line_count) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 p = ml_get_buf(buf, start, FALSE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 p = (char_u *)""; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 rettv->vval.v_string = vim_strsave(p); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 if (end < start) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 if (start < 1) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 start = 1; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 if (end > buf->b_ml.ml_line_count) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 end = buf->b_ml.ml_line_count; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 while (start <= end) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 if (list_append_string(rettv->vval.v_list, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 ml_get_buf(buf, start++, FALSE), -1) == FAIL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 /* |
31164
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
817 * "retlist" TRUE: "getbufline()" function |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
818 * "retlist" FALSE: "getbufoneline()" function |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 */ |
31164
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
820 static void |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
821 getbufline(typval_T *argvars, typval_T *rettv, int retlist) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 { |
22679
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
823 linenr_T lnum = 1; |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
824 linenr_T end = 1; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 buf_T *buf; |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
826 int did_emsg_before = did_emsg; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
828 if (in_vim9script() |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
829 && (check_for_buffer_arg(argvars, 0) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
830 || check_for_lnum_arg(argvars, 1) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
831 || check_for_opt_lnum_arg(argvars, 2) == FAIL)) |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
832 return; |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
833 |
22025
71f886a48ef5
patch 8.2.1562: Vim9: error when using "%" where a buffer is expected
Bram Moolenaar <Bram@vim.org>
parents:
22002
diff
changeset
|
834 buf = tv_get_buf_from_arg(&argvars[0]); |
22679
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
835 if (buf != NULL) |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
836 { |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
837 lnum = tv_get_lnum_buf(&argvars[1], buf); |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
838 if (did_emsg > did_emsg_before) |
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
839 return; |
22679
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
840 if (argvars[2].v_type == VAR_UNKNOWN) |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
841 end = lnum; |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
842 else |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
843 end = tv_get_lnum_buf(&argvars[2], buf); |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
844 } |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 |
31164
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
846 get_buffer_lines(buf, lnum, end, retlist, rettv); |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
847 } |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
848 |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
849 /* |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
850 * "getbufline()" function |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
851 */ |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
852 void |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
853 f_getbufline(typval_T *argvars, typval_T *rettv) |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
854 { |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
855 getbufline(argvars, rettv, TRUE); |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
856 } |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
857 |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
858 /* |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
859 * "getbufoneline()" function |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
860 */ |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
861 void |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
862 f_getbufoneline(typval_T *argvars, typval_T *rettv) |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
863 { |
7831da568864
patch 9.0.0916: getbufline() is inefficient for getting a single line
Bram Moolenaar <Bram@vim.org>
parents:
31160
diff
changeset
|
864 getbufline(argvars, rettv, FALSE); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 * "getline(lnum, [end])" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 f_getline(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 linenr_T lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 linenr_T end; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 int retlist; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 |
25314
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
877 if (in_vim9script() |
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
878 && (check_for_lnum_arg(argvars, 0) == FAIL |
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
879 || check_for_opt_lnum_arg(argvars, 1) == FAIL)) |
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
880 return; |
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
881 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 lnum = tv_get_lnum(argvars); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 if (argvars[1].v_type == VAR_UNKNOWN) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 end = 0; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 retlist = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 end = tv_get_lnum(&argvars[1]); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 retlist = TRUE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 get_buffer_lines(curbuf, lnum, end, retlist, rettv); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 * "setbufline()" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
900 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 f_setbufline(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 { |
25431
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
903 buf_set_append_line(argvars, rettv, FALSE); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
904 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 * "setline()" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 f_setline(typval_T *argvars, typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
912 linenr_T lnum; |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
913 int did_emsg_before = did_emsg; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
915 if (in_vim9script() && check_for_lnum_arg(argvars, 0) == FAIL) |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
916 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
917 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
918 lnum = tv_get_lnum(&argvars[0]); |
26782
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
919 if (did_emsg == did_emsg_before) |
b7b82279426f
patch 8.2.3919: Vim9: wrong argument for append() results in two errors
Bram Moolenaar <Bram@vim.org>
parents:
26775
diff
changeset
|
920 set_buffer_lines(curbuf, lnum, FALSE, &argvars[1], rettv); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 #endif // FEAT_EVAL |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 |
27018
268f6a3511df
patch 8.2.4038: various code not used when features are disabled
Bram Moolenaar <Bram@vim.org>
parents:
26978
diff
changeset
|
924 #if defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) || defined(PROTO) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 * Make "buf" the current buffer. restore_buffer() MUST be called to undo. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 * No autocommands will be executed. Use aucmd_prepbuf() if there are any. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 switch_buffer(bufref_T *save_curbuf, buf_T *buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 block_autocmds(); |
23456
f6514ca9f45e
patch 8.2.2271: ml_get error when changing hidden buffer in Python
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
933 #ifdef FEAT_FOLDING |
f6514ca9f45e
patch 8.2.2271: ml_get error when changing hidden buffer in Python
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
934 ++disable_fold_update; |
f6514ca9f45e
patch 8.2.2271: ml_get error when changing hidden buffer in Python
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
935 #endif |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 set_bufref(save_curbuf, curbuf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 --curbuf->b_nwindows; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 curbuf = buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 curwin->w_buffer = buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 ++curbuf->b_nwindows; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 * Restore the current buffer after using switch_buffer(). |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 restore_buffer(bufref_T *save_curbuf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 unblock_autocmds(); |
23456
f6514ca9f45e
patch 8.2.2271: ml_get error when changing hidden buffer in Python
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
950 #ifdef FEAT_FOLDING |
f6514ca9f45e
patch 8.2.2271: ml_get error when changing hidden buffer in Python
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
951 --disable_fold_update; |
f6514ca9f45e
patch 8.2.2271: ml_get error when changing hidden buffer in Python
Bram Moolenaar <Bram@vim.org>
parents:
22679
diff
changeset
|
952 #endif |
18777
3a68dc2a1bc1
patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
953 // Check for valid buffer, just in case. |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 if (bufref_valid(save_curbuf)) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 --curbuf->b_nwindows; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 curwin->w_buffer = save_curbuf->br_buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 curbuf = save_curbuf->br_buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 ++curbuf->b_nwindows; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 * Find a window for buffer "buf". |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 * If found OK is returned and "wp" and "tp" are set to the window and tabpage. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 * If not found FAIL is returned. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 static int |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 find_win_for_buf( |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 buf_T *buf, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 win_T **wp, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 tabpage_T **tp) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 FOR_ALL_TAB_WINDOWS(*tp, *wp) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 if ((*wp)->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 return OK; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 return FAIL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 * Find a window that contains "buf" and switch to it. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 * If there is no such window, use the current window and change "curbuf". |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 * Caller must initialize save_curbuf to NULL. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 * restore_win_for_buf() MUST be called later! |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 switch_to_win_for_buf( |
26978
aa613a3084b9
patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
988 buf_T *buf, |
aa613a3084b9
patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
989 switchwin_T *switchwin, |
aa613a3084b9
patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
990 bufref_T *save_curbuf) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 win_T *wp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 tabpage_T *tp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 if (find_win_for_buf(buf, &wp, &tp) == FAIL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 switch_buffer(save_curbuf, buf); |
26978
aa613a3084b9
patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
997 else if (switch_win(switchwin, wp, tp, TRUE) == FAIL) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 { |
26978
aa613a3084b9
patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
999 restore_win(switchwin, TRUE); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 switch_buffer(save_curbuf, buf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 restore_win_for_buf( |
26978
aa613a3084b9
patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
1006 switchwin_T *switchwin, |
aa613a3084b9
patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
1007 bufref_T *save_curbuf) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 if (save_curbuf->br_buf == NULL) |
26978
aa613a3084b9
patch 8.2.4018: ml_get error when win_execute redraws with Visual selection
Bram Moolenaar <Bram@vim.org>
parents:
26935
diff
changeset
|
1010 restore_win(switchwin, TRUE); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 restore_buffer(save_curbuf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 #endif |