Patch 8.1.0035
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.
Files: src/edit.c, src/ex_docmd.c, src/structs.h, src/window.c
*** ../vim-8.1.0034/src/edit.c 2018-06-03 14:42:17.840505115 +0200
--- src/edit.c 2018-06-06 09:06:43.329569894 +0200
***************
*** 811,816 ****
--- 811,824 ----
do
{
c = safe_vgetc();
+
+ if (stop_insert_mode)
+ {
+ // Insert mode ended, possibly from a callback.
+ count = 0;
+ nomove = TRUE;
+ goto doESCkey;
+ }
} while (c == K_IGNORE || c == K_NOP);
/* Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. */
***************
*** 1165,1170 ****
--- 1173,1190 ----
break;
case Ctrl_W: /* delete word before the cursor */
+ #ifdef FEAT_JOB_CHANNEL
+ if (bt_prompt(curbuf) && (mod_mask & MOD_MASK_SHIFT) == 0)
+ {
+ // In a prompt window CTRL-W is used for window commands.
+ // Use Shift-CTRL-W to delete a word.
+ stuffcharReadbuff(Ctrl_W);
+ restart_edit = 'i';
+ nomove = TRUE;
+ count = 0;
+ goto doESCkey;
+ }
+ #endif
did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space);
auto_format(FALSE, TRUE);
break;
***************
*** 1869,1874 ****
--- 1889,1907 ----
coladvance((colnr_T)MAXCOL);
changed_bytes(curbuf->b_ml.ml_line_count, 0);
}
+
+ // Insert always starts after the prompt, allow editing text after it.
+ if (Insstart_orig.lnum != curwin->w_cursor.lnum
+ || Insstart_orig.col != (int)STRLEN(prompt))
+ {
+ Insstart.lnum = curwin->w_cursor.lnum;
+ Insstart.col = STRLEN(prompt);
+ Insstart_orig = Insstart;
+ Insstart_textlen = Insstart.col;
+ Insstart_blank_vcol = MAXCOL;
+ arrow_used = FALSE;
+ }
+
if (cmdchar_todo == 'A')
coladvance((colnr_T)MAXCOL);
if (cmdchar_todo == 'I' || curwin->w_cursor.col <= (int)STRLEN(prompt))
*** ../vim-8.1.0034/src/ex_docmd.c 2018-05-08 21:57:39.000000000 +0200
--- src/ex_docmd.c 2018-06-06 08:58:58.317930716 +0200
***************
*** 7341,7347 ****
{
if (eap->addr_count == 0)
ex_win_close(eap->forceit, curwin, NULL);
! else {
FOR_ALL_WINDOWS(win)
{
winnr++;
--- 7341,7348 ----
{
if (eap->addr_count == 0)
ex_win_close(eap->forceit, curwin, NULL);
! else
! {
FOR_ALL_WINDOWS(win)
{
winnr++;
*** ../vim-8.1.0034/src/structs.h 2018-06-03 14:42:17.848505102 +0200
--- src/structs.h 2018-06-06 08:58:58.317930716 +0200
***************
*** 2360,2365 ****
--- 2360,2367 ----
char_u *b_prompt_text; // set by prompt_setprompt()
char_u *b_prompt_callback; // set by prompt_setcallback()
partial_T *b_prompt_partial; // set by prompt_setcallback()
+ int b_prompt_insert; // value for restart_edit when
entering
+ // a prompt buffer window.
#endif
#ifdef FEAT_MZSCHEME
void *b_mzscheme_ref; /* The MzScheme reference to this buffer */
*** ../vim-8.1.0034/src/window.c 2018-05-04 20:09:46.000000000 +0200
--- src/window.c 2018-06-06 08:58:58.321930713 +0200
***************
*** 2103,2108 ****
--- 2103,2131 ----
}
}
+ #ifdef FEAT_JOB_CHANNEL
+ static void
+ leaving_window(win_T *win)
+ {
+ // When leaving a prompt window stop Insert mode and perhaps restart
+ // it when entering that window again.
+ win->w_buffer->b_prompt_insert = restart_edit;
+ restart_edit = NUL;
+
+ // When leaving the window (or closing the window) was done from a
+ // callback we need to break out of the Insert mode loop.
+ if (State & INSERT)
+ stop_insert_mode = TRUE;
+ }
+
+ static void
+ entering_window(win_T *win)
+ {
+ // When entering the prompt window may restart Insert mode.
+ restart_edit = win->w_buffer->b_prompt_insert;
+ }
+ #endif
+
/*
* Close all windows for buffer "buf".
*/
***************
*** 2231,2236 ****
--- 2254,2262 ----
if (h != tabline_height())
shell_new_rows();
}
+ #ifdef FEAT_JOB_CHANNEL
+ entering_window(curwin);
+ #endif
/* Since goto_tabpage_tp above did not trigger *Enter autocommands, do
* that now. */
apply_autocmds(EVENT_TABCLOSED, NULL, NULL, FALSE, curbuf);
***************
*** 2296,2301 ****
--- 2322,2330 ----
if (win == curwin)
{
+ #ifdef FEAT_JOB_CHANNEL
+ leaving_window(curwin);
+ #endif
/*
* Guess which window is going to be the new current window.
* This may change because of the autocommands (sigh).
***************
*** 3649,3654 ****
--- 3678,3686 ----
* scrollbars. Have to update them anyway. */
gui_may_update_scrollbars();
#endif
+ #ifdef FEAT_JOB_CHANNEL
+ entering_window(curwin);
+ #endif
redraw_all_later(CLEAR);
apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
***************
*** 3822,3827 ****
--- 3854,3862 ----
{
tabpage_T *tp = curtab;
+ #ifdef FEAT_JOB_CHANNEL
+ leaving_window(curwin);
+ #endif
reset_VIsual_and_resel(); /* stop Visual mode */
if (trigger_leave_autocmds)
{
***************
*** 4318,4323 ****
--- 4353,4363 ----
if (wp == curwin && !curwin_invalid) /* nothing to do */
return;
+ #ifdef FEAT_JOB_CHANNEL
+ if (!curwin_invalid)
+ leaving_window(curwin);
+ #endif
+
if (!curwin_invalid && trigger_leave_autocmds)
{
/*
***************
*** 4389,4394 ****
--- 4429,4437 ----
shorten_fnames(TRUE);
}
+ #ifdef FEAT_JOB_CHANNEL
+ entering_window(curwin);
+ #endif
if (trigger_new_autocmds)
apply_autocmds(EVENT_WINNEW, NULL, NULL, FALSE, curbuf);
if (trigger_enter_autocmds)
*** ../vim-8.1.0034/src/version.c 2018-06-04 20:34:07.607373577 +0200
--- src/version.c 2018-06-06 09:01:35.521811501 +0200
***************
*** 763,764 ****
--- 763,766 ----
{ /* Add new patch number below this line */
+ /**/
+ 35,
/**/
--
How To Keep A Healthy Level Of Insanity:
12. Sing along at the opera.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.