Mercurial > vim
annotate src/evalbuffer.c @ 26125:18114bb393e0 v8.2.3595
patch 8.2.3595: check for signed overflow might not work everywhere
Commit: https://github.com/vim/vim/commit/0d5a12ea041c112b06b1aafde38846ae4cff8f4c
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 14 14:05:18 2021 +0000
patch 8.2.3595: check for signed overflow might not work everywhere
Problem: Check for signed overflow might not work everywhere.
Solution: Limit to 32 bit int. (closes https://github.com/vim/vim/issues/9043, closes https://github.com/vim/vim/issues/9067)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Nov 2021 15:15:03 +0100 |
parents | 634aed775408 |
children | 13ba00ef7687 |
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 typval_T tv; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 for (lnr = bp->b_listener; !abort && lnr != NULL; lnr = lnr->lr_next) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 if (lnr->lr_callback.cb_partial != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 tv.v_type = VAR_PARTIAL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 tv.vval.v_partial = lnr->lr_callback.cb_partial; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 # ifdef FEAT_JOB_CHANNEL |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 if (!abort && bp->b_prompt_callback.cb_partial != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 tv.v_type = VAR_PARTIAL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 tv.vval.v_partial = bp->b_prompt_callback.cb_partial; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 if (!abort && bp->b_prompt_interrupt.cb_partial != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 tv.v_type = VAR_PARTIAL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 tv.vval.v_partial = bp->b_prompt_interrupt.cb_partial; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); |
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 # endif |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 if (abort) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 break; |
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 return abort; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 buf_T * |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 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
|
62 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 int save_magic; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 char_u *save_cpo; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 buf_T *buf; |
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 // 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
|
68 save_magic = p_magic; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 p_magic = TRUE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 save_cpo = p_cpo; |
23493
f8382c4e6551
patch 8.2.2289: Vim9: 'cpo' can become empty
Bram Moolenaar <Bram@vim.org>
parents:
23456
diff
changeset
|
71 p_cpo = empty_option; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 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
|
74 TRUE, FALSE, curtab_only)); |
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 p_magic = save_magic; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 p_cpo = save_cpo; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 return buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 } |
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 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 * 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
|
83 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 buf_T * |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 find_buffer(typval_T *avar) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 buf_T *buf = 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 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
|
90 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
|
91 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
|
92 return NULL; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 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
|
94 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 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
|
96 if (buf == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 // 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
|
99 // 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
|
100 FOR_ALL_BUFFERS(buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 if (buf->b_fname != NULL |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 && (path_with_url(buf->b_fname) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 #ifdef FEAT_QUICKFIX |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 || bt_nofilename(buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 #endif |
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 && 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
|
108 break; |
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 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 return buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 } |
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 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 * 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
|
116 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 static void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 find_win_for_curbuf(void) |
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 wininfo_T *wip; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19564
diff
changeset
|
122 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
|
123 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 if (wip->wi_win != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 curwin = wip->wi_win; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 /* |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
133 * 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
|
134 * 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
|
135 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 static void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 set_buffer_lines( |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 buf_T *buf, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 linenr_T lnum_arg, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 int append, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 typval_T *lines, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 typval_T *rettv) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 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
|
145 char_u *line = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 list_T *l = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 listitem_T *li = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 long added = 0; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 linenr_T append_lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 buf_T *curbuf_save = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 win_T *curwin_save = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 int is_curbuf = buf == curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 // 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
|
155 // 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
|
156 // loaded. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 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
|
158 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 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
|
160 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 if (!is_curbuf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 curbuf_save = curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 curwin_save = curwin; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 curbuf = buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 find_win_for_curbuf(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 if (append) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 // 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
|
173 append_lnum = lnum - 1; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 // 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
|
176 // 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
|
177 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
|
178 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 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
|
180 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 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
|
182 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
|
183 { |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
184 // set proper return code |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
185 if (lnum > curbuf->b_ml.ml_line_count) |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
186 rettv->vval.v_number = 1; // FAIL |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
187 goto done; |
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
188 } |
20392
4c317d8c1051
patch 8.2.0751: Vim9: performance can be improved
Bram Moolenaar <Bram@vim.org>
parents:
20120
diff
changeset
|
189 CHECK_LIST_MATERIALIZE(l); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 li = l->lv_first; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 else |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
193 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
|
194 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 // default result is zero == OK |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 for (;;) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 if (l != NULL) |
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 // list argument, get next string |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 if (li == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 break; |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
203 vim_free(line); |
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
204 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
|
205 li = li->li_next; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 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
|
209 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
|
210 break; |
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 // 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
|
213 // 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
|
214 if (u_sync_once == 2) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 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
|
217 u_sync(TRUE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 } |
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 (!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
|
221 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 // Existing line, replace it. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 // Removes any existing text properties. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 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
|
225 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
|
226 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 changed_bytes(lnum, 0); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
228 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
|
229 check_cursor_col(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 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
|
231 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 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
|
234 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 // append the line |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 ++added; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 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
|
238 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
|
239 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 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
|
242 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 ++lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 } |
23788
d12ef361d9de
patch 8.2.2435: setline() gives an error for some types
Bram Moolenaar <Bram@vim.org>
parents:
23493
diff
changeset
|
245 vim_free(line); |
18010
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 if (added > 0) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 win_T *wp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 tabpage_T *tp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 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
|
253 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 // 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
|
255 // 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
|
256 // done in mark_adjust_internal(). |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 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
|
258 if (wp->w_buffer == buf |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 && (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
|
260 && 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
|
261 wp->w_cursor.lnum += added; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 check_cursor_col(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 update_topline(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 |
20120
16460964c304
patch 8.2.0615: regexp benchmark stest is old style
Bram Moolenaar <Bram@vim.org>
parents:
19888
diff
changeset
|
266 done: |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 if (!is_curbuf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 curbuf = curbuf_save; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 curwin = curwin_save; |
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 } |
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 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 * "append(lnum, string/list)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 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
|
279 { |
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
|
280 linenr_T lnum; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 |
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
|
282 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
|
283 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
|
284 |
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
|
285 lnum = tv_get_lnum(&argvars[0]); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 set_buffer_lines(curbuf, lnum, TRUE, &argvars[1], rettv); |
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 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 /* |
25431
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
290 * 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
|
291 */ |
25431
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
292 static void |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
293 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
|
294 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 linenr_T lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 |
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
|
298 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
|
299 && (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
|
300 || 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
|
301 || 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
|
302 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
|
303 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 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
|
305 if (buf == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 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
|
307 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 lnum = tv_get_lnum_buf(&argvars[1], buf); |
25431
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
310 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
|
311 } |
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 /* |
25431
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
315 * "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
|
316 */ |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
317 void |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
318 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
|
319 { |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
320 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
|
321 } |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
322 |
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
323 /* |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 * "bufadd(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 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
|
328 { |
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
|
329 char_u *name; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 |
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
|
331 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
|
332 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
|
333 |
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
|
334 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
|
335 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
|
336 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 * "bufexists(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 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
|
343 { |
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
|
344 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
|
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 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
|
348 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 * "buflisted(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 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
|
355 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 |
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
|
358 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
|
359 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
|
360 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 buf = find_buffer(&argvars[0]); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 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
|
363 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 * "bufload(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 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
|
370 { |
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
|
371 buf_T *buf; |
18010
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 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
|
374 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
|
375 |
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 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
|
377 if (buf != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 buffer_ensure_loaded(buf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 } |
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 * "bufloaded(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 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
|
386 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 |
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
|
389 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
|
390 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
|
391 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 buf = find_buffer(&argvars[0]); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 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
|
394 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 |
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 * "bufname(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 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
|
401 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 buf_T *buf; |
22002
c9517003821d
patch 8.2.1550: Vim9: bufname('%') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21855
diff
changeset
|
403 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
|
404 |
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
|
405 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
|
406 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
|
407 |
22002
c9517003821d
patch 8.2.1550: Vim9: bufname('%') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
21855
diff
changeset
|
408 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
|
409 buf = curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 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
|
411 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
|
412 rettv->v_type = VAR_STRING; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 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
|
414 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
|
415 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 rettv->vval.v_string = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 * "bufnr(expr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 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
|
424 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 int error = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 char_u *name; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
428 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
429 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
|
430 && (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
|
431 || (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
|
432 && 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
|
433 return; |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
434 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
435 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
|
436 buf = curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
437 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
|
438 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
|
439 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
440 // 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
|
441 // new buffer. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 if (buf == NULL |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 && 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
|
444 && 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
|
445 && !error |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 && (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
|
447 && !error) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 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
|
449 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 if (buf != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 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
|
452 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 rettv->vval.v_number = -1; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 static void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 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
|
458 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 win_T *wp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 int winnr = 0; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
461 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 |
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
|
463 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
|
464 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
|
465 |
22025
71f886a48ef5
patch 8.2.1562: Vim9: error when using "%" where a buffer is expected
Bram Moolenaar <Bram@vim.org>
parents:
22002
diff
changeset
|
466 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
|
467 FOR_ALL_WINDOWS(wp) |
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 ++winnr; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 if (wp->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 break; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 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
|
474 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 * "bufwinid(nr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
479 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 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
|
481 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 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
|
483 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 * "bufwinnr(nr)" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 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
|
490 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 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
|
492 } |
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 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 * "deletebufline()" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 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
|
499 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 linenr_T first, last; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 linenr_T lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
503 long count; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
504 int is_curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 buf_T *curbuf_save = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 win_T *curwin_save = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 tabpage_T *tp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
508 win_T *wp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
510 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
|
511 && (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
|
512 || 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
|
513 || 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
|
514 return; |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
515 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 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
|
517 if (buf == NULL) |
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 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
|
520 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 is_curbuf = buf == curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 first = tv_get_lnum_buf(&argvars[1], buf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 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
|
526 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
|
527 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 last = first; |
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 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
|
531 || 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
|
532 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 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
|
534 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 } |
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 if (!is_curbuf) |
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 curbuf_save = curbuf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 curwin_save = curwin; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 curbuf = buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 find_win_for_curbuf(); |
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 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
|
545 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
|
546 count = last - first + 1; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 // 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
|
549 // 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
|
550 if (u_sync_once == 2) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 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
|
553 u_sync(TRUE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 if (u_save(first - 1, last + 1) == FAIL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 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
|
559 } |
23893
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
560 else |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
561 { |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
562 for (lnum = first; lnum <= last; ++lnum) |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
563 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
|
564 |
23893
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
565 FOR_ALL_TAB_WINDOWS(tp, wp) |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
566 if (wp->w_buffer == buf) |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
567 { |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
568 if (wp->w_cursor.lnum > last) |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
569 wp->w_cursor.lnum -= count; |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
570 else if (wp->w_cursor.lnum> first) |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
571 wp->w_cursor.lnum = first; |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
572 if (wp->w_cursor.lnum > wp->w_buffer->b_ml.ml_line_count) |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
573 wp->w_cursor.lnum = wp->w_buffer->b_ml.ml_line_count; |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
574 } |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
575 check_cursor_col(); |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
576 deleted_lines_mark(first, count); |
a433d0070c45
patch 8.2.2489: current buffer is wrong after deletebufline() fails
Bram Moolenaar <Bram@vim.org>
parents:
23788
diff
changeset
|
577 } |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 if (!is_curbuf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 curbuf = curbuf_save; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 curwin = curwin_save; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 * 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
|
588 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 static dict_T * |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 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
|
591 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 dict_T *dict; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 tabpage_T *tp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 win_T *wp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 list_T *windows; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 dict = dict_alloc(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 if (dict == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 return NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 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
|
602 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
|
603 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
|
604 : 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
|
605 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
|
606 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
|
607 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
|
608 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
|
609 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
|
610 dict_add_number(dict, "hidden", |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 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
|
612 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 // 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
|
614 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
|
615 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 // 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
|
617 windows = list_alloc(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 if (windows != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 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
|
621 if (wp->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 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
|
623 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
|
624 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 |
18763
49b78d6465e5
patch 8.1.2371: FEAT_TEXT_PROP is a confusing name
Bram Moolenaar <Bram@vim.org>
parents:
18463
diff
changeset
|
626 #ifdef FEAT_PROP_POPUP |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 // 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
|
628 windows = list_alloc(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 if (windows != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 { |
19888
435726a03481
patch 8.2.0500: using the same loop in many places
Bram Moolenaar <Bram@vim.org>
parents:
19564
diff
changeset
|
631 FOR_ALL_POPUPWINS(wp) |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 if (wp->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 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
|
634 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
|
635 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
|
636 if (wp->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 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
|
638 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 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
|
640 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 #endif |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 #ifdef FEAT_SIGNS |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 if (buf->b_signlist != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 // 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
|
647 list_T *signs = list_alloc(); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 if (signs != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 get_buffer_signs(buf, signs); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 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
|
652 } |
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 #endif |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 |
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
|
656 #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
|
657 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
|
658 #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
|
659 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 return dict; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 } |
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 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 * "getbufinfo()" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 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
|
668 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 buf_T *buf = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 buf_T *argbuf = NULL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 dict_T *d; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 int filtered = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 int sel_buflisted = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 int sel_bufloaded = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 int sel_bufmodified = FALSE; |
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 if (rettv_list_alloc(rettv) != OK) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 |
25314
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
680 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
|
681 && 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
|
682 return; |
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
683 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 // 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
|
685 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
|
686 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 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
|
688 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 if (sel_d != NULL) |
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 filtered = TRUE; |
22105
bae2a3fa141f
patch 8.2.1602: Vim9: cannot use 'true" with getbufinfo()
Bram Moolenaar <Bram@vim.org>
parents:
22081
diff
changeset
|
692 sel_buflisted = dict_get_bool(sel_d, (char_u *)"buflisted", FALSE); |
bae2a3fa141f
patch 8.2.1602: Vim9: cannot use 'true" with getbufinfo()
Bram Moolenaar <Bram@vim.org>
parents:
22081
diff
changeset
|
693 sel_bufloaded = dict_get_bool(sel_d, (char_u *)"bufloaded", FALSE); |
bae2a3fa141f
patch 8.2.1602: Vim9: cannot use 'true" with getbufinfo()
Bram Moolenaar <Bram@vim.org>
parents:
22081
diff
changeset
|
694 sel_bufmodified = dict_get_bool(sel_d, (char_u *)"bufmodified", |
bae2a3fa141f
patch 8.2.1602: Vim9: cannot use 'true" with getbufinfo()
Bram Moolenaar <Bram@vim.org>
parents:
22081
diff
changeset
|
695 FALSE); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 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
|
699 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 // 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
|
701 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
|
702 if (argbuf == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 // 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
|
707 FOR_ALL_BUFFERS(buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 if (argbuf != NULL && argbuf != buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 continue; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 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
|
712 || (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
|
713 || (sel_bufmodified && !buf->b_changed))) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 continue; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 d = get_buffer_info(buf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 if (d != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 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
|
719 if (argbuf != NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
721 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 |
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 * 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
|
726 * 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
|
727 * buffer. |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 * 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
|
729 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 static void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 get_buffer_lines( |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
732 buf_T *buf, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 linenr_T start, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 linenr_T end, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 int retlist, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 typval_T *rettv) |
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 char_u *p; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 |
19181
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
740 if (retlist) |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
741 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
742 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
|
743 return; |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
744 } |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
745 else |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
746 { |
94eda51ba9ba
patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
18916
diff
changeset
|
747 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
|
748 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
|
749 } |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 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
|
752 return; |
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 if (!retlist) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 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
|
757 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
|
758 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 p = (char_u *)""; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 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
|
761 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 if (end < start) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 return; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 if (start < 1) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 start = 1; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 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
|
770 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
|
771 while (start <= end) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 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
|
773 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
|
774 break; |
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 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 * "getbufline()" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 f_getbufline(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
|
783 { |
22679
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
784 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
|
785 linenr_T end = 1; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 buf_T *buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
788 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
|
789 && (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
|
790 || 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
|
791 || 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
|
792 return; |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24248
diff
changeset
|
793 |
22025
71f886a48ef5
patch 8.2.1562: Vim9: error when using "%" where a buffer is expected
Bram Moolenaar <Bram@vim.org>
parents:
22002
diff
changeset
|
794 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
|
795 if (buf != NULL) |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
796 { |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
797 lnum = tv_get_lnum_buf(&argvars[1], buf); |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
798 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
|
799 end = lnum; |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
800 else |
9fa3f92248f6
patch 8.2.1888: Vim9: getbufline(-1, 1, '$') gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22105
diff
changeset
|
801 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
|
802 } |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 get_buffer_lines(buf, lnum, end, TRUE, rettv); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 |
19564
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
807 type_T * |
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
808 ret_f_getline(int argcount, type_T **argtypes UNUSED) |
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
809 { |
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
810 return argcount == 1 ? &t_string : &t_list_string; |
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
811 } |
06f29b6ea04a
patch 8.2.0339: Vim9: function return type may depend on arguments
Bram Moolenaar <Bram@vim.org>
parents:
19181
diff
changeset
|
812 |
18010
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 * "getline(lnum, [end])" function |
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 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 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
|
818 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 linenr_T lnum; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 linenr_T end; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 int retlist; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 |
25314
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
823 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
|
824 && (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
|
825 || 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
|
826 return; |
7e620652bd13
patch 8.2.3194: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25302
diff
changeset
|
827 |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 lnum = tv_get_lnum(argvars); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 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
|
830 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 end = 0; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 retlist = FALSE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
833 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 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
|
837 retlist = TRUE; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 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
|
841 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 * "setbufline()" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 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
|
848 { |
25431
634aed775408
patch 8.2.3252: duplicated code for adding buffer lines
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
849 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
|
850 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 * "setline()" function |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 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
|
857 { |
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
|
858 linenr_T lnum; |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 |
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
|
860 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
|
861 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
|
862 |
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
|
863 lnum = tv_get_lnum(&argvars[0]); |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 set_buffer_lines(curbuf, lnum, FALSE, &argvars[1], rettv); |
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 #endif // FEAT_EVAL |
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 #if defined(FEAT_JOB_CHANNEL) \ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 || defined(PROTO) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 * 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
|
873 * 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
|
874 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 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
|
877 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 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
|
879 #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
|
880 ++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
|
881 #endif |
18010
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 set_bufref(save_curbuf, curbuf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 --curbuf->b_nwindows; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 curbuf = buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 curwin->w_buffer = buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 ++curbuf->b_nwindows; |
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 |
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 * 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
|
891 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 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
|
894 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 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
|
896 #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
|
897 --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
|
898 #endif |
18777
3a68dc2a1bc1
patch 8.1.2378: using old C style comments
Bram Moolenaar <Bram@vim.org>
parents:
18763
diff
changeset
|
899 // 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
|
900 if (bufref_valid(save_curbuf)) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
901 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
902 --curbuf->b_nwindows; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
903 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
|
904 curbuf = save_curbuf->br_buf; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 ++curbuf->b_nwindows; |
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 } |
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 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 * 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
|
911 * 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
|
912 * 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
|
913 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 static int |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 find_win_for_buf( |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 buf_T *buf, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 win_T **wp, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 tabpage_T **tp) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 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
|
921 if ((*wp)->w_buffer == buf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 return OK; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 return FAIL; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 } |
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 /* |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 * 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
|
928 * 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
|
929 * 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
|
930 * 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
|
931 */ |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 switch_to_win_for_buf( |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 buf_T *buf, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 win_T **save_curwinp, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 tabpage_T **save_curtabp, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 bufref_T *save_curbuf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 win_T *wp; |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 tabpage_T *tp; |
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 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
|
943 switch_buffer(save_curbuf, buf); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 else if (switch_win(save_curwinp, save_curtabp, wp, tp, TRUE) == FAIL) |
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 restore_win(*save_curwinp, *save_curtabp, TRUE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 switch_buffer(save_curbuf, buf); |
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 } |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 void |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 restore_win_for_buf( |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 win_T *save_curwin, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 tabpage_T *save_curtab, |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 bufref_T *save_curbuf) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 { |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 if (save_curbuf->br_buf == NULL) |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 restore_win(save_curwin, save_curtab, TRUE); |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 else |
cf8e0c7e0cb9
patch 8.1.2001: some source files are too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 restore_buffer(save_curbuf); |
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 #endif |