forked from aniani/vim
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.
This commit is contained in:
@@ -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
|
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: "")
|
'bufhidden' 'bh' string (default: "")
|
||||||
local to buffer
|
local to buffer
|
||||||
{not in Vi}
|
{not in Vi}
|
||||||
{not available when compiled without the |+quickfix|
|
|
||||||
feature}
|
|
||||||
This option specifies what happens when a buffer is no longer
|
This option specifies what happens when a buffer is no longer
|
||||||
displayed in a window:
|
displayed in a window:
|
||||||
<empty> follow the global 'hidden' option
|
<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: "")
|
'buftype' 'bt' string (default: "")
|
||||||
local to buffer
|
local to buffer
|
||||||
{not in Vi}
|
{not in Vi}
|
||||||
{not available when compiled without the |+quickfix|
|
|
||||||
feature}
|
|
||||||
The value of this option specifies the type of a buffer:
|
The value of this option specifies the type of a buffer:
|
||||||
<empty> normal buffer
|
<empty> normal buffer
|
||||||
nofile buffer which is not related to a file and will not be
|
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|
|
or list of locations |:lwindow|
|
||||||
help help buffer (you are not supposed to set this
|
help help buffer (you are not supposed to set this
|
||||||
manually)
|
manually)
|
||||||
|
terminal buffer for a |terminal| (you are not supposed to set
|
||||||
|
this manually)
|
||||||
|
|
||||||
This option is used together with 'bufhidden' and 'swapfile' to
|
This option is used together with 'bufhidden' and 'swapfile' to
|
||||||
specify special kinds of buffers. See |special-buffers|.
|
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}
|
{not in Vi}
|
||||||
The key that precedes a Vim command in a terminal window. Other keys
|
The key that precedes a Vim command in a terminal window. Other keys
|
||||||
are sent to the job running in the window.
|
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
|
NOT IMPLEMENTED YET
|
||||||
|
|
||||||
|
|
||||||
*'thesaurus'* *'tsr'*
|
*'termsize'* *'tms'*
|
||||||
'termsize' 'tms' string (default "")
|
'termsize' 'tms' string (default "")
|
||||||
local to window
|
local to window
|
||||||
{not in Vi}
|
{not in Vi}
|
||||||
Size of the |terminal| window. Format: {rows}x{columns}.
|
Size of the |terminal| window. Format: {rows}x{columns}.
|
||||||
- When empty the terminal gets the size from the window.
|
- When empty the terminal gets the size from the window.
|
||||||
- When set (e.g., "24x80") the terminal size is fixed. If the window
|
- When set (e.g., "24x80") the terminal size is not adjusted to the
|
||||||
is smaller only the top-left part is displayed.
|
window size. If the window is smaller only the top-left part is
|
||||||
NOT IMPLEMENTED YET
|
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'* *'noterse'*
|
||||||
'terse' boolean (default off)
|
'terse' boolean (default off)
|
||||||
|
|||||||
22
src/buffer.c
22
src/buffer.c
@@ -468,7 +468,6 @@ close_buffer(
|
|||||||
int del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
|
int del_buf = (action == DOBUF_DEL || action == DOBUF_WIPE);
|
||||||
int wipe_buf = (action == DOBUF_WIPE);
|
int wipe_buf = (action == DOBUF_WIPE);
|
||||||
|
|
||||||
#ifdef FEAT_QUICKFIX
|
|
||||||
/*
|
/*
|
||||||
* Force unloading or deleting when 'bufhidden' says so.
|
* Force unloading or deleting when 'bufhidden' says so.
|
||||||
* The caller must take care of NOT deleting/freeing when 'bufhidden' is
|
* 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" */
|
else if (buf->b_p_bh[0] == 'u') /* 'bufhidden' == "unload" */
|
||||||
unload_buf = TRUE;
|
unload_buf = TRUE;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
/* Disallow deleting the buffer when it is locked (already being closed or
|
/* Disallow deleting the buffer when it is locked (already being closed or
|
||||||
@@ -1982,7 +1980,6 @@ buflist_new(
|
|||||||
return NULL;
|
return NULL;
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_QUICKFIX
|
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
if (buf == curbuf)
|
if (buf == curbuf)
|
||||||
#endif
|
#endif
|
||||||
@@ -1991,7 +1988,6 @@ buflist_new(
|
|||||||
clear_string_option(&buf->b_p_bh);
|
clear_string_option(&buf->b_p_bh);
|
||||||
clear_string_option(&buf->b_p_bt);
|
clear_string_option(&buf->b_p_bt);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (buf != curbuf || curbuf == NULL)
|
if (buf != curbuf || curbuf == NULL)
|
||||||
{
|
{
|
||||||
@@ -2165,10 +2161,8 @@ free_buf_options(
|
|||||||
clear_string_option(&buf->b_p_fenc);
|
clear_string_option(&buf->b_p_fenc);
|
||||||
#endif
|
#endif
|
||||||
clear_string_option(&buf->b_p_ff);
|
clear_string_option(&buf->b_p_ff);
|
||||||
#ifdef FEAT_QUICKFIX
|
|
||||||
clear_string_option(&buf->b_p_bh);
|
clear_string_option(&buf->b_p_bh);
|
||||||
clear_string_option(&buf->b_p_bt);
|
clear_string_option(&buf->b_p_bt);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#ifdef FEAT_FIND_ID
|
#ifdef FEAT_FIND_ID
|
||||||
clear_string_option(&buf->b_p_def);
|
clear_string_option(&buf->b_p_def);
|
||||||
@@ -3668,9 +3662,21 @@ maketitle(void)
|
|||||||
/* remove the file name */
|
/* remove the file name */
|
||||||
p = gettail_sep(buf + off);
|
p = gettail_sep(buf + off);
|
||||||
if (p == 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));
|
(size_t)(SPACE_FOR_DIR - off - 1));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
|
|
||||||
|
|||||||
@@ -4696,6 +4696,10 @@ job_cleanup(job_T *job)
|
|||||||
* not use "job" after this! */
|
* not use "job" after this! */
|
||||||
job_free(job);
|
job_free(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FEAT_TERMINAL
|
||||||
|
term_job_ended(job);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -8548,7 +8548,7 @@ ex_resize(exarg_T *eap)
|
|||||||
{
|
{
|
||||||
if (*eap->arg == '-' || *eap->arg == '+')
|
if (*eap->arg == '-' || *eap->arg == '+')
|
||||||
n += curwin->w_height;
|
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;
|
n = 9999;
|
||||||
win_setheight_win((int)n, wp);
|
win_setheight_win((int)n, wp);
|
||||||
}
|
}
|
||||||
@@ -11679,10 +11679,7 @@ put_view(
|
|||||||
*/
|
*/
|
||||||
if ((*flagp & SSOP_FOLDS)
|
if ((*flagp & SSOP_FOLDS)
|
||||||
&& wp->w_buffer->b_ffname != NULL
|
&& wp->w_buffer->b_ffname != NULL
|
||||||
# ifdef FEAT_QUICKFIX
|
&& (*wp->w_buffer->b_p_bt == NUL || wp->w_buffer->b_help))
|
||||||
&& (*wp->w_buffer->b_p_bt == NUL || wp->w_buffer->b_help)
|
|
||||||
# endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (put_folds(fd, wp) == FAIL)
|
if (put_folds(fd, wp) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
|
|||||||
@@ -6882,9 +6882,7 @@ buf_check_timestamp(
|
|||||||
* this buffer. */
|
* this buffer. */
|
||||||
if (buf->b_ffname == NULL
|
if (buf->b_ffname == NULL
|
||||||
|| buf->b_ml.ml_mfp == NULL
|
|| buf->b_ml.ml_mfp == NULL
|
||||||
#if defined(FEAT_QUICKFIX)
|
|
||||||
|| *buf->b_p_bt != NUL
|
|| *buf->b_p_bt != NUL
|
||||||
#endif
|
|
||||||
|| buf->b_saving
|
|| buf->b_saving
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
|| busy
|
|| busy
|
||||||
|
|||||||
28
src/option.c
28
src/option.c
@@ -287,10 +287,8 @@ static int p_bin;
|
|||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
static int p_bomb;
|
static int p_bomb;
|
||||||
#endif
|
#endif
|
||||||
#if defined(FEAT_QUICKFIX)
|
|
||||||
static char_u *p_bh;
|
static char_u *p_bh;
|
||||||
static char_u *p_bt;
|
static char_u *p_bt;
|
||||||
#endif
|
|
||||||
static int p_bl;
|
static int p_bl;
|
||||||
static int p_ci;
|
static int p_ci;
|
||||||
#ifdef FEAT_CINDENT
|
#ifdef FEAT_CINDENT
|
||||||
@@ -720,26 +718,16 @@ static struct vimoption options[] =
|
|||||||
#endif
|
#endif
|
||||||
SCRIPTID_INIT},
|
SCRIPTID_INIT},
|
||||||
{"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
|
{"bufhidden", "bh", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
|
||||||
#if defined(FEAT_QUICKFIX)
|
|
||||||
(char_u *)&p_bh, PV_BH,
|
(char_u *)&p_bh, PV_BH,
|
||||||
{(char_u *)"", (char_u *)0L}
|
{(char_u *)"", (char_u *)0L}
|
||||||
#else
|
|
||||||
(char_u *)NULL, PV_NONE,
|
|
||||||
{(char_u *)0L, (char_u *)0L}
|
|
||||||
#endif
|
|
||||||
SCRIPTID_INIT},
|
SCRIPTID_INIT},
|
||||||
{"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
|
{"buflisted", "bl", P_BOOL|P_VI_DEF|P_NOGLOB,
|
||||||
(char_u *)&p_bl, PV_BL,
|
(char_u *)&p_bl, PV_BL,
|
||||||
{(char_u *)1L, (char_u *)0L}
|
{(char_u *)1L, (char_u *)0L}
|
||||||
SCRIPTID_INIT},
|
SCRIPTID_INIT},
|
||||||
{"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
|
{"buftype", "bt", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB,
|
||||||
#if defined(FEAT_QUICKFIX)
|
|
||||||
(char_u *)&p_bt, PV_BT,
|
(char_u *)&p_bt, PV_BT,
|
||||||
{(char_u *)"", (char_u *)0L}
|
{(char_u *)"", (char_u *)0L}
|
||||||
#else
|
|
||||||
(char_u *)NULL, PV_NONE,
|
|
||||||
{(char_u *)0L, (char_u *)0L}
|
|
||||||
#endif
|
|
||||||
SCRIPTID_INIT},
|
SCRIPTID_INIT},
|
||||||
{"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
|
{"casemap", "cmp", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP,
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
@@ -3254,14 +3242,12 @@ static char *(p_debug_values[]) = {"msg", "throw", "beep", NULL};
|
|||||||
#ifdef FEAT_WINDOWS
|
#ifdef FEAT_WINDOWS
|
||||||
static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
|
static char *(p_ead_values[]) = {"both", "ver", "hor", NULL};
|
||||||
#endif
|
#endif
|
||||||
#if defined(FEAT_QUICKFIX)
|
|
||||||
#ifdef FEAT_AUTOCMD
|
#ifdef FEAT_AUTOCMD
|
||||||
static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "acwrite", NULL};
|
static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", "acwrite", NULL};
|
||||||
#else
|
#else
|
||||||
static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", NULL};
|
static char *(p_buftype_values[]) = {"nofile", "nowrite", "quickfix", "help", "terminal", NULL};
|
||||||
#endif
|
#endif
|
||||||
static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
|
static char *(p_bufhidden_values[]) = {"hide", "unload", "delete", "wipe", NULL};
|
||||||
#endif
|
|
||||||
static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
|
static char *(p_bs_values[]) = {"indent", "eol", "start", NULL};
|
||||||
#ifdef FEAT_FOLDING
|
#ifdef FEAT_FOLDING
|
||||||
static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
|
static char *(p_fdm_values[]) = {"manual", "expr", "marker", "indent", "syntax",
|
||||||
@@ -5649,10 +5635,8 @@ check_options(void)
|
|||||||
void
|
void
|
||||||
check_buf_options(buf_T *buf)
|
check_buf_options(buf_T *buf)
|
||||||
{
|
{
|
||||||
#if defined(FEAT_QUICKFIX)
|
|
||||||
check_string_option(&buf->b_p_bh);
|
check_string_option(&buf->b_p_bh);
|
||||||
check_string_option(&buf->b_p_bt);
|
check_string_option(&buf->b_p_bt);
|
||||||
#endif
|
|
||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
check_string_option(&buf->b_p_fenc);
|
check_string_option(&buf->b_p_fenc);
|
||||||
#endif
|
#endif
|
||||||
@@ -7115,7 +7099,6 @@ did_set_string_option(
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_QUICKFIX
|
|
||||||
/* When 'bufhidden' is set, check for valid value. */
|
/* When 'bufhidden' is set, check for valid value. */
|
||||||
else if (gvarp == &p_bh)
|
else if (gvarp == &p_bh)
|
||||||
{
|
{
|
||||||
@@ -7143,7 +7126,6 @@ did_set_string_option(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEAT_STL_OPT
|
#ifdef FEAT_STL_OPT
|
||||||
/* 'statusline' or 'rulerformat' */
|
/* 'statusline' or 'rulerformat' */
|
||||||
@@ -10722,10 +10704,8 @@ get_varp(struct vimoption *p)
|
|||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
|
case PV_BOMB: return (char_u *)&(curbuf->b_p_bomb);
|
||||||
#endif
|
#endif
|
||||||
#if defined(FEAT_QUICKFIX)
|
|
||||||
case PV_BH: return (char_u *)&(curbuf->b_p_bh);
|
case PV_BH: return (char_u *)&(curbuf->b_p_bh);
|
||||||
case PV_BT: return (char_u *)&(curbuf->b_p_bt);
|
case PV_BT: return (char_u *)&(curbuf->b_p_bt);
|
||||||
#endif
|
|
||||||
case PV_BL: return (char_u *)&(curbuf->b_p_bl);
|
case PV_BL: return (char_u *)&(curbuf->b_p_bl);
|
||||||
case PV_CI: return (char_u *)&(curbuf->b_p_ci);
|
case PV_CI: return (char_u *)&(curbuf->b_p_ci);
|
||||||
#ifdef FEAT_CINDENT
|
#ifdef FEAT_CINDENT
|
||||||
@@ -11119,10 +11099,8 @@ buf_copy_options(buf_T *buf, int flags)
|
|||||||
}
|
}
|
||||||
if (buf->b_p_ff != NULL)
|
if (buf->b_p_ff != NULL)
|
||||||
buf->b_start_ffc = *buf->b_p_ff;
|
buf->b_start_ffc = *buf->b_p_ff;
|
||||||
#if defined(FEAT_QUICKFIX)
|
|
||||||
buf->b_p_bh = empty_option;
|
buf->b_p_bh = empty_option;
|
||||||
buf->b_p_bt = empty_option;
|
buf->b_p_bt = empty_option;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
free_buf_options(buf, FALSE);
|
free_buf_options(buf, FALSE);
|
||||||
@@ -11284,10 +11262,8 @@ buf_copy_options(buf_T *buf, int flags)
|
|||||||
did_isk = TRUE;
|
did_isk = TRUE;
|
||||||
buf->b_p_ts = p_ts;
|
buf->b_p_ts = p_ts;
|
||||||
buf->b_help = FALSE;
|
buf->b_help = FALSE;
|
||||||
#ifdef FEAT_QUICKFIX
|
|
||||||
if (buf->b_p_bt[0] == 'h')
|
if (buf->b_p_bt[0] == 'h')
|
||||||
clear_string_option(&buf->b_p_bt);
|
clear_string_option(&buf->b_p_bt);
|
||||||
#endif
|
|
||||||
buf->b_p_ma = p_ma;
|
buf->b_p_ma = p_ma;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ void ex_cclose(exarg_T *eap);
|
|||||||
void ex_copen(exarg_T *eap);
|
void ex_copen(exarg_T *eap);
|
||||||
void ex_cbottom(exarg_T *eap);
|
void ex_cbottom(exarg_T *eap);
|
||||||
linenr_T qf_current_entry(win_T *wp);
|
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);
|
int grep_internal(cmdidx_T cmdidx);
|
||||||
void ex_make(exarg_T *eap);
|
void ex_make(exarg_T *eap);
|
||||||
int qf_get_size(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_cbuffer(exarg_T *eap);
|
||||||
void ex_cexpr(exarg_T *eap);
|
void ex_cexpr(exarg_T *eap);
|
||||||
void ex_helpgrep(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 : */
|
/* vim: set ft=c : */
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
void ex_terminal(exarg_T *eap);
|
void ex_terminal(exarg_T *eap);
|
||||||
void free_terminal(term_T *term);
|
void free_terminal(term_T *term);
|
||||||
void write_to_term(buf_T *buffer, char_u *msg, channel_T *channel);
|
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 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 : */
|
/* vim: set ft=c : */
|
||||||
|
|||||||
129
src/quickfix.c
129
src/quickfix.c
@@ -2169,7 +2169,7 @@ qf_jump(
|
|||||||
* quickfix window. */
|
* quickfix window. */
|
||||||
FOR_ALL_WINDOWS(usable_win_ptr)
|
FOR_ALL_WINDOWS(usable_win_ptr)
|
||||||
if (usable_win_ptr->w_llist == ll_ref
|
if (usable_win_ptr->w_llist == ll_ref
|
||||||
&& usable_win_ptr->w_buffer->b_p_bt[0] != 'q')
|
&& !bt_quickfix(usable_win_ptr->w_buffer))
|
||||||
{
|
{
|
||||||
usable_win = 1;
|
usable_win = 1;
|
||||||
break;
|
break;
|
||||||
@@ -3449,64 +3449,6 @@ qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last)
|
|||||||
|
|
||||||
#endif /* FEAT_WINDOWS */
|
#endif /* FEAT_WINDOWS */
|
||||||
|
|
||||||
/*
|
|
||||||
* Return TRUE if "buf" is the quickfix buffer.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
bt_quickfix(buf_T *buf)
|
|
||||||
{
|
|
||||||
return buf != NULL && buf->b_p_bt[0] == 'q';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return TRUE if "buf" is a "nofile" or "acwrite" buffer.
|
|
||||||
* This means the buffer name is not a file name.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
bt_nofile(buf_T *buf)
|
|
||||||
{
|
|
||||||
return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
|
|
||||||
|| buf->b_p_bt[0] == 'a');
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return TRUE if "buf" is a "nowrite" or "nofile" buffer.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
bt_dontwrite(buf_T *buf)
|
|
||||||
{
|
|
||||||
return buf != NULL && buf->b_p_bt[0] == 'n';
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
bt_dontwrite_msg(buf_T *buf)
|
|
||||||
{
|
|
||||||
if (bt_dontwrite(buf))
|
|
||||||
{
|
|
||||||
EMSG(_("E382: Cannot write, 'buftype' option is set"));
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return TRUE if the buffer should be hidden, according to 'hidden', ":hide"
|
|
||||||
* and 'bufhidden'.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
buf_hide(buf_T *buf)
|
|
||||||
{
|
|
||||||
/* 'bufhidden' overrules 'hidden' and ":hide", check it first */
|
|
||||||
switch (buf->b_p_bh[0])
|
|
||||||
{
|
|
||||||
case 'u': /* "unload" */
|
|
||||||
case 'w': /* "wipe" */
|
|
||||||
case 'd': return FALSE; /* "delete" */
|
|
||||||
case 'h': return TRUE; /* "hide" */
|
|
||||||
}
|
|
||||||
return (p_hid || cmdmod.hide);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return TRUE when using ":vimgrep" for ":grep".
|
* Return TRUE when using ":vimgrep" for ":grep".
|
||||||
*/
|
*/
|
||||||
@@ -5584,3 +5526,72 @@ ex_helpgrep(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FEAT_QUICKFIX */
|
#endif /* FEAT_QUICKFIX */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if "buf" is the quickfix buffer.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
bt_quickfix(buf_T *buf)
|
||||||
|
{
|
||||||
|
return buf != NULL && buf->b_p_bt[0] == 'q';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if "buf" is a terminal buffer.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
bt_terminal(buf_T *buf)
|
||||||
|
{
|
||||||
|
return buf != NULL && buf->b_p_bt[0] == 't';
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if "buf" is a "nofile", "acwrite" or "terminal" buffer.
|
||||||
|
* This means the buffer name is not a file name.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
bt_nofile(buf_T *buf)
|
||||||
|
{
|
||||||
|
return buf != NULL && ((buf->b_p_bt[0] == 'n' && buf->b_p_bt[2] == 'f')
|
||||||
|
|| buf->b_p_bt[0] == 'a'
|
||||||
|
|| buf->b_p_bt[0] == 't');
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if "buf" is a "nowrite", "nofile" or "terminal" buffer.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
bt_dontwrite(buf_T *buf)
|
||||||
|
{
|
||||||
|
return buf != NULL && (buf->b_p_bt[0] == 'n' || buf->b_p_bt[0] == 't');
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
bt_dontwrite_msg(buf_T *buf)
|
||||||
|
{
|
||||||
|
if (bt_dontwrite(buf))
|
||||||
|
{
|
||||||
|
EMSG(_("E382: Cannot write, 'buftype' option is set"));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if the buffer should be hidden, according to 'hidden', ":hide"
|
||||||
|
* and 'bufhidden'.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
buf_hide(buf_T *buf)
|
||||||
|
{
|
||||||
|
/* 'bufhidden' overrules 'hidden' and ":hide", check it first */
|
||||||
|
switch (buf->b_p_bh[0])
|
||||||
|
{
|
||||||
|
case 'u': /* "unload" */
|
||||||
|
case 'w': /* "wipe" */
|
||||||
|
case 'd': return FALSE; /* "delete" */
|
||||||
|
case 'h': return TRUE; /* "hide" */
|
||||||
|
}
|
||||||
|
return (p_hid || cmdmod.hide);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2088,9 +2088,9 @@ struct file_buffer
|
|||||||
#ifdef FEAT_MBYTE
|
#ifdef FEAT_MBYTE
|
||||||
int b_p_bomb; /* 'bomb' */
|
int b_p_bomb; /* 'bomb' */
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEAT_QUICKFIX
|
|
||||||
char_u *b_p_bh; /* 'bufhidden' */
|
char_u *b_p_bh; /* 'bufhidden' */
|
||||||
char_u *b_p_bt; /* 'buftype' */
|
char_u *b_p_bt; /* 'buftype' */
|
||||||
|
#ifdef FEAT_QUICKFIX
|
||||||
#define BUF_HAS_QF_ENTRY 1
|
#define BUF_HAS_QF_ENTRY 1
|
||||||
#define BUF_HAS_LL_ENTRY 2
|
#define BUF_HAS_LL_ENTRY 2
|
||||||
int b_has_qf_entry;
|
int b_has_qf_entry;
|
||||||
|
|||||||
@@ -33,9 +33,8 @@
|
|||||||
* while, if the terminal window is visible, the screen contents is drawn.
|
* while, if the terminal window is visible, the screen contents is drawn.
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
* - cursor flickers when moving the cursor
|
* - do not store terminal buffer in viminfo
|
||||||
* - set buffer options to be scratch, hidden, nomodifiable, etc.
|
* - put terminal title in the statusline
|
||||||
* - set buffer name to command, add (1) to avoid duplicates.
|
|
||||||
* - Add a scrollback buffer (contains lines to scroll off the top).
|
* - Add a scrollback buffer (contains lines to scroll off the top).
|
||||||
* Can use the buf_T lines, store attributes somewhere else?
|
* Can use the buf_T lines, store attributes somewhere else?
|
||||||
* - When the job ends:
|
* - When the job ends:
|
||||||
@@ -53,7 +52,6 @@
|
|||||||
* - support minimal size when 'termsize' is empty?
|
* - support minimal size when 'termsize' is empty?
|
||||||
* - implement "term" for job_start(): more job options when starting a
|
* - implement "term" for job_start(): more job options when starting a
|
||||||
* terminal.
|
* terminal.
|
||||||
* - implement ":buf {term-buf-name}"
|
|
||||||
* - implement term_list() list of buffers with a terminal
|
* - implement term_list() list of buffers with a terminal
|
||||||
* - implement term_getsize(buf)
|
* - implement term_getsize(buf)
|
||||||
* - implement term_setsize(buf)
|
* - implement term_setsize(buf)
|
||||||
@@ -192,7 +190,31 @@ ex_terminal(exarg_T *eap)
|
|||||||
term->tl_next = first_term;
|
term->tl_next = first_term;
|
||||||
first_term = term;
|
first_term = term;
|
||||||
|
|
||||||
/* TODO: set buffer type, hidden, etc. */
|
if (buflist_findname(cmd) == NULL)
|
||||||
|
curbuf->b_ffname = vim_strsave(cmd);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
size_t len = STRLEN(cmd) + 10;
|
||||||
|
char_u *p = alloc(len);
|
||||||
|
|
||||||
|
for (i = 1; p != NULL; ++i)
|
||||||
|
{
|
||||||
|
vim_snprintf((char *)p, len, "%s (%d)", cmd, i);
|
||||||
|
if (buflist_findname(p) == NULL)
|
||||||
|
{
|
||||||
|
curbuf->b_ffname = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
curbuf->b_fname = curbuf->b_ffname;
|
||||||
|
|
||||||
|
/* Mark the buffer as changed, so that it's not easy to abandon the job. */
|
||||||
|
curbuf->b_changed = TRUE;
|
||||||
|
curbuf->b_p_ma = FALSE;
|
||||||
|
set_string_option_direct((char_u *)"buftype", -1,
|
||||||
|
(char_u *)"terminal", OPT_FREE|OPT_LOCAL, 0);
|
||||||
|
|
||||||
set_term_and_win_size(term);
|
set_term_and_win_size(term);
|
||||||
|
|
||||||
@@ -490,6 +512,26 @@ terminal_loop(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when a job has finished.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
term_job_ended(job_T *job)
|
||||||
|
{
|
||||||
|
if (curbuf->b_term != NULL && curbuf->b_term->tl_job == job)
|
||||||
|
maketitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if the job for "buf" is still running.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
term_job_running(buf_T *buf)
|
||||||
|
{
|
||||||
|
return buf->b_term != NULL && buf->b_term->tl_job != NULL
|
||||||
|
&& buf->b_term->tl_job->jv_status == JOB_STARTED;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
position_cursor(win_T *wp, VTermPos *pos)
|
position_cursor(win_T *wp, VTermPos *pos)
|
||||||
{
|
{
|
||||||
@@ -850,13 +892,20 @@ setup_job_options(jobopt_T *opt, int rows, int cols)
|
|||||||
opt->jo_out_mode = MODE_RAW;
|
opt->jo_out_mode = MODE_RAW;
|
||||||
opt->jo_err_mode = MODE_RAW;
|
opt->jo_err_mode = MODE_RAW;
|
||||||
opt->jo_set = JO_MODE | JO_OUT_MODE | JO_ERR_MODE;
|
opt->jo_set = JO_MODE | JO_OUT_MODE | JO_ERR_MODE;
|
||||||
|
|
||||||
opt->jo_io[PART_OUT] = JIO_BUFFER;
|
opt->jo_io[PART_OUT] = JIO_BUFFER;
|
||||||
opt->jo_io[PART_ERR] = JIO_BUFFER;
|
opt->jo_io[PART_ERR] = JIO_BUFFER;
|
||||||
opt->jo_set |= JO_OUT_IO + (JO_OUT_IO << (PART_ERR - PART_OUT));
|
opt->jo_set |= JO_OUT_IO + JO_ERR_IO;
|
||||||
|
|
||||||
|
opt->jo_modifiable[PART_OUT] = 0;
|
||||||
|
opt->jo_modifiable[PART_ERR] = 0;
|
||||||
|
opt->jo_set |= JO_OUT_MODIFIABLE + JO_ERR_MODIFIABLE;
|
||||||
|
|
||||||
opt->jo_io_buf[PART_OUT] = curbuf->b_fnum;
|
opt->jo_io_buf[PART_OUT] = curbuf->b_fnum;
|
||||||
opt->jo_io_buf[PART_ERR] = curbuf->b_fnum;
|
opt->jo_io_buf[PART_ERR] = curbuf->b_fnum;
|
||||||
opt->jo_pty = TRUE;
|
opt->jo_pty = TRUE;
|
||||||
opt->jo_set |= JO_OUT_BUF + (JO_OUT_BUF << (PART_ERR - PART_OUT));
|
opt->jo_set |= JO_OUT_BUF + JO_ERR_BUF;
|
||||||
|
|
||||||
opt->jo_term_rows = rows;
|
opt->jo_term_rows = rows;
|
||||||
opt->jo_term_cols = cols;
|
opt->jo_term_cols = cols;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -769,6 +769,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
761,
|
||||||
/**/
|
/**/
|
||||||
760,
|
760,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user