Mercurial > vim
annotate src/job.c @ 26581:8da90cdcec68 v8.2.3820
patch 8.2.3820: "vrc" does not replace composing characters
Commit: https://github.com/vim/vim/commit/8ee6028de3daa9af9e5f90fa9e583ff407bee04f
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Dec 15 21:08:50 2021 +0000
patch 8.2.3820: "vrc" does not replace composing characters
Problem: "vrc" does not replace composing characters, while "rc" does.
Solution: Check the byte length including composing characters.
(closes #9351)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 15 Dec 2021 22:15:18 +0100 |
parents | d413104a94c8 |
children | bce848ec8b1b |
rev | line source |
---|---|
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 * |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 * VIM - Vi IMproved by Bram Moolenaar |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 * |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 * Do ":help uganda" in Vim to read copying and usage conditions. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 * Do ":help credits" in Vim to see a list of people who contributed. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 * Implements starting jobs and controlling them. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
13 #include "vim.h" |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
14 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 #if defined(FEAT_JOB_CHANNEL) || defined(PROTO) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 #define FOR_ALL_JOBS(job) \ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 for ((job) = first_job; (job) != NULL; (job) = (job)->jv_next) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 static int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 handle_mode(typval_T *item, jobopt_T *opt, ch_mode_T *modep, int jo) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 char_u *val = tv_get_string(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 opt->jo_set |= jo; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 if (STRCMP(val, "nl") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
27 *modep = MODE_NL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
28 else if (STRCMP(val, "raw") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 *modep = MODE_RAW; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 else if (STRCMP(val, "js") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 *modep = MODE_JS; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 else if (STRCMP(val, "json") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
33 *modep = MODE_JSON; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
34 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
35 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
36 semsg(_(e_invarg2), val); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
37 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
38 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 return OK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 static int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 handle_io(typval_T *item, ch_part_T part, jobopt_T *opt) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 char_u *val = tv_get_string(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 opt->jo_set |= JO_OUT_IO << (part - PART_OUT); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 if (STRCMP(val, "null") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 opt->jo_io[part] = JIO_NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 else if (STRCMP(val, "pipe") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
51 opt->jo_io[part] = JIO_PIPE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 else if (STRCMP(val, "file") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 opt->jo_io[part] = JIO_FILE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 else if (STRCMP(val, "buffer") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 opt->jo_io[part] = JIO_BUFFER; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 else if (STRCMP(val, "out") == 0 && part == PART_ERR) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 opt->jo_io[part] = JIO_OUT; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 semsg(_(e_invarg2), val); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 return OK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 * Clear a jobopt_T before using it. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 clear_job_options(jobopt_T *opt) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
71 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
72 CLEAR_POINTER(opt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
74 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
76 * Free any members of a jobopt_T. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 free_job_options(jobopt_T *opt) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
80 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 if (opt->jo_callback.cb_partial != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
82 partial_unref(opt->jo_callback.cb_partial); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
83 else if (opt->jo_callback.cb_name != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 func_unref(opt->jo_callback.cb_name); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 if (opt->jo_out_cb.cb_partial != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
86 partial_unref(opt->jo_out_cb.cb_partial); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
87 else if (opt->jo_out_cb.cb_name != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 func_unref(opt->jo_out_cb.cb_name); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 if (opt->jo_err_cb.cb_partial != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
90 partial_unref(opt->jo_err_cb.cb_partial); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 else if (opt->jo_err_cb.cb_name != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
92 func_unref(opt->jo_err_cb.cb_name); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 if (opt->jo_close_cb.cb_partial != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 partial_unref(opt->jo_close_cb.cb_partial); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 else if (opt->jo_close_cb.cb_name != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
96 func_unref(opt->jo_close_cb.cb_name); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 if (opt->jo_exit_cb.cb_partial != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 partial_unref(opt->jo_exit_cb.cb_partial); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
99 else if (opt->jo_exit_cb.cb_name != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
100 func_unref(opt->jo_exit_cb.cb_name); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 if (opt->jo_env != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
102 dict_unref(opt->jo_env); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
103 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 * Get the PART_ number from the first character of an option name. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 static int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 part_from_char(int c) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 return c == 'i' ? PART_IN : c == 'o' ? PART_OUT: PART_ERR; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 * Get the option entries from the dict in "tv", parse them and put the result |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 * in "opt". |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 * Only accept JO_ options in "supported" and JO2_ options in "supported2". |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 * If an option value is invalid return FAIL. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 typval_T *item; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 char_u *val; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 dict_T *dict; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 int todo; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 hashitem_T *hi; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 ch_part_T part; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 if (tv->v_type == VAR_UNKNOWN) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 return OK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 if (tv->v_type != VAR_DICT) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 emsg(_(e_dictreq)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 dict = tv->vval.v_dict; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 if (dict == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 return OK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 todo = (int)dict->dv_hashtab.ht_used; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 if (!HASHITEM_EMPTY(hi)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 item = &dict_lookup(hi)->di_tv; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 if (STRCMP(hi->hi_key, "mode") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 if (!(supported & JO_MODE)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 if (handle_mode(item, opt, &opt->jo_mode, JO_MODE) == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 else if (STRCMP(hi->hi_key, "in_mode") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 if (!(supported & JO_IN_MODE)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 if (handle_mode(item, opt, &opt->jo_in_mode, JO_IN_MODE) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
161 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
162 else if (STRCMP(hi->hi_key, "out_mode") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
163 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
164 if (!(supported & JO_OUT_MODE)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
165 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
166 if (handle_mode(item, opt, &opt->jo_out_mode, JO_OUT_MODE) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
167 == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
168 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
169 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
170 else if (STRCMP(hi->hi_key, "err_mode") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
171 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
172 if (!(supported & JO_ERR_MODE)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
173 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
174 if (handle_mode(item, opt, &opt->jo_err_mode, JO_ERR_MODE) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
175 == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
176 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
177 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
178 else if (STRCMP(hi->hi_key, "noblock") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
179 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
180 if (!(supported & JO_MODE)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
181 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
182 opt->jo_noblock = tv_get_bool(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
183 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
184 else if (STRCMP(hi->hi_key, "in_io") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 || STRCMP(hi->hi_key, "out_io") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 || STRCMP(hi->hi_key, "err_io") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 if (!(supported & JO_OUT_IO)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 if (handle_io(item, part_from_char(*hi->hi_key), opt) == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 else if (STRCMP(hi->hi_key, "in_name") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 || STRCMP(hi->hi_key, "out_name") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 || STRCMP(hi->hi_key, "err_name") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 part = part_from_char(*hi->hi_key); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 if (!(supported & JO_OUT_IO)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 opt->jo_set |= JO_OUT_NAME << (part - PART_OUT); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 opt->jo_io_name[part] = tv_get_string_buf_chk(item, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 opt->jo_io_name_buf[part]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 else if (STRCMP(hi->hi_key, "pty") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 if (!(supported & JO_MODE)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 opt->jo_pty = tv_get_bool(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 else if (STRCMP(hi->hi_key, "in_buf") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 || STRCMP(hi->hi_key, "out_buf") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 || STRCMP(hi->hi_key, "err_buf") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 part = part_from_char(*hi->hi_key); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 if (!(supported & JO_OUT_IO)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 opt->jo_set |= JO_OUT_BUF << (part - PART_OUT); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 opt->jo_io_buf[part] = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
221 if (opt->jo_io_buf[part] <= 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
222 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
223 semsg(_(e_invargNval), hi->hi_key, tv_get_string(item)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
224 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
225 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
226 if (buflist_findnr(opt->jo_io_buf[part]) == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
227 { |
26439
b18f3b0f317c
patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26113
diff
changeset
|
228 semsg(_(e_buffer_nr_does_not_exist), |
b18f3b0f317c
patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26113
diff
changeset
|
229 (long)opt->jo_io_buf[part]); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
230 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
231 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
232 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
233 else if (STRCMP(hi->hi_key, "out_modifiable") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
234 || STRCMP(hi->hi_key, "err_modifiable") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
235 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
236 part = part_from_char(*hi->hi_key); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
237 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
238 if (!(supported & JO_OUT_IO)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
239 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
240 opt->jo_set |= JO_OUT_MODIFIABLE << (part - PART_OUT); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
241 opt->jo_modifiable[part] = tv_get_bool(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
242 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 else if (STRCMP(hi->hi_key, "out_msg") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
244 || STRCMP(hi->hi_key, "err_msg") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
245 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
246 part = part_from_char(*hi->hi_key); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
247 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
248 if (!(supported & JO_OUT_IO)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
249 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
250 opt->jo_set2 |= JO2_OUT_MSG << (part - PART_OUT); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
251 opt->jo_message[part] = tv_get_bool(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
252 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
253 else if (STRCMP(hi->hi_key, "in_top") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
254 || STRCMP(hi->hi_key, "in_bot") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
255 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
256 linenr_T *lp; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
257 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
258 if (!(supported & JO_OUT_IO)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
259 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
260 if (hi->hi_key[3] == 't') |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
261 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
262 lp = &opt->jo_in_top; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
263 opt->jo_set |= JO_IN_TOP; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
264 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
265 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
266 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
267 lp = &opt->jo_in_bot; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
268 opt->jo_set |= JO_IN_BOT; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
269 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
270 *lp = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
271 if (*lp < 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
272 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
273 semsg(_(e_invargNval), hi->hi_key, tv_get_string(item)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
274 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
275 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
276 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
277 else if (STRCMP(hi->hi_key, "channel") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
278 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
279 if (!(supported & JO_OUT_IO)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
280 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
281 opt->jo_set |= JO_CHANNEL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
282 if (item->v_type != VAR_CHANNEL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
283 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
284 semsg(_(e_invargval), "channel"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
285 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
286 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
287 opt->jo_channel = item->vval.v_channel; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
288 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
289 else if (STRCMP(hi->hi_key, "callback") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
290 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
291 if (!(supported & JO_CALLBACK)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
292 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
293 opt->jo_set |= JO_CALLBACK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
294 opt->jo_callback = get_callback(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
295 if (opt->jo_callback.cb_name == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
296 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
297 semsg(_(e_invargval), "callback"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
298 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
299 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
300 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
301 else if (STRCMP(hi->hi_key, "out_cb") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
302 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
303 if (!(supported & JO_OUT_CALLBACK)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
304 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
305 opt->jo_set |= JO_OUT_CALLBACK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
306 opt->jo_out_cb = get_callback(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
307 if (opt->jo_out_cb.cb_name == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
308 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
309 semsg(_(e_invargval), "out_cb"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
310 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
311 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
312 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
313 else if (STRCMP(hi->hi_key, "err_cb") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
314 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
315 if (!(supported & JO_ERR_CALLBACK)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
316 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
317 opt->jo_set |= JO_ERR_CALLBACK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
318 opt->jo_err_cb = get_callback(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
319 if (opt->jo_err_cb.cb_name == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
320 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
321 semsg(_(e_invargval), "err_cb"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
322 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
323 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
324 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
325 else if (STRCMP(hi->hi_key, "close_cb") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
326 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
327 if (!(supported & JO_CLOSE_CALLBACK)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
328 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
329 opt->jo_set |= JO_CLOSE_CALLBACK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
330 opt->jo_close_cb = get_callback(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
331 if (opt->jo_close_cb.cb_name == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
332 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
333 semsg(_(e_invargval), "close_cb"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
334 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
335 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
336 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
337 else if (STRCMP(hi->hi_key, "drop") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
338 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
339 int never = FALSE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
340 val = tv_get_string(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
341 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
342 if (STRCMP(val, "never") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
343 never = TRUE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
344 else if (STRCMP(val, "auto") != 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
345 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
346 semsg(_(e_invargNval), "drop", val); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
347 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
348 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
349 opt->jo_drop_never = never; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
350 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
351 else if (STRCMP(hi->hi_key, "exit_cb") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
352 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
353 if (!(supported & JO_EXIT_CB)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
354 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
355 opt->jo_set |= JO_EXIT_CB; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
356 opt->jo_exit_cb = get_callback(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
357 if (opt->jo_exit_cb.cb_name == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
358 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
359 semsg(_(e_invargval), "exit_cb"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
360 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
361 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
362 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
363 #ifdef FEAT_TERMINAL |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
364 else if (STRCMP(hi->hi_key, "term_name") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
365 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
366 if (!(supported2 & JO2_TERM_NAME)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
367 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
368 opt->jo_set2 |= JO2_TERM_NAME; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
369 opt->jo_term_name = tv_get_string_buf_chk(item, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
370 opt->jo_term_name_buf); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
371 if (opt->jo_term_name == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
372 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
373 semsg(_(e_invargval), "term_name"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
374 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
375 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
376 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
377 else if (STRCMP(hi->hi_key, "term_finish") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
378 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
379 if (!(supported2 & JO2_TERM_FINISH)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
380 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
381 val = tv_get_string(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
382 if (STRCMP(val, "open") != 0 && STRCMP(val, "close") != 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
383 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
384 semsg(_(e_invargNval), "term_finish", val); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
385 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
386 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
387 opt->jo_set2 |= JO2_TERM_FINISH; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
388 opt->jo_term_finish = *val; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
389 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
390 else if (STRCMP(hi->hi_key, "term_opencmd") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
391 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
392 char_u *p; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
393 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
394 if (!(supported2 & JO2_TERM_OPENCMD)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
395 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
396 opt->jo_set2 |= JO2_TERM_OPENCMD; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
397 p = opt->jo_term_opencmd = tv_get_string_buf_chk(item, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
398 opt->jo_term_opencmd_buf); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
399 if (p != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
400 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
401 // Must have %d and no other %. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
402 p = vim_strchr(p, '%'); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
403 if (p != NULL && (p[1] != 'd' |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
404 || vim_strchr(p + 2, '%') != NULL)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
405 p = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
406 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
407 if (p == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
408 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
409 semsg(_(e_invargval), "term_opencmd"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
410 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
411 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
412 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
413 else if (STRCMP(hi->hi_key, "eof_chars") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
414 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
415 if (!(supported2 & JO2_EOF_CHARS)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
416 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
417 opt->jo_set2 |= JO2_EOF_CHARS; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
418 opt->jo_eof_chars = tv_get_string_buf_chk(item, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
419 opt->jo_eof_chars_buf); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
420 if (opt->jo_eof_chars == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
421 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
422 semsg(_(e_invargval), "eof_chars"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
423 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
424 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
425 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
426 else if (STRCMP(hi->hi_key, "term_rows") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
427 { |
26105
fd1cbe72815a
patch 8.2.3585: crash when passing float to "term_rows" of term_start()
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
428 int error = FALSE; |
fd1cbe72815a
patch 8.2.3585: crash when passing float to "term_rows" of term_start()
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
429 |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
430 if (!(supported2 & JO2_TERM_ROWS)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
431 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
432 opt->jo_set2 |= JO2_TERM_ROWS; |
26105
fd1cbe72815a
patch 8.2.3585: crash when passing float to "term_rows" of term_start()
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
433 opt->jo_term_rows = tv_get_number_chk(item, &error); |
fd1cbe72815a
patch 8.2.3585: crash when passing float to "term_rows" of term_start()
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
434 if (error) |
fd1cbe72815a
patch 8.2.3585: crash when passing float to "term_rows" of term_start()
Bram Moolenaar <Bram@vim.org>
parents:
26057
diff
changeset
|
435 return FAIL; |
26113
c421c9599d83
patch 8.2.3589: failure when "term_rows" of term_start() is an unusual value
Bram Moolenaar <Bram@vim.org>
parents:
26105
diff
changeset
|
436 if (opt->jo_term_rows < 0 || opt->jo_term_rows > 1000) |
c421c9599d83
patch 8.2.3589: failure when "term_rows" of term_start() is an unusual value
Bram Moolenaar <Bram@vim.org>
parents:
26105
diff
changeset
|
437 { |
c421c9599d83
patch 8.2.3589: failure when "term_rows" of term_start() is an unusual value
Bram Moolenaar <Bram@vim.org>
parents:
26105
diff
changeset
|
438 semsg(_(e_invargval), "term_rows"); |
c421c9599d83
patch 8.2.3589: failure when "term_rows" of term_start() is an unusual value
Bram Moolenaar <Bram@vim.org>
parents:
26105
diff
changeset
|
439 return FAIL; |
c421c9599d83
patch 8.2.3589: failure when "term_rows" of term_start() is an unusual value
Bram Moolenaar <Bram@vim.org>
parents:
26105
diff
changeset
|
440 } |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
441 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
442 else if (STRCMP(hi->hi_key, "term_cols") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
443 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
444 if (!(supported2 & JO2_TERM_COLS)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
445 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
446 opt->jo_set2 |= JO2_TERM_COLS; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
447 opt->jo_term_cols = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
448 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
449 else if (STRCMP(hi->hi_key, "vertical") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
450 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
451 if (!(supported2 & JO2_VERTICAL)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
452 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
453 opt->jo_set2 |= JO2_VERTICAL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
454 opt->jo_vertical = tv_get_bool(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
455 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
456 else if (STRCMP(hi->hi_key, "curwin") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
457 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
458 if (!(supported2 & JO2_CURWIN)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
459 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
460 opt->jo_set2 |= JO2_CURWIN; |
22155
de47cb7b41e6
patch 8.2.1627: Vim9: cannot pass "true" to submatch/term_gettty/term_start
Bram Moolenaar <Bram@vim.org>
parents:
22095
diff
changeset
|
461 opt->jo_curwin = tv_get_bool(item); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
462 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
463 else if (STRCMP(hi->hi_key, "bufnr") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
464 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
465 int nr; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
466 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
467 if (!(supported2 & JO2_CURWIN)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
468 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
469 opt->jo_set2 |= JO2_BUFNR; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
470 nr = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
471 if (nr <= 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
472 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
473 semsg(_(e_invargNval), hi->hi_key, tv_get_string(item)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
474 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
475 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
476 opt->jo_bufnr_buf = buflist_findnr(nr); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
477 if (opt->jo_bufnr_buf == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
478 { |
26439
b18f3b0f317c
patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26113
diff
changeset
|
479 semsg(_(e_buffer_nr_does_not_exist), (long)nr); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
480 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
481 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
482 if (opt->jo_bufnr_buf->b_nwindows == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
483 || opt->jo_bufnr_buf->b_term == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
484 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
485 semsg(_(e_invarg2), "bufnr"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
486 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
487 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
488 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
489 else if (STRCMP(hi->hi_key, "hidden") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
490 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
491 if (!(supported2 & JO2_HIDDEN)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
492 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
493 opt->jo_set2 |= JO2_HIDDEN; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
494 opt->jo_hidden = tv_get_bool(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
495 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
496 else if (STRCMP(hi->hi_key, "norestore") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
497 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
498 if (!(supported2 & JO2_NORESTORE)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
499 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
500 opt->jo_set2 |= JO2_NORESTORE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
501 opt->jo_term_norestore = tv_get_bool(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
502 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
503 else if (STRCMP(hi->hi_key, "term_kill") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
504 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
505 if (!(supported2 & JO2_TERM_KILL)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
506 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
507 opt->jo_set2 |= JO2_TERM_KILL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
508 opt->jo_term_kill = tv_get_string_buf_chk(item, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
509 opt->jo_term_kill_buf); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
510 if (opt->jo_term_kill == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
511 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
512 semsg(_(e_invargval), "term_kill"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
513 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
514 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
515 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
516 else if (STRCMP(hi->hi_key, "tty_type") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
517 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
518 char_u *p; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
519 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
520 if (!(supported2 & JO2_TTY_TYPE)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
521 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
522 opt->jo_set2 |= JO2_TTY_TYPE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
523 p = tv_get_string_chk(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
524 if (p == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
525 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
526 semsg(_(e_invargval), "tty_type"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
527 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
528 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
529 // Allow empty string, "winpty", "conpty". |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
530 if (!(*p == NUL || STRCMP(p, "winpty") == 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
531 || STRCMP(p, "conpty") == 0)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
532 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
533 semsg(_(e_invargval), "tty_type"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
534 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
535 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
536 opt->jo_tty_type = p[0]; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
537 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
538 # if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
539 else if (STRCMP(hi->hi_key, "ansi_colors") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
540 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
541 int n = 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
542 listitem_T *li; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
543 long_u rgb[16]; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
544 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
545 if (!(supported2 & JO2_ANSI_COLORS)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
546 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
547 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
548 if (item == NULL || item->v_type != VAR_LIST |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
549 || item->vval.v_list == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
550 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
551 semsg(_(e_invargval), "ansi_colors"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
552 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
553 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
554 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
555 CHECK_LIST_MATERIALIZE(item->vval.v_list); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
556 li = item->vval.v_list->lv_first; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
557 for (; li != NULL && n < 16; li = li->li_next, n++) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
558 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
559 char_u *color_name; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
560 guicolor_T guicolor; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
561 int called_emsg_before = called_emsg; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
562 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
563 color_name = tv_get_string_chk(&li->li_tv); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
564 if (color_name == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
565 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
566 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
567 guicolor = GUI_GET_COLOR(color_name); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
568 if (guicolor == INVALCOLOR) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
569 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
570 if (called_emsg_before == called_emsg) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
571 // may not get the error if the GUI didn't start |
26057
92c424550367
patch 8.2.3562: cannot add color names
Bram Moolenaar <Bram@vim.org>
parents:
25686
diff
changeset
|
572 semsg(_(e_cannot_allocate_color_str), color_name); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
573 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
574 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
575 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
576 rgb[n] = GUI_MCH_GET_RGB(guicolor); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
577 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
578 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
579 if (n != 16 || li != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
580 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
581 semsg(_(e_invargval), "ansi_colors"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
582 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
583 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
584 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
585 opt->jo_set2 |= JO2_ANSI_COLORS; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
586 memcpy(opt->jo_ansi_colors, rgb, sizeof(rgb)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
587 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
588 # endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
589 else if (STRCMP(hi->hi_key, "term_highlight") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
590 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
591 char_u *p; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
592 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
593 if (!(supported2 & JO2_TERM_HIGHLIGHT)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
594 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
595 opt->jo_set2 |= JO2_TERM_HIGHLIGHT; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
596 p = tv_get_string_buf_chk(item, opt->jo_term_highlight_buf); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
597 if (p == NULL || *p == NUL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
598 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
599 semsg(_(e_invargval), "term_highlight"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
600 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
601 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
602 opt->jo_term_highlight = p; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
603 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
604 else if (STRCMP(hi->hi_key, "term_api") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
605 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
606 if (!(supported2 & JO2_TERM_API)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
607 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
608 opt->jo_set2 |= JO2_TERM_API; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
609 opt->jo_term_api = tv_get_string_buf_chk(item, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
610 opt->jo_term_api_buf); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
611 if (opt->jo_term_api == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
612 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
613 semsg(_(e_invargval), "term_api"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
614 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
615 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
616 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
617 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
618 else if (STRCMP(hi->hi_key, "env") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
619 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
620 if (!(supported2 & JO2_ENV)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
621 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
622 if (item->v_type != VAR_DICT) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
623 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
624 semsg(_(e_invargval), "env"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
625 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
626 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
627 opt->jo_set2 |= JO2_ENV; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
628 opt->jo_env = item->vval.v_dict; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
629 if (opt->jo_env != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
630 ++opt->jo_env->dv_refcount; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
631 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
632 else if (STRCMP(hi->hi_key, "cwd") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
633 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
634 if (!(supported2 & JO2_CWD)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
635 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
636 opt->jo_cwd = tv_get_string_buf_chk(item, opt->jo_cwd_buf); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
637 if (opt->jo_cwd == NULL || !mch_isdir(opt->jo_cwd) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
638 #ifndef MSWIN // Win32 directories don't have the concept of "executable" |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
639 || mch_access((char *)opt->jo_cwd, X_OK) != 0 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
640 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
641 ) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
642 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
643 semsg(_(e_invargval), "cwd"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
644 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
645 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
646 opt->jo_set2 |= JO2_CWD; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
647 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
648 else if (STRCMP(hi->hi_key, "waittime") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
649 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
650 if (!(supported & JO_WAITTIME)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
651 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
652 opt->jo_set |= JO_WAITTIME; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
653 opt->jo_waittime = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
654 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
655 else if (STRCMP(hi->hi_key, "timeout") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
656 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
657 if (!(supported & JO_TIMEOUT)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
658 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
659 opt->jo_set |= JO_TIMEOUT; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
660 opt->jo_timeout = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
661 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
662 else if (STRCMP(hi->hi_key, "out_timeout") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
663 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
664 if (!(supported & JO_OUT_TIMEOUT)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
665 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
666 opt->jo_set |= JO_OUT_TIMEOUT; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
667 opt->jo_out_timeout = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
668 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
669 else if (STRCMP(hi->hi_key, "err_timeout") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
670 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
671 if (!(supported & JO_ERR_TIMEOUT)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
672 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
673 opt->jo_set |= JO_ERR_TIMEOUT; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
674 opt->jo_err_timeout = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
675 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
676 else if (STRCMP(hi->hi_key, "part") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
677 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
678 if (!(supported & JO_PART)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
679 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
680 opt->jo_set |= JO_PART; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
681 val = tv_get_string(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
682 if (STRCMP(val, "err") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
683 opt->jo_part = PART_ERR; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
684 else if (STRCMP(val, "out") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
685 opt->jo_part = PART_OUT; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
686 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
687 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
688 semsg(_(e_invargNval), "part", val); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
689 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
690 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
691 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
692 else if (STRCMP(hi->hi_key, "id") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
693 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
694 if (!(supported & JO_ID)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
695 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
696 opt->jo_set |= JO_ID; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
697 opt->jo_id = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
698 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
699 else if (STRCMP(hi->hi_key, "stoponexit") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
700 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
701 if (!(supported & JO_STOPONEXIT)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
702 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
703 opt->jo_set |= JO_STOPONEXIT; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
704 opt->jo_stoponexit = tv_get_string_buf_chk(item, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
705 opt->jo_stoponexit_buf); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
706 if (opt->jo_stoponexit == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
707 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
708 semsg(_(e_invargval), "stoponexit"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
709 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
710 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
711 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
712 else if (STRCMP(hi->hi_key, "block_write") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
713 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
714 if (!(supported & JO_BLOCK_WRITE)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
715 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
716 opt->jo_set |= JO_BLOCK_WRITE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
717 opt->jo_block_write = tv_get_number(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
718 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
719 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
720 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
721 --todo; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
722 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
723 if (todo > 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
724 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
725 semsg(_(e_invarg2), hi->hi_key); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
726 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
727 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
728 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
729 return OK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
730 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
731 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
732 static job_T *first_job = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
733 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
734 static void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
735 job_free_contents(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
736 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
737 int i; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
738 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
739 ch_log(job->jv_channel, "Freeing job"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
740 if (job->jv_channel != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
741 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
742 // The link from the channel to the job doesn't count as a reference, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
743 // thus don't decrement the refcount of the job. The reference from |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
744 // the job to the channel does count the reference, decrement it and |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
745 // NULL the reference. We don't set ch_job_killed, unreferencing the |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
746 // job doesn't mean it stops running. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
747 job->jv_channel->ch_job = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
748 channel_unref(job->jv_channel); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
749 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
750 mch_clear_job(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
751 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
752 vim_free(job->jv_tty_in); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
753 vim_free(job->jv_tty_out); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
754 vim_free(job->jv_stoponexit); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
755 #ifdef UNIX |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
756 vim_free(job->jv_termsig); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
757 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
758 #ifdef MSWIN |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
759 vim_free(job->jv_tty_type); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
760 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
761 free_callback(&job->jv_exit_cb); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
762 if (job->jv_argv != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
763 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
764 for (i = 0; job->jv_argv[i] != NULL; i++) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
765 vim_free(job->jv_argv[i]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
766 vim_free(job->jv_argv); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
767 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
768 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
769 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
770 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
771 * Remove "job" from the list of jobs. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
772 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
773 static void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
774 job_unlink(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
775 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
776 if (job->jv_next != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
777 job->jv_next->jv_prev = job->jv_prev; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
778 if (job->jv_prev == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
779 first_job = job->jv_next; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
780 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
781 job->jv_prev->jv_next = job->jv_next; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
782 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
783 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
784 static void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
785 job_free_job(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
786 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
787 job_unlink(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
788 vim_free(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
789 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
790 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
791 static void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
792 job_free(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
793 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
794 if (!in_free_unref_items) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
795 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
796 job_free_contents(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
797 job_free_job(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
798 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
799 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
800 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
801 static job_T *jobs_to_free = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
802 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
803 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
804 * Put "job" in a list to be freed later, when it's no longer referenced. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
805 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
806 static void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
807 job_free_later(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
808 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
809 job_unlink(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
810 job->jv_next = jobs_to_free; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
811 jobs_to_free = job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
812 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
813 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
814 static void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
815 free_jobs_to_free_later(void) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
816 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
817 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
818 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
819 while (jobs_to_free != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
820 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
821 job = jobs_to_free; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
822 jobs_to_free = job->jv_next; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
823 job_free_contents(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
824 vim_free(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
825 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
826 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
827 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
828 #if defined(EXITFREE) || defined(PROTO) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
829 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
830 job_free_all(void) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
831 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
832 while (first_job != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
833 job_free(first_job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
834 free_jobs_to_free_later(); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
835 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
836 # ifdef FEAT_TERMINAL |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
837 free_unused_terminals(); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
838 # endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
839 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
840 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
841 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
842 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
843 * Return TRUE if we need to check if the process of "job" has ended. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
844 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
845 static int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
846 job_need_end_check(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
847 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
848 return job->jv_status == JOB_STARTED |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
849 && (job->jv_stoponexit != NULL || job->jv_exit_cb.cb_name != NULL); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
850 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
851 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
852 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
853 * Return TRUE if the channel of "job" is still useful. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
854 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
855 static int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
856 job_channel_still_useful(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
857 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
858 return job->jv_channel != NULL && channel_still_useful(job->jv_channel); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
859 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
860 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
861 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
862 * Return TRUE if the channel of "job" is closeable. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
863 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
864 static int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
865 job_channel_can_close(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
866 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
867 return job->jv_channel != NULL && channel_can_close(job->jv_channel); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
868 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
869 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
870 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
871 * Return TRUE if the job should not be freed yet. Do not free the job when |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
872 * it has not ended yet and there is a "stoponexit" flag, an exit callback |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
873 * or when the associated channel will do something with the job output. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
874 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
875 static int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
876 job_still_useful(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
877 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
878 return job_need_end_check(job) || job_channel_still_useful(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
879 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
880 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
881 #if defined(GUI_MAY_FORK) || defined(GUI_MAY_SPAWN) || defined(PROTO) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
882 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
883 * Return TRUE when there is any running job that we care about. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
884 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
885 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
886 job_any_running() |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
887 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
888 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
889 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
890 FOR_ALL_JOBS(job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
891 if (job_still_useful(job)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
892 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
893 ch_log(NULL, "GUI not forking because a job is running"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
894 return TRUE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
895 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
896 return FALSE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
897 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
898 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
899 |
23144
de5c000f14c4
patch 8.2.2118: dead code in the job support
Bram Moolenaar <Bram@vim.org>
parents:
22934
diff
changeset
|
900 // Unix uses argv[] for the command, other systems use a string. |
de5c000f14c4
patch 8.2.2118: dead code in the job support
Bram Moolenaar <Bram@vim.org>
parents:
22934
diff
changeset
|
901 #if defined(UNIX) |
de5c000f14c4
patch 8.2.2118: dead code in the job support
Bram Moolenaar <Bram@vim.org>
parents:
22934
diff
changeset
|
902 # define USE_ARGV |
de5c000f14c4
patch 8.2.2118: dead code in the job support
Bram Moolenaar <Bram@vim.org>
parents:
22934
diff
changeset
|
903 #endif |
de5c000f14c4
patch 8.2.2118: dead code in the job support
Bram Moolenaar <Bram@vim.org>
parents:
22934
diff
changeset
|
904 |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
905 #if !defined(USE_ARGV) || defined(PROTO) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
906 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
907 * Escape one argument for an external command. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
908 * Returns the escaped string in allocated memory. NULL when out of memory. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
909 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
910 static char_u * |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
911 win32_escape_arg(char_u *arg) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
912 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
913 int slen, dlen; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
914 int escaping = 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
915 int i; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
916 char_u *s, *d; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
917 char_u *escaped_arg; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
918 int has_spaces = FALSE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
919 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
920 // First count the number of extra bytes required. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
921 slen = (int)STRLEN(arg); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
922 dlen = slen; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
923 for (s = arg; *s != NUL; MB_PTR_ADV(s)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
924 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
925 if (*s == '"' || *s == '\\') |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
926 ++dlen; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
927 if (*s == ' ' || *s == '\t') |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
928 has_spaces = TRUE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
929 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
930 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
931 if (has_spaces) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
932 dlen += 2; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
933 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
934 if (dlen == slen) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
935 return vim_strsave(arg); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
936 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
937 // Allocate memory for the result and fill it. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
938 escaped_arg = alloc(dlen + 1); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
939 if (escaped_arg == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
940 return NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
941 memset(escaped_arg, 0, dlen+1); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
942 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
943 d = escaped_arg; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
944 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
945 if (has_spaces) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
946 *d++ = '"'; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
947 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
948 for (s = arg; *s != NUL;) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
949 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
950 switch (*s) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
951 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
952 case '"': |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
953 for (i = 0; i < escaping; i++) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
954 *d++ = '\\'; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
955 escaping = 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
956 *d++ = '\\'; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
957 *d++ = *s++; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
958 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
959 case '\\': |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
960 escaping++; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
961 *d++ = *s++; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
962 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
963 default: |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
964 escaping = 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
965 MB_COPY_CHAR(s, d); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
966 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
967 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
968 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
969 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
970 // add terminating quote and finish with a NUL |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
971 if (has_spaces) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
972 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
973 for (i = 0; i < escaping; i++) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
974 *d++ = '\\'; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
975 *d++ = '"'; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
976 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
977 *d = NUL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
978 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
979 return escaped_arg; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
980 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
981 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
982 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
983 * Build a command line from a list, taking care of escaping. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
984 * The result is put in gap->ga_data. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
985 * Returns FAIL when out of memory. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
986 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
987 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
988 win32_build_cmd(list_T *l, garray_T *gap) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
989 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
990 listitem_T *li; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
991 char_u *s; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
992 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
993 CHECK_LIST_MATERIALIZE(l); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
994 FOR_ALL_LIST_ITEMS(l, li) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
995 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
996 s = tv_get_string_chk(&li->li_tv); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
997 if (s == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
998 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
999 s = win32_escape_arg(s); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1000 if (s == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1001 return FAIL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1002 ga_concat(gap, s); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1003 vim_free(s); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1004 if (li->li_next != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1005 ga_append(gap, ' '); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1006 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1007 return OK; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1008 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1009 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1010 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1011 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1012 * NOTE: Must call job_cleanup() only once right after the status of "job" |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1013 * changed to JOB_ENDED (i.e. after job_status() returned "dead" first or |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1014 * mch_detect_ended_job() returned non-NULL). |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1015 * If the job is no longer used it will be removed from the list of jobs, and |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1016 * deleted a bit later. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1017 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1018 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1019 job_cleanup(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1020 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1021 if (job->jv_status != JOB_ENDED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1022 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1023 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1024 // Ready to cleanup the job. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1025 job->jv_status = JOB_FINISHED; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1026 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1027 // When only channel-in is kept open, close explicitly. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1028 if (job->jv_channel != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1029 ch_close_part(job->jv_channel, PART_IN); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1030 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1031 if (job->jv_exit_cb.cb_name != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1032 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1033 typval_T argv[3]; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1034 typval_T rettv; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1035 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1036 // Invoke the exit callback. Make sure the refcount is > 0. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1037 ch_log(job->jv_channel, "Invoking exit callback %s", |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1038 job->jv_exit_cb.cb_name); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1039 ++job->jv_refcount; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1040 argv[0].v_type = VAR_JOB; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1041 argv[0].vval.v_job = job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1042 argv[1].v_type = VAR_NUMBER; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1043 argv[1].vval.v_number = job->jv_exitval; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1044 call_callback(&job->jv_exit_cb, -1, &rettv, 2, argv); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1045 clear_tv(&rettv); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1046 --job->jv_refcount; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1047 channel_need_redraw = TRUE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1048 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1049 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1050 if (job->jv_channel != NULL && job->jv_channel->ch_anonymous_pipe) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1051 job->jv_channel->ch_killing = TRUE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1052 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1053 // Do not free the job in case the close callback of the associated channel |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1054 // isn't invoked yet and may get information by job_info(). |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1055 if (job->jv_refcount == 0 && !job_channel_still_useful(job)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1056 // The job was already unreferenced and the associated channel was |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1057 // detached, now that it ended it can be freed. However, a caller might |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1058 // still use it, thus free it a bit later. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1059 job_free_later(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1060 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1061 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1062 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1063 * Mark references in jobs that are still useful. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1064 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1065 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1066 set_ref_in_job(int copyID) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1067 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1068 int abort = FALSE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1069 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1070 typval_T tv; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1071 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1072 for (job = first_job; !abort && job != NULL; job = job->jv_next) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1073 if (job_still_useful(job)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1074 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1075 tv.v_type = VAR_JOB; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1076 tv.vval.v_job = job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1077 abort = abort || set_ref_in_item(&tv, copyID, NULL, NULL); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1078 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1079 return abort; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1080 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1081 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1082 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1083 * Dereference "job". Note that after this "job" may have been freed. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1084 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1085 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1086 job_unref(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1087 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1088 if (job != NULL && --job->jv_refcount <= 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1089 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1090 // Do not free the job if there is a channel where the close callback |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1091 // may get the job info. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1092 if (!job_channel_still_useful(job)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1093 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1094 // Do not free the job when it has not ended yet and there is a |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1095 // "stoponexit" flag or an exit callback. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1096 if (!job_need_end_check(job)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1097 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1098 job_free(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1099 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1100 else if (job->jv_channel != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1101 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1102 // Do remove the link to the channel, otherwise it hangs |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1103 // around until Vim exits. See job_free() for refcount. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1104 ch_log(job->jv_channel, "detaching channel from job"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1105 job->jv_channel->ch_job = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1106 channel_unref(job->jv_channel); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1107 job->jv_channel = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1108 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1109 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1110 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1111 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1112 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1113 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1114 free_unused_jobs_contents(int copyID, int mask) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1115 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1116 int did_free = FALSE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1117 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1118 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1119 FOR_ALL_JOBS(job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1120 if ((job->jv_copyID & mask) != (copyID & mask) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1121 && !job_still_useful(job)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1122 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1123 // Free the channel and ordinary items it contains, but don't |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1124 // recurse into Lists, Dictionaries etc. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1125 job_free_contents(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1126 did_free = TRUE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1127 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1128 return did_free; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1129 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1130 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1131 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1132 free_unused_jobs(int copyID, int mask) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1133 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1134 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1135 job_T *job_next; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1136 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1137 for (job = first_job; job != NULL; job = job_next) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1138 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1139 job_next = job->jv_next; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1140 if ((job->jv_copyID & mask) != (copyID & mask) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1141 && !job_still_useful(job)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1142 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1143 // Free the job struct itself. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1144 job_free_job(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1145 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1146 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1147 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1148 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1149 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1150 * Allocate a job. Sets the refcount to one and sets options default. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1151 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1152 job_T * |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1153 job_alloc(void) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1154 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1155 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1156 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1157 job = ALLOC_CLEAR_ONE(job_T); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1158 if (job != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1159 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1160 job->jv_refcount = 1; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1161 job->jv_stoponexit = vim_strsave((char_u *)"term"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1162 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1163 if (first_job != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1164 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1165 first_job->jv_prev = job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1166 job->jv_next = first_job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1167 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1168 first_job = job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1169 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1170 return job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1171 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1172 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1173 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1174 job_set_options(job_T *job, jobopt_T *opt) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1175 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1176 if (opt->jo_set & JO_STOPONEXIT) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1177 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1178 vim_free(job->jv_stoponexit); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1179 if (opt->jo_stoponexit == NULL || *opt->jo_stoponexit == NUL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1180 job->jv_stoponexit = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1181 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1182 job->jv_stoponexit = vim_strsave(opt->jo_stoponexit); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1183 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1184 if (opt->jo_set & JO_EXIT_CB) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1185 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1186 free_callback(&job->jv_exit_cb); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1187 if (opt->jo_exit_cb.cb_name == NULL || *opt->jo_exit_cb.cb_name == NUL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1188 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1189 job->jv_exit_cb.cb_name = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1190 job->jv_exit_cb.cb_partial = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1191 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1192 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1193 copy_callback(&job->jv_exit_cb, &opt->jo_exit_cb); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1194 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1195 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1196 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1197 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1198 * Called when Vim is exiting: kill all jobs that have the "stoponexit" flag. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1199 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1200 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1201 job_stop_on_exit(void) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1202 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1203 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1204 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1205 FOR_ALL_JOBS(job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1206 if (job->jv_status == JOB_STARTED && job->jv_stoponexit != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1207 mch_signal_job(job, job->jv_stoponexit); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1208 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1209 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1210 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1211 * Return TRUE when there is any job that has an exit callback and might exit, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1212 * which means job_check_ended() should be called more often. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1213 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1214 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1215 has_pending_job(void) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1216 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1217 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1218 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1219 FOR_ALL_JOBS(job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1220 // Only should check if the channel has been closed, if the channel is |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1221 // open the job won't exit. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1222 if ((job->jv_status == JOB_STARTED && !job_channel_still_useful(job)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1223 || (job->jv_status == JOB_FINISHED |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1224 && job_channel_can_close(job))) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1225 return TRUE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1226 return FALSE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1227 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1228 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1229 #define MAX_CHECK_ENDED 8 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1230 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1231 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1232 * Called once in a while: check if any jobs that seem useful have ended. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1233 * Returns TRUE if a job did end. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1234 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1235 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1236 job_check_ended(void) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1237 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1238 int i; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1239 int did_end = FALSE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1240 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1241 // be quick if there are no jobs to check |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1242 if (first_job == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1243 return did_end; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1244 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1245 for (i = 0; i < MAX_CHECK_ENDED; ++i) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1246 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1247 // NOTE: mch_detect_ended_job() must only return a job of which the |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1248 // status was just set to JOB_ENDED. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1249 job_T *job = mch_detect_ended_job(first_job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1250 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1251 if (job == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1252 break; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1253 did_end = TRUE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1254 job_cleanup(job); // may add "job" to jobs_to_free |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1255 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1256 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1257 // Actually free jobs that were cleaned up. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1258 free_jobs_to_free_later(); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1259 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1260 if (channel_need_redraw) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1261 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1262 channel_need_redraw = FALSE; |
26466
d413104a94c8
patch 8.2.3763: when editing the cmdline a callback may cause a scroll up
Bram Moolenaar <Bram@vim.org>
parents:
26452
diff
changeset
|
1263 redraw_after_callback(TRUE, FALSE); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1264 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1265 return did_end; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1266 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1267 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1268 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1269 * Create a job and return it. Implements job_start(). |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1270 * "argv_arg" is only for Unix. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1271 * When "argv_arg" is NULL then "argvars" is used. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1272 * The returned job has a refcount of one. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1273 * Returns NULL when out of memory. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1274 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1275 job_T * |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1276 job_start( |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1277 typval_T *argvars, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1278 char **argv_arg UNUSED, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1279 jobopt_T *opt_arg, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1280 job_T **term_job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1281 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1282 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1283 char_u *cmd = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1284 char **argv = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1285 int argc = 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1286 int i; |
23144
de5c000f14c4
patch 8.2.2118: dead code in the job support
Bram Moolenaar <Bram@vim.org>
parents:
22934
diff
changeset
|
1287 #ifndef USE_ARGV |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1288 garray_T ga; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1289 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1290 jobopt_T opt; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1291 ch_part_T part; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1292 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1293 job = job_alloc(); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1294 if (job == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1295 return NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1296 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1297 job->jv_status = JOB_FAILED; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1298 #ifndef USE_ARGV |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1299 ga_init2(&ga, (int)sizeof(char*), 20); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1300 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1301 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1302 if (opt_arg != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1303 opt = *opt_arg; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1304 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1305 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1306 // Default mode is NL. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1307 clear_job_options(&opt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1308 opt.jo_mode = MODE_NL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1309 if (get_job_options(&argvars[1], &opt, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1310 JO_MODE_ALL + JO_CB_ALL + JO_TIMEOUT_ALL + JO_STOPONEXIT |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1311 + JO_EXIT_CB + JO_OUT_IO + JO_BLOCK_WRITE, |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1312 JO2_ENV + JO2_CWD) == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1313 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1314 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1315 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1316 // Check that when io is "file" that there is a file name. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1317 for (part = PART_OUT; part < PART_COUNT; ++part) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1318 if ((opt.jo_set & (JO_OUT_IO << (part - PART_OUT))) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1319 && opt.jo_io[part] == JIO_FILE |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1320 && (!(opt.jo_set & (JO_OUT_NAME << (part - PART_OUT))) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1321 || *opt.jo_io_name[part] == NUL)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1322 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1323 emsg(_("E920: _io file requires _name to be set")); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1324 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1325 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1326 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1327 if ((opt.jo_set & JO_IN_IO) && opt.jo_io[PART_IN] == JIO_BUFFER) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1328 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1329 buf_T *buf = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1330 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1331 // check that we can find the buffer before starting the job |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1332 if (opt.jo_set & JO_IN_BUF) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1333 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1334 buf = buflist_findnr(opt.jo_io_buf[PART_IN]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1335 if (buf == NULL) |
26439
b18f3b0f317c
patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26113
diff
changeset
|
1336 semsg(_(e_buffer_nr_does_not_exist), |
b18f3b0f317c
patch 8.2.3750: error messages are everywhere
Bram Moolenaar <Bram@vim.org>
parents:
26113
diff
changeset
|
1337 (long)opt.jo_io_buf[PART_IN]); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1338 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1339 else if (!(opt.jo_set & JO_IN_NAME)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1340 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1341 emsg(_("E915: in_io buffer requires in_buf or in_name to be set")); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1342 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1343 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1344 buf = buflist_find_by_name(opt.jo_io_name[PART_IN], FALSE); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1345 if (buf == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1346 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1347 if (buf->b_ml.ml_mfp == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1348 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1349 char_u numbuf[NUMBUFLEN]; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1350 char_u *s; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1351 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1352 if (opt.jo_set & JO_IN_BUF) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1353 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1354 sprintf((char *)numbuf, "%d", opt.jo_io_buf[PART_IN]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1355 s = numbuf; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1356 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1357 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1358 s = opt.jo_io_name[PART_IN]; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1359 semsg(_("E918: buffer must be loaded: %s"), s); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1360 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1361 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1362 job->jv_in_buf = buf; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1363 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1364 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1365 job_set_options(job, &opt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1366 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1367 #ifdef USE_ARGV |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1368 if (argv_arg != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1369 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1370 // Make a copy of argv_arg for job->jv_argv. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1371 for (i = 0; argv_arg[i] != NULL; i++) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1372 argc++; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1373 argv = ALLOC_MULT(char *, argc + 1); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1374 if (argv == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1375 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1376 for (i = 0; i < argc; i++) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1377 argv[i] = (char *)vim_strsave((char_u *)argv_arg[i]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1378 argv[argc] = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1379 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1380 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1381 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1382 if (argvars[0].v_type == VAR_STRING) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1383 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1384 // Command is a string. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1385 cmd = argvars[0].vval.v_string; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1386 if (cmd == NULL || *skipwhite(cmd) == NUL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1387 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1388 emsg(_(e_invarg)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1389 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1390 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1391 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1392 if (build_argv_from_string(cmd, &argv, &argc) == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1393 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1394 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1395 else if (argvars[0].v_type != VAR_LIST |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1396 || argvars[0].vval.v_list == NULL |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1397 || argvars[0].vval.v_list->lv_len < 1) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1398 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1399 emsg(_(e_invarg)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1400 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1401 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1402 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1403 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1404 list_T *l = argvars[0].vval.v_list; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1405 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1406 if (build_argv_from_list(l, &argv, &argc) == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1407 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1408 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1409 // Empty command is invalid. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1410 if (argc == 0 || *skipwhite((char_u *)argv[0]) == NUL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1411 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1412 emsg(_(e_invarg)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1413 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1414 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1415 #ifndef USE_ARGV |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1416 if (win32_build_cmd(l, &ga) == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1417 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1418 cmd = ga.ga_data; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1419 if (cmd == NULL || *skipwhite(cmd) == NUL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1420 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1421 emsg(_(e_invarg)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1422 goto theend; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1423 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1424 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1425 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1426 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1427 // Save the command used to start the job. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1428 job->jv_argv = argv; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1429 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1430 if (term_job != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1431 *term_job = job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1432 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1433 #ifdef USE_ARGV |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1434 if (ch_log_active()) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1435 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1436 garray_T ga; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1437 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1438 ga_init2(&ga, (int)sizeof(char), 200); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1439 for (i = 0; i < argc; ++i) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1440 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1441 if (i > 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1442 ga_concat(&ga, (char_u *)" "); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1443 ga_concat(&ga, (char_u *)argv[i]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1444 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1445 ga_append(&ga, NUL); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1446 ch_log(NULL, "Starting job: %s", (char *)ga.ga_data); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1447 ga_clear(&ga); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1448 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1449 mch_job_start(argv, job, &opt, term_job != NULL); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1450 #else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1451 ch_log(NULL, "Starting job: %s", (char *)cmd); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1452 mch_job_start((char *)cmd, job, &opt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1453 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1454 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1455 // If the channel is reading from a buffer, write lines now. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1456 if (job->jv_channel != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1457 channel_write_in(job->jv_channel); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1458 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1459 theend: |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1460 #ifndef USE_ARGV |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1461 vim_free(ga.ga_data); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1462 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1463 if (argv != NULL && argv != job->jv_argv) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1464 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1465 for (i = 0; argv[i] != NULL; i++) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1466 vim_free(argv[i]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1467 vim_free(argv); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1468 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1469 free_job_options(&opt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1470 return job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1471 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1472 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1473 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1474 * Get the status of "job" and invoke the exit callback when needed. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1475 * The returned string is not allocated. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1476 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1477 char * |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1478 job_status(job_T *job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1479 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1480 char *result; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1481 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1482 if (job->jv_status >= JOB_ENDED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1483 // No need to check, dead is dead. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1484 result = "dead"; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1485 else if (job->jv_status == JOB_FAILED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1486 result = "fail"; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1487 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1488 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1489 result = mch_job_status(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1490 if (job->jv_status == JOB_ENDED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1491 job_cleanup(job); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1492 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1493 return result; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1494 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1495 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1496 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1497 * Send a signal to "job". Implements job_stop(). |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1498 * When "type" is not NULL use this for the type. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1499 * Otherwise use argvars[1] for the type. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1500 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1501 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1502 job_stop(job_T *job, typval_T *argvars, char *type) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1503 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1504 char_u *arg; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1505 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1506 if (type != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1507 arg = (char_u *)type; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1508 else if (argvars[1].v_type == VAR_UNKNOWN) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1509 arg = (char_u *)""; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1510 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1511 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1512 arg = tv_get_string_chk(&argvars[1]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1513 if (arg == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1514 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1515 emsg(_(e_invarg)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1516 return 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1517 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1518 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1519 if (job->jv_status == JOB_FAILED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1520 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1521 ch_log(job->jv_channel, "Job failed to start, job_stop() skipped"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1522 return 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1523 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1524 if (job->jv_status == JOB_ENDED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1525 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1526 ch_log(job->jv_channel, "Job has already ended, job_stop() skipped"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1527 return 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1528 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1529 ch_log(job->jv_channel, "Stopping job with '%s'", (char *)arg); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1530 if (mch_signal_job(job, arg) == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1531 return 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1532 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1533 // Assume that only "kill" will kill the job. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1534 if (job->jv_channel != NULL && STRCMP(arg, "kill") == 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1535 job->jv_channel->ch_job_killed = TRUE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1536 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1537 // We don't try freeing the job, obviously the caller still has a |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1538 // reference to it. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1539 return 1; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1540 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1541 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1542 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1543 invoke_prompt_callback(void) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1544 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1545 typval_T rettv; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1546 typval_T argv[2]; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1547 char_u *text; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1548 char_u *prompt; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1549 linenr_T lnum = curbuf->b_ml.ml_line_count; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1550 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1551 // Add a new line for the prompt before invoking the callback, so that |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1552 // text can always be inserted above the last line. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1553 ml_append(lnum, (char_u *)"", 0, FALSE); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1554 curwin->w_cursor.lnum = lnum + 1; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1555 curwin->w_cursor.col = 0; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1556 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1557 if (curbuf->b_prompt_callback.cb_name == NULL |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1558 || *curbuf->b_prompt_callback.cb_name == NUL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1559 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1560 text = ml_get(lnum); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1561 prompt = prompt_text(); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1562 if (STRLEN(text) >= STRLEN(prompt)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1563 text += STRLEN(prompt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1564 argv[0].v_type = VAR_STRING; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1565 argv[0].vval.v_string = vim_strsave(text); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1566 argv[1].v_type = VAR_UNKNOWN; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1567 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1568 call_callback(&curbuf->b_prompt_callback, -1, &rettv, 1, argv); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1569 clear_tv(&argv[0]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1570 clear_tv(&rettv); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1571 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1572 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1573 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1574 * Return TRUE when the interrupt callback was invoked. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1575 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1576 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1577 invoke_prompt_interrupt(void) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1578 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1579 typval_T rettv; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1580 typval_T argv[1]; |
26452
65b4109a4297
patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents:
26439
diff
changeset
|
1581 int ret; |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1582 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1583 if (curbuf->b_prompt_interrupt.cb_name == NULL |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1584 || *curbuf->b_prompt_interrupt.cb_name == NUL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1585 return FALSE; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1586 argv[0].v_type = VAR_UNKNOWN; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1587 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1588 got_int = FALSE; // don't skip executing commands |
26452
65b4109a4297
patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents:
26439
diff
changeset
|
1589 ret = call_callback(&curbuf->b_prompt_interrupt, -1, &rettv, 0, argv); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1590 clear_tv(&rettv); |
26452
65b4109a4297
patch 8.2.3756: might crash when callback is not valid
Bram Moolenaar <Bram@vim.org>
parents:
26439
diff
changeset
|
1591 return ret == FAIL ? FALSE : TRUE; |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1592 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1593 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1594 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1595 * Return the effective prompt for the specified buffer. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1596 */ |
25567
0082503ff2ff
patch 8.2.3320: some local functions are not static
Bram Moolenaar <Bram@vim.org>
parents:
25384
diff
changeset
|
1597 static char_u * |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1598 buf_prompt_text(buf_T* buf) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1599 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1600 if (buf->b_prompt_text == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1601 return (char_u *)"% "; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1602 return buf->b_prompt_text; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1603 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1604 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1605 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1606 * Return the effective prompt for the current buffer. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1607 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1608 char_u * |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1609 prompt_text(void) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1610 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1611 return buf_prompt_text(curbuf); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1612 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1613 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1614 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1615 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1616 * Prepare for prompt mode: Make sure the last line has the prompt text. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1617 * Move the cursor to this line. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1618 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1619 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1620 init_prompt(int cmdchar_todo) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1621 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1622 char_u *prompt = prompt_text(); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1623 char_u *text; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1624 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1625 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1626 text = ml_get_curline(); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1627 if (STRNCMP(text, prompt, STRLEN(prompt)) != 0) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1628 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1629 // prompt is missing, insert it or append a line with it |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1630 if (*text == NUL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1631 ml_replace(curbuf->b_ml.ml_line_count, prompt, TRUE); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1632 else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1633 ml_append(curbuf->b_ml.ml_line_count, prompt, 0, FALSE); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1634 curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1635 coladvance((colnr_T)MAXCOL); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1636 changed_bytes(curbuf->b_ml.ml_line_count, 0); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1637 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1638 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1639 // Insert always starts after the prompt, allow editing text after it. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1640 if (Insstart_orig.lnum != curwin->w_cursor.lnum |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1641 || Insstart_orig.col != (int)STRLEN(prompt)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1642 set_insstart(curwin->w_cursor.lnum, (int)STRLEN(prompt)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1643 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1644 if (cmdchar_todo == 'A') |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1645 coladvance((colnr_T)MAXCOL); |
22934
3f04c2cf0ced
patch 8.2.2014: using CTRL-O in a prompt buffer moves cursor to start
Bram Moolenaar <Bram@vim.org>
parents:
22618
diff
changeset
|
1646 if (curwin->w_cursor.col < (int)STRLEN(prompt)) |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1647 curwin->w_cursor.col = (int)STRLEN(prompt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1648 // Make sure the cursor is in a valid position. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1649 check_cursor(); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1650 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1651 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1652 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1653 * Return TRUE if the cursor is in the editable position of the prompt line. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1654 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1655 int |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1656 prompt_curpos_editable() |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1657 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1658 return curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1659 && curwin->w_cursor.col >= (int)STRLEN(prompt_text()); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1660 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1661 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1662 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1663 * "prompt_setcallback({buffer}, {callback})" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1664 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1665 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1666 f_prompt_setcallback(typval_T *argvars, typval_T *rettv UNUSED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1667 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1668 buf_T *buf; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1669 callback_T callback; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1670 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1671 if (check_secure()) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1672 return; |
25348
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25338
diff
changeset
|
1673 |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25338
diff
changeset
|
1674 if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL) |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25338
diff
changeset
|
1675 return; |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25338
diff
changeset
|
1676 |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1677 buf = tv_get_buf(&argvars[0], FALSE); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1678 if (buf == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1679 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1680 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1681 callback = get_callback(&argvars[1]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1682 if (callback.cb_name == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1683 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1684 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1685 free_callback(&buf->b_prompt_callback); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1686 set_callback(&buf->b_prompt_callback, &callback); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1687 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1688 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1689 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1690 * "prompt_setinterrupt({buffer}, {callback})" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1691 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1692 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1693 f_prompt_setinterrupt(typval_T *argvars, typval_T *rettv UNUSED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1694 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1695 buf_T *buf; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1696 callback_T callback; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1697 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1698 if (check_secure()) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1699 return; |
25348
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25338
diff
changeset
|
1700 |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25338
diff
changeset
|
1701 if (in_vim9script() && check_for_buffer_arg(argvars, 0) == FAIL) |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25338
diff
changeset
|
1702 return; |
75031a22be39
patch 8.2.3211: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25338
diff
changeset
|
1703 |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1704 buf = tv_get_buf(&argvars[0], FALSE); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1705 if (buf == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1706 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1707 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1708 callback = get_callback(&argvars[1]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1709 if (callback.cb_name == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1710 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1711 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1712 free_callback(&buf->b_prompt_interrupt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1713 set_callback(&buf->b_prompt_interrupt, &callback); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1714 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1715 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1716 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1717 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1718 * "prompt_getprompt({buffer})" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1719 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1720 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1721 f_prompt_getprompt(typval_T *argvars, typval_T *rettv) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1722 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1723 buf_T *buf; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1724 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1725 // return an empty string by default, e.g. it's not a prompt buffer |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1726 rettv->v_type = VAR_STRING; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1727 rettv->vval.v_string = NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1728 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1729 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:
25348
diff
changeset
|
1730 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1731 |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1732 buf = tv_get_buf_from_arg(&argvars[0]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1733 if (buf == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1734 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1735 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1736 if (!bt_prompt(buf)) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1737 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1738 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1739 rettv->vval.v_string = vim_strsave(buf_prompt_text(buf)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1740 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1741 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1742 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1743 * "prompt_setprompt({buffer}, {text})" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1744 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1745 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1746 f_prompt_setprompt(typval_T *argvars, typval_T *rettv UNUSED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1747 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1748 buf_T *buf; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1749 char_u *text; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1750 |
25272
712e867f9721
patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24812
diff
changeset
|
1751 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
|
1752 && (check_for_buffer_arg(argvars, 0) == FAIL |
25272
712e867f9721
patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24812
diff
changeset
|
1753 || check_for_string_arg(argvars, 1) == FAIL)) |
712e867f9721
patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24812
diff
changeset
|
1754 return; |
712e867f9721
patch 8.2.3173: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
24812
diff
changeset
|
1755 |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1756 if (check_secure()) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1757 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1758 buf = tv_get_buf(&argvars[0], FALSE); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1759 if (buf == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1760 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1761 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1762 text = tv_get_string(&argvars[1]); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1763 vim_free(buf->b_prompt_text); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1764 buf->b_prompt_text = vim_strsave(text); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1765 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1766 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1767 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1768 * Get the job from the argument. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1769 * Returns NULL if the job is invalid. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1770 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1771 static job_T * |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1772 get_job_arg(typval_T *tv) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1773 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1774 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1775 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1776 if (tv->v_type != VAR_JOB) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1777 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1778 semsg(_(e_invarg2), tv_get_string(tv)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1779 return NULL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1780 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1781 job = tv->vval.v_job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1782 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1783 if (job == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1784 emsg(_("E916: not a valid job")); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1785 return job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1786 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1787 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1788 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1789 * "job_getchannel()" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1790 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1791 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1792 f_job_getchannel(typval_T *argvars, typval_T *rettv) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1793 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1794 job_T *job; |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1795 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1796 if (in_vim9script() && check_for_job_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:
25348
diff
changeset
|
1797 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1798 |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1799 job = get_job_arg(&argvars[0]); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1800 if (job != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1801 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1802 rettv->v_type = VAR_CHANNEL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1803 rettv->vval.v_channel = job->jv_channel; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1804 if (job->jv_channel != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1805 ++job->jv_channel->ch_refcount; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1806 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1807 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1808 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1809 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1810 * Implementation of job_info(). |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1811 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1812 static void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1813 job_info(job_T *job, dict_T *dict) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1814 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1815 dictitem_T *item; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1816 varnumber_T nr; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1817 list_T *l; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1818 int i; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1819 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1820 dict_add_string(dict, "status", (char_u *)job_status(job)); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1821 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1822 item = dictitem_alloc((char_u *)"channel"); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1823 if (item == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1824 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1825 item->di_tv.v_type = VAR_CHANNEL; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1826 item->di_tv.vval.v_channel = job->jv_channel; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1827 if (job->jv_channel != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1828 ++job->jv_channel->ch_refcount; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1829 if (dict_add(dict, item) == FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1830 dictitem_free(item); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1831 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1832 #ifdef UNIX |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1833 nr = job->jv_pid; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1834 #else |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1835 nr = job->jv_proc_info.dwProcessId; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1836 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1837 dict_add_number(dict, "process", nr); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1838 dict_add_string(dict, "tty_in", job->jv_tty_in); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1839 dict_add_string(dict, "tty_out", job->jv_tty_out); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1840 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1841 dict_add_number(dict, "exitval", job->jv_exitval); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1842 dict_add_string(dict, "exit_cb", job->jv_exit_cb.cb_name); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1843 dict_add_string(dict, "stoponexit", job->jv_stoponexit); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1844 #ifdef UNIX |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1845 dict_add_string(dict, "termsig", job->jv_termsig); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1846 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1847 #ifdef MSWIN |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1848 dict_add_string(dict, "tty_type", job->jv_tty_type); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1849 #endif |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1850 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1851 l = list_alloc(); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1852 if (l != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1853 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1854 dict_add_list(dict, "cmd", l); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1855 if (job->jv_argv != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1856 for (i = 0; job->jv_argv[i] != NULL; i++) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1857 list_append_string(l, (char_u *)job->jv_argv[i], -1); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1858 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1859 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1860 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1861 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1862 * Implementation of job_info() to return info for all jobs. |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1863 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1864 static void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1865 job_info_all(list_T *l) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1866 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1867 job_T *job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1868 typval_T tv; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1869 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1870 FOR_ALL_JOBS(job) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1871 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1872 tv.v_type = VAR_JOB; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1873 tv.vval.v_job = job; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1874 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1875 if (list_append_tv(l, &tv) != OK) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1876 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1877 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1878 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1879 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1880 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1881 * "job_info()" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1882 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1883 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1884 f_job_info(typval_T *argvars, typval_T *rettv) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1885 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1886 if (in_vim9script() && check_for_opt_job_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:
25348
diff
changeset
|
1887 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1888 |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1889 if (argvars[0].v_type != VAR_UNKNOWN) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1890 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1891 job_T *job; |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1892 |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1893 job = get_job_arg(&argvars[0]); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1894 if (job != NULL && rettv_dict_alloc(rettv) != FAIL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1895 job_info(job, rettv->vval.v_dict); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1896 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1897 else if (rettv_list_alloc(rettv) == OK) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1898 job_info_all(rettv->vval.v_list); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1899 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1900 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1901 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1902 * "job_setoptions()" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1903 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1904 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1905 f_job_setoptions(typval_T *argvars, typval_T *rettv UNUSED) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1906 { |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1907 job_T *job; |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1908 jobopt_T opt; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1909 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1910 if (in_vim9script() |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1911 && (check_for_job_arg(argvars, 0) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1912 || check_for_dict_arg(argvars, 1) == FAIL)) |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1913 return; |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1914 |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1915 job = get_job_arg(&argvars[0]); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1916 if (job == NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1917 return; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1918 clear_job_options(&opt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1919 if (get_job_options(&argvars[1], &opt, JO_STOPONEXIT + JO_EXIT_CB, 0) == OK) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1920 job_set_options(job, &opt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1921 free_job_options(&opt); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1922 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1923 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1924 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1925 * "job_start()" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1926 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1927 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1928 f_job_start(typval_T *argvars, typval_T *rettv) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1929 { |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1930 rettv->v_type = VAR_JOB; |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1931 if (check_restricted() || check_secure()) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1932 return; |
25338
e2be9f3c5907
patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
1933 |
e2be9f3c5907
patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
1934 if (in_vim9script() |
e2be9f3c5907
patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
1935 && (check_for_string_or_list_arg(argvars, 0) == FAIL |
e2be9f3c5907
patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
1936 || check_for_opt_dict_arg(argvars, 1) == FAIL)) |
e2be9f3c5907
patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
1937 return; |
e2be9f3c5907
patch 8.2.3206: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25314
diff
changeset
|
1938 |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1939 rettv->vval.v_job = job_start(argvars, NULL, NULL, NULL); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1940 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1941 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1942 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1943 * "job_status()" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1944 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1945 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1946 f_job_status(typval_T *argvars, typval_T *rettv) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1947 { |
25384
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1948 if (in_vim9script() && check_for_job_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:
25348
diff
changeset
|
1949 return; |
e8e2c4d33b9b
patch 8.2.3229: Vim9: runtime and compile time type checks are not the same
Bram Moolenaar <Bram@vim.org>
parents:
25348
diff
changeset
|
1950 |
22618
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1951 if (argvars[0].v_type == VAR_JOB && argvars[0].vval.v_job == NULL) |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1952 { |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1953 // A job that never started returns "fail". |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1954 rettv->v_type = VAR_STRING; |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1955 rettv->vval.v_string = vim_strsave((char_u *)"fail"); |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1956 } |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1957 else |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1958 { |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1959 job_T *job = get_job_arg(&argvars[0]); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1960 |
22618
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1961 if (job != NULL) |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1962 { |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1963 rettv->v_type = VAR_STRING; |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1964 rettv->vval.v_string = vim_strsave((char_u *)job_status(job)); |
c2d8b596dd0f
patch 8.2.1857: Vim9: using job_status() on an unused var gives an error
Bram Moolenaar <Bram@vim.org>
parents:
22155
diff
changeset
|
1965 } |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1966 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1967 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1968 |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1969 /* |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1970 * "job_stop()" function |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1971 */ |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1972 void |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1973 f_job_stop(typval_T *argvars, typval_T *rettv) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1974 { |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1975 job_T *job; |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1976 |
25302
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1977 if (in_vim9script() |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1978 && (check_for_job_arg(argvars, 0) == FAIL |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1979 || check_for_opt_string_or_number_arg(argvars, 1) == FAIL)) |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1980 return; |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1981 |
4d3c68196d05
patch 8.2.3188: Vim9: argument types are not checked at compile time
Bram Moolenaar <Bram@vim.org>
parents:
25272
diff
changeset
|
1982 job = get_job_arg(&argvars[0]); |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1983 if (job != NULL) |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1984 rettv->vval.v_number = job_stop(job, argvars, NULL); |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1985 } |
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1986 |
24812
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1987 /* |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1988 * Get a string with information about the job in "varp" in "buf". |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1989 * "buf" must be at least NUMBUFLEN long. |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1990 */ |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1991 char_u * |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1992 job_to_string_buf(typval_T *varp, char_u *buf) |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1993 { |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1994 job_T *job = varp->vval.v_job; |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1995 char *status; |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1996 |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
1997 if (job == NULL) |
25686
838a0108a92d
patch 8.2.3379: crash when using NULL job
Bram Moolenaar <Bram@vim.org>
parents:
25567
diff
changeset
|
1998 { |
838a0108a92d
patch 8.2.3379: crash when using NULL job
Bram Moolenaar <Bram@vim.org>
parents:
25567
diff
changeset
|
1999 vim_snprintf((char *)buf, NUMBUFLEN, "no process"); |
838a0108a92d
patch 8.2.3379: crash when using NULL job
Bram Moolenaar <Bram@vim.org>
parents:
25567
diff
changeset
|
2000 return buf; |
838a0108a92d
patch 8.2.3379: crash when using NULL job
Bram Moolenaar <Bram@vim.org>
parents:
25567
diff
changeset
|
2001 } |
24812
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2002 status = job->jv_status == JOB_FAILED ? "fail" |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2003 : job->jv_status >= JOB_ENDED ? "dead" |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2004 : "run"; |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2005 # ifdef UNIX |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2006 vim_snprintf((char *)buf, NUMBUFLEN, |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2007 "process %ld %s", (long)job->jv_pid, status); |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2008 # elif defined(MSWIN) |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2009 vim_snprintf((char *)buf, NUMBUFLEN, |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2010 "process %ld %s", |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2011 (long)job->jv_proc_info.dwProcessId, |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2012 status); |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2013 # else |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2014 // fall-back |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2015 vim_snprintf((char *)buf, NUMBUFLEN, "process ? %s", status); |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2016 # endif |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2017 return buf; |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2018 } |
8fdf839af1f4
patch 8.2.2944: Vim9: no error when using job or channel as a string
Bram Moolenaar <Bram@vim.org>
parents:
23144
diff
changeset
|
2019 |
22095
2cc0de1e05a6
patch 8.2.1597: the channel source file is too big
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2020 #endif // FEAT_JOB_CHANNEL |