mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Merge remote-tracking branch 'vim/master'
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
# Format of this file: https://lgtm.com/help/lgtm/lgtm.yml-configuration-file
|
||||
path_classifiers:
|
||||
documentation:
|
||||
- runtime/tutor/tutor*
|
||||
@@ -4,6 +4,7 @@
|
||||
# source files for all source archives
|
||||
SRC_ALL = \
|
||||
.hgignore \
|
||||
.lgtm.yml \
|
||||
.travis.yml \
|
||||
appveyor.yml \
|
||||
src/appveyor.bat \
|
||||
|
||||
+15
-5
@@ -1845,6 +1845,20 @@ no_write_message_nobang(buf_T *buf UNUSED)
|
||||
|
||||
static int top_file_num = 1; /* highest file number */
|
||||
|
||||
/*
|
||||
* Return TRUE if the current buffer is empty, unnamed, unmodified and used in
|
||||
* only one window. That means it can be re-used.
|
||||
*/
|
||||
int
|
||||
curbuf_reusable(void)
|
||||
{
|
||||
return (curbuf != NULL
|
||||
&& curbuf->b_ffname == NULL
|
||||
&& curbuf->b_nwindows <= 1
|
||||
&& (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY())
|
||||
&& !curbufIsChanged());
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a file name to the buffer list. Return a pointer to the buffer.
|
||||
* If the same file name already exists return a pointer to that buffer.
|
||||
@@ -1925,11 +1939,7 @@ buflist_new(
|
||||
* buffer.)
|
||||
*/
|
||||
buf = NULL;
|
||||
if ((flags & BLN_CURBUF)
|
||||
&& curbuf != NULL
|
||||
&& curbuf->b_ffname == NULL
|
||||
&& curbuf->b_nwindows <= 1
|
||||
&& (curbuf->b_ml.ml_mfp == NULL || BUFEMPTY()))
|
||||
if ((flags & BLN_CURBUF) && curbuf_reusable())
|
||||
{
|
||||
buf = curbuf;
|
||||
/* It's like this buffer is deleted. Watch out for autocommands that
|
||||
|
||||
+38
-8
@@ -347,6 +347,15 @@ channel_still_useful(channel_T *channel)
|
||||
&& has_err_msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if "channel" is closeable (i.e. all readable fds are closed).
|
||||
*/
|
||||
static int
|
||||
channel_can_close(channel_T *channel)
|
||||
{
|
||||
return channel->ch_to_be_closed == 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Close a channel and free all its resources.
|
||||
*/
|
||||
@@ -911,7 +920,7 @@ channel_open(
|
||||
channel->ch_nb_close_cb = nb_close_cb;
|
||||
channel->ch_hostname = (char *)vim_strsave((char_u *)hostname);
|
||||
channel->ch_port = port_in;
|
||||
channel->ch_to_be_closed |= (1 << PART_SOCK);
|
||||
channel->ch_to_be_closed |= (1U << PART_SOCK);
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
channel_gui_register_one(channel, PART_SOCK);
|
||||
@@ -1007,7 +1016,8 @@ ch_close_part(channel_T *channel, ch_part_T part)
|
||||
}
|
||||
*fd = INVALID_FD;
|
||||
|
||||
channel->ch_to_be_closed &= ~(1 << part);
|
||||
/* channel is closed, may want to end the job if it was the last */
|
||||
channel->ch_to_be_closed &= ~(1U << part);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1018,6 +1028,12 @@ channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err)
|
||||
{
|
||||
ch_close_part(channel, PART_IN);
|
||||
channel->CH_IN_FD = in;
|
||||
# if defined(UNIX)
|
||||
/* Do not end the job when all output channels are closed, wait until
|
||||
* the job ended. */
|
||||
if (isatty(in))
|
||||
channel->ch_to_be_closed |= (1U << PART_IN);
|
||||
# endif
|
||||
}
|
||||
if (out != INVALID_FD)
|
||||
{
|
||||
@@ -1026,7 +1042,7 @@ channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err)
|
||||
# endif
|
||||
ch_close_part(channel, PART_OUT);
|
||||
channel->CH_OUT_FD = out;
|
||||
channel->ch_to_be_closed |= (1 << PART_OUT);
|
||||
channel->ch_to_be_closed |= (1U << PART_OUT);
|
||||
# if defined(FEAT_GUI)
|
||||
channel_gui_register_one(channel, PART_OUT);
|
||||
# endif
|
||||
@@ -1044,7 +1060,7 @@ channel_set_pipes(channel_T *channel, sock_T in, sock_T out, sock_T err)
|
||||
# endif
|
||||
{
|
||||
channel->CH_ERR_FD = err;
|
||||
channel->ch_to_be_closed |= (1 << PART_ERR);
|
||||
channel->ch_to_be_closed |= (1U << PART_ERR);
|
||||
# if defined(FEAT_GUI)
|
||||
channel_gui_register_one(channel, PART_ERR);
|
||||
# endif
|
||||
@@ -4242,9 +4258,9 @@ channel_parse_messages(void)
|
||||
}
|
||||
while (channel != NULL)
|
||||
{
|
||||
if (channel->ch_to_be_closed == 0)
|
||||
if (channel_can_close(channel))
|
||||
{
|
||||
channel->ch_to_be_closed = (1 << PART_COUNT);
|
||||
channel->ch_to_be_closed = (1U << PART_COUNT);
|
||||
channel_close_now(channel);
|
||||
/* channel may have been freed, start over */
|
||||
channel = first_channel;
|
||||
@@ -5121,6 +5137,15 @@ job_channel_still_useful(job_T *job)
|
||||
return job->jv_channel != NULL && channel_still_useful(job->jv_channel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if the channel of "job" is closeable.
|
||||
*/
|
||||
static int
|
||||
job_channel_can_close(job_T *job)
|
||||
{
|
||||
return job->jv_channel != NULL && channel_can_close(job->jv_channel);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return TRUE if the job should not be freed yet. Do not free the job when
|
||||
* it has not ended yet and there is a "stoponexit" flag, an exit callback
|
||||
@@ -5251,6 +5276,10 @@ job_cleanup(job_T *job)
|
||||
/* Ready to cleanup the job. */
|
||||
job->jv_status = JOB_FINISHED;
|
||||
|
||||
/* When only channel-in is kept open, close explicitly. */
|
||||
if (job->jv_channel != NULL)
|
||||
ch_close_part(job->jv_channel, PART_IN);
|
||||
|
||||
if (job->jv_exit_cb != NULL)
|
||||
{
|
||||
typval_T argv[3];
|
||||
@@ -5455,8 +5484,9 @@ has_pending_job(void)
|
||||
for (job = first_job; job != NULL; job = job->jv_next)
|
||||
/* Only should check if the channel has been closed, if the channel is
|
||||
* open the job won't exit. */
|
||||
if (job->jv_status == JOB_STARTED && job->jv_exit_cb != NULL
|
||||
&& !job_channel_still_useful(job))
|
||||
if ((job->jv_status == JOB_STARTED && !job_channel_still_useful(job))
|
||||
|| (job->jv_status == JOB_FINISHED
|
||||
&& job_channel_can_close(job)))
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+6
-1
@@ -1417,7 +1417,12 @@ getvcol_nolist(pos_T *posp)
|
||||
colnr_T vcol;
|
||||
|
||||
curwin->w_p_list = FALSE;
|
||||
getvcol(curwin, posp, NULL, &vcol, NULL);
|
||||
#ifdef FEAT_VIRTUALEDIT
|
||||
if (posp->coladd)
|
||||
getvvcol(curwin, posp, NULL, &vcol, NULL);
|
||||
else
|
||||
#endif
|
||||
getvcol(curwin, posp, NULL, &vcol, NULL);
|
||||
curwin->w_p_list = list_save;
|
||||
return vcol;
|
||||
}
|
||||
|
||||
+3
-3
@@ -1383,7 +1383,7 @@ doESCkey:
|
||||
goto doESCkey;
|
||||
}
|
||||
#endif
|
||||
if (ins_eol(c) && !p_im)
|
||||
if (ins_eol(c) == FAIL && !p_im)
|
||||
goto doESCkey; /* out of memory */
|
||||
auto_format(FALSE, FALSE);
|
||||
inserted_space = FALSE;
|
||||
@@ -10234,7 +10234,7 @@ ins_tab(void)
|
||||
|
||||
/*
|
||||
* Handle CR or NL in insert mode.
|
||||
* Return TRUE when out of memory or can't undo.
|
||||
* Return FAIL when out of memory or can't undo.
|
||||
*/
|
||||
static int
|
||||
ins_eol(int c)
|
||||
@@ -10299,7 +10299,7 @@ ins_eol(int c)
|
||||
foldOpenCursor();
|
||||
#endif
|
||||
|
||||
return (!i);
|
||||
return i;
|
||||
}
|
||||
|
||||
#ifdef FEAT_DIGRAPHS
|
||||
|
||||
+1
-1
@@ -10221,7 +10221,7 @@ set_buffer_lines(buf_T *buf, linenr_T lnum, typval_T *lines, typval_T *rettv)
|
||||
}
|
||||
|
||||
rettv->vval.v_number = 1; /* FAIL */
|
||||
if (line == NULL || lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1)
|
||||
if (line == NULL || lnum > curbuf->b_ml.ml_line_count + 1)
|
||||
break;
|
||||
|
||||
/* When coming here from Insert mode, sync undo, so that this can be
|
||||
|
||||
+8
-4
@@ -1420,7 +1420,7 @@ check_due_timer(void)
|
||||
if (balloonEval != NULL)
|
||||
general_beval_cb(balloonEval, 0);
|
||||
}
|
||||
else if (this_due > 0 && (next_due == -1 || next_due > this_due))
|
||||
else if (next_due == -1 || next_due > this_due)
|
||||
next_due = this_due;
|
||||
}
|
||||
#endif
|
||||
@@ -3014,6 +3014,8 @@ ex_next(exarg_T *eap)
|
||||
ex_argedit(exarg_T *eap)
|
||||
{
|
||||
int i = eap->addr_count ? (int)eap->line2 : curwin->w_arg_idx + 1;
|
||||
// Whether curbuf will be reused, curbuf->b_ffname will be set.
|
||||
int curbuf_is_reusable = curbuf_reusable();
|
||||
|
||||
if (do_arglist(eap->arg, AL_ADD, i) == FAIL)
|
||||
return;
|
||||
@@ -3021,8 +3023,9 @@ ex_argedit(exarg_T *eap)
|
||||
maketitle();
|
||||
#endif
|
||||
|
||||
if (curwin->w_arg_idx == 0 && (curbuf->b_ml.ml_flags & ML_EMPTY)
|
||||
&& curbuf->b_ffname == NULL)
|
||||
if (curwin->w_arg_idx == 0
|
||||
&& (curbuf->b_ml.ml_flags & ML_EMPTY)
|
||||
&& (curbuf->b_ffname == NULL || curbuf_is_reusable))
|
||||
i = 0;
|
||||
/* Edit the argument. */
|
||||
if (i < ARGCOUNT)
|
||||
@@ -3354,7 +3357,8 @@ alist_add_list(
|
||||
for (i = 0; i < count; ++i)
|
||||
{
|
||||
ARGLIST[after + i].ae_fname = files[i];
|
||||
ARGLIST[after + i].ae_fnum = buflist_add(files[i], BLN_LISTED);
|
||||
ARGLIST[after + i].ae_fnum =
|
||||
buflist_add(files[i], BLN_LISTED | BLN_CURBUF);
|
||||
}
|
||||
ALIST(curwin)->al_ga.ga_len += count;
|
||||
if (old_argcount > 0 && curwin->w_arg_idx >= after)
|
||||
|
||||
+1
-1
@@ -1392,7 +1392,7 @@ retry:
|
||||
|
||||
/* If the crypt layer is buffering, not producing
|
||||
* anything yet, need to read more. */
|
||||
if (size > 0 && decrypted_size == 0)
|
||||
if (decrypted_size == 0)
|
||||
continue;
|
||||
|
||||
if (linerest == 0)
|
||||
|
||||
+5
-5
@@ -4119,7 +4119,7 @@ map_to_exists_mode(char_u *rhs, int mode, int abbr)
|
||||
mapblock_T *mp;
|
||||
int hash;
|
||||
# ifdef FEAT_LOCALMAP
|
||||
int expand_buffer = FALSE;
|
||||
int exp_buffer = FALSE;
|
||||
|
||||
validate_maphash();
|
||||
|
||||
@@ -4134,14 +4134,14 @@ map_to_exists_mode(char_u *rhs, int mode, int abbr)
|
||||
if (hash > 0) /* there is only one abbr list */
|
||||
break;
|
||||
#ifdef FEAT_LOCALMAP
|
||||
if (expand_buffer)
|
||||
if (exp_buffer)
|
||||
mp = curbuf->b_first_abbr;
|
||||
else
|
||||
#endif
|
||||
mp = first_abbr;
|
||||
}
|
||||
# ifdef FEAT_LOCALMAP
|
||||
else if (expand_buffer)
|
||||
else if (exp_buffer)
|
||||
mp = curbuf->b_maphash[hash];
|
||||
# endif
|
||||
else
|
||||
@@ -4154,9 +4154,9 @@ map_to_exists_mode(char_u *rhs, int mode, int abbr)
|
||||
}
|
||||
}
|
||||
# ifdef FEAT_LOCALMAP
|
||||
if (expand_buffer)
|
||||
if (exp_buffer)
|
||||
break;
|
||||
expand_buffer = TRUE;
|
||||
exp_buffer = TRUE;
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
+31
-5
@@ -494,9 +494,11 @@ static int s_getting_focus = FALSE;
|
||||
static int s_x_pending;
|
||||
static int s_y_pending;
|
||||
static UINT s_kFlags_pending;
|
||||
static UINT s_wait_timer = 0; /* Timer for get char from user */
|
||||
static UINT s_wait_timer = 0; // Timer for get char from user
|
||||
static int s_timed_out = FALSE;
|
||||
static int dead_key = 0; /* 0: no dead key, 1: dead key pressed */
|
||||
static int dead_key = 0; // 0: no dead key, 1: dead key pressed
|
||||
static UINT surrogate_pending_ch = 0; // 0: no surrogate pending,
|
||||
// else a high surrogate
|
||||
|
||||
#ifdef FEAT_BEVAL_GUI
|
||||
/* balloon-eval WM_NOTIFY_HANDLER */
|
||||
@@ -708,6 +710,12 @@ _OnDeadChar(
|
||||
* Convert Unicode character "ch" to bytes in "string[slen]".
|
||||
* When "had_alt" is TRUE the ALT key was included in "ch".
|
||||
* Return the length.
|
||||
* Because the Windows API uses UTF-16, we have to deal with surrogate
|
||||
* pairs; this is where we choose to deal with them: if "ch" is a high
|
||||
* surrogate, it will be stored, and the length returned will be zero; the next
|
||||
* char_to_string call will then include the high surrogate, decoding the pair
|
||||
* of UTF-16 code units to a single Unicode code point, presuming it is the
|
||||
* matching low surrogate.
|
||||
*/
|
||||
static int
|
||||
char_to_string(int ch, char_u *string, int slen, int had_alt)
|
||||
@@ -718,8 +726,27 @@ char_to_string(int ch, char_u *string, int slen, int had_alt)
|
||||
WCHAR wstring[2];
|
||||
char_u *ws = NULL;
|
||||
|
||||
wstring[0] = ch;
|
||||
len = 1;
|
||||
if (surrogate_pending_ch != 0)
|
||||
{
|
||||
/* We don't guarantee ch is a low surrogate to match the high surrogate
|
||||
* we already have; it should be, but if it isn't, tough luck. */
|
||||
wstring[0] = surrogate_pending_ch;
|
||||
wstring[1] = ch;
|
||||
surrogate_pending_ch = 0;
|
||||
len = 2;
|
||||
}
|
||||
else if (ch >= 0xD800 && ch <= 0xDBFF) /* high surrogate */
|
||||
{
|
||||
/* We don't have the entire code point yet, only the first UTF-16 code
|
||||
* unit; so just remember it and use it in the next call. */
|
||||
surrogate_pending_ch = ch;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
wstring[0] = ch;
|
||||
len = 1;
|
||||
}
|
||||
|
||||
/* "ch" is a UTF-16 character. Convert it to a string of bytes. When
|
||||
* "enc_codepage" is non-zero use the standard Win32 function,
|
||||
@@ -743,7 +770,6 @@ char_to_string(int ch, char_u *string, int slen, int had_alt)
|
||||
}
|
||||
else
|
||||
{
|
||||
len = 1;
|
||||
ws = utf16_to_enc(wstring, &len);
|
||||
if (ws == NULL)
|
||||
len = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "vterm.h"
|
||||
|
||||
#define DEFINE_INLINES
|
||||
#include "../src/utf8.h" /* fill_utf8 */
|
||||
#include "../src/utf8.h" // fill_utf8
|
||||
|
||||
#define streq(a,b) (!strcmp(a,b))
|
||||
|
||||
@@ -21,7 +21,7 @@ static int rows;
|
||||
|
||||
static enum {
|
||||
FORMAT_PLAIN,
|
||||
FORMAT_SGR
|
||||
FORMAT_SGR,
|
||||
} format = FORMAT_PLAIN;
|
||||
|
||||
static int col2index(VTermColor target)
|
||||
@@ -44,8 +44,8 @@ static void dump_cell(const VTermScreenCell *cell, const VTermScreenCell *prevce
|
||||
break;
|
||||
case FORMAT_SGR:
|
||||
{
|
||||
/* If all 7 attributes change, that means 7 SGRs max */
|
||||
/* Each colour could consume up to 3 */
|
||||
// If all 7 attributes change, that means 7 SGRs max
|
||||
// Each colour could consume up to 3
|
||||
int sgr[7 + 2*3]; int sgri = 0;
|
||||
|
||||
if(!prevcell->attrs.bold && cell->attrs.bold)
|
||||
|
||||
@@ -35,7 +35,7 @@ static int getchoice(int *argip, int argc, char *argv[], const char *options[])
|
||||
typedef enum {
|
||||
OFF,
|
||||
ON,
|
||||
QUERY
|
||||
QUERY,
|
||||
} BoolQuery;
|
||||
|
||||
static BoolQuery getboolq(int *argip, int argc, char *argv[])
|
||||
@@ -105,7 +105,7 @@ static char *read_csi()
|
||||
unsigned char csi[32];
|
||||
int i = 0;
|
||||
|
||||
await_c1(0x9B); /* CSI */
|
||||
await_c1(0x9B); // CSI
|
||||
|
||||
/* TODO: This really should be a more robust CSI parser
|
||||
*/
|
||||
@@ -116,7 +116,7 @@ static char *read_csi()
|
||||
}
|
||||
csi[++i] = 0;
|
||||
|
||||
/* TODO: returns longer than 32? */
|
||||
// TODO: returns longer than 32?
|
||||
|
||||
return strdup((char *)csi);
|
||||
}
|
||||
@@ -131,7 +131,7 @@ static char *read_dcs()
|
||||
|
||||
for(i = 0; i < sizeof(dcs)-1; ) {
|
||||
char c = getchar();
|
||||
if(c == 0x9c) /* ST */
|
||||
if(c == 0x9c) // ST
|
||||
break;
|
||||
if(in_esc && c == 0x5c)
|
||||
break;
|
||||
@@ -301,12 +301,12 @@ int main(int argc, char *argv[])
|
||||
do_dec_mode(12, getboolq(&argi, argc, argv), "curblink");
|
||||
}
|
||||
else if(streq(arg, "curshape")) {
|
||||
/* TODO: This ought to query the current value of DECSCUSR because it */
|
||||
/* may need blinking on or off */
|
||||
// TODO: This ought to query the current value of DECSCUSR because it
|
||||
// may need blinking on or off
|
||||
const char *choices[] = {"block", "under", "bar", "query", NULL};
|
||||
int shape = getchoice(&argi, argc, argv, choices);
|
||||
switch(shape) {
|
||||
case 3: /* query */
|
||||
case 3: // query
|
||||
shape = query_rqss_numeric(" q");
|
||||
switch(shape) {
|
||||
case 1: case 2:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Require getopt(3) */
|
||||
// Require getopt(3)
|
||||
#define _XOPEN_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -22,28 +22,28 @@ static int parser_text(const char bytes[], size_t len, void *user)
|
||||
|
||||
int i;
|
||||
for(i = 0; i < len; /* none */) {
|
||||
if(b[i] < 0x20) /* C0 */
|
||||
if(b[i] < 0x20) // C0
|
||||
break;
|
||||
else if(b[i] < 0x80) /* ASCII */
|
||||
else if(b[i] < 0x80) // ASCII
|
||||
i++;
|
||||
else if(b[i] < 0xa0) /* C1 */
|
||||
else if(b[i] < 0xa0) // C1
|
||||
break;
|
||||
else if(b[i] < 0xc0) /* UTF-8 continuation */
|
||||
else if(b[i] < 0xc0) // UTF-8 continuation
|
||||
break;
|
||||
else if(b[i] < 0xe0) { /* UTF-8 2-byte */
|
||||
/* 2-byte UTF-8 */
|
||||
else if(b[i] < 0xe0) { // UTF-8 2-byte
|
||||
// 2-byte UTF-8
|
||||
if(len < i+2) break;
|
||||
i += 2;
|
||||
}
|
||||
else if(b[i] < 0xf0) { /* UTF-8 3-byte */
|
||||
else if(b[i] < 0xf0) { // UTF-8 3-byte
|
||||
if(len < i+3) break;
|
||||
i += 3;
|
||||
}
|
||||
else if(b[i] < 0xf8) { /* UTF-8 4-byte */
|
||||
else if(b[i] < 0xf8) { // UTF-8 4-byte
|
||||
if(len < i+4) break;
|
||||
i += 4;
|
||||
}
|
||||
else /* otherwise invalid */
|
||||
else // otherwise invalid
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ int main(int argc, char *argv[])
|
||||
file = argv[optind++];
|
||||
|
||||
if(!file || streq(file, "-"))
|
||||
fd = 0; /* stdin */
|
||||
fd = 0; // stdin
|
||||
else {
|
||||
fd = open(file, O_RDONLY);
|
||||
if(fd == -1) {
|
||||
|
||||
@@ -110,30 +110,30 @@ typedef union {
|
||||
|
||||
typedef enum {
|
||||
/* VTERM_ATTR_NONE = 0 */
|
||||
VTERM_ATTR_BOLD = 1, /* bool: 1, 22 */
|
||||
VTERM_ATTR_UNDERLINE, /* number: 4, 21, 24 */
|
||||
VTERM_ATTR_ITALIC, /* bool: 3, 23 */
|
||||
VTERM_ATTR_BLINK, /* bool: 5, 25 */
|
||||
VTERM_ATTR_REVERSE, /* bool: 7, 27 */
|
||||
VTERM_ATTR_STRIKE, /* bool: 9, 29 */
|
||||
VTERM_ATTR_FONT, /* number: 10-19 */
|
||||
VTERM_ATTR_FOREGROUND, /* color: 30-39 90-97 */
|
||||
VTERM_ATTR_BACKGROUND, /* color: 40-49 100-107 */
|
||||
VTERM_ATTR_BOLD = 1, // bool: 1, 22
|
||||
VTERM_ATTR_UNDERLINE, // number: 4, 21, 24
|
||||
VTERM_ATTR_ITALIC, // bool: 3, 23
|
||||
VTERM_ATTR_BLINK, // bool: 5, 25
|
||||
VTERM_ATTR_REVERSE, // bool: 7, 27
|
||||
VTERM_ATTR_STRIKE, // bool: 9, 29
|
||||
VTERM_ATTR_FONT, // number: 10-19
|
||||
VTERM_ATTR_FOREGROUND, // color: 30-39 90-97
|
||||
VTERM_ATTR_BACKGROUND, // color: 40-49 100-107
|
||||
|
||||
VTERM_N_ATTRS
|
||||
} VTermAttr;
|
||||
|
||||
typedef enum {
|
||||
/* VTERM_PROP_NONE = 0 */
|
||||
VTERM_PROP_CURSORVISIBLE = 1, /* bool */
|
||||
VTERM_PROP_CURSORBLINK, /* bool */
|
||||
VTERM_PROP_ALTSCREEN, /* bool */
|
||||
VTERM_PROP_TITLE, /* string */
|
||||
VTERM_PROP_ICONNAME, /* string */
|
||||
VTERM_PROP_REVERSE, /* bool */
|
||||
VTERM_PROP_CURSORSHAPE, /* number */
|
||||
VTERM_PROP_MOUSE, /* number */
|
||||
VTERM_PROP_CURSORCOLOR, /* string */
|
||||
VTERM_PROP_CURSORVISIBLE = 1, // bool
|
||||
VTERM_PROP_CURSORBLINK, // bool
|
||||
VTERM_PROP_ALTSCREEN, // bool
|
||||
VTERM_PROP_TITLE, // string
|
||||
VTERM_PROP_ICONNAME, // string
|
||||
VTERM_PROP_REVERSE, // bool
|
||||
VTERM_PROP_CURSORSHAPE, // number
|
||||
VTERM_PROP_MOUSE, // number
|
||||
VTERM_PROP_CURSORCOLOR, // string
|
||||
|
||||
VTERM_N_PROPS
|
||||
} VTermProp;
|
||||
@@ -211,9 +211,9 @@ void vterm_mouse_move(VTerm *vt, int row, int col, VTermModifier mod);
|
||||
* Button 4 is scroll wheel down, button 5 is scroll wheel up. */
|
||||
void vterm_mouse_button(VTerm *vt, int button, int pressed, VTermModifier mod);
|
||||
|
||||
/* ------------
|
||||
* Parser layer
|
||||
* ------------ */
|
||||
// ------------
|
||||
// Parser layer
|
||||
// ------------
|
||||
|
||||
/* Flag to indicate non-final subparameters in a single CSI parameter.
|
||||
* Consider
|
||||
@@ -249,9 +249,9 @@ typedef struct {
|
||||
void vterm_parser_set_callbacks(VTerm *vt, const VTermParserCallbacks *callbacks, void *user);
|
||||
void *vterm_parser_get_cbdata(VTerm *vt);
|
||||
|
||||
/* -----------
|
||||
* State layer
|
||||
* ----------- */
|
||||
// -----------
|
||||
// State layer
|
||||
// -----------
|
||||
|
||||
typedef struct {
|
||||
int (*putglyph)(VTermGlyphInfo *info, VTermPos pos, void *user);
|
||||
@@ -287,7 +287,7 @@ VTermState *vterm_obtain_state(VTerm *vt);
|
||||
void vterm_state_set_callbacks(VTermState *state, const VTermStateCallbacks *callbacks, void *user);
|
||||
void *vterm_state_get_cbdata(VTermState *state);
|
||||
|
||||
/* Only invokes control, csi, osc, dcs */
|
||||
// Only invokes control, csi, osc, dcs
|
||||
void vterm_state_set_unrecognised_fallbacks(VTermState *state, const VTermParserCallbacks *fallbacks, void *user);
|
||||
void *vterm_state_get_unrecognised_fbdata(VTermState *state);
|
||||
|
||||
@@ -307,9 +307,9 @@ void vterm_state_focus_in(VTermState *state);
|
||||
void vterm_state_focus_out(VTermState *state);
|
||||
const VTermLineInfo *vterm_state_get_lineinfo(const VTermState *state, int row);
|
||||
|
||||
/* ------------
|
||||
* Screen layer
|
||||
* ------------ */
|
||||
// ------------
|
||||
// Screen layer
|
||||
// ------------
|
||||
|
||||
typedef struct {
|
||||
unsigned int bold : 1;
|
||||
@@ -356,7 +356,7 @@ VTermScreen *vterm_obtain_screen(VTerm *vt);
|
||||
void vterm_screen_set_callbacks(VTermScreen *screen, const VTermScreenCallbacks *callbacks, void *user);
|
||||
void *vterm_screen_get_cbdata(VTermScreen *screen);
|
||||
|
||||
/* Only invokes control, csi, osc, dcs */
|
||||
// Only invokes control, csi, osc, dcs
|
||||
void vterm_screen_set_unrecognised_fallbacks(VTermScreen *screen, const VTermParserCallbacks *fallbacks, void *user);
|
||||
void *vterm_screen_get_unrecognised_fbdata(VTermScreen *screen);
|
||||
|
||||
@@ -409,9 +409,9 @@ int vterm_screen_get_cell(const VTermScreen *screen, VTermPos pos, VTermScreenCe
|
||||
|
||||
int vterm_screen_is_eol(const VTermScreen *screen, VTermPos pos);
|
||||
|
||||
/* ---------
|
||||
* Utilities
|
||||
* --------- */
|
||||
// ---------
|
||||
// Utilities
|
||||
// ---------
|
||||
|
||||
VTermValueType vterm_get_attr_type(VTermAttr attr);
|
||||
VTermValueType vterm_get_prop_type(VTermProp prop);
|
||||
|
||||
@@ -55,7 +55,7 @@ typedef enum {
|
||||
VTERM_KEY_KP_ENTER,
|
||||
VTERM_KEY_KP_EQUAL,
|
||||
|
||||
VTERM_KEY_MAX, /* Must be last */
|
||||
VTERM_KEY_MAX, // Must be last
|
||||
VTERM_N_KEYS = VTERM_KEY_MAX
|
||||
} VTermKey;
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#endif
|
||||
|
||||
struct UTF8DecoderData {
|
||||
/* number of bytes remaining in this codepoint */
|
||||
// number of bytes remaining in this codepoint
|
||||
int bytes_remaining;
|
||||
|
||||
/* number of bytes total in this codepoint once it's finished
|
||||
(for detecting overlongs) */
|
||||
// number of bytes total in this codepoint once it's finished
|
||||
// (for detecting overlongs)
|
||||
int bytes_total;
|
||||
|
||||
int this_cp;
|
||||
@@ -42,7 +42,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
|
||||
printf(" pos=%zd c=%02x rem=%d\n", *pos, c, data->bytes_remaining);
|
||||
#endif
|
||||
|
||||
if(c < 0x20) /* C0 */
|
||||
if(c < 0x20) // C0
|
||||
return;
|
||||
|
||||
else if(c >= 0x20 && c < 0x7f) {
|
||||
@@ -58,7 +58,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
|
||||
#endif
|
||||
}
|
||||
|
||||
else if(c == 0x7f) /* DEL */
|
||||
else if(c == 0x7f) // DEL
|
||||
return;
|
||||
|
||||
else if(c >= 0x80 && c < 0xc0) {
|
||||
@@ -75,7 +75,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
|
||||
#ifdef DEBUG_PRINT_UTF8
|
||||
printf(" UTF-8 raw char U+%04x bytelen=%d ", data->this_cp, data->bytes_total);
|
||||
#endif
|
||||
/* Check for overlong sequences */
|
||||
// Check for overlong sequences
|
||||
switch(data->bytes_total) {
|
||||
case 2:
|
||||
if(data->this_cp < 0x0080) data->this_cp = UNICODE_INVALID;
|
||||
@@ -93,7 +93,7 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
|
||||
if(data->this_cp < 0x4000000) data->this_cp = UNICODE_INVALID;
|
||||
break;
|
||||
}
|
||||
/* Now look for plain invalid ones */
|
||||
// Now look for plain invalid ones
|
||||
if((data->this_cp >= 0xD800 && data->this_cp <= 0xDFFF) ||
|
||||
data->this_cp == 0xFFFE ||
|
||||
data->this_cp == 0xFFFF)
|
||||
|
||||
+48
-48
@@ -15,7 +15,7 @@ void vterm_keyboard_unichar(VTerm *vt, uint32_t c, VTermModifier mod)
|
||||
mod &= ~VTERM_MOD_SHIFT;
|
||||
|
||||
if(mod == 0) {
|
||||
/* Normal text - ignore just shift */
|
||||
// Normal text - ignore just shift
|
||||
char str[6];
|
||||
int seqlen = fill_utf8(c, str);
|
||||
vterm_push_output_bytes(vt, str, seqlen);
|
||||
@@ -62,7 +62,7 @@ typedef struct {
|
||||
KEYCODE_CSI,
|
||||
KEYCODE_CSI_CURSOR,
|
||||
KEYCODE_CSINUM,
|
||||
KEYCODE_KEYPAD
|
||||
KEYCODE_KEYPAD,
|
||||
} type;
|
||||
char literal;
|
||||
int csinum;
|
||||
@@ -70,61 +70,61 @@ typedef struct {
|
||||
|
||||
/* Order here must be exactly the same as VTermKey enum! */
|
||||
static keycodes_s keycodes[] = {
|
||||
{ KEYCODE_NONE, 0, 0 }, /* NONE */
|
||||
{ KEYCODE_NONE, 0, 0 }, // NONE
|
||||
|
||||
{ KEYCODE_ENTER, '\r', 0 }, /* ENTER */
|
||||
{ KEYCODE_TAB, '\t', 0 }, /* TAB */
|
||||
{ KEYCODE_LITERAL, '\x7f', 0 }, /* BACKSPACE == ASCII DEL */
|
||||
{ KEYCODE_LITERAL, '\x1b', 0 }, /* ESCAPE */
|
||||
{ KEYCODE_ENTER, '\r', 0 }, // ENTER
|
||||
{ KEYCODE_TAB, '\t', 0 }, // TAB
|
||||
{ KEYCODE_LITERAL, '\x7f', 0 }, // BACKSPACE == ASCII DEL
|
||||
{ KEYCODE_LITERAL, '\x1b', 0 }, // ESCAPE
|
||||
|
||||
{ KEYCODE_CSI_CURSOR, 'A', 0 }, /* UP */
|
||||
{ KEYCODE_CSI_CURSOR, 'B', 0 }, /* DOWN */
|
||||
{ KEYCODE_CSI_CURSOR, 'D', 0 }, /* LEFT */
|
||||
{ KEYCODE_CSI_CURSOR, 'C', 0 }, /* RIGHT */
|
||||
{ KEYCODE_CSI_CURSOR, 'A', 0 }, // UP
|
||||
{ KEYCODE_CSI_CURSOR, 'B', 0 }, // DOWN
|
||||
{ KEYCODE_CSI_CURSOR, 'D', 0 }, // LEFT
|
||||
{ KEYCODE_CSI_CURSOR, 'C', 0 }, // RIGHT
|
||||
|
||||
{ KEYCODE_CSINUM, '~', 2 }, /* INS */
|
||||
{ KEYCODE_CSINUM, '~', 3 }, /* DEL */
|
||||
{ KEYCODE_CSI_CURSOR, 'H', 0 }, /* HOME */
|
||||
{ KEYCODE_CSI_CURSOR, 'F', 0 }, /* END */
|
||||
{ KEYCODE_CSINUM, '~', 5 }, /* PAGEUP */
|
||||
{ KEYCODE_CSINUM, '~', 6 }, /* PAGEDOWN */
|
||||
{ KEYCODE_CSINUM, '~', 2 }, // INS
|
||||
{ KEYCODE_CSINUM, '~', 3 }, // DEL
|
||||
{ KEYCODE_CSI_CURSOR, 'H', 0 }, // HOME
|
||||
{ KEYCODE_CSI_CURSOR, 'F', 0 }, // END
|
||||
{ KEYCODE_CSINUM, '~', 5 }, // PAGEUP
|
||||
{ KEYCODE_CSINUM, '~', 6 }, // PAGEDOWN
|
||||
};
|
||||
|
||||
static keycodes_s keycodes_fn[] = {
|
||||
{ KEYCODE_NONE, 0, 0 }, /* F0 - shouldn't happen */
|
||||
{ KEYCODE_CSI_CURSOR, 'P', 0 }, /* F1 */
|
||||
{ KEYCODE_CSI_CURSOR, 'Q', 0 }, /* F2 */
|
||||
{ KEYCODE_CSI_CURSOR, 'R', 0 }, /* F3 */
|
||||
{ KEYCODE_CSI_CURSOR, 'S', 0 }, /* F4 */
|
||||
{ KEYCODE_CSINUM, '~', 15 }, /* F5 */
|
||||
{ KEYCODE_CSINUM, '~', 17 }, /* F6 */
|
||||
{ KEYCODE_CSINUM, '~', 18 }, /* F7 */
|
||||
{ KEYCODE_CSINUM, '~', 19 }, /* F8 */
|
||||
{ KEYCODE_CSINUM, '~', 20 }, /* F9 */
|
||||
{ KEYCODE_CSINUM, '~', 21 }, /* F10 */
|
||||
{ KEYCODE_CSINUM, '~', 23 }, /* F11 */
|
||||
{ KEYCODE_CSINUM, '~', 24 }, /* F12 */
|
||||
{ KEYCODE_NONE, 0, 0 }, // F0 - shouldn't happen
|
||||
{ KEYCODE_CSI_CURSOR, 'P', 0 }, // F1
|
||||
{ KEYCODE_CSI_CURSOR, 'Q', 0 }, // F2
|
||||
{ KEYCODE_CSI_CURSOR, 'R', 0 }, // F3
|
||||
{ KEYCODE_CSI_CURSOR, 'S', 0 }, // F4
|
||||
{ KEYCODE_CSINUM, '~', 15 }, // F5
|
||||
{ KEYCODE_CSINUM, '~', 17 }, // F6
|
||||
{ KEYCODE_CSINUM, '~', 18 }, // F7
|
||||
{ KEYCODE_CSINUM, '~', 19 }, // F8
|
||||
{ KEYCODE_CSINUM, '~', 20 }, // F9
|
||||
{ KEYCODE_CSINUM, '~', 21 }, // F10
|
||||
{ KEYCODE_CSINUM, '~', 23 }, // F11
|
||||
{ KEYCODE_CSINUM, '~', 24 }, // F12
|
||||
};
|
||||
|
||||
static keycodes_s keycodes_kp[] = {
|
||||
{ KEYCODE_KEYPAD, '0', 'p' }, /* KP_0 */
|
||||
{ KEYCODE_KEYPAD, '1', 'q' }, /* KP_1 */
|
||||
{ KEYCODE_KEYPAD, '2', 'r' }, /* KP_2 */
|
||||
{ KEYCODE_KEYPAD, '3', 's' }, /* KP_3 */
|
||||
{ KEYCODE_KEYPAD, '4', 't' }, /* KP_4 */
|
||||
{ KEYCODE_KEYPAD, '5', 'u' }, /* KP_5 */
|
||||
{ KEYCODE_KEYPAD, '6', 'v' }, /* KP_6 */
|
||||
{ KEYCODE_KEYPAD, '7', 'w' }, /* KP_7 */
|
||||
{ KEYCODE_KEYPAD, '8', 'x' }, /* KP_8 */
|
||||
{ KEYCODE_KEYPAD, '9', 'y' }, /* KP_9 */
|
||||
{ KEYCODE_KEYPAD, '*', 'j' }, /* KP_MULT */
|
||||
{ KEYCODE_KEYPAD, '+', 'k' }, /* KP_PLUS */
|
||||
{ KEYCODE_KEYPAD, ',', 'l' }, /* KP_COMMA */
|
||||
{ KEYCODE_KEYPAD, '-', 'm' }, /* KP_MINUS */
|
||||
{ KEYCODE_KEYPAD, '.', 'n' }, /* KP_PERIOD */
|
||||
{ KEYCODE_KEYPAD, '/', 'o' }, /* KP_DIVIDE */
|
||||
{ KEYCODE_KEYPAD, '\n', 'M' }, /* KP_ENTER */
|
||||
{ KEYCODE_KEYPAD, '=', 'X' }, /* KP_EQUAL */
|
||||
{ KEYCODE_KEYPAD, '0', 'p' }, // KP_0
|
||||
{ KEYCODE_KEYPAD, '1', 'q' }, // KP_1
|
||||
{ KEYCODE_KEYPAD, '2', 'r' }, // KP_2
|
||||
{ KEYCODE_KEYPAD, '3', 's' }, // KP_3
|
||||
{ KEYCODE_KEYPAD, '4', 't' }, // KP_4
|
||||
{ KEYCODE_KEYPAD, '5', 'u' }, // KP_5
|
||||
{ KEYCODE_KEYPAD, '6', 'v' }, // KP_6
|
||||
{ KEYCODE_KEYPAD, '7', 'w' }, // KP_7
|
||||
{ KEYCODE_KEYPAD, '8', 'x' }, // KP_8
|
||||
{ KEYCODE_KEYPAD, '9', 'y' }, // KP_9
|
||||
{ KEYCODE_KEYPAD, '*', 'j' }, // KP_MULT
|
||||
{ KEYCODE_KEYPAD, '+', 'k' }, // KP_PLUS
|
||||
{ KEYCODE_KEYPAD, ',', 'l' }, // KP_COMMA
|
||||
{ KEYCODE_KEYPAD, '-', 'm' }, // KP_MINUS
|
||||
{ KEYCODE_KEYPAD, '.', 'n' }, // KP_PERIOD
|
||||
{ KEYCODE_KEYPAD, '/', 'o' }, // KP_DIVIDE
|
||||
{ KEYCODE_KEYPAD, '\n', 'M' }, // KP_ENTER
|
||||
{ KEYCODE_KEYPAD, '=', 'X' }, // KP_EQUAL
|
||||
};
|
||||
|
||||
void vterm_keyboard_key(VTerm *vt, VTermKey key, VTermModifier mod)
|
||||
|
||||
+16
-16
@@ -148,18 +148,18 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len)
|
||||
for( ; pos < len; pos++) {
|
||||
unsigned char c = bytes[pos];
|
||||
|
||||
if(c == 0x00 || c == 0x7f) { /* NUL, DEL */
|
||||
if(c == 0x00 || c == 0x7f) { // NUL, DEL
|
||||
if(vt->parser.state >= STRING) {
|
||||
more_string(vt, string_start, bytes + pos - string_start);
|
||||
string_start = bytes + pos + 1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(c == 0x18 || c == 0x1a) { /* CAN, SUB */
|
||||
if(c == 0x18 || c == 0x1a) { // CAN, SUB
|
||||
ENTER_NORMAL_STATE();
|
||||
continue;
|
||||
}
|
||||
else if(c == 0x1b) { /* ESC */
|
||||
else if(c == 0x1b) { // ESC
|
||||
vt->parser.intermedlen = 0;
|
||||
if(vt->parser.state == STRING)
|
||||
vt->parser.state = ESC_IN_STRING;
|
||||
@@ -167,11 +167,11 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len)
|
||||
ENTER_STATE(ESC);
|
||||
continue;
|
||||
}
|
||||
else if(c == 0x07 && /* BEL, can stand for ST in OSC or DCS state */
|
||||
else if(c == 0x07 && // BEL, can stand for ST in OSC or DCS state
|
||||
vt->parser.state == STRING) {
|
||||
/* fallthrough */
|
||||
// fallthrough
|
||||
}
|
||||
else if(c < 0x20) { /* other C0 */
|
||||
else if(c < 0x20) { // other C0
|
||||
if(vt->parser.state >= STRING)
|
||||
more_string(vt, string_start, bytes + pos - string_start);
|
||||
do_control(vt, c);
|
||||
@@ -179,30 +179,30 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len)
|
||||
string_start = bytes + pos + 1;
|
||||
continue;
|
||||
}
|
||||
/* else fallthrough */
|
||||
// else fallthrough
|
||||
|
||||
switch(vt->parser.state) {
|
||||
case ESC_IN_STRING:
|
||||
if(c == 0x5c) { /* ST */
|
||||
if(c == 0x5c) { // ST
|
||||
vt->parser.state = STRING;
|
||||
done_string(vt, string_start, bytes + pos - string_start - 1);
|
||||
ENTER_NORMAL_STATE();
|
||||
break;
|
||||
}
|
||||
vt->parser.state = ESC;
|
||||
/* else fallthrough */
|
||||
// else fallthrough
|
||||
|
||||
case ESC:
|
||||
switch(c) {
|
||||
case 0x50: /* DCS */
|
||||
case 0x50: // DCS
|
||||
start_string(vt, VTERM_PARSER_DCS);
|
||||
ENTER_STRING_STATE();
|
||||
break;
|
||||
case 0x5b: /* CSI */
|
||||
case 0x5b: // CSI
|
||||
vt->parser.csi_leaderlen = 0;
|
||||
ENTER_STATE(CSI_LEADER);
|
||||
break;
|
||||
case 0x5d: /* OSC */
|
||||
case 0x5d: // OSC
|
||||
start_string(vt, VTERM_PARSER_OSC);
|
||||
ENTER_STRING_STATE();
|
||||
break;
|
||||
@@ -298,14 +298,14 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len)
|
||||
case NORMAL:
|
||||
if(c >= 0x80 && c < 0xa0 && !vt->mode.utf8) {
|
||||
switch(c) {
|
||||
case 0x90: /* DCS */
|
||||
case 0x90: // DCS
|
||||
start_string(vt, VTERM_PARSER_DCS);
|
||||
ENTER_STRING_STATE();
|
||||
break;
|
||||
case 0x9b: /* CSI */
|
||||
case 0x9b: // CSI
|
||||
ENTER_STATE(CSI_LEADER);
|
||||
break;
|
||||
case 0x9d: /* OSC */
|
||||
case 0x9d: // OSC
|
||||
start_string(vt, VTERM_PARSER_OSC);
|
||||
ENTER_STRING_STATE();
|
||||
break;
|
||||
@@ -325,7 +325,7 @@ size_t vterm_input_write(VTerm *vt, const char *bytes, size_t len)
|
||||
eaten = 1;
|
||||
}
|
||||
|
||||
pos += (eaten - 1); /* we'll ++ it again in a moment */
|
||||
pos += (eaten - 1); // we'll ++ it again in a moment
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
+52
-52
@@ -4,24 +4,24 @@
|
||||
|
||||
static const VTermColor ansi_colors[] = {
|
||||
/* R G B index */
|
||||
{ 0, 0, 0, 1 }, /* black */
|
||||
{ 224, 0, 0, 2 }, /* red */
|
||||
{ 0, 224, 0, 3 }, /* green */
|
||||
{ 224, 224, 0, 4 }, /* yellow */
|
||||
{ 0, 0, 224, 5 }, /* blue */
|
||||
{ 224, 0, 224, 6 }, /* magenta */
|
||||
{ 0, 224, 224, 7 }, /* cyan */
|
||||
{ 224, 224, 224, 8 }, /* white == light grey */
|
||||
{ 0, 0, 0, 1 }, // black
|
||||
{ 224, 0, 0, 2 }, // red
|
||||
{ 0, 224, 0, 3 }, // green
|
||||
{ 224, 224, 0, 4 }, // yellow
|
||||
{ 0, 0, 224, 5 }, // blue
|
||||
{ 224, 0, 224, 6 }, // magenta
|
||||
{ 0, 224, 224, 7 }, // cyan
|
||||
{ 224, 224, 224, 8 }, // white == light grey
|
||||
|
||||
/* high intensity */
|
||||
{ 128, 128, 128, 9 }, /* black */
|
||||
{ 255, 64, 64, 10 }, /* red */
|
||||
{ 64, 255, 64, 11 }, /* green */
|
||||
{ 255, 255, 64, 12 }, /* yellow */
|
||||
{ 64, 64, 255, 13 }, /* blue */
|
||||
{ 255, 64, 255, 14 }, /* magenta */
|
||||
{ 64, 255, 255, 15 }, /* cyan */
|
||||
{ 255, 255, 255, 16 }, /* white for real */
|
||||
// high intensity
|
||||
{ 128, 128, 128, 9 }, // black
|
||||
{ 255, 64, 64, 10 }, // red
|
||||
{ 64, 255, 64, 11 }, // green
|
||||
{ 255, 255, 64, 12 }, // yellow
|
||||
{ 64, 64, 255, 13 }, // blue
|
||||
{ 255, 64, 255, 14 }, // magenta
|
||||
{ 64, 255, 255, 15 }, // cyan
|
||||
{ 255, 255, 255, 16 }, // white for real
|
||||
};
|
||||
|
||||
static int ramp6[] = {
|
||||
@@ -47,11 +47,11 @@ static int lookup_colour_ansi(const VTermState *state, long index, VTermColor *c
|
||||
static int lookup_colour_palette(const VTermState *state, long index, VTermColor *col)
|
||||
{
|
||||
if(index >= 0 && index < 16) {
|
||||
/* Normal 8 colours or high intensity - parse as palette 0 */
|
||||
// Normal 8 colours or high intensity - parse as palette 0
|
||||
return lookup_colour_ansi(state, index, col);
|
||||
}
|
||||
else if(index >= 16 && index < 232) {
|
||||
/* 216-colour cube */
|
||||
// 216-colour cube
|
||||
index -= 16;
|
||||
|
||||
col->blue = ramp6[index % 6];
|
||||
@@ -62,7 +62,7 @@ static int lookup_colour_palette(const VTermState *state, long index, VTermColor
|
||||
return TRUE;
|
||||
}
|
||||
else if(index >= 232 && index < 256) {
|
||||
/* 24 greyscales */
|
||||
// 24 greyscales
|
||||
index -= 232;
|
||||
|
||||
col->blue = ramp24[index];
|
||||
@@ -79,7 +79,7 @@ static int lookup_colour_palette(const VTermState *state, long index, VTermColor
|
||||
static int lookup_colour(const VTermState *state, int palette, const long args[], int argcount, VTermColor *col, int *index)
|
||||
{
|
||||
switch(palette) {
|
||||
case 2: /* RGB mode - 3 args contain colour values directly */
|
||||
case 2: // RGB mode - 3 args contain colour values directly
|
||||
if(argcount < 3)
|
||||
return argcount;
|
||||
|
||||
@@ -90,7 +90,7 @@ static int lookup_colour(const VTermState *state, int palette, const long args[]
|
||||
|
||||
return 3;
|
||||
|
||||
case 5: /* XTerm 256-colour mode */
|
||||
case 5: // XTerm 256-colour mode
|
||||
if(index)
|
||||
*index = CSI_ARG_OR(args[0], -1);
|
||||
|
||||
@@ -104,7 +104,7 @@ static int lookup_colour(const VTermState *state, int palette, const long args[]
|
||||
}
|
||||
}
|
||||
|
||||
/* Some conveniences */
|
||||
// Some conveniences
|
||||
|
||||
static void setpenattr(VTermState *state, VTermAttr attr, VTermValueType type UNUSED, VTermValue *val)
|
||||
{
|
||||
@@ -153,7 +153,7 @@ INTERNAL void vterm_state_newpen(VTermState *state)
|
||||
{
|
||||
int col;
|
||||
|
||||
/* 90% grey so that pure white is brighter */
|
||||
// 90% grey so that pure white is brighter
|
||||
state->default_fg.red = state->default_fg.green = state->default_fg.blue = 240;
|
||||
state->default_fg.ansi_index = VTERM_ANSI_INDEX_DEFAULT;
|
||||
state->default_bg.red = state->default_bg.green = state->default_bg.blue = 0;
|
||||
@@ -232,98 +232,98 @@ void vterm_state_set_bold_highbright(VTermState *state, int bold_is_highbright)
|
||||
|
||||
INTERNAL void vterm_state_setpen(VTermState *state, const long args[], int argcount)
|
||||
{
|
||||
/* SGR - ECMA-48 8.3.117 */
|
||||
// SGR - ECMA-48 8.3.117
|
||||
|
||||
int argi = 0;
|
||||
int value;
|
||||
|
||||
while(argi < argcount) {
|
||||
/* This logic is easier to do 'done' backwards; set it true, and make it
|
||||
false again in the 'default' case */
|
||||
// This logic is easier to do 'done' backwards; set it true, and make it
|
||||
// false again in the 'default' case
|
||||
int done = 1;
|
||||
|
||||
long arg;
|
||||
switch(arg = CSI_ARG(args[argi])) {
|
||||
case CSI_ARG_MISSING:
|
||||
case 0: /* Reset */
|
||||
case 0: // Reset
|
||||
vterm_state_resetpen(state);
|
||||
break;
|
||||
|
||||
case 1: /* Bold on */
|
||||
case 1: // Bold on
|
||||
state->pen.bold = 1;
|
||||
setpenattr_bool(state, VTERM_ATTR_BOLD, 1);
|
||||
if(state->fg_index > -1 && state->fg_index < 8 && state->bold_is_highbright)
|
||||
set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, state->fg_index + (state->pen.bold ? 8 : 0));
|
||||
break;
|
||||
|
||||
case 3: /* Italic on */
|
||||
case 3: // Italic on
|
||||
state->pen.italic = 1;
|
||||
setpenattr_bool(state, VTERM_ATTR_ITALIC, 1);
|
||||
break;
|
||||
|
||||
case 4: /* Underline single */
|
||||
case 4: // Underline single
|
||||
state->pen.underline = 1;
|
||||
setpenattr_int(state, VTERM_ATTR_UNDERLINE, 1);
|
||||
break;
|
||||
|
||||
case 5: /* Blink */
|
||||
case 5: // Blink
|
||||
state->pen.blink = 1;
|
||||
setpenattr_bool(state, VTERM_ATTR_BLINK, 1);
|
||||
break;
|
||||
|
||||
case 7: /* Reverse on */
|
||||
case 7: // Reverse on
|
||||
state->pen.reverse = 1;
|
||||
setpenattr_bool(state, VTERM_ATTR_REVERSE, 1);
|
||||
break;
|
||||
|
||||
case 9: /* Strikethrough on */
|
||||
case 9: // Strikethrough on
|
||||
state->pen.strike = 1;
|
||||
setpenattr_bool(state, VTERM_ATTR_STRIKE, 1);
|
||||
break;
|
||||
|
||||
case 10: case 11: case 12: case 13: case 14:
|
||||
case 15: case 16: case 17: case 18: case 19: /* Select font */
|
||||
case 15: case 16: case 17: case 18: case 19: // Select font
|
||||
state->pen.font = CSI_ARG(args[argi]) - 10;
|
||||
setpenattr_int(state, VTERM_ATTR_FONT, state->pen.font);
|
||||
break;
|
||||
|
||||
case 21: /* Underline double */
|
||||
case 21: // Underline double
|
||||
state->pen.underline = 2;
|
||||
setpenattr_int(state, VTERM_ATTR_UNDERLINE, 2);
|
||||
break;
|
||||
|
||||
case 22: /* Bold off */
|
||||
case 22: // Bold off
|
||||
state->pen.bold = 0;
|
||||
setpenattr_bool(state, VTERM_ATTR_BOLD, 0);
|
||||
break;
|
||||
|
||||
case 23: /* Italic and Gothic (currently unsupported) off */
|
||||
case 23: // Italic and Gothic (currently unsupported) off
|
||||
state->pen.italic = 0;
|
||||
setpenattr_bool(state, VTERM_ATTR_ITALIC, 0);
|
||||
break;
|
||||
|
||||
case 24: /* Underline off */
|
||||
case 24: // Underline off
|
||||
state->pen.underline = 0;
|
||||
setpenattr_int(state, VTERM_ATTR_UNDERLINE, 0);
|
||||
break;
|
||||
|
||||
case 25: /* Blink off */
|
||||
case 25: // Blink off
|
||||
state->pen.blink = 0;
|
||||
setpenattr_bool(state, VTERM_ATTR_BLINK, 0);
|
||||
break;
|
||||
|
||||
case 27: /* Reverse off */
|
||||
case 27: // Reverse off
|
||||
state->pen.reverse = 0;
|
||||
setpenattr_bool(state, VTERM_ATTR_REVERSE, 0);
|
||||
break;
|
||||
|
||||
case 29: /* Strikethrough off */
|
||||
case 29: // Strikethrough off
|
||||
state->pen.strike = 0;
|
||||
setpenattr_bool(state, VTERM_ATTR_STRIKE, 0);
|
||||
break;
|
||||
|
||||
case 30: case 31: case 32: case 33:
|
||||
case 34: case 35: case 36: case 37: /* Foreground colour palette */
|
||||
case 34: case 35: case 36: case 37: // Foreground colour palette
|
||||
value = CSI_ARG(args[argi]) - 30;
|
||||
state->fg_index = value;
|
||||
if(state->pen.bold && state->bold_is_highbright)
|
||||
@@ -331,7 +331,7 @@ INTERNAL void vterm_state_setpen(VTermState *state, const long args[], int argco
|
||||
set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
|
||||
break;
|
||||
|
||||
case 38: /* Foreground colour alternative palette */
|
||||
case 38: // Foreground colour alternative palette
|
||||
state->fg_index = -1;
|
||||
if(argcount - argi < 1)
|
||||
return;
|
||||
@@ -339,20 +339,20 @@ INTERNAL void vterm_state_setpen(VTermState *state, const long args[], int argco
|
||||
setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
|
||||
break;
|
||||
|
||||
case 39: /* Foreground colour default */
|
||||
case 39: // Foreground colour default
|
||||
state->fg_index = -1;
|
||||
state->pen.fg = state->default_fg;
|
||||
setpenattr_col(state, VTERM_ATTR_FOREGROUND, state->pen.fg);
|
||||
break;
|
||||
|
||||
case 40: case 41: case 42: case 43:
|
||||
case 44: case 45: case 46: case 47: /* Background colour palette */
|
||||
case 44: case 45: case 46: case 47: // Background colour palette
|
||||
value = CSI_ARG(args[argi]) - 40;
|
||||
state->bg_index = value;
|
||||
set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
|
||||
break;
|
||||
|
||||
case 48: /* Background colour alternative palette */
|
||||
case 48: // Background colour alternative palette
|
||||
state->bg_index = -1;
|
||||
if(argcount - argi < 1)
|
||||
return;
|
||||
@@ -360,21 +360,21 @@ INTERNAL void vterm_state_setpen(VTermState *state, const long args[], int argco
|
||||
setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
|
||||
break;
|
||||
|
||||
case 49: /* Default background */
|
||||
case 49: // Default background
|
||||
state->bg_index = -1;
|
||||
state->pen.bg = state->default_bg;
|
||||
setpenattr_col(state, VTERM_ATTR_BACKGROUND, state->pen.bg);
|
||||
break;
|
||||
|
||||
case 90: case 91: case 92: case 93:
|
||||
case 94: case 95: case 96: case 97: /* Foreground colour high-intensity palette */
|
||||
case 94: case 95: case 96: case 97: // Foreground colour high-intensity palette
|
||||
value = CSI_ARG(args[argi]) - 90 + 8;
|
||||
state->fg_index = value;
|
||||
set_pen_col_ansi(state, VTERM_ATTR_FOREGROUND, value);
|
||||
break;
|
||||
|
||||
case 100: case 101: case 102: case 103:
|
||||
case 104: case 105: case 106: case 107: /* Background colour high-intensity palette */
|
||||
case 104: case 105: case 106: case 107: // Background colour high-intensity palette
|
||||
value = CSI_ARG(args[argi]) - 100 + 8;
|
||||
state->bg_index = value;
|
||||
set_pen_col_ansi(state, VTERM_ATTR_BACKGROUND, value);
|
||||
@@ -432,7 +432,7 @@ INTERNAL int vterm_state_getpen(VTermState *state, long args[], int argcount UNU
|
||||
args[argi++] = state->fg_index;
|
||||
}
|
||||
else if(state->fg_index == -1) {
|
||||
/* Send palette 2 if the actual FG colour is not default */
|
||||
// Send palette 2 if the actual FG colour is not default
|
||||
if(state->pen.fg.red != state->default_fg.red ||
|
||||
state->pen.fg.green != state->default_fg.green ||
|
||||
state->pen.fg.blue != state->default_fg.blue ) {
|
||||
@@ -454,7 +454,7 @@ INTERNAL int vterm_state_getpen(VTermState *state, long args[], int argcount UNU
|
||||
args[argi++] = state->bg_index;
|
||||
}
|
||||
else if(state->bg_index == -1) {
|
||||
/* Send palette 2 if the actual BG colour is not default */
|
||||
// Send palette 2 if the actual BG colour is not default
|
||||
if(state->pen.bg.red != state->default_bg.red ||
|
||||
state->pen.bg.green != state->default_bg.green ||
|
||||
state->pen.bg.blue != state->default_bg.blue ) {
|
||||
|
||||
+14
-14
@@ -115,17 +115,17 @@ static void damagerect(VTermScreen *screen, VTermRect rect)
|
||||
/* Emit damage longer than one row. Try to merge with existing damage in
|
||||
* the same row */
|
||||
if(rect.end_row > rect.start_row + 1) {
|
||||
/* Bigger than 1 line - flush existing, emit this */
|
||||
// Bigger than 1 line - flush existing, emit this
|
||||
vterm_screen_flush_damage(screen);
|
||||
emit = rect;
|
||||
}
|
||||
else if(screen->damaged.start_row == -1) {
|
||||
/* None stored yet */
|
||||
// None stored yet
|
||||
screen->damaged = rect;
|
||||
return;
|
||||
}
|
||||
else if(rect.start_row == screen->damaged.start_row) {
|
||||
/* Merge with the stored line */
|
||||
// Merge with the stored line
|
||||
if(screen->damaged.start_col > rect.start_col)
|
||||
screen->damaged.start_col = rect.start_col;
|
||||
if(screen->damaged.end_col < rect.end_col)
|
||||
@@ -133,7 +133,7 @@ static void damagerect(VTermScreen *screen, VTermRect rect)
|
||||
return;
|
||||
}
|
||||
else {
|
||||
/* Emit the currently stored line, store a new one */
|
||||
// Emit the currently stored line, store a new one
|
||||
emit = screen->damaged;
|
||||
screen->damaged = rect;
|
||||
}
|
||||
@@ -208,9 +208,9 @@ static int moverect_internal(VTermRect dest, VTermRect src, void *user)
|
||||
VTermScreen *screen = user;
|
||||
|
||||
if(screen->callbacks && screen->callbacks->sb_pushline &&
|
||||
dest.start_row == 0 && dest.start_col == 0 && /* starts top-left corner */
|
||||
dest.end_col == screen->cols && /* full width */
|
||||
screen->buffer == screen->buffers[0]) { /* not altscreen */
|
||||
dest.start_row == 0 && dest.start_col == 0 && // starts top-left corner
|
||||
dest.end_col == screen->cols && // full width
|
||||
screen->buffer == screen->buffers[0]) { // not altscreen
|
||||
VTermPos pos;
|
||||
for(pos.row = 0; pos.row < src.start_row; pos.row++) {
|
||||
for(pos.col = 0; pos.col < screen->cols; pos.col++)
|
||||
@@ -252,7 +252,7 @@ static int moverect_user(VTermRect dest, VTermRect src, void *user)
|
||||
|
||||
if(screen->callbacks && screen->callbacks->moverect) {
|
||||
if(screen->damage_merge != VTERM_DAMAGE_SCROLL)
|
||||
/* Avoid an infinite loop */
|
||||
// Avoid an infinite loop
|
||||
vterm_screen_flush_damage(screen);
|
||||
|
||||
if((*screen->callbacks->moverect)(dest, src, screen->cbdata))
|
||||
@@ -488,11 +488,11 @@ static int resize(int new_rows, int new_cols, VTermPos *delta, void *user)
|
||||
int first_blank_row;
|
||||
|
||||
if(!is_altscreen && new_rows < old_rows) {
|
||||
/* Fewer rows - determine if we're going to scroll at all, and if so, push
|
||||
those lines to scrollback */
|
||||
// Fewer rows - determine if we're going to scroll at all, and if so, push
|
||||
// those lines to scrollback
|
||||
VTermPos pos = { 0, 0 };
|
||||
VTermPos cursor = screen->state->pos;
|
||||
/* Find the first blank row after the cursor. */
|
||||
// Find the first blank row after the cursor.
|
||||
for(pos.row = old_rows - 1; pos.row >= new_rows; pos.row--)
|
||||
if(!vterm_screen_is_eol(screen, pos) || cursor.row == pos.row)
|
||||
break;
|
||||
@@ -702,10 +702,10 @@ static size_t _get_chars(const VTermScreen *screen, const int utf8, void *buffer
|
||||
int i;
|
||||
|
||||
if(cell->chars[0] == 0)
|
||||
/* Erased cell, might need a space */
|
||||
// Erased cell, might need a space
|
||||
padding++;
|
||||
else if(cell->chars[0] == (uint32_t)-1)
|
||||
/* Gap behind a double-width char, do nothing */
|
||||
// Gap behind a double-width char, do nothing
|
||||
;
|
||||
else {
|
||||
while(padding) {
|
||||
@@ -912,7 +912,7 @@ int vterm_screen_get_attrs_extent(const VTermScreen *screen, VTermRect *extent,
|
||||
|
||||
ScreenCell *target = getcell(screen, pos.row, pos.col);
|
||||
|
||||
/* TODO: bounds check */
|
||||
// TODO: bounds check
|
||||
extent->start_row = pos.row;
|
||||
extent->end_row = pos.row + 1;
|
||||
|
||||
|
||||
+107
-107
@@ -101,7 +101,7 @@ static void scroll(VTermState *state, VTermRect rect, int downward, int rightwar
|
||||
else if(rightward < -cols)
|
||||
rightward = -cols;
|
||||
|
||||
/* Update lineinfo if full line */
|
||||
// Update lineinfo if full line
|
||||
if(rect.start_col == 0 && rect.end_col == state->cols && rightward == 0) {
|
||||
int height = rect.end_row - rect.start_row - abs(downward);
|
||||
|
||||
@@ -221,7 +221,7 @@ static void set_lineinfo(VTermState *state, int row, int force, int dwl, int dhl
|
||||
info.doublewidth = DWL_OFF;
|
||||
else if(dwl == DWL_ON)
|
||||
info.doublewidth = DWL_ON;
|
||||
/* else -1 to ignore */
|
||||
// else -1 to ignore
|
||||
|
||||
if(dhl == DHL_OFF)
|
||||
info.doubleheight = DHL_OFF;
|
||||
@@ -248,8 +248,8 @@ static int on_text(const char bytes[], size_t len, void *user)
|
||||
|
||||
VTermPos oldpos = state->pos;
|
||||
|
||||
/* We'll have at most len codepoints, plus one from a previous incomplete
|
||||
* sequence. */
|
||||
// We'll have at most len codepoints, plus one from a previous incomplete
|
||||
// sequence.
|
||||
codepoints = vterm_allocator_malloc(state->vt, (len + 1) * sizeof(uint32_t));
|
||||
|
||||
encoding =
|
||||
@@ -317,7 +317,7 @@ static int on_text(const char bytes[], size_t len, void *user)
|
||||
}
|
||||
|
||||
for(; i < npoints; i++) {
|
||||
/* Try to find combining characters following this */
|
||||
// Try to find combining characters following this
|
||||
int glyph_starts = i;
|
||||
int glyph_ends;
|
||||
int width = 0;
|
||||
@@ -422,54 +422,54 @@ static int on_control(unsigned char control, void *user)
|
||||
VTermPos oldpos = state->pos;
|
||||
|
||||
switch(control) {
|
||||
case 0x07: /* BEL - ECMA-48 8.3.3 */
|
||||
case 0x07: // BEL - ECMA-48 8.3.3
|
||||
if(state->callbacks && state->callbacks->bell)
|
||||
(*state->callbacks->bell)(state->cbdata);
|
||||
break;
|
||||
|
||||
case 0x08: /* BS - ECMA-48 8.3.5 */
|
||||
case 0x08: // BS - ECMA-48 8.3.5
|
||||
if(state->pos.col > 0)
|
||||
state->pos.col--;
|
||||
break;
|
||||
|
||||
case 0x09: /* HT - ECMA-48 8.3.60 */
|
||||
case 0x09: // HT - ECMA-48 8.3.60
|
||||
tab(state, 1, +1);
|
||||
break;
|
||||
|
||||
case 0x0a: /* LF - ECMA-48 8.3.74 */
|
||||
case 0x0b: /* VT */
|
||||
case 0x0c: /* FF */
|
||||
case 0x0a: // LF - ECMA-48 8.3.74
|
||||
case 0x0b: // VT
|
||||
case 0x0c: // FF
|
||||
linefeed(state);
|
||||
if(state->mode.newline)
|
||||
state->pos.col = 0;
|
||||
break;
|
||||
|
||||
case 0x0d: /* CR - ECMA-48 8.3.15 */
|
||||
case 0x0d: // CR - ECMA-48 8.3.15
|
||||
state->pos.col = 0;
|
||||
break;
|
||||
|
||||
case 0x0e: /* LS1 - ECMA-48 8.3.76 */
|
||||
case 0x0e: // LS1 - ECMA-48 8.3.76
|
||||
state->gl_set = 1;
|
||||
break;
|
||||
|
||||
case 0x0f: /* LS0 - ECMA-48 8.3.75 */
|
||||
case 0x0f: // LS0 - ECMA-48 8.3.75
|
||||
state->gl_set = 0;
|
||||
break;
|
||||
|
||||
case 0x84: /* IND - DEPRECATED but implemented for completeness */
|
||||
case 0x84: // IND - DEPRECATED but implemented for completeness
|
||||
linefeed(state);
|
||||
break;
|
||||
|
||||
case 0x85: /* NEL - ECMA-48 8.3.86 */
|
||||
case 0x85: // NEL - ECMA-48 8.3.86
|
||||
linefeed(state);
|
||||
state->pos.col = 0;
|
||||
break;
|
||||
|
||||
case 0x88: /* HTS - ECMA-48 8.3.62 */
|
||||
case 0x88: // HTS - ECMA-48 8.3.62
|
||||
set_col_tabstop(state, state->pos.col);
|
||||
break;
|
||||
|
||||
case 0x8d: /* RI - ECMA-48 8.3.104 */
|
||||
case 0x8d: // RI - ECMA-48 8.3.104
|
||||
if(state->pos.row == state->scrollregion_top) {
|
||||
VTermRect rect;
|
||||
rect.start_row = state->scrollregion_top;
|
||||
@@ -483,11 +483,11 @@ static int on_control(unsigned char control, void *user)
|
||||
state->pos.row--;
|
||||
break;
|
||||
|
||||
case 0x8e: /* SS2 - ECMA-48 8.3.141 */
|
||||
case 0x8e: // SS2 - ECMA-48 8.3.141
|
||||
state->gsingle_set = 2;
|
||||
break;
|
||||
|
||||
case 0x8f: /* SS3 - ECMA-48 8.3.142 */
|
||||
case 0x8f: // SS3 - ECMA-48 8.3.142
|
||||
state->gsingle_set = 3;
|
||||
break;
|
||||
|
||||
@@ -580,11 +580,11 @@ static int on_escape(const char *bytes, size_t len, void *user)
|
||||
return 0;
|
||||
|
||||
switch(bytes[1]) {
|
||||
case 'F': /* S7C1T */
|
||||
case 'F': // S7C1T
|
||||
state->vt->mode.ctrl8bit = 0;
|
||||
break;
|
||||
|
||||
case 'G': /* S8C1T */
|
||||
case 'G': // S8C1T
|
||||
state->vt->mode.ctrl8bit = 1;
|
||||
break;
|
||||
|
||||
@@ -598,31 +598,31 @@ static int on_escape(const char *bytes, size_t len, void *user)
|
||||
return 0;
|
||||
|
||||
switch(bytes[1]) {
|
||||
case '3': /* DECDHL top */
|
||||
case '3': // DECDHL top
|
||||
if(state->mode.leftrightmargin)
|
||||
break;
|
||||
set_lineinfo(state, state->pos.row, NO_FORCE, DWL_ON, DHL_TOP);
|
||||
break;
|
||||
|
||||
case '4': /* DECDHL bottom */
|
||||
case '4': // DECDHL bottom
|
||||
if(state->mode.leftrightmargin)
|
||||
break;
|
||||
set_lineinfo(state, state->pos.row, NO_FORCE, DWL_ON, DHL_BOTTOM);
|
||||
break;
|
||||
|
||||
case '5': /* DECSWL */
|
||||
case '5': // DECSWL
|
||||
if(state->mode.leftrightmargin)
|
||||
break;
|
||||
set_lineinfo(state, state->pos.row, NO_FORCE, DWL_OFF, DHL_OFF);
|
||||
break;
|
||||
|
||||
case '6': /* DECDWL */
|
||||
case '6': // DECDWL
|
||||
if(state->mode.leftrightmargin)
|
||||
break;
|
||||
set_lineinfo(state, state->pos.row, NO_FORCE, DWL_ON, DHL_OFF);
|
||||
break;
|
||||
|
||||
case '8': /* DECALN */
|
||||
case '8': // DECALN
|
||||
{
|
||||
VTermPos pos;
|
||||
uint32_t E[] = { 'E', 0 };
|
||||
@@ -637,7 +637,7 @@ static int on_escape(const char *bytes, size_t len, void *user)
|
||||
}
|
||||
return 2;
|
||||
|
||||
case '(': case ')': case '*': case '+': /* SCS */
|
||||
case '(': case ')': case '*': case '+': // SCS
|
||||
if(len != 2)
|
||||
return 0;
|
||||
|
||||
@@ -655,26 +655,26 @@ static int on_escape(const char *bytes, size_t len, void *user)
|
||||
|
||||
return 2;
|
||||
|
||||
case '7': /* DECSC */
|
||||
case '7': // DECSC
|
||||
savecursor(state, 1);
|
||||
return 1;
|
||||
|
||||
case '8': /* DECRC */
|
||||
case '8': // DECRC
|
||||
savecursor(state, 0);
|
||||
return 1;
|
||||
|
||||
case '<': /* Ignored by VT100. Used in VT52 mode to switch up to VT100 */
|
||||
case '<': // Ignored by VT100. Used in VT52 mode to switch up to VT100
|
||||
return 1;
|
||||
|
||||
case '=': /* DECKPAM */
|
||||
case '=': // DECKPAM
|
||||
state->mode.keypad = 1;
|
||||
return 1;
|
||||
|
||||
case '>': /* DECKPNM */
|
||||
case '>': // DECKPNM
|
||||
state->mode.keypad = 0;
|
||||
return 1;
|
||||
|
||||
case 'c': /* RIS - ECMA-48 8.3.105 */
|
||||
case 'c': // RIS - ECMA-48 8.3.105
|
||||
{
|
||||
VTermPos oldpos = state->pos;
|
||||
vterm_state_reset(state, 1);
|
||||
@@ -683,23 +683,23 @@ static int on_escape(const char *bytes, size_t len, void *user)
|
||||
return 1;
|
||||
}
|
||||
|
||||
case 'n': /* LS2 - ECMA-48 8.3.78 */
|
||||
case 'n': // LS2 - ECMA-48 8.3.78
|
||||
state->gl_set = 2;
|
||||
return 1;
|
||||
|
||||
case 'o': /* LS3 - ECMA-48 8.3.80 */
|
||||
case 'o': // LS3 - ECMA-48 8.3.80
|
||||
state->gl_set = 3;
|
||||
return 1;
|
||||
|
||||
case '~': /* LS1R - ECMA-48 8.3.77 */
|
||||
case '~': // LS1R - ECMA-48 8.3.77
|
||||
state->gr_set = 1;
|
||||
return 1;
|
||||
|
||||
case '}': /* LS2R - ECMA-48 8.3.79 */
|
||||
case '}': // LS2R - ECMA-48 8.3.79
|
||||
state->gr_set = 2;
|
||||
return 1;
|
||||
|
||||
case '|': /* LS3R - ECMA-48 8.3.81 */
|
||||
case '|': // LS3R - ECMA-48 8.3.81
|
||||
state->gr_set = 3;
|
||||
return 1;
|
||||
|
||||
@@ -711,11 +711,11 @@ static int on_escape(const char *bytes, size_t len, void *user)
|
||||
static void set_mode(VTermState *state, int num, int val)
|
||||
{
|
||||
switch(num) {
|
||||
case 4: /* IRM - ECMA-48 7.2.10 */
|
||||
case 4: // IRM - ECMA-48 7.2.10
|
||||
state->mode.insert = val;
|
||||
break;
|
||||
|
||||
case 20: /* LNM - ANSI X3.4-1977 */
|
||||
case 20: // LNM - ANSI X3.4-1977
|
||||
state->mode.newline = val;
|
||||
break;
|
||||
|
||||
@@ -732,11 +732,11 @@ static void set_dec_mode(VTermState *state, int num, int val)
|
||||
state->mode.cursor = val;
|
||||
break;
|
||||
|
||||
case 5: /* DECSCNM - screen mode */
|
||||
case 5: // DECSCNM - screen mode
|
||||
settermprop_bool(state, VTERM_PROP_REVERSE, val);
|
||||
break;
|
||||
|
||||
case 6: /* DECOM - origin mode */
|
||||
case 6: // DECOM - origin mode
|
||||
{
|
||||
VTermPos oldpos = state->pos;
|
||||
state->mode.origin = val;
|
||||
@@ -758,13 +758,13 @@ static void set_dec_mode(VTermState *state, int num, int val)
|
||||
settermprop_bool(state, VTERM_PROP_CURSORVISIBLE, val);
|
||||
break;
|
||||
|
||||
case 69: /* DECVSSM - vertical split screen mode */
|
||||
/* DECLRMM - left/right margin mode */
|
||||
case 69: // DECVSSM - vertical split screen mode
|
||||
// DECLRMM - left/right margin mode
|
||||
state->mode.leftrightmargin = val;
|
||||
if(val) {
|
||||
int row;
|
||||
|
||||
/* Setting DECVSSM must clear doublewidth/doubleheight state of every line */
|
||||
// Setting DECVSSM must clear doublewidth/doubleheight state of every line
|
||||
for(row = 0; row < state->rows; row++)
|
||||
set_lineinfo(state, row, FORCE, DWL_OFF, DHL_OFF);
|
||||
}
|
||||
@@ -911,7 +911,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
int selective;
|
||||
|
||||
if(leader && leader[0]) {
|
||||
if(leader[1]) /* longer than 1 char */
|
||||
if(leader[1]) // longer than 1 char
|
||||
return 0;
|
||||
|
||||
switch(leader[0]) {
|
||||
@@ -925,7 +925,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
}
|
||||
|
||||
if(intermed && intermed[0]) {
|
||||
if(intermed[1]) /* longer than 1 char */
|
||||
if(intermed[1]) // longer than 1 char
|
||||
return 0;
|
||||
|
||||
switch(intermed[0]) {
|
||||
@@ -949,7 +949,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
#define INTERMED(i,b) ((i << 16) | b)
|
||||
|
||||
switch(intermed_byte << 16 | leader_byte << 8 | command) {
|
||||
case 0x40: /* ICH - ECMA-48 8.3.64 */
|
||||
case 0x40: // ICH - ECMA-48 8.3.64
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
|
||||
if(!is_cursor_in_scrollregion(state))
|
||||
@@ -967,54 +967,54 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case 0x41: /* CUU - ECMA-48 8.3.22 */
|
||||
case 0x41: // CUU - ECMA-48 8.3.22
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.row -= count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x42: /* CUD - ECMA-48 8.3.19 */
|
||||
case 0x42: // CUD - ECMA-48 8.3.19
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.row += count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x43: /* CUF - ECMA-48 8.3.20 */
|
||||
case 0x43: // CUF - ECMA-48 8.3.20
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.col += count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x44: /* CUB - ECMA-48 8.3.18 */
|
||||
case 0x44: // CUB - ECMA-48 8.3.18
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.col -= count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x45: /* CNL - ECMA-48 8.3.12 */
|
||||
case 0x45: // CNL - ECMA-48 8.3.12
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.col = 0;
|
||||
state->pos.row += count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x46: /* CPL - ECMA-48 8.3.13 */
|
||||
case 0x46: // CPL - ECMA-48 8.3.13
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.col = 0;
|
||||
state->pos.row -= count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x47: /* CHA - ECMA-48 8.3.9 */
|
||||
case 0x47: // CHA - ECMA-48 8.3.9
|
||||
val = CSI_ARG_OR(args[0], 1);
|
||||
state->pos.col = val-1;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x48: /* CUP - ECMA-48 8.3.21 */
|
||||
case 0x48: // CUP - ECMA-48 8.3.21
|
||||
row = CSI_ARG_OR(args[0], 1);
|
||||
col = argcount < 2 || CSI_ARG_IS_MISSING(args[1]) ? 1 : CSI_ARG(args[1]);
|
||||
/* zero-based */
|
||||
// zero-based
|
||||
state->pos.row = row-1;
|
||||
state->pos.col = col-1;
|
||||
if(state->mode.origin) {
|
||||
@@ -1024,13 +1024,13 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x49: /* CHT - ECMA-48 8.3.10 */
|
||||
case 0x49: // CHT - ECMA-48 8.3.10
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
tab(state, count, +1);
|
||||
break;
|
||||
|
||||
case 0x4a: /* ED - ECMA-48 8.3.39 */
|
||||
case LEADER('?', 0x4a): /* DECSED - Selective Erase in Display */
|
||||
case 0x4a: // ED - ECMA-48 8.3.39
|
||||
case LEADER('?', 0x4a): // DECSED - Selective Erase in Display
|
||||
selective = (leader_byte == '?');
|
||||
switch(CSI_ARG(args[0])) {
|
||||
case CSI_ARG_MISSING:
|
||||
@@ -1072,8 +1072,8 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x4b: /* EL - ECMA-48 8.3.41 */
|
||||
case LEADER('?', 0x4b): /* DECSEL - Selective Erase in Line */
|
||||
case 0x4b: // EL - ECMA-48 8.3.41
|
||||
case LEADER('?', 0x4b): // DECSEL - Selective Erase in Line
|
||||
selective = (leader_byte == '?');
|
||||
rect.start_row = state->pos.row;
|
||||
rect.end_row = state->pos.row + 1;
|
||||
@@ -1095,7 +1095,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case 0x4c: /* IL - ECMA-48 8.3.67 */
|
||||
case 0x4c: // IL - ECMA-48 8.3.67
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
|
||||
if(!is_cursor_in_scrollregion(state))
|
||||
@@ -1110,7 +1110,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case 0x4d: /* DL - ECMA-48 8.3.32 */
|
||||
case 0x4d: // DL - ECMA-48 8.3.32
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
|
||||
if(!is_cursor_in_scrollregion(state))
|
||||
@@ -1125,7 +1125,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case 0x50: /* DCH - ECMA-48 8.3.26 */
|
||||
case 0x50: // DCH - ECMA-48 8.3.26
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
|
||||
if(!is_cursor_in_scrollregion(state))
|
||||
@@ -1143,7 +1143,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case 0x53: /* SU - ECMA-48 8.3.147 */
|
||||
case 0x53: // SU - ECMA-48 8.3.147
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
|
||||
rect.start_row = state->scrollregion_top;
|
||||
@@ -1155,7 +1155,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case 0x54: /* SD - ECMA-48 8.3.113 */
|
||||
case 0x54: // SD - ECMA-48 8.3.113
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
|
||||
rect.start_row = state->scrollregion_top;
|
||||
@@ -1167,7 +1167,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case 0x58: /* ECH - ECMA-48 8.3.38 */
|
||||
case 0x58: // ECH - ECMA-48 8.3.38
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
|
||||
rect.start_row = state->pos.row;
|
||||
@@ -1179,36 +1179,36 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
erase(state, rect, 0);
|
||||
break;
|
||||
|
||||
case 0x5a: /* CBT - ECMA-48 8.3.7 */
|
||||
case 0x5a: // CBT - ECMA-48 8.3.7
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
tab(state, count, -1);
|
||||
break;
|
||||
|
||||
case 0x60: /* HPA - ECMA-48 8.3.57 */
|
||||
case 0x60: // HPA - ECMA-48 8.3.57
|
||||
col = CSI_ARG_OR(args[0], 1);
|
||||
state->pos.col = col-1;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x61: /* HPR - ECMA-48 8.3.59 */
|
||||
case 0x61: // HPR - ECMA-48 8.3.59
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.col += count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x63: /* DA - ECMA-48 8.3.24 */
|
||||
case 0x63: // DA - ECMA-48 8.3.24
|
||||
val = CSI_ARG_OR(args[0], 0);
|
||||
if(val == 0)
|
||||
/* DEC VT100 response */
|
||||
// DEC VT100 response
|
||||
vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "?1;2c");
|
||||
break;
|
||||
|
||||
case LEADER('>', 0x63): /* DEC secondary Device Attributes */
|
||||
/* This returns xterm version number 100. */
|
||||
case LEADER('>', 0x63): // DEC secondary Device Attributes
|
||||
// This returns xterm version number 100.
|
||||
vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, ">%d;%d;%dc", 0, 100, 0);
|
||||
break;
|
||||
|
||||
case 0x64: /* VPA - ECMA-48 8.3.158 */
|
||||
case 0x64: // VPA - ECMA-48 8.3.158
|
||||
row = CSI_ARG_OR(args[0], 1);
|
||||
state->pos.row = row-1;
|
||||
if(state->mode.origin)
|
||||
@@ -1216,16 +1216,16 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x65: /* VPR - ECMA-48 8.3.160 */
|
||||
case 0x65: // VPR - ECMA-48 8.3.160
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.row += count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x66: /* HVP - ECMA-48 8.3.63 */
|
||||
case 0x66: // HVP - ECMA-48 8.3.63
|
||||
row = CSI_ARG_OR(args[0], 1);
|
||||
col = argcount < 2 || CSI_ARG_IS_MISSING(args[1]) ? 1 : CSI_ARG(args[1]);
|
||||
/* zero-based */
|
||||
// zero-based
|
||||
state->pos.row = row-1;
|
||||
state->pos.col = col-1;
|
||||
if(state->mode.origin) {
|
||||
@@ -1235,7 +1235,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x67: /* TBC - ECMA-48 8.3.154 */
|
||||
case 0x67: // TBC - ECMA-48 8.3.154
|
||||
val = CSI_ARG_OR(args[0], 0);
|
||||
|
||||
switch(val) {
|
||||
@@ -1257,44 +1257,44 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x68: /* SM - ECMA-48 8.3.125 */
|
||||
case 0x68: // SM - ECMA-48 8.3.125
|
||||
if(!CSI_ARG_IS_MISSING(args[0]))
|
||||
set_mode(state, CSI_ARG(args[0]), 1);
|
||||
break;
|
||||
|
||||
case LEADER('?', 0x68): /* DEC private mode set */
|
||||
case LEADER('?', 0x68): // DEC private mode set
|
||||
if(!CSI_ARG_IS_MISSING(args[0]))
|
||||
set_dec_mode(state, CSI_ARG(args[0]), 1);
|
||||
break;
|
||||
|
||||
case 0x6a: /* HPB - ECMA-48 8.3.58 */
|
||||
case 0x6a: // HPB - ECMA-48 8.3.58
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.col -= count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x6b: /* VPB - ECMA-48 8.3.159 */
|
||||
case 0x6b: // VPB - ECMA-48 8.3.159
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
state->pos.row -= count;
|
||||
state->at_phantom = 0;
|
||||
break;
|
||||
|
||||
case 0x6c: /* RM - ECMA-48 8.3.106 */
|
||||
case 0x6c: // RM - ECMA-48 8.3.106
|
||||
if(!CSI_ARG_IS_MISSING(args[0]))
|
||||
set_mode(state, CSI_ARG(args[0]), 0);
|
||||
break;
|
||||
|
||||
case LEADER('?', 0x6c): /* DEC private mode reset */
|
||||
case LEADER('?', 0x6c): // DEC private mode reset
|
||||
if(!CSI_ARG_IS_MISSING(args[0]))
|
||||
set_dec_mode(state, CSI_ARG(args[0]), 0);
|
||||
break;
|
||||
|
||||
case 0x6d: /* SGR - ECMA-48 8.3.117 */
|
||||
case 0x6d: // SGR - ECMA-48 8.3.117
|
||||
vterm_state_setpen(state, args, argcount);
|
||||
break;
|
||||
|
||||
case 0x6e: /* DSR - ECMA-48 8.3.35 */
|
||||
case LEADER('?', 0x6e): /* DECDSR */
|
||||
case 0x6e: // DSR - ECMA-48 8.3.35
|
||||
case LEADER('?', 0x6e): // DECDSR
|
||||
val = CSI_ARG_OR(args[0], 0);
|
||||
|
||||
{
|
||||
@@ -1302,12 +1302,12 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
switch(val) {
|
||||
case 0: case 1: case 2: case 3: case 4:
|
||||
/* ignore - these are replies */
|
||||
// ignore - these are replies
|
||||
break;
|
||||
case 5:
|
||||
vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "%s0n", qmark);
|
||||
break;
|
||||
case 6: /* CPR - cursor position report */
|
||||
case 6: // CPR - cursor position report
|
||||
vterm_push_output_sprintf_ctrl(state->vt, C1_CSI, "%s%d;%dR", qmark, state->pos.row + 1, state->pos.col + 1);
|
||||
break;
|
||||
}
|
||||
@@ -1315,7 +1315,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
break;
|
||||
|
||||
|
||||
case LEADER('!', 0x70): /* DECSTR - DEC soft terminal reset */
|
||||
case LEADER('!', 0x70): // DECSTR - DEC soft terminal reset
|
||||
vterm_state_reset(state, 0);
|
||||
break;
|
||||
|
||||
@@ -1323,7 +1323,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
request_dec_mode(state, CSI_ARG(args[0]));
|
||||
break;
|
||||
|
||||
case INTERMED(' ', 0x71): /* DECSCUSR - DEC set cursor shape */
|
||||
case INTERMED(' ', 0x71): // DECSCUSR - DEC set cursor shape
|
||||
val = CSI_ARG_OR(args[0], 1);
|
||||
|
||||
switch(val) {
|
||||
@@ -1355,7 +1355,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case INTERMED('"', 0x71): /* DECSCA - DEC select character protection attribute */
|
||||
case INTERMED('"', 0x71): // DECSCA - DEC select character protection attribute
|
||||
val = CSI_ARG_OR(args[0], 0);
|
||||
|
||||
switch(val) {
|
||||
@@ -1369,7 +1369,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case 0x72: /* DECSTBM - DEC custom */
|
||||
case 0x72: // DECSTBM - DEC custom
|
||||
state->scrollregion_top = CSI_ARG_OR(args[0], 1) - 1;
|
||||
state->scrollregion_bottom = argcount < 2 || CSI_ARG_IS_MISSING(args[1]) ? -1 : CSI_ARG(args[1]);
|
||||
LBOUND(state->scrollregion_top, 0);
|
||||
@@ -1381,15 +1381,15 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
UBOUND(state->scrollregion_bottom, state->rows);
|
||||
|
||||
if(SCROLLREGION_BOTTOM(state) <= state->scrollregion_top) {
|
||||
/* Invalid */
|
||||
// Invalid
|
||||
state->scrollregion_top = 0;
|
||||
state->scrollregion_bottom = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 0x73: /* DECSLRM - DEC custom */
|
||||
/* Always allow setting these margins, just they won't take effect without DECVSSM */
|
||||
case 0x73: // DECSLRM - DEC custom
|
||||
// Always allow setting these margins, just they won't take effect without DECVSSM
|
||||
state->scrollregion_left = CSI_ARG_OR(args[0], 1) - 1;
|
||||
state->scrollregion_right = argcount < 2 || CSI_ARG_IS_MISSING(args[1]) ? -1 : CSI_ARG(args[1]);
|
||||
LBOUND(state->scrollregion_left, 0);
|
||||
@@ -1402,7 +1402,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
if(state->scrollregion_right > -1 &&
|
||||
state->scrollregion_right <= state->scrollregion_left) {
|
||||
/* Invalid */
|
||||
// Invalid
|
||||
state->scrollregion_left = 0;
|
||||
state->scrollregion_right = -1;
|
||||
}
|
||||
@@ -1417,7 +1417,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
}
|
||||
break;
|
||||
|
||||
case INTERMED('\'', 0x7D): /* DECIC */
|
||||
case INTERMED('\'', 0x7D): // DECIC
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
|
||||
if(!is_cursor_in_scrollregion(state))
|
||||
@@ -1432,7 +1432,7 @@ static int on_csi(const char *leader, const long args[], int argcount, const cha
|
||||
|
||||
break;
|
||||
|
||||
case INTERMED('\'', 0x7E): /* DECDC */
|
||||
case INTERMED('\'', 0x7E): // DECDC
|
||||
count = CSI_ARG_COUNT(args[0]);
|
||||
|
||||
if(!is_cursor_in_scrollregion(state))
|
||||
@@ -1545,7 +1545,7 @@ static void request_status_string(VTermState *state, const char *command, size_t
|
||||
{
|
||||
if(cmdlen == 1)
|
||||
switch(command[0]) {
|
||||
case 'm': /* Query SGR */
|
||||
case 'm': // Query SGR
|
||||
{
|
||||
long args[20];
|
||||
int argc = vterm_state_getpen(state, args, sizeof(args)/sizeof(args[0]));
|
||||
@@ -1561,10 +1561,10 @@ static void request_status_string(VTermState *state, const char *command, size_t
|
||||
vterm_push_output_sprintf_ctrl(state->vt, C1_ST, "");
|
||||
}
|
||||
return;
|
||||
case 'r': /* Query DECSTBM */
|
||||
case 'r': // Query DECSTBM
|
||||
vterm_push_output_sprintf_dcs(state->vt, "1$r%d;%dr", state->scrollregion_top+1, SCROLLREGION_BOTTOM(state));
|
||||
return;
|
||||
case 's': /* Query DECSLRM */
|
||||
case 's': // Query DECSLRM
|
||||
vterm_push_output_sprintf_dcs(state->vt, "1$r%d;%ds", SCROLLREGION_LEFT(state)+1, SCROLLREGION_RIGHT(state));
|
||||
return;
|
||||
}
|
||||
@@ -1779,7 +1779,7 @@ void vterm_state_reset(VTermState *state, int hard)
|
||||
|
||||
state->protected_cell = 0;
|
||||
|
||||
/* Initialise the props */
|
||||
// Initialise the props
|
||||
settermprop_bool(state, VTERM_PROP_CURSORVISIBLE, 1);
|
||||
settermprop_bool(state, VTERM_PROP_CURSORBLINK, 1);
|
||||
settermprop_int (state, VTERM_PROP_CURSORSHAPE, VTERM_PROP_CURSORSHAPE_BLOCK);
|
||||
@@ -1859,7 +1859,7 @@ int vterm_state_set_termprop(VTermState *state, VTermProp prop, VTermValue *val)
|
||||
case VTERM_PROP_TITLE:
|
||||
case VTERM_PROP_ICONNAME:
|
||||
case VTERM_PROP_CURSORCOLOR:
|
||||
/* we don't store these, just transparently pass through */
|
||||
// we don't store these, just transparently pass through
|
||||
return 1;
|
||||
case VTERM_PROP_CURSORVISIBLE:
|
||||
state->mode.cursor_visible = val->boolean;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
#include "vterm_internal.h"
|
||||
|
||||
/* ### The following from http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
|
||||
* With modifications:
|
||||
* made functions static
|
||||
* moved 'combining' table to file scope, so other functions can see it
|
||||
* ###################################################################
|
||||
*/
|
||||
// ### The following from http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
|
||||
// With modifications:
|
||||
// made functions static
|
||||
// moved 'combining' table to file scope, so other functions can see it
|
||||
// ###################################################################
|
||||
|
||||
/*
|
||||
* This is an implementation of wcwidth() and wcswidth() (defined in
|
||||
@@ -336,9 +335,8 @@ vterm_is_combining(uint32_t codepoint)
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* ################################
|
||||
* ### The rest added by Paul Evans */
|
||||
// ################################
|
||||
// ### The rest added by Paul Evans
|
||||
|
||||
INTERNAL int vterm_unicode_width(uint32_t codepoint)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ INLINE int fill_utf8(long codepoint, char *str)
|
||||
{
|
||||
int nbytes = utf8_seqlen(codepoint);
|
||||
|
||||
/* This is easier done backwards */
|
||||
// This is easier done backwards
|
||||
int b = nbytes;
|
||||
while(b > 1) {
|
||||
b--;
|
||||
|
||||
@@ -27,8 +27,8 @@ static void default_free(void *ptr, void *allocdata UNUSED)
|
||||
}
|
||||
|
||||
static VTermAllocatorFunctions default_allocator = {
|
||||
&default_malloc, /* malloc */
|
||||
&default_free /* free */
|
||||
&default_malloc, // malloc
|
||||
&default_free // free
|
||||
};
|
||||
|
||||
VTerm *vterm_new(int rows, int cols)
|
||||
|
||||
@@ -37,7 +37,7 @@ typedef struct VTermEncoding VTermEncoding;
|
||||
typedef struct {
|
||||
VTermEncoding *enc;
|
||||
|
||||
/* This size should be increased if required by other stateful encodings */
|
||||
// This size should be increased if required by other stateful encodings
|
||||
char data[4*sizeof(uint32_t)];
|
||||
} VTermEncodingInstance;
|
||||
|
||||
@@ -105,9 +105,9 @@ struct VTermState
|
||||
|
||||
/* Last glyph output, for Unicode recombining purposes */
|
||||
uint32_t *combine_chars;
|
||||
size_t combine_chars_size; /* Number of ELEMENTS in the above */
|
||||
int combine_width; /* The width of the glyph above */
|
||||
VTermPos combine_pos; /* Position before movement */
|
||||
size_t combine_chars_size; // Number of ELEMENTS in the above
|
||||
int combine_width; // The width of the glyph above
|
||||
VTermPos combine_pos; // Position before movement
|
||||
|
||||
struct {
|
||||
unsigned int keypad:1;
|
||||
@@ -133,7 +133,7 @@ struct VTermState
|
||||
|
||||
VTermColor default_fg;
|
||||
VTermColor default_bg;
|
||||
VTermColor colors[16]; /* Store the 8 ANSI and the 8 ANSI high-brights only */
|
||||
VTermColor colors[16]; // Store the 8 ANSI and the 8 ANSI high-brights only
|
||||
|
||||
int fg_index;
|
||||
int bg_index;
|
||||
@@ -183,7 +183,7 @@ struct VTerm
|
||||
ESC,
|
||||
/* below here are the "string states" */
|
||||
STRING,
|
||||
ESC_IN_STRING
|
||||
ESC_IN_STRING,
|
||||
} state;
|
||||
|
||||
int intermedlen;
|
||||
@@ -248,7 +248,7 @@ enum {
|
||||
C1_DCS = 0x90,
|
||||
C1_CSI = 0x9b,
|
||||
C1_ST = 0x9c,
|
||||
C1_OSC = 0x9d
|
||||
C1_OSC = 0x9d,
|
||||
};
|
||||
|
||||
void vterm_state_push_output_sprintf_CSI(VTermState *vts, const char *format, ...);
|
||||
|
||||
+12
-3
@@ -588,7 +588,7 @@ cin_is_cinword(char_u *line)
|
||||
* "second_line_indent": indent for after ^^D in Insert mode or if flag
|
||||
* OPENLINE_COM_LIST
|
||||
*
|
||||
* Return TRUE for success, FALSE for failure
|
||||
* Return OK for success, FAIL for failure
|
||||
*/
|
||||
int
|
||||
open_line(
|
||||
@@ -606,7 +606,7 @@ open_line(
|
||||
int newindent = 0; /* auto-indent of the new line */
|
||||
int n;
|
||||
int trunc_line = FALSE; /* truncate current line afterwards */
|
||||
int retval = FALSE; /* return value, default is FAIL */
|
||||
int retval = FAIL; /* return value */
|
||||
#ifdef FEAT_COMMENTS
|
||||
int extra_len = 0; /* length of p_extra string */
|
||||
int lead_len; /* length of comment leader */
|
||||
@@ -1642,7 +1642,7 @@ open_line(
|
||||
}
|
||||
#endif
|
||||
|
||||
retval = TRUE; /* success! */
|
||||
retval = OK; /* success! */
|
||||
theend:
|
||||
curbuf->b_p_pi = saved_pi;
|
||||
vim_free(saved_line);
|
||||
@@ -3600,6 +3600,11 @@ prompt_for_number(int *mouse_used)
|
||||
cmdline_row = 0;
|
||||
save_State = State;
|
||||
State = ASKMORE; /* prevents a screen update when using a timer */
|
||||
#ifdef FEAT_MOUSE
|
||||
/* May show different mouse shape. */
|
||||
setmouse();
|
||||
#endif
|
||||
|
||||
|
||||
i = get_number(TRUE, mouse_used);
|
||||
if (KeyTyped)
|
||||
@@ -3614,6 +3619,10 @@ prompt_for_number(int *mouse_used)
|
||||
else
|
||||
cmdline_row = save_cmdline_row;
|
||||
State = save_State;
|
||||
#ifdef FEAT_MOUSE
|
||||
/* May need to restore mouse shape. */
|
||||
setmouse();
|
||||
#endif
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
+2
-2
@@ -2610,7 +2610,7 @@ do_mouse(
|
||||
end_visual_mode();
|
||||
}
|
||||
}
|
||||
else if (c1 < 0)
|
||||
else
|
||||
{
|
||||
tabpage_T *tp;
|
||||
|
||||
@@ -8524,7 +8524,7 @@ n_opencmd(cmdarg_T *cap)
|
||||
#ifdef FEAT_COMMENTS
|
||||
has_format_option(FO_OPEN_COMS) ? OPENLINE_DO_COM :
|
||||
#endif
|
||||
0, 0))
|
||||
0, 0) == OK)
|
||||
{
|
||||
#ifdef FEAT_CONCEAL
|
||||
if (curwin->w_p_cole > 0 && oldline != curwin->w_cursor.lnum)
|
||||
|
||||
+16
-10
@@ -3909,17 +3909,23 @@ set_option_default(
|
||||
dvi = ((flags & P_VI_DEF) || compatible) ? VI_DEFAULT : VIM_DEFAULT;
|
||||
if (flags & P_STRING)
|
||||
{
|
||||
/* Use set_string_option_direct() for local options to handle
|
||||
* freeing and allocating the value. */
|
||||
if (options[opt_idx].indir != PV_NONE)
|
||||
set_string_option_direct(NULL, opt_idx,
|
||||
options[opt_idx].def_val[dvi], opt_flags, 0);
|
||||
else
|
||||
/* skip 'termkey' and 'termsize, they are duplicates of
|
||||
* 'termwinkey' and 'termwinsize' */
|
||||
if (STRCMP(options[opt_idx].fullname, "termkey") != 0
|
||||
&& STRCMP(options[opt_idx].fullname, "termsize") != 0)
|
||||
{
|
||||
if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
|
||||
free_string_option(*(char_u **)(varp));
|
||||
*(char_u **)varp = options[opt_idx].def_val[dvi];
|
||||
options[opt_idx].flags &= ~P_ALLOCED;
|
||||
/* Use set_string_option_direct() for local options to handle
|
||||
* freeing and allocating the value. */
|
||||
if (options[opt_idx].indir != PV_NONE)
|
||||
set_string_option_direct(NULL, opt_idx,
|
||||
options[opt_idx].def_val[dvi], opt_flags, 0);
|
||||
else
|
||||
{
|
||||
if ((opt_flags & OPT_FREE) && (flags & P_ALLOCED))
|
||||
free_string_option(*(char_u **)(varp));
|
||||
*(char_u **)varp = options[opt_idx].def_val[dvi];
|
||||
options[opt_idx].flags &= ~P_ALLOCED;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (flags & P_NUM)
|
||||
|
||||
+9
-8
@@ -441,7 +441,7 @@ mch_inchar(
|
||||
/* no character available within "wtime" */
|
||||
return 0;
|
||||
|
||||
if (wtime < 0)
|
||||
else
|
||||
{
|
||||
/* no character available within 'updatetime' */
|
||||
did_start_blocking = TRUE;
|
||||
@@ -5660,13 +5660,14 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options)
|
||||
close(fd_err[1]);
|
||||
if (channel != NULL)
|
||||
{
|
||||
channel_set_pipes(channel,
|
||||
use_file_for_in || use_null_for_in
|
||||
? INVALID_FD : fd_in[1] < 0 ? pty_master_fd : fd_in[1],
|
||||
use_file_for_out || use_null_for_out
|
||||
? INVALID_FD : fd_out[0] < 0 ? pty_master_fd : fd_out[0],
|
||||
use_out_for_err || use_file_for_err || use_null_for_err
|
||||
? INVALID_FD : fd_err[0] < 0 ? pty_master_fd : fd_err[0]);
|
||||
int in_fd = use_file_for_in || use_null_for_in
|
||||
? INVALID_FD : fd_in[1] < 0 ? pty_master_fd : fd_in[1];
|
||||
int out_fd = use_file_for_out || use_null_for_out
|
||||
? INVALID_FD : fd_out[0] < 0 ? pty_master_fd : fd_out[0];
|
||||
int err_fd = use_out_for_err || use_file_for_err || use_null_for_err
|
||||
? INVALID_FD : fd_err[0] < 0 ? pty_master_fd : fd_err[0];
|
||||
|
||||
channel_set_pipes(channel, in_fd, out_fd, err_fd);
|
||||
channel_set_job(channel, job, options);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -15,6 +15,7 @@ void enter_buffer(buf_T *buf);
|
||||
void do_autochdir(void);
|
||||
void no_write_message(void);
|
||||
void no_write_message_nobang(buf_T *buf);
|
||||
int curbuf_reusable(void);
|
||||
buf_T *buflist_new(char_u *ffname, char_u *sfname, linenr_T lnum, int flags);
|
||||
void free_buf_options(buf_T *buf, int free_p_ff);
|
||||
int buflist_getfile(int n, linenr_T lnum, int options, int forceit);
|
||||
|
||||
+370
-233
@@ -46,6 +46,7 @@ struct qfline_S
|
||||
* There is a stack of error lists.
|
||||
*/
|
||||
#define LISTCOUNT 10
|
||||
#define INVALID_QFIDX (-1)
|
||||
|
||||
/*
|
||||
* Quickfix/Location list definition
|
||||
@@ -5085,7 +5086,7 @@ qf_getprop_qfidx(qf_info_T *qi, dict_T *what)
|
||||
{
|
||||
qf_idx = di->di_tv.vval.v_number - 1;
|
||||
if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
|
||||
qf_idx = -1;
|
||||
qf_idx = INVALID_QFIDX;
|
||||
}
|
||||
}
|
||||
else if (di->di_tv.v_type == VAR_STRING
|
||||
@@ -5094,7 +5095,7 @@ qf_getprop_qfidx(qf_info_T *qi, dict_T *what)
|
||||
/* Get the last quickfix list number */
|
||||
qf_idx = qi->qf_listcount - 1;
|
||||
else
|
||||
qf_idx = -1;
|
||||
qf_idx = INVALID_QFIDX;
|
||||
}
|
||||
|
||||
if ((di = dict_find(what, (char_u *)"id", -1)) != NULL)
|
||||
@@ -5109,7 +5110,7 @@ qf_getprop_qfidx(qf_info_T *qi, dict_T *what)
|
||||
qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number);
|
||||
}
|
||||
else
|
||||
qf_idx = -1;
|
||||
qf_idx = INVALID_QFIDX;
|
||||
}
|
||||
|
||||
return qf_idx;
|
||||
@@ -5251,7 +5252,7 @@ qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
|
||||
qf_idx = qf_getprop_qfidx(qi, what);
|
||||
|
||||
/* List is not present or is empty */
|
||||
if (qi == NULL || qi->qf_listcount == 0 || qf_idx == -1)
|
||||
if (qi == NULL || qi->qf_listcount == 0 || qf_idx == INVALID_QFIDX)
|
||||
return qf_getprop_defaults(qi, flags, retdict);
|
||||
|
||||
if (flags & QF_GETLIST_TITLE)
|
||||
@@ -5405,19 +5406,19 @@ qf_add_entries(
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the quickfix list index from 'nr' or 'id'
|
||||
*/
|
||||
static int
|
||||
qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)
|
||||
qf_setprop_get_qfidx(
|
||||
qf_info_T *qi,
|
||||
dict_T *what,
|
||||
int action,
|
||||
int *newlist)
|
||||
{
|
||||
dictitem_T *di;
|
||||
int retval = FAIL;
|
||||
int qf_idx;
|
||||
int newlist = FALSE;
|
||||
char_u *errorformat = p_efm;
|
||||
int qf_idx = qi->qf_curlist; /* default is the current list */
|
||||
|
||||
if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
|
||||
newlist = TRUE;
|
||||
|
||||
qf_idx = qi->qf_curlist; /* default is the current list */
|
||||
if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL)
|
||||
{
|
||||
/* Use the specified quickfix/location list */
|
||||
@@ -5434,42 +5435,163 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)
|
||||
* non-available list and add the new list at the end of the
|
||||
* stack.
|
||||
*/
|
||||
newlist = TRUE;
|
||||
qf_idx = qi->qf_listcount - 1;
|
||||
*newlist = TRUE;
|
||||
qf_idx = qi->qf_listcount > 0 ? qi->qf_listcount - 1 : 0;
|
||||
}
|
||||
else if (qf_idx < 0 || qf_idx >= qi->qf_listcount)
|
||||
return FAIL;
|
||||
return INVALID_QFIDX;
|
||||
else if (action != ' ')
|
||||
newlist = FALSE; /* use the specified list */
|
||||
*newlist = FALSE; /* use the specified list */
|
||||
}
|
||||
else if (di->di_tv.v_type == VAR_STRING
|
||||
&& di->di_tv.vval.v_string != NULL
|
||||
&& STRCMP(di->di_tv.vval.v_string, "$") == 0)
|
||||
&& di->di_tv.vval.v_string != NULL
|
||||
&& STRCMP(di->di_tv.vval.v_string, "$") == 0)
|
||||
{
|
||||
if (qi->qf_listcount > 0)
|
||||
qf_idx = qi->qf_listcount - 1;
|
||||
else if (newlist)
|
||||
else if (*newlist)
|
||||
qf_idx = 0;
|
||||
else
|
||||
return FAIL;
|
||||
return INVALID_QFIDX;
|
||||
}
|
||||
else
|
||||
return FAIL;
|
||||
return INVALID_QFIDX;
|
||||
}
|
||||
|
||||
if (!newlist && (di = dict_find(what, (char_u *)"id", -1)) != NULL)
|
||||
if (!*newlist && (di = dict_find(what, (char_u *)"id", -1)) != NULL)
|
||||
{
|
||||
/* Use the quickfix/location list with the specified id */
|
||||
if (di->di_tv.v_type == VAR_NUMBER)
|
||||
{
|
||||
qf_idx = qf_id2nr(qi, di->di_tv.vval.v_number);
|
||||
if (qf_idx == -1)
|
||||
return FAIL; /* List not found */
|
||||
}
|
||||
else
|
||||
return FAIL;
|
||||
if (di->di_tv.v_type != VAR_NUMBER)
|
||||
return INVALID_QFIDX;
|
||||
|
||||
return qf_id2nr(qi, di->di_tv.vval.v_number);
|
||||
}
|
||||
|
||||
return qf_idx;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the quickfix list title.
|
||||
*/
|
||||
static int
|
||||
qf_setprop_title(qf_info_T *qi, int qf_idx, dict_T *what, dictitem_T *di)
|
||||
{
|
||||
if (di->di_tv.v_type != VAR_STRING)
|
||||
return FAIL;
|
||||
|
||||
vim_free(qi->qf_lists[qf_idx].qf_title);
|
||||
qi->qf_lists[qf_idx].qf_title =
|
||||
get_dict_string(what, (char_u *)"title", TRUE);
|
||||
if (qf_idx == qi->qf_curlist)
|
||||
qf_update_win_titlevar(qi);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set quickfix list items/entries.
|
||||
*/
|
||||
static int
|
||||
qf_setprop_items(qf_info_T *qi, int qf_idx, dictitem_T *di, int action)
|
||||
{
|
||||
int retval = FAIL;
|
||||
char_u *title_save;
|
||||
|
||||
if (di->di_tv.v_type != VAR_LIST)
|
||||
return FAIL;
|
||||
|
||||
title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title);
|
||||
retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list,
|
||||
title_save, action == ' ' ? 'a' : action);
|
||||
if (action == 'r')
|
||||
{
|
||||
/*
|
||||
* When replacing the quickfix list entries using
|
||||
* qf_add_entries(), the title is set with a ':' prefix.
|
||||
* Restore the title with the saved title.
|
||||
*/
|
||||
vim_free(qi->qf_lists[qf_idx].qf_title);
|
||||
qi->qf_lists[qf_idx].qf_title = vim_strsave(title_save);
|
||||
}
|
||||
vim_free(title_save);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set quickfix list items/entries from a list of lines.
|
||||
*/
|
||||
static int
|
||||
qf_setprop_items_from_lines(
|
||||
qf_info_T *qi,
|
||||
int qf_idx,
|
||||
dict_T *what,
|
||||
dictitem_T *di,
|
||||
int action)
|
||||
{
|
||||
char_u *errorformat = p_efm;
|
||||
dictitem_T *efm_di;
|
||||
int retval = FAIL;
|
||||
|
||||
/* Use the user supplied errorformat settings (if present) */
|
||||
if ((efm_di = dict_find(what, (char_u *)"efm", -1)) != NULL)
|
||||
{
|
||||
if (efm_di->di_tv.v_type != VAR_STRING ||
|
||||
efm_di->di_tv.vval.v_string == NULL)
|
||||
return FAIL;
|
||||
errorformat = efm_di->di_tv.vval.v_string;
|
||||
}
|
||||
|
||||
/* Only a List value is supported */
|
||||
if (di->di_tv.v_type != VAR_LIST || di->di_tv.vval.v_list == NULL)
|
||||
return FAIL;
|
||||
|
||||
if (action == 'r')
|
||||
qf_free_items(qi, qf_idx);
|
||||
if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, errorformat,
|
||||
FALSE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0)
|
||||
retval = OK;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set quickfix list context.
|
||||
*/
|
||||
static int
|
||||
qf_setprop_context(qf_info_T *qi, int qf_idx, dictitem_T *di)
|
||||
{
|
||||
typval_T *ctx;
|
||||
|
||||
free_tv(qi->qf_lists[qf_idx].qf_ctx);
|
||||
ctx = alloc_tv();
|
||||
if (ctx != NULL)
|
||||
copy_tv(&di->di_tv, ctx);
|
||||
qi->qf_lists[qf_idx].qf_ctx = ctx;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set quickfix/location list properties (title, items, context).
|
||||
* Also used to add items from parsing a list of lines.
|
||||
* Used by the setqflist() and setloclist() VimL functions.
|
||||
*/
|
||||
static int
|
||||
qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)
|
||||
{
|
||||
dictitem_T *di;
|
||||
int retval = FAIL;
|
||||
int qf_idx;
|
||||
int newlist = FALSE;
|
||||
|
||||
if (action == ' ' || qi->qf_curlist == qi->qf_listcount)
|
||||
newlist = TRUE;
|
||||
|
||||
qf_idx = qf_setprop_get_qfidx(qi, what, action, &newlist);
|
||||
if (qf_idx == INVALID_QFIDX) /* List not found */
|
||||
return FAIL;
|
||||
|
||||
if (newlist)
|
||||
{
|
||||
qi->qf_curlist = qf_idx;
|
||||
@@ -5478,73 +5600,13 @@ qf_set_properties(qf_info_T *qi, dict_T *what, int action, char_u *title)
|
||||
}
|
||||
|
||||
if ((di = dict_find(what, (char_u *)"title", -1)) != NULL)
|
||||
{
|
||||
if (di->di_tv.v_type == VAR_STRING)
|
||||
{
|
||||
vim_free(qi->qf_lists[qf_idx].qf_title);
|
||||
qi->qf_lists[qf_idx].qf_title =
|
||||
get_dict_string(what, (char_u *)"title", TRUE);
|
||||
if (qf_idx == qi->qf_curlist)
|
||||
qf_update_win_titlevar(qi);
|
||||
retval = OK;
|
||||
}
|
||||
}
|
||||
|
||||
retval = qf_setprop_title(qi, qf_idx, what, di);
|
||||
if ((di = dict_find(what, (char_u *)"items", -1)) != NULL)
|
||||
{
|
||||
if (di->di_tv.v_type == VAR_LIST)
|
||||
{
|
||||
char_u *title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title);
|
||||
|
||||
retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list,
|
||||
title_save, action == ' ' ? 'a' : action);
|
||||
if (action == 'r')
|
||||
{
|
||||
/*
|
||||
* When replacing the quickfix list entries using
|
||||
* qf_add_entries(), the title is set with a ':' prefix.
|
||||
* Restore the title with the saved title.
|
||||
*/
|
||||
vim_free(qi->qf_lists[qf_idx].qf_title);
|
||||
qi->qf_lists[qf_idx].qf_title = vim_strsave(title_save);
|
||||
}
|
||||
vim_free(title_save);
|
||||
}
|
||||
}
|
||||
|
||||
if ((di = dict_find(what, (char_u *)"efm", -1)) != NULL)
|
||||
{
|
||||
if (di->di_tv.v_type != VAR_STRING || di->di_tv.vval.v_string == NULL)
|
||||
return FAIL;
|
||||
errorformat = di->di_tv.vval.v_string;
|
||||
}
|
||||
|
||||
retval = qf_setprop_items(qi, qf_idx, di, action);
|
||||
if ((di = dict_find(what, (char_u *)"lines", -1)) != NULL)
|
||||
{
|
||||
/* Only a List value is supported */
|
||||
if (di->di_tv.v_type == VAR_LIST && di->di_tv.vval.v_list != NULL)
|
||||
{
|
||||
if (action == 'r')
|
||||
qf_free_items(qi, qf_idx);
|
||||
if (qf_init_ext(qi, qf_idx, NULL, NULL, &di->di_tv, errorformat,
|
||||
FALSE, (linenr_T)0, (linenr_T)0, NULL, NULL) > 0)
|
||||
retval = OK;
|
||||
}
|
||||
else
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
retval = qf_setprop_items_from_lines(qi, qf_idx, what, di, action);
|
||||
if ((di = dict_find(what, (char_u *)"context", -1)) != NULL)
|
||||
{
|
||||
typval_T *ctx;
|
||||
|
||||
free_tv(qi->qf_lists[qf_idx].qf_ctx);
|
||||
ctx = alloc_tv();
|
||||
if (ctx != NULL)
|
||||
copy_tv(&di->di_tv, ctx);
|
||||
qi->qf_lists[qf_idx].qf_ctx = ctx;
|
||||
retval = OK;
|
||||
}
|
||||
retval = qf_setprop_context(qi, qf_idx, di);
|
||||
|
||||
if (retval == OK)
|
||||
qf_list_changed(qi, qf_idx);
|
||||
@@ -5879,6 +5941,216 @@ ex_cexpr(exarg_T *eap)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Get the location list for ":lhelpgrep"
|
||||
*/
|
||||
static qf_info_T *
|
||||
hgr_get_ll(int *new_ll)
|
||||
{
|
||||
win_T *wp;
|
||||
qf_info_T *qi;
|
||||
|
||||
/* If the current window is a help window, then use it */
|
||||
if (bt_help(curwin->w_buffer))
|
||||
wp = curwin;
|
||||
else
|
||||
/* Find an existing help window */
|
||||
FOR_ALL_WINDOWS(wp)
|
||||
if (bt_help(wp->w_buffer))
|
||||
break;
|
||||
|
||||
if (wp == NULL) /* Help window not found */
|
||||
qi = NULL;
|
||||
else
|
||||
qi = wp->w_llist;
|
||||
|
||||
if (qi == NULL)
|
||||
{
|
||||
/* Allocate a new location list for help text matches */
|
||||
if ((qi = ll_new_list()) == NULL)
|
||||
return NULL;
|
||||
*new_ll = TRUE;
|
||||
}
|
||||
|
||||
return qi;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for a pattern in a help file.
|
||||
*/
|
||||
static void
|
||||
hgr_search_file(
|
||||
qf_info_T *qi,
|
||||
char_u *fname,
|
||||
#ifdef FEAT_MBYTE
|
||||
vimconv_T *p_vc,
|
||||
#endif
|
||||
regmatch_T *p_regmatch)
|
||||
{
|
||||
FILE *fd;
|
||||
long lnum;
|
||||
|
||||
fd = mch_fopen((char *)fname, "r");
|
||||
if (fd == NULL)
|
||||
return;
|
||||
|
||||
lnum = 1;
|
||||
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
|
||||
{
|
||||
char_u *line = IObuff;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Convert a line if 'encoding' is not utf-8 and
|
||||
* the line contains a non-ASCII character. */
|
||||
if (p_vc->vc_type != CONV_NONE
|
||||
&& has_non_ascii(IObuff))
|
||||
{
|
||||
line = string_convert(p_vc, IObuff, NULL);
|
||||
if (line == NULL)
|
||||
line = IObuff;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (vim_regexec(p_regmatch, line, (colnr_T)0))
|
||||
{
|
||||
int l = (int)STRLEN(line);
|
||||
|
||||
/* remove trailing CR, LF, spaces, etc. */
|
||||
while (l > 0 && line[l - 1] <= ' ')
|
||||
line[--l] = NUL;
|
||||
|
||||
if (qf_add_entry(qi,
|
||||
qi->qf_curlist,
|
||||
NULL, /* dir */
|
||||
fname,
|
||||
0,
|
||||
line,
|
||||
lnum,
|
||||
(int)(p_regmatch->startp[0] - line)
|
||||
+ 1, /* col */
|
||||
FALSE, /* vis_col */
|
||||
NULL, /* search pattern */
|
||||
0, /* nr */
|
||||
1, /* type */
|
||||
TRUE /* valid */
|
||||
) == FAIL)
|
||||
{
|
||||
got_int = TRUE;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (line != IObuff)
|
||||
vim_free(line);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
if (line != IObuff)
|
||||
vim_free(line);
|
||||
#endif
|
||||
++lnum;
|
||||
line_breakcheck();
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for a pattern in all the help files in the doc directory under
|
||||
* the given directory.
|
||||
*/
|
||||
static void
|
||||
hgr_search_files_in_dir(
|
||||
qf_info_T *qi,
|
||||
char_u *dirname,
|
||||
regmatch_T *p_regmatch
|
||||
#ifdef FEAT_MBYTE
|
||||
, vimconv_T *p_vc
|
||||
#endif
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
, char_u *lang
|
||||
#endif
|
||||
)
|
||||
{
|
||||
int fcount;
|
||||
char_u **fnames;
|
||||
int fi;
|
||||
|
||||
/* Find all "*.txt" and "*.??x" files in the "doc" directory. */
|
||||
add_pathsep(dirname);
|
||||
STRCAT(dirname, "doc/*.\\(txt\\|??x\\)");
|
||||
if (gen_expand_wildcards(1, &dirname, &fcount,
|
||||
&fnames, EW_FILE|EW_SILENT) == OK
|
||||
&& fcount > 0)
|
||||
{
|
||||
for (fi = 0; fi < fcount && !got_int; ++fi)
|
||||
{
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
/* Skip files for a different language. */
|
||||
if (lang != NULL
|
||||
&& STRNICMP(lang, fnames[fi]
|
||||
+ STRLEN(fnames[fi]) - 3, 2) != 0
|
||||
&& !(STRNICMP(lang, "en", 2) == 0
|
||||
&& STRNICMP("txt", fnames[fi]
|
||||
+ STRLEN(fnames[fi]) - 3, 3) == 0))
|
||||
continue;
|
||||
#endif
|
||||
|
||||
hgr_search_file(qi, fnames[fi],
|
||||
#ifdef FEAT_MBYTE
|
||||
p_vc,
|
||||
#endif
|
||||
p_regmatch);
|
||||
}
|
||||
FreeWild(fcount, fnames);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Search for a pattern in all the help files in the 'runtimepath'.
|
||||
*/
|
||||
static void
|
||||
hgr_search_in_rtp(qf_info_T *qi, regmatch_T *p_regmatch, char_u *arg)
|
||||
{
|
||||
char_u *p;
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
char_u *lang;
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
vimconv_T vc;
|
||||
|
||||
/* Help files are in utf-8 or latin1, convert lines when 'encoding'
|
||||
* differs. */
|
||||
vc.vc_type = CONV_NONE;
|
||||
if (!enc_utf8)
|
||||
convert_setup(&vc, (char_u *)"utf-8", p_enc);
|
||||
#endif
|
||||
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
/* Check for a specified language */
|
||||
lang = check_help_lang(arg);
|
||||
#endif
|
||||
|
||||
/* Go through all directories in 'runtimepath' */
|
||||
p = p_rtp;
|
||||
while (*p != NUL && !got_int)
|
||||
{
|
||||
copy_option_part(&p, NameBuff, MAXPATHL, ",");
|
||||
|
||||
hgr_search_files_in_dir(qi, NameBuff, p_regmatch
|
||||
#ifdef FEAT_MBYTE
|
||||
, &vc
|
||||
#endif
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
, lang
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef FEAT_MBYTE
|
||||
if (vc.vc_type != CONV_NONE)
|
||||
convert_setup(&vc, NULL, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* ":helpgrep {pattern}"
|
||||
*/
|
||||
@@ -5887,25 +6159,10 @@ ex_helpgrep(exarg_T *eap)
|
||||
{
|
||||
regmatch_T regmatch;
|
||||
char_u *save_cpo;
|
||||
char_u *p;
|
||||
int fcount;
|
||||
char_u **fnames;
|
||||
FILE *fd;
|
||||
int fi;
|
||||
long lnum;
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
char_u *lang;
|
||||
#endif
|
||||
qf_info_T *qi = &ql_info;
|
||||
int new_qi = FALSE;
|
||||
win_T *wp;
|
||||
char_u *au_name = NULL;
|
||||
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
/* Check for a specified language */
|
||||
lang = check_help_lang(eap->arg);
|
||||
#endif
|
||||
|
||||
switch (eap->cmdidx)
|
||||
{
|
||||
case CMD_helpgrep: au_name = (char_u *)"helpgrep"; break;
|
||||
@@ -5927,141 +6184,21 @@ ex_helpgrep(exarg_T *eap)
|
||||
|
||||
if (eap->cmdidx == CMD_lhelpgrep)
|
||||
{
|
||||
/* If the current window is a help window, then use it */
|
||||
if (bt_help(curwin->w_buffer))
|
||||
wp = curwin;
|
||||
else
|
||||
/* Find an existing help window */
|
||||
FOR_ALL_WINDOWS(wp)
|
||||
if (bt_help(wp->w_buffer))
|
||||
break;
|
||||
|
||||
if (wp == NULL) /* Help window not found */
|
||||
qi = NULL;
|
||||
else
|
||||
qi = wp->w_llist;
|
||||
|
||||
qi = hgr_get_ll(&new_qi);
|
||||
if (qi == NULL)
|
||||
{
|
||||
/* Allocate a new location list for help text matches */
|
||||
if ((qi = ll_new_list()) == NULL)
|
||||
return;
|
||||
new_qi = TRUE;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING);
|
||||
regmatch.rm_ic = FALSE;
|
||||
if (regmatch.regprog != NULL)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
vimconv_T vc;
|
||||
|
||||
/* Help files are in utf-8 or latin1, convert lines when 'encoding'
|
||||
* differs. */
|
||||
vc.vc_type = CONV_NONE;
|
||||
if (!enc_utf8)
|
||||
convert_setup(&vc, (char_u *)"utf-8", p_enc);
|
||||
#endif
|
||||
|
||||
/* create a new quickfix list */
|
||||
qf_new_list(qi, *eap->cmdlinep);
|
||||
|
||||
/* Go through all directories in 'runtimepath' */
|
||||
p = p_rtp;
|
||||
while (*p != NUL && !got_int)
|
||||
{
|
||||
copy_option_part(&p, NameBuff, MAXPATHL, ",");
|
||||
|
||||
/* Find all "*.txt" and "*.??x" files in the "doc" directory. */
|
||||
add_pathsep(NameBuff);
|
||||
STRCAT(NameBuff, "doc/*.\\(txt\\|??x\\)");
|
||||
if (gen_expand_wildcards(1, &NameBuff, &fcount,
|
||||
&fnames, EW_FILE|EW_SILENT) == OK
|
||||
&& fcount > 0)
|
||||
{
|
||||
for (fi = 0; fi < fcount && !got_int; ++fi)
|
||||
{
|
||||
#ifdef FEAT_MULTI_LANG
|
||||
/* Skip files for a different language. */
|
||||
if (lang != NULL
|
||||
&& STRNICMP(lang, fnames[fi]
|
||||
+ STRLEN(fnames[fi]) - 3, 2) != 0
|
||||
&& !(STRNICMP(lang, "en", 2) == 0
|
||||
&& STRNICMP("txt", fnames[fi]
|
||||
+ STRLEN(fnames[fi]) - 3, 3) == 0))
|
||||
continue;
|
||||
#endif
|
||||
fd = mch_fopen((char *)fnames[fi], "r");
|
||||
if (fd != NULL)
|
||||
{
|
||||
lnum = 1;
|
||||
while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
|
||||
{
|
||||
char_u *line = IObuff;
|
||||
#ifdef FEAT_MBYTE
|
||||
/* Convert a line if 'encoding' is not utf-8 and
|
||||
* the line contains a non-ASCII character. */
|
||||
if (vc.vc_type != CONV_NONE
|
||||
&& has_non_ascii(IObuff))
|
||||
{
|
||||
line = string_convert(&vc, IObuff, NULL);
|
||||
if (line == NULL)
|
||||
line = IObuff;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (vim_regexec(®match, line, (colnr_T)0))
|
||||
{
|
||||
int l = (int)STRLEN(line);
|
||||
|
||||
/* remove trailing CR, LF, spaces, etc. */
|
||||
while (l > 0 && line[l - 1] <= ' ')
|
||||
line[--l] = NUL;
|
||||
|
||||
if (qf_add_entry(qi,
|
||||
qi->qf_curlist,
|
||||
NULL, /* dir */
|
||||
fnames[fi],
|
||||
0,
|
||||
line,
|
||||
lnum,
|
||||
(int)(regmatch.startp[0] - line)
|
||||
+ 1, /* col */
|
||||
FALSE, /* vis_col */
|
||||
NULL, /* search pattern */
|
||||
0, /* nr */
|
||||
1, /* type */
|
||||
TRUE /* valid */
|
||||
) == FAIL)
|
||||
{
|
||||
got_int = TRUE;
|
||||
#ifdef FEAT_MBYTE
|
||||
if (line != IObuff)
|
||||
vim_free(line);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
if (line != IObuff)
|
||||
vim_free(line);
|
||||
#endif
|
||||
++lnum;
|
||||
line_breakcheck();
|
||||
}
|
||||
fclose(fd);
|
||||
}
|
||||
}
|
||||
FreeWild(fcount, fnames);
|
||||
}
|
||||
}
|
||||
hgr_search_in_rtp(qi, ®match, eap->arg);
|
||||
|
||||
vim_regfree(regmatch.regprog);
|
||||
#ifdef FEAT_MBYTE
|
||||
if (vc.vc_type != CONV_NONE)
|
||||
convert_setup(&vc, NULL, NULL);
|
||||
#endif
|
||||
|
||||
qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
|
||||
qi->qf_lists[qi->qf_curlist].qf_ptr =
|
||||
|
||||
+1
-1
@@ -4080,7 +4080,7 @@ again:
|
||||
goto again;
|
||||
}
|
||||
|
||||
if (do_include || r < 1)
|
||||
if (do_include)
|
||||
{
|
||||
/* Include up to the '>'. */
|
||||
while (*ml_get_cursor() != '>')
|
||||
|
||||
+46
-58
@@ -108,10 +108,10 @@ char *tgetstr(char *, char **);
|
||||
/* Change this to "if 1" to debug what happens with termresponse. */
|
||||
# if 0
|
||||
# define DEBUG_TERMRESPONSE
|
||||
static void log_tr(char *msg);
|
||||
# define LOG_TR(msg) log_tr(msg)
|
||||
static void log_tr(const char *fmt, ...);
|
||||
# define LOG_TR(msg) log_tr msg
|
||||
# else
|
||||
# define LOG_TR(msg)
|
||||
# define LOG_TR(msg) do { /**/ } while (0)
|
||||
# endif
|
||||
|
||||
# define STATUS_GET 1 /* send request when switching to RAW mode */
|
||||
@@ -1522,15 +1522,13 @@ may_adjust_color_count(int val)
|
||||
init_highlight(TRUE, FALSE);
|
||||
# ifdef DEBUG_TERMRESPONSE
|
||||
{
|
||||
char buf[100];
|
||||
int r = redraw_asap(CLEAR);
|
||||
int r = redraw_asap(CLEAR);
|
||||
|
||||
sprintf(buf, "Received t_Co, redraw_asap(): %d", r);
|
||||
log_tr(buf);
|
||||
log_tr("Received t_Co, redraw_asap(): %d", r);
|
||||
}
|
||||
# else
|
||||
#else
|
||||
redraw_asap(CLEAR);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1954,7 +1952,7 @@ set_termname(char_u *term)
|
||||
full_screen = TRUE; /* we can use termcap codes from now on */
|
||||
set_term_defaults(); /* use current values as defaults */
|
||||
#ifdef FEAT_TERMRESPONSE
|
||||
LOG_TR("setting crv_status to STATUS_GET");
|
||||
LOG_TR(("setting crv_status to STATUS_GET"));
|
||||
crv_status = STATUS_GET; /* Get terminal version later */
|
||||
#endif
|
||||
|
||||
@@ -2367,7 +2365,7 @@ term_7to8bit(char_u *p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef FEAT_GUI
|
||||
#if defined(FEAT_GUI) || defined(PROTO)
|
||||
int
|
||||
term_is_gui(char_u *name)
|
||||
{
|
||||
@@ -2829,7 +2827,7 @@ term_get_winpos(int *x, int *y, varnumber_T timeout)
|
||||
|
||||
winpos_x = prev_winpos_x;
|
||||
winpos_y = prev_winpos_y;
|
||||
if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_y >= 0)
|
||||
if (timeout < 10 && prev_winpos_y >= 0 && prev_winpos_x >= 0)
|
||||
{
|
||||
/* Polling: return previous values if we have them. */
|
||||
*x = winpos_x;
|
||||
@@ -3516,7 +3514,7 @@ may_req_termresponse(void)
|
||||
&& starting == 0
|
||||
&& *T_CRV != NUL)
|
||||
{
|
||||
LOG_TR("Sending CRV request");
|
||||
LOG_TR(("Sending CRV request"));
|
||||
out_str(T_CRV);
|
||||
crv_status = STATUS_SENT;
|
||||
/* check for the characters now, otherwise they might be eaten by
|
||||
@@ -3547,7 +3545,7 @@ may_req_ambiguous_char_width(void)
|
||||
{
|
||||
char_u buf[16];
|
||||
|
||||
LOG_TR("Sending U7 request");
|
||||
LOG_TR(("Sending U7 request"));
|
||||
/* Do this in the second row. In the first row the returned sequence
|
||||
* may be CSI 1;2R, which is the same as <S-F3>. */
|
||||
term_windgoto(1, 0);
|
||||
@@ -3589,7 +3587,7 @@ may_req_bg_color(void)
|
||||
/* Only request foreground if t_RF is set. */
|
||||
if (rfg_status == STATUS_GET && *T_RFG != NUL)
|
||||
{
|
||||
LOG_TR("Sending FG request");
|
||||
LOG_TR(("Sending FG request"));
|
||||
out_str(T_RFG);
|
||||
rfg_status = STATUS_SENT;
|
||||
didit = TRUE;
|
||||
@@ -3599,7 +3597,7 @@ may_req_bg_color(void)
|
||||
/* Only request background if t_RB is set. */
|
||||
if (rbg_status == STATUS_GET && *T_RBG != NUL)
|
||||
{
|
||||
LOG_TR("Sending BG request");
|
||||
LOG_TR(("Sending BG request"));
|
||||
out_str(T_RBG);
|
||||
rbg_status = STATUS_SENT;
|
||||
didit = TRUE;
|
||||
@@ -3617,11 +3615,12 @@ may_req_bg_color(void)
|
||||
|
||||
# ifdef DEBUG_TERMRESPONSE
|
||||
static void
|
||||
log_tr(char *msg)
|
||||
log_tr(const char *fmt, ...)
|
||||
{
|
||||
static FILE *fd_tr = NULL;
|
||||
static proftime_T start;
|
||||
proftime_T now;
|
||||
va_list ap;
|
||||
|
||||
if (fd_tr == NULL)
|
||||
{
|
||||
@@ -3630,11 +3629,14 @@ log_tr(char *msg)
|
||||
}
|
||||
now = start;
|
||||
profile_end(&now);
|
||||
fprintf(fd_tr, "%s: %s %s\n",
|
||||
profile_msg(&now),
|
||||
must_redraw == NOT_VALID ? "NV"
|
||||
: must_redraw == CLEAR ? "CL" : " ",
|
||||
msg);
|
||||
fprintf(fd_tr, "%s: %s ", profile_msg(&now),
|
||||
must_redraw == NOT_VALID ? "NV"
|
||||
: must_redraw == CLEAR ? "CL" : " ");
|
||||
va_start(ap, fmt);
|
||||
vfprintf(fd_tr, fmt, ap);
|
||||
va_end(ap);
|
||||
fputc('\n', fd_tr);
|
||||
fflush(fd_tr);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
@@ -4185,7 +4187,7 @@ switch_to_8bit(void)
|
||||
need_gather = TRUE; /* need to fill termleader[] */
|
||||
}
|
||||
detected_8bit = TRUE;
|
||||
LOG_TR("Switching to 8 bit");
|
||||
LOG_TR(("Switching to 8 bit"));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4518,7 +4520,7 @@ check_termcode(
|
||||
}
|
||||
if (i == len)
|
||||
{
|
||||
LOG_TR("Not enough characters for CRV");
|
||||
LOG_TR(("Not enough characters for CRV"));
|
||||
return -1;
|
||||
}
|
||||
if (extra > 0)
|
||||
@@ -4535,7 +4537,7 @@ check_termcode(
|
||||
{
|
||||
char *aw = NULL;
|
||||
|
||||
LOG_TR("Received U7 status");
|
||||
LOG_TR(("Received U7 status: %s", tp));
|
||||
u7_status = STATUS_GOT;
|
||||
did_cursorhold = TRUE;
|
||||
if (col == 2)
|
||||
@@ -4551,13 +4553,9 @@ check_termcode(
|
||||
(char_u *)aw, 0);
|
||||
# ifdef DEBUG_TERMRESPONSE
|
||||
{
|
||||
char buf[100];
|
||||
int r = redraw_asap(CLEAR);
|
||||
int r = redraw_asap(CLEAR);
|
||||
|
||||
sprintf(buf,
|
||||
"set 'ambiwidth', redraw_asap(): %d",
|
||||
r);
|
||||
log_tr(buf);
|
||||
log_tr("set 'ambiwidth', redraw_asap(): %d", r);
|
||||
}
|
||||
# else
|
||||
redraw_asap(CLEAR);
|
||||
@@ -4578,7 +4576,7 @@ check_termcode(
|
||||
{
|
||||
int version = col;
|
||||
|
||||
LOG_TR("Received CRV response");
|
||||
LOG_TR(("Received CRV response: %s", tp));
|
||||
crv_status = STATUS_GOT;
|
||||
did_cursorhold = TRUE;
|
||||
|
||||
@@ -4604,7 +4602,7 @@ check_termcode(
|
||||
/* if xterm version >= 141 try to get termcap codes */
|
||||
if (version >= 141)
|
||||
{
|
||||
LOG_TR("Enable checking for XT codes");
|
||||
LOG_TR(("Enable checking for XT codes"));
|
||||
check_for_codes = TRUE;
|
||||
need_gather = TRUE;
|
||||
req_codes_from_term();
|
||||
@@ -4694,7 +4692,7 @@ check_termcode(
|
||||
&& *T_CSH != NUL
|
||||
&& *T_CRS != NUL)
|
||||
{
|
||||
LOG_TR("Sending cursor style request");
|
||||
LOG_TR(("Sending cursor style request"));
|
||||
out_str(T_CRS);
|
||||
rcs_status = STATUS_SENT;
|
||||
need_flush = TRUE;
|
||||
@@ -4707,7 +4705,7 @@ check_termcode(
|
||||
&& !is_not_xterm
|
||||
&& *T_CRC != NUL)
|
||||
{
|
||||
LOG_TR("Sending cursor blink mode request");
|
||||
LOG_TR(("Sending cursor blink mode request"));
|
||||
out_str(T_CRC);
|
||||
rbm_status = STATUS_SENT;
|
||||
need_flush = TRUE;
|
||||
@@ -4743,7 +4741,7 @@ check_termcode(
|
||||
{
|
||||
initial_cursor_blink = (tp[j + 4] == '1');
|
||||
rbm_status = STATUS_GOT;
|
||||
LOG_TR("Received cursor blinking mode response");
|
||||
LOG_TR(("Received cursor blinking mode response: %s", tp));
|
||||
key_name[0] = (int)KS_EXTRA;
|
||||
key_name[1] = (int)KE_IGNORE;
|
||||
slen = i + 1;
|
||||
@@ -4785,7 +4783,7 @@ check_termcode(
|
||||
}
|
||||
if (i == len)
|
||||
{
|
||||
LOG_TR("not enough characters for winpos");
|
||||
LOG_TR(("not enough characters for winpos"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -4831,7 +4829,7 @@ check_termcode(
|
||||
char *newval = (3 * '6' < tp[j+7] + tp[j+12]
|
||||
+ tp[j+17]) ? "light" : "dark";
|
||||
|
||||
LOG_TR("Received RBG response");
|
||||
LOG_TR(("Received RBG response: %s", tp));
|
||||
rbg_status = STATUS_GOT;
|
||||
#ifdef FEAT_TERMINAL
|
||||
bg_r = rval;
|
||||
@@ -4851,7 +4849,7 @@ check_termcode(
|
||||
#ifdef FEAT_TERMINAL
|
||||
else
|
||||
{
|
||||
LOG_TR("Received RFG response");
|
||||
LOG_TR(("Received RFG response: %s", tp));
|
||||
rfg_status = STATUS_GOT;
|
||||
fg_r = rval;
|
||||
fg_g = gval;
|
||||
@@ -4872,7 +4870,7 @@ check_termcode(
|
||||
}
|
||||
if (i == len)
|
||||
{
|
||||
LOG_TR("not enough characters for RB");
|
||||
LOG_TR(("not enough characters for RB"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -4946,7 +4944,7 @@ check_termcode(
|
||||
initial_cursor_shape_blink =
|
||||
(number & 1) ? FALSE : TRUE;
|
||||
rcs_status = STATUS_GOT;
|
||||
LOG_TR("Received cursor shape response");
|
||||
LOG_TR(("Received cursor shape response: %s", tp));
|
||||
|
||||
key_name[0] = (int)KS_EXTRA;
|
||||
key_name[1] = (int)KE_IGNORE;
|
||||
@@ -4963,7 +4961,7 @@ check_termcode(
|
||||
{
|
||||
/* These codes arrive many together, each code can be
|
||||
* truncated at any point. */
|
||||
LOG_TR("not enough characters for XT");
|
||||
LOG_TR(("not enough characters for XT"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -5916,7 +5914,7 @@ check_termcode(
|
||||
}
|
||||
|
||||
#ifdef FEAT_TERMRESPONSE
|
||||
LOG_TR("normal character");
|
||||
LOG_TR(("normal character"));
|
||||
#endif
|
||||
|
||||
return 0; /* no match found */
|
||||
@@ -6399,15 +6397,10 @@ req_more_codes_from_term(void)
|
||||
* many, there can be a buffer overflow somewhere. */
|
||||
while (xt_index_out < xt_index_in + 10 && key_names[xt_index_out] != NULL)
|
||||
{
|
||||
# ifdef DEBUG_TERMRESPONSE
|
||||
char dbuf[100];
|
||||
char *key_name = key_names[xt_index_out];
|
||||
|
||||
sprintf(dbuf, "Requesting XT %d: %s",
|
||||
xt_index_out, key_names[xt_index_out]);
|
||||
log_tr(dbuf);
|
||||
# endif
|
||||
sprintf(buf, "\033P+q%02x%02x\033\\",
|
||||
key_names[xt_index_out][0], key_names[xt_index_out][1]);
|
||||
LOG_TR(("Requesting XT %d: %s", xt_index_out, key_name));
|
||||
sprintf(buf, "\033P+q%02x%02x\033\\", key_name[0], key_name[1]);
|
||||
out_str_nf((char_u *)buf);
|
||||
++xt_index_out;
|
||||
}
|
||||
@@ -6450,14 +6443,9 @@ got_code_from_term(char_u *code, int len)
|
||||
break;
|
||||
}
|
||||
}
|
||||
# ifdef DEBUG_TERMRESPONSE
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
sprintf(buf, "Received XT %d: %s", xt_index_in, (char *)name);
|
||||
log_tr(buf);
|
||||
}
|
||||
# endif
|
||||
LOG_TR(("Received XT %d: %s", xt_index_in, (char *)name));
|
||||
|
||||
if (key_names[i] != NULL)
|
||||
{
|
||||
for (i = 8; (c = hexhex2nr(code + i)) >= 0; i += 2)
|
||||
|
||||
@@ -308,6 +308,18 @@ func Test_argedit()
|
||||
%argd
|
||||
bwipe! C
|
||||
bwipe! D
|
||||
|
||||
" :argedit reuses the current buffer if it is empty
|
||||
%argd
|
||||
" make sure to use a new buffer number for x when it is loaded
|
||||
bw! x
|
||||
new
|
||||
let a = bufnr('')
|
||||
argedit x
|
||||
call assert_equal(a, bufnr(''))
|
||||
call assert_equal('x', bufname(''))
|
||||
%argd
|
||||
bw! x
|
||||
endfunc
|
||||
|
||||
" Test for the :argdelete command
|
||||
|
||||
@@ -1848,3 +1848,14 @@ func Test_zz_ch_log()
|
||||
call assert_match("%s%s", text[2])
|
||||
call delete('Xlog')
|
||||
endfunc
|
||||
|
||||
func Test_keep_pty_open()
|
||||
if !has('unix')
|
||||
return
|
||||
endif
|
||||
|
||||
let job = job_start(s:python . ' -c "import time;time.sleep(0.2)"', {'out_io': 'null', 'err_io': 'null', 'pty': 1})
|
||||
let elapsed = WaitFor({-> job_status(job) ==# 'dead'})
|
||||
call assert_inrange(200, 1000, elapsed)
|
||||
call job_stop(job)
|
||||
endfunc
|
||||
|
||||
@@ -173,7 +173,6 @@ func Test_command_count_4()
|
||||
only!
|
||||
|
||||
exe bufnr . 'buf'
|
||||
bnext
|
||||
let bufnr = bufnr('%')
|
||||
let buffers = []
|
||||
.,$-bufdo call add(buffers, bufnr('%'))
|
||||
|
||||
@@ -1795,6 +1795,9 @@ func Xproperty_tests(cchar)
|
||||
call assert_equal(0, s)
|
||||
let d = g:Xgetlist({"title":1})
|
||||
call assert_equal('Sample', d.title)
|
||||
" Try setting title to a non-string value
|
||||
call assert_equal(-1, g:Xsetlist([], 'a', {'title' : ['Test']}))
|
||||
call assert_equal('Sample', g:Xgetlist({"title":1}).title)
|
||||
|
||||
Xopen
|
||||
call assert_equal('Sample', w:quickfix_title)
|
||||
@@ -1943,6 +1946,9 @@ func Xproperty_tests(cchar)
|
||||
call g:Xsetlist([], 'a', {'items' : [{'filename':'F1', 'lnum':10}]})
|
||||
call assert_equal(10, g:Xgetlist({'items':1}).items[0].lnum)
|
||||
|
||||
" Try setting the items using a string
|
||||
call assert_equal(-1, g:Xsetlist([], ' ', {'items' : 'Test'}))
|
||||
|
||||
" Save and restore the quickfix stack
|
||||
call g:Xsetlist([], 'f')
|
||||
call assert_equal(0, g:Xgetlist({'nr':'$'}).nr)
|
||||
@@ -2296,6 +2302,12 @@ func XvimgrepTests(cchar)
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal('Editor:Emacs EmAcS', l[0].text)
|
||||
|
||||
" Test for unloading a buffer after vimgrep searched the buffer
|
||||
%bwipe
|
||||
Xvimgrep /Editor/j Xtestfile*
|
||||
call assert_equal(0, getbufinfo('Xtestfile1')[0].loaded)
|
||||
call assert_equal([], getbufinfo('Xtestfile2'))
|
||||
|
||||
call delete('Xtestfile1')
|
||||
call delete('Xtestfile2')
|
||||
endfunc
|
||||
|
||||
@@ -38,6 +38,24 @@ func Test_paste_end_of_line()
|
||||
exe "normal! 2G$lllA\<C-O>:normal! \"agP\r"
|
||||
call assert_equal('123456', getline(2))
|
||||
|
||||
bwipe!
|
||||
set virtualedit=
|
||||
endfunc
|
||||
|
||||
func Test_edit_CTRL_G()
|
||||
new
|
||||
set virtualedit=insert
|
||||
call setline(1, ['123', '1', '12'])
|
||||
exe "normal! ggA\<c-g>jx\<c-g>jx"
|
||||
call assert_equal(['123', '1 x', '12 x'], getline(1,'$'))
|
||||
|
||||
set virtualedit=all
|
||||
%d_
|
||||
call setline(1, ['1', '12'])
|
||||
exe "normal! ggllix\<c-g>jx"
|
||||
call assert_equal(['1 x', '12x'], getline(1,'$'))
|
||||
|
||||
|
||||
bwipe!
|
||||
set virtualedit=
|
||||
endfunc
|
||||
|
||||
@@ -1874,18 +1874,15 @@ fill_input_buf(int exit_on_error UNUSED)
|
||||
len = 0; /* to avoid gcc warning */
|
||||
for (try = 0; try < 100; ++try)
|
||||
{
|
||||
# ifdef VMS
|
||||
len = vms_read(
|
||||
# else
|
||||
len = read(read_cmd_fd,
|
||||
# endif
|
||||
(char *)inbuf + inbufcount, (size_t)((INBUFLEN - inbufcount)
|
||||
size_t readlen = (size_t)((INBUFLEN - inbufcount)
|
||||
# ifdef FEAT_MBYTE
|
||||
/ input_conv.vc_factor
|
||||
/ input_conv.vc_factor
|
||||
# endif
|
||||
));
|
||||
# if 0
|
||||
) /* avoid syntax highlight error */
|
||||
);
|
||||
# ifdef VMS
|
||||
len = vms_read((char *)inbuf + inbufcount, readlen);
|
||||
# else
|
||||
len = read(read_cmd_fd, (char *)inbuf + inbufcount, readlen);
|
||||
# endif
|
||||
|
||||
if (len > 0 || got_int)
|
||||
|
||||
@@ -776,6 +776,36 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
1765,
|
||||
/**/
|
||||
1764,
|
||||
/**/
|
||||
1763,
|
||||
/**/
|
||||
1762,
|
||||
/**/
|
||||
1761,
|
||||
/**/
|
||||
1760,
|
||||
/**/
|
||||
1759,
|
||||
/**/
|
||||
1758,
|
||||
/**/
|
||||
1757,
|
||||
/**/
|
||||
1756,
|
||||
/**/
|
||||
1755,
|
||||
/**/
|
||||
1754,
|
||||
/**/
|
||||
1753,
|
||||
/**/
|
||||
1752,
|
||||
/**/
|
||||
1751,
|
||||
/**/
|
||||
1750,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user