Mercurial > vim
comparison src/terminal.c @ 13575:4df23d9bad47 v8.0.1660
patch 8.0.1660: the terminal API "drop" command doesn't support options
commit https://github.com/vim/vim/commit/333b80acf3a44e462456e6d5730e47ffa449c83d
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Apr 4 22:57:29 2018 +0200
patch 8.0.1660: the terminal API "drop" command doesn't support options
Problem: The terminal API "drop" command doesn't support options.
Solution: Implement the options.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 04 Apr 2018 23:00:07 +0200 |
parents | 4911058c43eb |
children | 4cb743db55b3 |
comparison
equal
deleted
inserted
replaced
13574:73c69063091f | 13575:4df23d9bad47 |
---|---|
36 * that buffer, attributes come from the scrollback buffer tl_scrollback. | 36 * that buffer, attributes come from the scrollback buffer tl_scrollback. |
37 * When the buffer is changed it is turned into a normal buffer, the attributes | 37 * When the buffer is changed it is turned into a normal buffer, the attributes |
38 * in tl_scrollback are no longer used. | 38 * in tl_scrollback are no longer used. |
39 * | 39 * |
40 * TODO: | 40 * TODO: |
41 * - For the "drop" command accept another argument for options. | |
42 * - Add a way to set the 16 ANSI colors, to be used for 'termguicolors' and in | 41 * - Add a way to set the 16 ANSI colors, to be used for 'termguicolors' and in |
43 * the GUI. | 42 * the GUI. |
44 * - Win32: Make terminal used for :!cmd in the GUI work better. Allow for | 43 * - Win32: Make terminal used for :!cmd in the GUI work better. Allow for |
45 * redirection. | 44 * redirection. |
46 * - implement term_setsize() | 45 * - implement term_setsize() |
3150 */ | 3149 */ |
3151 static void | 3150 static void |
3152 handle_drop_command(listitem_T *item) | 3151 handle_drop_command(listitem_T *item) |
3153 { | 3152 { |
3154 char_u *fname = get_tv_string(&item->li_tv); | 3153 char_u *fname = get_tv_string(&item->li_tv); |
3154 listitem_T *opt_item = item->li_next; | |
3155 int bufnr; | 3155 int bufnr; |
3156 win_T *wp; | 3156 win_T *wp; |
3157 tabpage_T *tp; | 3157 tabpage_T *tp; |
3158 exarg_T ea; | 3158 exarg_T ea; |
3159 char_u *tofree = NULL; | |
3159 | 3160 |
3160 bufnr = buflist_add(fname, BLN_LISTED | BLN_NOOPT); | 3161 bufnr = buflist_add(fname, BLN_LISTED | BLN_NOOPT); |
3161 FOR_ALL_TAB_WINDOWS(tp, wp) | 3162 FOR_ALL_TAB_WINDOWS(tp, wp) |
3162 { | 3163 { |
3163 if (wp->w_buffer->b_fnum == bufnr) | 3164 if (wp->w_buffer->b_fnum == bufnr) |
3166 goto_tabpage_win(tp, wp); | 3167 goto_tabpage_win(tp, wp); |
3167 return; | 3168 return; |
3168 } | 3169 } |
3169 } | 3170 } |
3170 | 3171 |
3171 /* open in new window, like ":sbuffer N" */ | |
3172 vim_memset(&ea, 0, sizeof(ea)); | 3172 vim_memset(&ea, 0, sizeof(ea)); |
3173 ea.cmd = (char_u *)"sbuffer"; | 3173 |
3174 goto_buffer(&ea, DOBUF_FIRST, FORWARD, bufnr); | 3174 if (opt_item != NULL && opt_item->li_tv.v_type == VAR_DICT |
3175 && opt_item->li_tv.vval.v_dict != NULL) | |
3176 { | |
3177 dict_T *dict = opt_item->li_tv.vval.v_dict; | |
3178 char_u *p; | |
3179 | |
3180 p = get_dict_string(dict, (char_u *)"ff", FALSE); | |
3181 if (p == NULL) | |
3182 p = get_dict_string(dict, (char_u *)"fileformat", FALSE); | |
3183 if (p != NULL) | |
3184 { | |
3185 if (check_ff_value(p) == FAIL) | |
3186 ch_log(NULL, "Invalid ff argument to drop: %s", p); | |
3187 else | |
3188 ea.force_ff = *p; | |
3189 } | |
3190 p = get_dict_string(dict, (char_u *)"enc", FALSE); | |
3191 if (p == NULL) | |
3192 p = get_dict_string(dict, (char_u *)"encoding", FALSE); | |
3193 if (p != NULL) | |
3194 { | |
3195 ea.cmd = alloc((int)STRLEN(p) + 10); | |
3196 if (ea.cmd != NULL) | |
3197 { | |
3198 sprintf((char *)ea.cmd, "sbuf ++enc=%s", p); | |
3199 ea.force_enc = 11; | |
3200 tofree = ea.cmd; | |
3201 } | |
3202 } | |
3203 | |
3204 p = get_dict_string(dict, (char_u *)"bad", FALSE); | |
3205 if (p != NULL) | |
3206 get_bad_opt(p, &ea); | |
3207 | |
3208 if (dict_find(dict, (char_u *)"bin", -1) != NULL) | |
3209 ea.force_bin = FORCE_BIN; | |
3210 if (dict_find(dict, (char_u *)"binary", -1) != NULL) | |
3211 ea.force_bin = FORCE_BIN; | |
3212 if (dict_find(dict, (char_u *)"nobin", -1) != NULL) | |
3213 ea.force_bin = FORCE_NOBIN; | |
3214 if (dict_find(dict, (char_u *)"nobinary", -1) != NULL) | |
3215 ea.force_bin = FORCE_NOBIN; | |
3216 } | |
3217 | |
3218 /* open in new window, like ":split fname" */ | |
3219 if (ea.cmd == NULL) | |
3220 ea.cmd = (char_u *)"split"; | |
3221 ea.arg = fname; | |
3222 ea.cmdidx = CMD_split; | |
3223 ex_splitview(&ea); | |
3224 | |
3225 vim_free(tofree); | |
3175 } | 3226 } |
3176 | 3227 |
3177 /* | 3228 /* |
3178 * Handles a function call from the job running in a terminal. | 3229 * Handles a function call from the job running in a terminal. |
3179 * "item" is the function name, "item->li_next" has the arguments. | 3230 * "item" is the function name, "item->li_next" has the arguments. |