Permalink
Browse files

patch 8.0.0761: options not set properly for a terminal buffer

Problem:    Options of a buffer for a terminal window are not set properly.
Solution:   Add "terminal" value for 'buftype'.  Make 'buftype' and
            'bufhidden' not depend on the quickfix feature.
            Also set the buffer name and show "running" or "finished" in the
            window title.
  • Loading branch information...
brammool committed Jul 23, 2017
1 parent 065f41c commit 1f2903c43109b16594d141a730659317b15f388d
Showing with 184 additions and 133 deletions.
  1. +15 −10 runtime/doc/options.txt
  2. +16 −10 src/buffer.c
  3. +4 −0 src/channel.c
  4. +2 −5 src/ex_docmd.c
  5. +0 −2 src/fileio.c
  6. +9 −33 src/option.c
  7. +6 −5 src/proto/quickfix.pro
  8. +3 −1 src/proto/terminal.pro
  9. +70 −59 src/quickfix.c
  10. +1 −1 src/structs.h
  11. +56 −7 src/terminal.c
  12. +2 −0 src/version.c
View
@@ -1,4 +1,4 @@
*options.txt* For Vim version 8.0. Last change: 2017 Jul 15
*options.txt* For Vim version 8.0. Last change: 2017 Jul 23
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1319,8 +1319,6 @@ A jump table for the options with a short description can be found at |Q_op|.
'bufhidden' 'bh' string (default: "")
local to buffer
{not in Vi}
{not available when compiled without the |+quickfix|
feature}
This option specifies what happens when a buffer is no longer
displayed in a window:
<empty> follow the global 'hidden' option
@@ -1355,8 +1353,6 @@ A jump table for the options with a short description can be found at |Q_op|.
'buftype' 'bt' string (default: "")
local to buffer
{not in Vi}
{not available when compiled without the |+quickfix|
feature}
The value of this option specifies the type of a buffer:
<empty> normal buffer
nofile buffer which is not related to a file and will not be
@@ -1369,6 +1365,8 @@ A jump table for the options with a short description can be found at |Q_op|.
or list of locations |:lwindow|
help help buffer (you are not supposed to set this
manually)
terminal buffer for a |terminal| (you are not supposed to set
this manually)
This option is used together with 'bufhidden' and 'swapfile' to
specify special kinds of buffers. See |special-buffers|.
@@ -7760,19 +7758,26 @@ A jump table for the options with a short description can be found at |Q_op|.
{not in Vi}
The key that precedes a Vim command in a terminal window. Other keys
are sent to the job running in the window.
The string must be one key stroke.
The string must be one key stroke but can be multiple bytes.
NOT IMPLEMENTED YET
*'thesaurus'* *'tsr'*
*'termsize'* *'tms'*
'termsize' 'tms' string (default "")
local to window
{not in Vi}
Size of the |terminal| window. Format: {rows}x{columns}.
- When empty the terminal gets the size from the window.
- When set (e.g., "24x80") the terminal size is fixed. If the window
is smaller only the top-left part is displayed.
NOT IMPLEMENTED YET
- When set (e.g., "24x80") the terminal size is not adjusted to the
window size. If the window is smaller only the top-left part is
displayed.
When rows is zero then use the height of the window.
When columns is zero then use the width of the window.
For example: "30x0" uses 30 rows with the current window width.
Using "0x0" is the same as empty.
Note that the command running in the terminal window may still change
the size of the terminal. In that case the Vim window will be
adjusted to that size, if possible.
*'terse'* *'noterse'*
'terse' boolean (default off)
View
@@ -468,7 +468,6 @@ close_buffer(
int del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
int wipe_buf = (action == DOBUF_WIPE);
#ifdef FEAT_QUICKFIX
/*
* Force unloading or deleting when 'bufhidden' says so.
* The caller must take care of NOT deleting/freeing when 'bufhidden' is
@@ -487,7 +486,6 @@ close_buffer(
}
else if (buf->b_p_bh[0] == 'u') /* 'bufhidden' == "unload" */
unload_buf = TRUE;
#endif
#ifdef FEAT_AUTOCMD
/* Disallow deleting the buffer when it is locked (already being closed or
@@ -1982,16 +1980,14 @@ buflist_new(
return NULL;
# endif
#endif
#ifdef FEAT_QUICKFIX
# ifdef FEAT_AUTOCMD
#ifdef FEAT_AUTOCMD
if (buf == curbuf)
# endif
#endif
{
/* Make sure 'bufhidden' and 'buftype' are empty */
clear_string_option(&buf->b_p_bh);
clear_string_option(&buf->b_p_bt);
}
#endif
}
if (buf != curbuf || curbuf == NULL)
{
@@ -2165,10 +2161,8 @@ free_buf_options(
clear_string_option(&buf->b_p_fenc);
#endif
clear_string_option(&buf->b_p_ff);
#ifdef FEAT_QUICKFIX
clear_string_option(&buf->b_p_bh);
clear_string_option(&buf->b_p_bt);
#endif
}
#ifdef FEAT_FIND_ID
clear_string_option(&buf->b_p_def);
@@ -3668,9 +3662,21 @@ maketitle(void)
/* remove the file name */
p = gettail_sep(buf + off);
if (p == buf + off)
/* must be a help buffer */
vim_strncpy(buf + off, (char_u *)_("help"),
{
char *txt;
#ifdef FEAT_TERMINAL
if (curbuf->b_term != NULL)
txt = term_job_running(curbuf)
? _("running") : _("finished");
else
#endif
txt = _("help");
/* must be a help or terminal buffer */
vim_strncpy(buf + off, (char_u *)txt,
(size_t)(SPACE_FOR_DIR - off - 1));
}
else
*p = NUL;
View
@@ -4696,6 +4696,10 @@ job_cleanup(job_T *job)
* not use "job" after this! */
job_free(job);
}
#ifdef FEAT_TERMINAL
term_job_ended(job);
#endif
}
/*
View
@@ -8548,7 +8548,7 @@ ex_resize(exarg_T *eap)
{
if (*eap->arg == '-' || *eap->arg == '+')
n += curwin->w_height;
else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */
else if (n == 0 && eap->arg[0] == NUL) /* default is very high */
n = 9999;
win_setheight_win((int)n, wp);
}
@@ -11679,10 +11679,7 @@ put_view(
*/
if ((*flagp & SSOP_FOLDS)
&& wp->w_buffer->b_ffname != NULL
# ifdef FEAT_QUICKFIX
&& (*wp->w_buffer->b_p_bt == NUL || wp->w_buffer->b_help)
# endif
)
&& (*wp->w_buffer->b_p_bt == NUL || wp->w_buffer->b_help))
{
if (put_folds(fd, wp) == FAIL)
return FAIL;
View
@@ -6882,9 +6882,7 @@ buf_check_timestamp(
* this buffer. */
if (buf->b_ffname == NULL
|| buf->b_ml.ml_mfp == NULL
#if defined(FEAT_QUICKFIX)
|| *buf->b_p_bt != NUL
#endif
|| buf->b_saving
#ifdef FEAT_AUTOCMD
|| busy
View
@@ -287,10 +287,8 @@ static int p_bin;
#ifdef FEAT_MBYTE
static int p_bomb;
#endif
#if defined(FEAT_QUICKFIX)
static char_u *p_bh;
static char_u *p_bt;
#endif
static int p_bl;
static int p_ci;
#ifdef FEAT_CINDENT
@@ -720,26 +718,16 @@ static struct vimoption options[] =
#endif
SCRIPTID_INIT},
{"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
#if defined(FEAT_QUICKFIX)
(char_u *)&p_bh, PV_BH,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
(char_u *)&p_bl, PV_BL,
{(char_u *)1L, (char_u *)0L}
SCRIPTID_INIT},
{"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
#if defined(FEAT_QUICKFIX)
(char_u *)&p_bt, PV_BT,
{(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)0L, (char_u *)0L}
#endif
SCRIPTID_INIT},
{"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
#ifdef FEAT_MBYTE
@@ -3254,14 +3242,12 @@ static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
#ifdef FEAT_WINDOWS
static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
#endif
#if defined(FEAT_QUICKFIX)
# ifdef FEAT_AUTOCMD
static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
# else
static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
# endif
static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
#ifdef FEAT_AUTOCMD
static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", NULL};
#else
static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", NULL};
#endif
static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
#ifdef FEAT_FOLDING
static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
@@ -5649,10 +5635,8 @@ check_options(void)
void
check_buf_options(buf_T *buf)
{
#if defined(FEAT_QUICKFIX)
check_string_option(&buf->b_p_bh);
check_string_option(&buf->b_p_bt);
#endif
#ifdef FEAT_MBYTE
check_string_option(&buf->b_p_fenc);
#endif
@@ -7115,7 +7099,6 @@ did_set_string_option(
}
#endif
#ifdef FEAT_QUICKFIX
/* When 'bufhidden' is set, check for valid value. */
else if (gvarp == &p_bh)
{
@@ -7130,20 +7113,19 @@ did_set_string_option(
errmsg = e_invarg;
else
{
# ifdef FEAT_WINDOWS
#ifdef FEAT_WINDOWS
if (curwin->w_status_height)
{
curwin->w_redr_status = TRUE;
redraw_later(VALID);
}
# endif
#endif
curbuf->b_help = (curbuf->b_p_bt[0] == 'h');
# ifdef FEAT_TITLE
#ifdef FEAT_TITLE
redraw_titles();
# endif
#endif
}
}
#endif
#ifdef FEAT_STL_OPT
/* 'statusline' or 'rulerformat' */
@@ -10722,10 +10704,8 @@ get_varp(struct vimoption *p)
#ifdef FEAT_MBYTE
case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
#endif
#if defined(FEAT_QUICKFIX)
case PV_BH: return (char_u *)&(curbuf->b_p_bh);
case PV_BT: return (char_u *)&(curbuf->b_p_bt);
#endif
case PV_BL: return (char_u *)&(curbuf->b_p_bl);
case PV_CI: return (char_u *)&(curbuf->b_p_ci);
#ifdef FEAT_CINDENT
@@ -11119,10 +11099,8 @@ buf_copy_options(buf_T *buf, int flags)
}
if (buf->b_p_ff != NULL)
buf->b_start_ffc = *buf->b_p_ff;
#if defined(FEAT_QUICKFIX)
buf->b_p_bh = empty_option;
buf->b_p_bt = empty_option;
#endif
}
else
free_buf_options(buf, FALSE);
@@ -11284,10 +11262,8 @@ buf_copy_options(buf_T *buf, int flags)
did_isk = TRUE;
buf->b_p_ts = p_ts;
buf->b_help = FALSE;
#ifdef FEAT_QUICKFIX
if (buf->b_p_bt[0] == 'h')
clear_string_option(&buf->b_p_bt);
#endif
buf->b_p_ma = p_ma;
}
}
View
@@ -12,11 +12,6 @@ void ex_cclose(exarg_T *eap);
void ex_copen(exarg_T *eap);
void ex_cbottom(exarg_T *eap);
linenr_T qf_current_entry(win_T *wp);
int bt_quickfix(buf_T *buf);
int bt_nofile(buf_T *buf);
int bt_dontwrite(buf_T *buf);
int bt_dontwrite_msg(buf_T *buf);
int buf_hide(buf_T *buf);
int grep_internal(cmdidx_T cmdidx);
void ex_make(exarg_T *eap);
int qf_get_size(exarg_T *eap);
@@ -33,4 +28,10 @@ int set_ref_in_quickfix(int copyID);
void ex_cbuffer(exarg_T *eap);
void ex_cexpr(exarg_T *eap);
void ex_helpgrep(exarg_T *eap);
int bt_quickfix(buf_T *buf);
int bt_terminal(buf_T *buf);
int bt_nofile(buf_T *buf);
int bt_dontwrite(buf_T *buf);
int bt_dontwrite_msg(buf_T *buf);
int buf_hide(buf_T *buf);
/* vim: set ft=c : */
View
@@ -2,6 +2,8 @@
void ex_terminal(exarg_T *eap);
void free_terminal(term_T *term);
void write_to_term(buf_T *buffer, char_u *msg, channel_T *channel);
void term_update_window(win_T *wp);
void terminal_loop(void);
void term_job_ended(job_T *job);
int term_job_running(buf_T *buf);
void term_update_window(win_T *wp);
/* vim: set ft=c : */
Oops, something went wrong.

0 comments on commit 1f2903c

Please sign in to comment.