Mercurial > vim
comparison src/window.c @ 14035:bccd66fa00c1 v8.1.0035
patch 8.1.0035: not easy to switch between prompt buffer and other windows
commit https://github.com/vim/vim/commit/6d41c78e353b630bc1a72cbff9160311d2a81e8c
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Jun 6 09:11:12 2018 +0200
patch 8.1.0035: not easy to switch between prompt buffer and other windows
Problem: Not easy to switch between prompt buffer and other windows.
Solution: Accept CTRL-W commands in Insert mode. Start and stop Insert mode
as one would expect.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 06 Jun 2018 09:15:06 +0200 |
parents | 79419af4b29c |
children | afce2005fdc8 |
comparison
equal
deleted
inserted
replaced
14034:95fca5692b7f | 14035:bccd66fa00c1 |
---|---|
2101 totwincount -= wincount; | 2101 totwincount -= wincount; |
2102 } | 2102 } |
2103 } | 2103 } |
2104 } | 2104 } |
2105 | 2105 |
2106 #ifdef FEAT_JOB_CHANNEL | |
2107 static void | |
2108 leaving_window(win_T *win) | |
2109 { | |
2110 // When leaving a prompt window stop Insert mode and perhaps restart | |
2111 // it when entering that window again. | |
2112 win->w_buffer->b_prompt_insert = restart_edit; | |
2113 restart_edit = NUL; | |
2114 | |
2115 // When leaving the window (or closing the window) was done from a | |
2116 // callback we need to break out of the Insert mode loop. | |
2117 if (State & INSERT) | |
2118 stop_insert_mode = TRUE; | |
2119 } | |
2120 | |
2121 static void | |
2122 entering_window(win_T *win) | |
2123 { | |
2124 // When entering the prompt window may restart Insert mode. | |
2125 restart_edit = win->w_buffer->b_prompt_insert; | |
2126 } | |
2127 #endif | |
2128 | |
2106 /* | 2129 /* |
2107 * Close all windows for buffer "buf". | 2130 * Close all windows for buffer "buf". |
2108 */ | 2131 */ |
2109 void | 2132 void |
2110 close_windows( | 2133 close_windows( |
2229 | 2252 |
2230 win_close_othertab(win, free_buf, prev_curtab); | 2253 win_close_othertab(win, free_buf, prev_curtab); |
2231 if (h != tabline_height()) | 2254 if (h != tabline_height()) |
2232 shell_new_rows(); | 2255 shell_new_rows(); |
2233 } | 2256 } |
2257 #ifdef FEAT_JOB_CHANNEL | |
2258 entering_window(curwin); | |
2259 #endif | |
2234 /* Since goto_tabpage_tp above did not trigger *Enter autocommands, do | 2260 /* Since goto_tabpage_tp above did not trigger *Enter autocommands, do |
2235 * that now. */ | 2261 * that now. */ |
2236 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); | 2262 apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf); |
2237 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); | 2263 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); |
2238 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); | 2264 apply_autocmds(EVENT_TABENTER, NULL, NULL, FALSE, curbuf); |
2294 else | 2320 else |
2295 clear_snapshot(curtab, SNAP_HELP_IDX); | 2321 clear_snapshot(curtab, SNAP_HELP_IDX); |
2296 | 2322 |
2297 if (win == curwin) | 2323 if (win == curwin) |
2298 { | 2324 { |
2325 #ifdef FEAT_JOB_CHANNEL | |
2326 leaving_window(curwin); | |
2327 #endif | |
2299 /* | 2328 /* |
2300 * Guess which window is going to be the new current window. | 2329 * Guess which window is going to be the new current window. |
2301 * This may change because of the autocommands (sigh). | 2330 * This may change because of the autocommands (sigh). |
2302 */ | 2331 */ |
2303 wp = frame2win(win_altframe(win, NULL)); | 2332 wp = frame2win(win_altframe(win, NULL)); |
3647 #if defined(FEAT_GUI) | 3676 #if defined(FEAT_GUI) |
3648 /* When 'guioptions' includes 'L' or 'R' may have to remove or add | 3677 /* When 'guioptions' includes 'L' or 'R' may have to remove or add |
3649 * scrollbars. Have to update them anyway. */ | 3678 * scrollbars. Have to update them anyway. */ |
3650 gui_may_update_scrollbars(); | 3679 gui_may_update_scrollbars(); |
3651 #endif | 3680 #endif |
3681 #ifdef FEAT_JOB_CHANNEL | |
3682 entering_window(curwin); | |
3683 #endif | |
3652 | 3684 |
3653 redraw_all_later(CLEAR); | 3685 redraw_all_later(CLEAR); |
3654 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); | 3686 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); |
3655 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); | 3687 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); |
3656 apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf); | 3688 apply_autocmds(EVENT_TABNEW, NULL, NULL, FALSE, curbuf); |
3820 NULL if unknown */ | 3852 NULL if unknown */ |
3821 int trigger_leave_autocmds UNUSED) | 3853 int trigger_leave_autocmds UNUSED) |
3822 { | 3854 { |
3823 tabpage_T *tp = curtab; | 3855 tabpage_T *tp = curtab; |
3824 | 3856 |
3857 #ifdef FEAT_JOB_CHANNEL | |
3858 leaving_window(curwin); | |
3859 #endif | |
3825 reset_VIsual_and_resel(); /* stop Visual mode */ | 3860 reset_VIsual_and_resel(); /* stop Visual mode */ |
3826 if (trigger_leave_autocmds) | 3861 if (trigger_leave_autocmds) |
3827 { | 3862 { |
3828 if (new_curbuf != curbuf) | 3863 if (new_curbuf != curbuf) |
3829 { | 3864 { |
4316 int other_buffer = FALSE; | 4351 int other_buffer = FALSE; |
4317 | 4352 |
4318 if (wp == curwin && !curwin_invalid) /* nothing to do */ | 4353 if (wp == curwin && !curwin_invalid) /* nothing to do */ |
4319 return; | 4354 return; |
4320 | 4355 |
4356 #ifdef FEAT_JOB_CHANNEL | |
4357 if (!curwin_invalid) | |
4358 leaving_window(curwin); | |
4359 #endif | |
4360 | |
4321 if (!curwin_invalid && trigger_leave_autocmds) | 4361 if (!curwin_invalid && trigger_leave_autocmds) |
4322 { | 4362 { |
4323 /* | 4363 /* |
4324 * Be careful: If autocommands delete the window, return now. | 4364 * Be careful: If autocommands delete the window, return now. |
4325 */ | 4365 */ |
4387 ignored = mch_chdir((char *)globaldir); | 4427 ignored = mch_chdir((char *)globaldir); |
4388 VIM_CLEAR(globaldir); | 4428 VIM_CLEAR(globaldir); |
4389 shorten_fnames(TRUE); | 4429 shorten_fnames(TRUE); |
4390 } | 4430 } |
4391 | 4431 |
4432 #ifdef FEAT_JOB_CHANNEL | |
4433 entering_window(curwin); | |
4434 #endif | |
4392 if (trigger_new_autocmds) | 4435 if (trigger_new_autocmds) |
4393 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); | 4436 apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf); |
4394 if (trigger_enter_autocmds) | 4437 if (trigger_enter_autocmds) |
4395 { | 4438 { |
4396 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); | 4439 apply_autocmds(EVENT_WINENTER, NULL, NULL, FALSE, curbuf); |