summaryrefslogtreecommitdiff
path: root/src/terminal.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-12-05 21:33:15 +0100
committerBram Moolenaar <Bram@vim.org>2019-12-05 21:33:15 +0100
commit0d6f5d9740dbad1b0207f3ab257de806169dd905 (patch)
tree3b4d840ac6f3972bfab2599cc52555ce55d66eaa /src/terminal.c
parent63d9e730f726341bf41ee4f4b829253cb9879110 (diff)
downloadvim-git-0d6f5d9740dbad1b0207f3ab257de806169dd905.tar.gz
patch 8.1.2395: using old C style commentsv8.1.2395
Problem: Using old C style comments. Solution: Use // comments where appropriate.
Diffstat (limited to 'src/terminal.c')
-rw-r--r--src/terminal.c605
1 files changed, 301 insertions, 304 deletions
diff --git a/src/terminal.c b/src/terminal.c
index dcb4c398d..da27a9c17 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -51,7 +51,7 @@
#include "libvterm/include/vterm.h"
-/* This is VTermScreenCell without the characters, thus much smaller. */
+// This is VTermScreenCell without the characters, thus much smaller.
typedef struct {
VTermScreenCellAttrs attrs;
char width;
@@ -83,7 +83,7 @@ typedef struct _DYN_STARTUPINFOEXW
} DYN_STARTUPINFOEXW, *PDYN_STARTUPINFOEXW;
#endif
-/* typedef term_T in structs.h */
+// typedef term_T in structs.h
struct terminal_S {
term_T *tl_next;
@@ -91,22 +91,22 @@ struct terminal_S {
job_T *tl_job;
buf_T *tl_buffer;
#if defined(FEAT_GUI)
- int tl_system; /* when non-zero used for :!cmd output */
- int tl_toprow; /* row with first line of system terminal */
+ int tl_system; // when non-zero used for :!cmd output
+ int tl_toprow; // row with first line of system terminal
#endif
- /* Set when setting the size of a vterm, reset after redrawing. */
+ // Set when setting the size of a vterm, reset after redrawing.
int tl_vterm_size_changed;
- int tl_normal_mode; /* TRUE: Terminal-Normal mode */
+ int tl_normal_mode; // TRUE: Terminal-Normal mode
int tl_channel_closed;
int tl_channel_recently_closed; // still need to handle tl_finish
int tl_finish;
#define TL_FINISH_UNSET NUL
-#define TL_FINISH_CLOSE 'c' /* ++close or :terminal without argument */
-#define TL_FINISH_NOCLOSE 'n' /* ++noclose */
-#define TL_FINISH_OPEN 'o' /* ++open */
+#define TL_FINISH_CLOSE 'c' // ++close or :terminal without argument
+#define TL_FINISH_NOCLOSE 'n' // ++noclose
+#define TL_FINISH_OPEN 'o' // ++open
char_u *tl_opencmd;
char_u *tl_eof_chars;
char_u *tl_api; // prefix for terminal API function
@@ -127,22 +127,22 @@ struct terminal_S {
#endif
char_u *tl_kill;
- /* last known vterm size */
+ // last known vterm size
int tl_rows;
int tl_cols;
- char_u *tl_title; /* NULL or allocated */
- char_u *tl_status_text; /* NULL or allocated */
+ char_u *tl_title; // NULL or allocated
+ char_u *tl_status_text; // NULL or allocated
- /* Range of screen rows to update. Zero based. */
- int tl_dirty_row_start; /* MAX_ROW if nothing dirty */
- int tl_dirty_row_end; /* row below last one to update */
- int tl_dirty_snapshot; /* text updated after making snapshot */
+ // Range of screen rows to update. Zero based.
+ int tl_dirty_row_start; // MAX_ROW if nothing dirty
+ int tl_dirty_row_end; // row below last one to update
+ int tl_dirty_snapshot; // text updated after making snapshot
#ifdef FEAT_TIMERS
int tl_timer_set;
proftime_T tl_timer_due;
#endif
- int tl_postponed_scroll; /* to be scrolled up */
+ int tl_postponed_scroll; // to be scrolled up
garray_T tl_scrollback;
int tl_scrollback_scrolled;
@@ -150,27 +150,27 @@ struct terminal_S {
cellattr_T tl_default_color;
- linenr_T tl_top_diff_rows; /* rows of top diff file or zero */
- linenr_T tl_bot_diff_rows; /* rows of bottom diff file */
+ linenr_T tl_top_diff_rows; // rows of top diff file or zero
+ linenr_T tl_bot_diff_rows; // rows of bottom diff file
VTermPos tl_cursor_pos;
int tl_cursor_visible;
int tl_cursor_blink;
- int tl_cursor_shape; /* 1: block, 2: underline, 3: bar */
- char_u *tl_cursor_color; /* NULL or allocated */
+ int tl_cursor_shape; // 1: block, 2: underline, 3: bar
+ char_u *tl_cursor_color; // NULL or allocated
int tl_using_altscreen;
};
-#define TMODE_ONCE 1 /* CTRL-\ CTRL-N used */
-#define TMODE_LOOP 2 /* CTRL-W N used */
+#define TMODE_ONCE 1 // CTRL-\ CTRL-N used
+#define TMODE_LOOP 2 // CTRL-W N used
/*
* List of all active terminals.
*/
static term_T *first_term = NULL;
-/* Terminal active in terminal_loop(). */
+// Terminal active in terminal_loop().
static term_T *in_terminal_loop = NULL;
#ifdef MSWIN
@@ -178,7 +178,7 @@ static BOOL has_winpty = FALSE;
static BOOL has_conpty = FALSE;
#endif
-#define MAX_ROW 999999 /* used for tl_dirty_row_end to update all rows */
+#define MAX_ROW 999999 // used for tl_dirty_row_end to update all rows
#define KEY_BUF_LEN 200
/*
@@ -194,16 +194,16 @@ static void update_system_term(term_T *term);
static void handle_postponed_scrollback(term_T *term);
-/* The character that we know (or assume) that the terminal expects for the
- * backspace key. */
+// The character that we know (or assume) that the terminal expects for the
+// backspace key.
static int term_backspace_char = BS;
-/* "Terminal" highlight group colors. */
+// "Terminal" highlight group colors.
static int term_default_cterm_fg = -1;
static int term_default_cterm_bg = -1;
-/* Store the last set and the desired cursor properties, so that we only update
- * them when needed. Doing it unnecessary may result in flicker. */
+// Store the last set and the desired cursor properties, so that we only update
+// them when needed. Doing it unnecessary may result in flicker.
static char_u *last_set_cursor_color = NULL;
static char_u *desired_cursor_color = NULL;
static int last_set_cursor_shape = -1;
@@ -212,9 +212,8 @@ static int last_set_cursor_blink = -1;
static int desired_cursor_blink = -1;
-/**************************************
- * 1. Generic code for all systems.
- */
+///////////////////////////////////////
+// 1. Generic code for all systems.
static int
cursor_color_equal(char_u *lhs_color, char_u *rhs_color)
@@ -259,7 +258,7 @@ parse_termwinsize(win_T *wp, int *rows, int *cols)
{
char_u *p = vim_strchr(wp->w_p_tws, 'x');
- /* Syntax of value was already checked when it's set. */
+ // Syntax of value was already checked when it's set.
if (p == NULL)
{
minsize = TRUE;
@@ -280,8 +279,8 @@ set_term_and_win_size(term_T *term)
#ifdef FEAT_GUI
if (term->tl_system)
{
- /* Use the whole screen for the system command. However, it will start
- * at the command line and scroll up as needed, using tl_toprow. */
+ // Use the whole screen for the system command. However, it will start
+ // at the command line and scroll up as needed, using tl_toprow.
term->tl_rows = Rows;
term->tl_cols = Columns;
return;
@@ -326,12 +325,12 @@ init_job_options(jobopt_T *opt)
setup_job_options(jobopt_T *opt, int rows, int cols)
{
#ifndef MSWIN
- /* Win32: Redirecting the job output won't work, thus always connect stdout
- * here. */
+ // Win32: Redirecting the job output won't work, thus always connect stdout
+ // here.
if (!(opt->jo_set & JO_OUT_IO))
#endif
{
- /* Connect stdout to the terminal. */
+ // Connect stdout to the terminal.
opt->jo_io[PART_OUT] = JIO_BUFFER;
opt->jo_io_buf[PART_OUT] = curbuf->b_fnum;
opt->jo_modifiable[PART_OUT] = 0;
@@ -339,12 +338,12 @@ setup_job_options(jobopt_T *opt, int rows, int cols)
}
#ifndef MSWIN
- /* Win32: Redirecting the job output won't work, thus always connect stderr
- * here. */
+ // Win32: Redirecting the job output won't work, thus always connect stderr
+ // here.
if (!(opt->jo_set & JO_ERR_IO))
#endif
{
- /* Connect stderr to the terminal. */
+ // Connect stderr to the terminal.
opt->jo_io[PART_ERR] = JIO_BUFFER;
opt->jo_io_buf[PART_ERR] = curbuf->b_fnum;
opt->jo_modifiable[PART_ERR] = 0;
@@ -384,8 +383,8 @@ term_close_buffer(buf_T *buf, buf_T *old_curbuf)
++curbuf->b_nwindows;
}
- /* Wiping out the buffer will also close the window and call
- * free_terminal(). */
+ // Wiping out the buffer will also close the window and call
+ // free_terminal().
do_buffer(DOBUF_WIPE, DOBUF_FIRST, FORWARD, buf->b_fnum, TRUE);
}
@@ -440,7 +439,7 @@ term_start(
vim_memset(&split_ea, 0, sizeof(split_ea));
if (opt->jo_curwin)
{
- /* Create a new buffer in the current window. */
+ // Create a new buffer in the current window.
if (!can_abandon(curbuf, flags & TERM_START_FORCEIT))
{
no_write_message();
@@ -460,8 +459,8 @@ term_start(
{
buf_T *buf;
- /* Create a new buffer without a window. Make it the current buffer for
- * a moment to be able to do the initialisations. */
+ // Create a new buffer without a window. Make it the current buffer for
+ // a moment to be able to do the initialisations.
buf = buflist_new((char_u *)"", NULL, (linenr_T)0,
BLN_NEW | BLN_LISTED);
if (buf == NULL || ml_open(buf) == FAIL)
@@ -477,7 +476,7 @@ term_start(
}
else
{
- /* Open a new window or tab. */
+ // Open a new window or tab.
split_ea.cmdidx = CMD_new;
split_ea.cmd = (char_u *)"new";
split_ea.arg = (char_u *)"";
@@ -497,7 +496,7 @@ term_start(
ex_splitview(&split_ea);
if (curwin == old_curwin)
{
- /* split failed */
+ // split failed
vim_free(term);
return NULL;
}
@@ -507,15 +506,15 @@ term_start(
if (!opt->jo_hidden)
{
- /* Only one size was taken care of with :new, do the other one. With
- * "curwin" both need to be done. */
+ // Only one size was taken care of with :new, do the other one. With
+ // "curwin" both need to be done.
if (opt->jo_term_rows > 0 && (opt->jo_curwin || vertical))
win_setheight(opt->jo_term_rows);
if (opt->jo_term_cols > 0 && (opt->jo_curwin || !vertical))
win_setwidth(opt->jo_term_cols);
}
- /* Link the new terminal in the list of active terminals. */
+ // Link the new terminal in the list of active terminals.
term->tl_next = first_term;
first_term = term;
@@ -549,8 +548,8 @@ term_start(
for (i = 0; p != NULL; ++i)
{
- /* Prepend a ! to the command name to avoid the buffer name equals
- * the executable, otherwise ":w!" would overwrite it. */
+ // Prepend a ! to the command name to avoid the buffer name equals
+ // the executable, otherwise ":w!" would overwrite it.
if (i == 0)
vim_snprintf((char *)p, len, "!%s", cmd);
else
@@ -576,8 +575,8 @@ term_start(
// Avoid that 'buftype' is reset when this buffer is entered.
curbuf->b_p_initialized = TRUE;
- /* Mark the buffer as not modifiable. It can only be made modifiable after
- * the job finished. */
+ // Mark the buffer as not modifiable. It can only be made modifiable after
+ // the job finished.
curbuf->b_p_ma = FALSE;
set_term_and_win_size(term);
@@ -590,7 +589,7 @@ term_start(
return curbuf;
#if defined(FEAT_SESSION)
- /* Remember the command for the session file. */
+ // Remember the command for the session file.
if (opt->jo_term_norestore || argv != NULL)
{
term->tl_command = vim_strsave((char_u *)"NONE");
@@ -647,7 +646,7 @@ term_start(
else
term->tl_api = vim_strsave((char_u *)"Tapi_");
- /* System dependent: setup the vterm and maybe start the job in it. */
+ // System dependent: setup the vterm and maybe start the job in it.
if (argv == NULL
&& argvar->v_type == VAR_STRING
&& argvar->vval.v_string != NULL
@@ -659,20 +658,20 @@ term_start(
newbuf = curbuf;
if (res == OK)
{
- /* Get and remember the size we ended up with. Update the pty. */
+ // Get and remember the size we ended up with. Update the pty.
vterm_get_size(term->tl_vterm, &term->tl_rows, &term->tl_cols);
term_report_winsize(term, term->tl_rows, term->tl_cols);
#ifdef FEAT_GUI
if (term->tl_system)
{
- /* display first line below typed command */
+ // display first line below typed command
term->tl_toprow = msg_row + 1;
term->tl_dirty_row_end = 0;
}
#endif
- /* Make sure we don't get stuck on sending keys to the job, it leads to
- * a deadlock if the job is waiting for Vim to read. */
+ // Make sure we don't get stuck on sending keys to the job, it leads to
+ // a deadlock if the job is waiting for Vim to read.
channel_set_nonblock(term->tl_job->jv_channel, PART_IN);
if (old_curbuf != NULL)
@@ -816,17 +815,17 @@ ex_terminal(exarg_T *eap)
}
if (*cmd == NUL)
{
- /* Make a copy of 'shell', an autocommand may change the option. */
+ // Make a copy of 'shell', an autocommand may change the option.
tofree = cmd = vim_strsave(p_sh);
- /* default to close when the shell exits */
+ // default to close when the shell exits
if (opt.jo_term_finish == NUL)
opt.jo_term_finish = 'c';
}
if (eap->addr_count > 0)
{
- /* Write lines from current buffer to the job. */
+ // Write lines from current buffer to the job.
opt.jo_set |= JO_IN_IO | JO_IN_BUF | JO_IN_TOP | JO_IN_BOT;
opt.jo_io[PART_IN] = JIO_BUFFER;
opt.jo_io_buf[PART_IN] = curbuf->b_fnum;
@@ -886,9 +885,9 @@ term_write_session(FILE *fd, win_T *wp)
{
term_T *term = wp->w_buffer->b_term;
- /* Create the terminal and run the command. This is not without
- * risk, but let's assume the user only creates a session when this
- * will be OK. */
+ // Create the terminal and run the command. This is not without
+ // risk, but let's assume the user only creates a session when this
+ // will be OK.
if (fprintf(fd, "terminal ++curwin ++cols=%d ++rows=%d ",
term->tl_cols, term->tl_rows) < 0)
return FAIL;
@@ -1044,7 +1043,7 @@ term_write_job_output(term_T *term, char_u *msg, size_t len)
vterm_input_write(vterm, (char *)msg, len);
- /* flush vterm buffer when vterm responded to control sequence */
+ // flush vterm buffer when vterm responded to control sequence
if (prevlen != vterm_output_get_buffer_current(vterm))
{
char buf[KEY_BUF_LEN];
@@ -1055,7 +1054,7 @@ term_write_job_output(term_T *term, char_u *msg, size_t len)
(char_u *)buf, (int)curlen, NULL);
}
- /* this invokes the damage callbacks */
+ // this invokes the damage callbacks
vterm_screen_flush_damage(vterm_obtain_screen(vterm));
}
@@ -1097,8 +1096,8 @@ write_to_term(buf_T *buffer, char_u *msg, channel_T *channel)
term_T *term = buffer->b_term;
#ifdef MSWIN
- /* Win32: Cannot redirect output of the job, intercept it here and write to
- * the file. */
+ // Win32: Cannot redirect output of the job, intercept it here and write to
+ // the file.
if (term->tl_out_fd != NULL)
{
ch_log(channel, "Writing %d bytes to output file", (int)len);
@@ -1118,14 +1117,14 @@ write_to_term(buf_T *buffer, char_u *msg, channel_T *channel)
#ifdef FEAT_GUI
if (term->tl_system)
{
- /* show system output, scrolling up the screen as needed */
+ // show system output, scrolling up the screen as needed
update_system_term(term);
update_cursor(term, TRUE);
}
else
#endif
- /* In Terminal-Normal mode we are displaying the buffer, not the terminal
- * contents, thus no screen update is needed. */
+ // In Terminal-Normal mode we are displaying the buffer, not the terminal
+ // contents, thus no screen update is needed.
if (!term->tl_normal_mode)
{
// Don't use update_screen() when editing the command line, it gets
@@ -1135,8 +1134,8 @@ write_to_term(buf_T *buffer, char_u *msg, channel_T *channel)
if (buffer == curbuf && (State & CMDLINE) == 0)
{
update_screen(VALID_NO_UPDATE);
- /* update_screen() can be slow, check the terminal wasn't closed
- * already */
+ // update_screen() can be slow, check the terminal wasn't closed
+ // already
if (buffer == curbuf && curbuf->b_term != NULL)
update_cursor(curbuf->b_term, TRUE);
}
@@ -1171,23 +1170,23 @@ static int enter_mouse_row = -1;
term_mouse_click(VTerm *vterm, int key)
{
#if defined(FEAT_CLIPBOARD)
- /* For modeless selection mouse drag and release events are ignored, unless
- * they are preceded with a mouse down event */
+ // For modeless selection mouse drag and release events are ignored, unless
+ // they are preceded with a mouse down event
static int ignore_drag_release = TRUE;
VTermMouseState mouse_state;
vterm_state_get_mousestate(vterm_obtain_state(vterm), &mouse_state);
if (mouse_state.flags == 0)
{
- /* Terminal is not using the mouse, use modeless selection. */
+ // Terminal is not using the mouse, use modeless selection.
switch (key)
{
case K_LEFTDRAG:
case K_LEFTRELEASE:
case K_RIGHTDRAG:
case K_RIGHTRELEASE:
- /* Ignore drag and release events when the button-down wasn't
- * seen before. */
+ // Ignore drag and release events when the button-down wasn't
+ // seen before.
if (ignore_drag_release)
{
int save_mouse_col, save_mouse_row;
@@ -1195,8 +1194,8 @@ term_mouse_click(VTerm *vterm, int key)
if (enter_mouse_col < 0)
break;
- /* mouse click in the window gave us focus, handle that
- * click now */
+ // mouse click in the window gave us focus, handle that
+ // click now
save_mouse_col = mouse_col;
save_mouse_row = mouse_row;
mouse_col = enter_mouse_col;
@@ -1205,14 +1204,14 @@ term_mouse_click(VTerm *vterm, int key)
mouse_col = save_mouse_col;
mouse_row = save_mouse_row;
}
- /* FALLTHROUGH */
+ // FALLTHROUGH
case K_LEFTMOUSE:
case K_RIGHTMOUSE:
if (key == K_LEFTRELEASE || key == K_RIGHTRELEASE)
ignore_drag_release = TRUE;
else
ignore_drag_release = FALSE;
- /* Should we call mouse_has() here? */
+ // Should we call mouse_has() here?
if (clip_star.available)
{
int button, is_click, is_drag;
@@ -1222,7 +1221,7 @@ term_mouse_click(VTerm *vterm, int key)
if (mouse_model_popup() && button == MOUSE_LEFT
&& (mod_mask & MOD_MASK_SHIFT))
{
- /* Translate shift-left to right button. */
+ // Translate shift-left to right button.
button = MOUSE_RIGHT;
mod_mask &= ~MOD_MASK_SHIFT;
}
@@ -1274,10 +1273,10 @@ term_convert_key(term_T *term, int c, int modmask, char *buf)
switch (c)
{
- /* don't use VTERM_KEY_ENTER, it may do an unwanted conversion */
+ // don't use VTERM_KEY_ENTER, it may do an unwanted conversion
- /* don't use VTERM_KEY_BACKSPACE, it always
- * becomes 0x7f DEL */
+ // don't use VTERM_KEY_BACKSPACE, it always
+ // becomes 0x7f DEL
case K_BS: c = term_backspace_char; break;
case ESC: key = VTERM_KEY_ESCAPE; break;
@@ -1318,16 +1317,16 @@ term_convert_key(term_T *term, int c, int modmask, char *buf)
case K_K7: key = VTERM_KEY_KP_7; break;
case K_K8: key = VTERM_KEY_KP_8; break;
case K_K9: key = VTERM_KEY_KP_9; break;
- case K_KDEL: key = VTERM_KEY_DEL; break; /* TODO */
+ case K_KDEL: key = VTERM_KEY_DEL; break; // TODO
case K_KDIVIDE: key = VTERM_KEY_KP_DIVIDE; break;
- case K_KEND: key = VTERM_KEY_KP_1; break; /* TODO */
+ case K_KEND: key = VTERM_KEY_KP_1; break; // TODO
case K_KENTER: key = VTERM_KEY_KP_ENTER; break;
- case K_KHOME: key = VTERM_KEY_KP_7; break; /* TODO */
- case K_KINS: key = VTERM_KEY_KP_0; break; /* TODO */
+ case K_KHOME: key = VTERM_KEY_KP_7; break; // TODO
+ case K_KINS: key = VTERM_KEY_KP_0; break; // TODO
case K_KMINUS: key = VTERM_KEY_KP_MINUS; break;
case K_KMULTIPLY: key = VTERM_KEY_KP_MULT; break;
- case K_KPAGEDOWN: key = VTERM_KEY_KP_3; break; /* TODO */
- case K_KPAGEUP: key = VTERM_KEY_KP_9; break; /* TODO */
+ case K_KPAGEDOWN: key = VTERM_KEY_KP_3; break; // TODO
+ case K_KPAGEUP: key = VTERM_KEY_KP_9; break; // TODO
case K_KPLUS: key = VTERM_KEY_KP_PLUS; break;
case K_KPOINT: key = VTERM_KEY_KP_PERIOD; break;
case K_LEFT: key = VTERM_KEY_LEFT; break;
@@ -1423,13 +1422,13 @@ term_convert_key(term_T *term, int c, int modmask, char *buf)
* - Write output to channel.
*/
if (key != VTERM_KEY_NONE)
- /* Special key, let vterm convert it. */
+ // Special key, let vterm convert it.
vterm_keyboard_key(vterm, key, mod);
else if (!other)
- /* Normal character, let vterm convert it. */
+ // Normal character, let vterm convert it.
vterm_keyboard_unichar(vterm, c, mod);
- /* Read back the converted escape sequence. */
+ // Read back the converted escape sequence.
return (int)vterm_output_read(vterm, buf, KEY_BUF_LEN);
}
@@ -1441,8 +1440,8 @@ term_convert_key(term_T *term, int c, int modmask, char *buf)
static int
term_job_running_check(term_T *term, int check_job_status)
{
- /* Also consider the job finished when the channel is closed, to avoid a
- * race condition when updating the title. */
+ // Also consider the job finished when the channel is closed, to avoid a
+ // race condition when updating the title.
if (term != NULL
&& term->tl_job != NULL
&& channel_is_open(term->tl_job->jv_channel))
@@ -1475,8 +1474,8 @@ term_job_running(term_T *term)
int
term_none_open(term_T *term)
{
- /* Also consider the job finished when the channel is closed, to avoid a
- * race condition when updating the title. */
+ // Also consider the job finished when the channel is closed, to avoid a
+ // race condition when updating the title.
return term != NULL
&& term->tl_job != NULL
&& channel_is_open(term->tl_job->jv_channel)
@@ -1569,7 +1568,7 @@ add_scrollback_line_to_buffer(term_T *term, char_u *text, int len)
ml_append_buf(term->tl_buffer, lnum, text, len + 1, FALSE);
if (empty)
{
- /* Delete the empty line that was in the empty buffer. */
+ // Delete the empty line that was in the empty buffer.
curbuf = buf;
ml_delete(1, FALSE);
curbuf = curwin->w_buffer;
@@ -1588,7 +1587,7 @@ cell2cellattr(const VTermScreenCell *cell, cellattr_T *attr)
static int
equal_celattr(cellattr_T *a, cellattr_T *b)
{
- /* Comparing the colors should be sufficient. */
+ // Comparing the colors should be sufficient.
return a->fg.red == b->fg.red
&& a->fg.green == b->fg.green
&& a->fg.blue == b->fg.blue
@@ -1671,8 +1670,8 @@ update_snapshot(term_T *term)
ch_log(term->tl_job == NULL ? NULL : term->tl_job->jv_channel,
"Adding terminal window snapshot to buffer");
- /* First remove the lines that were appended before, they might be
- * outdated. */
+ // First remove the lines that were appended before, they might be
+ // outdated.
cleanup_scrollback(term);
screen = vterm_obtain_screen(term->tl_vterm);
@@ -1688,7 +1687,7 @@ update_snapshot(term_T *term)
new_fill_attr = term->tl_default_color;
}
else
- /* Assume the last attr is the filler attr. */
+ // Assume the last attr is the filler attr.
cell2cellattr(&cell, &new_fill_attr);
if (len == 0 && equal_celattr(&new_fill_attr, &fill_attr))
@@ -1697,7 +1696,7 @@ update_snapshot(term_T *term)
{
while (lines_skipped > 0)
{
- /* Line was skipped, add an empty line. */
+ // Line was skipped, add an empty line.
--lines_skipped;
if (add_empty_scrollback(term, &fill_attr, 0) == OK)
add_scrollback_line_to_buffer(term, (char_u *)"", 0);
@@ -1793,13 +1792,13 @@ may_move_terminal_to_buffer(term_T *term, int redraw)
if (term->tl_vterm == NULL)
return;
- /* Update the snapshot only if something changes or the buffer does not
- * have all the lines. */
+ // Update the snapshot only if something changes or the buffer does not
+ // have all the lines.
if (term->tl_dirty_snapshot || term->tl_buffer->b_ml.ml_line_count
<= term->tl_scrollback_scrolled)
update_snapshot(term);
- /* Obtain the current background color. */
+ // Obtain the current background color.
vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm),
&term->tl_default_color.fg, &term->tl_default_color.bg);
@@ -1894,18 +1893,18 @@ term_enter_normal_mode(void)
set_terminal_mode(term, TRUE);
- /* Append the current terminal contents to the buffer. */
+ // Append the current terminal contents to the buffer.
may_move_terminal_to_buffer(term, TRUE);
- /* Move the window cursor to the position of the cursor in the
- * terminal. */
+ // Move the window cursor to the position of the cursor in the
+ // terminal.
curwin->w_cursor.lnum = term->tl_scrollback_scrolled
+ term->tl_cursor_pos.row + 1;
check_cursor();
if (coladvance(term->tl_cursor_pos.col) == FAIL)
coladvance(MAXCOL);
- /* Display the same lines as in the terminal. */
+ // Display the same lines as in the terminal.
curwin->w_topline = term->tl_scrollback_scrolled + 1;
}
@@ -1979,7 +1978,7 @@ send_keys_to_term(term_T *term, int c, int modmask, int typed)
size_t len;
int dragging_outside = FALSE;
- /* Catch keys that need to be handled as in Normal mode. */
+ // Catch keys that need to be handled as in Normal mode.
switch (c)
{
case NUL:
@@ -2002,7 +2001,7 @@ send_keys_to_term(term_T *term, int c, int modmask, int typed)
case K_X1DRAG:
case K_X2DRAG:
dragging_outside = mouse_was_outside;
- /* FALLTHROUGH */
+ // FALLTHROUGH
case K_LEFTMOUSE:
case K_LEFTMOUSE_NM:
case K_LEFTRELEASE:
@@ -2027,8 +2026,8 @@ send_keys_to_term(term_T *term, int c, int modmask, int typed)
|| mouse_col >= W_ENDCOL(curwin)
|| dragging_outside)
{
- /* click or scroll outside the current window or on status line
- * or vertical separator */
+ // click or scroll outside the current window or on status line
+ // or vertical separator
if (typed)
{
stuffcharReadbuff(c);
@@ -2080,14 +2079,14 @@ term_paste_register(int prev_c UNUSED)
clear_showcmd();
#endif
if (!term_use_loop())
- /* job finished while waiting for a character */
+ // job finished while waiting for a character
return;
- /* CTRL-W "= prompt for expression to evaluate. */
+ // CTRL-W "= prompt for expression to evaluate.
if (c == '=' && get_expr_register() != '=')
return;
if (!term_use_loop())
- /* job finished while waiting for a character */
+ // job finished while waiting for a character
return;
l = (list_T *)get_reg_contents(c, GREG_LIST);
@@ -2162,7 +2161,7 @@ term_get_cursor_shape(guicolor_T *fg, guicolor_T *bg)
entry.blinkoff = 250;
}
- /* The "Terminal" highlight group overrules the defaults. */
+ // The "Terminal" highlight group overrules the defaults.
id = syn_name2id((char_u *)"Terminal");
if (id != 0)
{
@@ -2200,7 +2199,7 @@ may_output_cursor_props(void)
last_set_cursor_blink = desired_cursor_blink;
term_cursor_color(cursor_color_get(desired_cursor_color));
if (desired_cursor_shape == -1 || desired_cursor_blink == -1)
- /* this will restore the initial cursor style, if possible */
+ // this will restore the initial cursor style, if possible
ui_cursor_shape_forced(TRUE);
else
term_cursor_shape(desired_cursor_shape, desired_cursor_blink);
@@ -2214,8 +2213,8 @@ may_output_cursor_props(void)
may_set_cursor_props(term_T *term)
{
#ifdef FEAT_GUI
- /* For the GUI the cursor properties are obtained with
- * term_get_cursor_shape(). */
+ // For the GUI the cursor properties are obtained with
+ // term_get_cursor_shape().
if (gui.in_use)
return;
#endif
@@ -2343,10 +2342,10 @@ terminal_loop(int blocking)
#endif
int restore_cursor = FALSE;
- /* Remember the terminal we are sending keys to. However, the terminal
- * might be closed while waiting for a character, e.g. typing "exit" in a
- * shell and ++close was used. Therefore use curbuf->b_term instead of a
- * stored reference. */
+ // Remember the terminal we are sending keys to. However, the terminal
+ // might be closed while waiting for a character, e.g. typing "exit" in a
+ // shell and ++close was used. Therefore use curbuf->b_term instead of a
+ // stored reference.
in_terminal_loop = curbuf->b_term;
if (*curwin->w_p_twk != NUL)
@@ -2369,7 +2368,7 @@ terminal_loop(int blocking)
if (update_screen(0) == FAIL)
break;
if (!term_use_loop_check(TRUE) || in_terminal_loop != curbuf->b_term)
- /* job finished while redrawing */
+ // job finished while redrawing
break;
update_cursor(curbuf->b_term, FALSE);
@@ -2378,8 +2377,8 @@ terminal_loop(int blocking)
raw_c = term_vgetc();
if (!term_use_loop_check(TRUE) || in_terminal_loop != curbuf->b_term)
{
- /* Job finished while waiting for a character. Push back the
- * received character. */
+ // Job finished while waiting for a character. Push back the
+ // received character.
if (raw_c != K_IGNORE)
vungetc(raw_c);
break;
@@ -2398,20 +2397,20 @@ terminal_loop(int blocking)
{
ttyinfo_T info;
- /* Get the current backspace character of the pty. */
+ // Get the current backspace character of the pty.
if (get_tty_info(tty_fd, &info) == OK)
term_backspace_char = info.backspace;
}
#endif
#ifdef MSWIN
- /* On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT.
- * Use CTRL-BREAK to kill the job. */
+ // On Windows winpty handles CTRL-C, don't send a CTRL_C_EVENT.
+ // Use CTRL-BREAK to kill the job.
if (ctrl_break_was_pressed)
mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill");
#endif
- /* Was either CTRL-W (termwinkey) or CTRL-\ pressed?
- * Not in a system terminal. */
+ // Was either CTRL-W (termwinkey) or CTRL-\ pressed?
+ // Not in a system terminal.
if ((c == (termwinkey == 0 ? Ctrl_W : termwinkey) || c == Ctrl_BSL)
#ifdef FEAT_GUI
&& !curbuf->b_term->tl_system
@@ -2434,14 +2433,14 @@ terminal_loop(int blocking)
#endif
if (!term_use_loop_check(TRUE)
|| in_terminal_loop != curbuf->b_term)
- /* job finished while waiting for a character */
+ // job finished while waiting for a character
break;
if (prev_c == Ctrl_BSL)
{
if (c == Ctrl_N)
{
- /* CTRL-\ CTRL-N : go to Terminal-Normal mode. */
+ // CTRL-\ CTRL-N : go to Terminal-Normal mode.
term_enter_normal_mode();
ret = FAIL;
goto theend;
@@ -2453,23 +2452,23 @@ terminal_loop(int blocking)
}
else if (c == Ctrl_C)
{
- /* "CTRL-W CTRL-C" or 'termwinkey' CTRL-C: end the job */
+ // "CTRL-W CTRL-C" or 'termwinkey' CTRL-C: end the job
mch_signal_job(curbuf->b_term->tl_job, (char_u *)"kill");
}
else if (c == '.')
{
- /* "CTRL-W .": send CTRL-W to the job */
- /* "'termwinkey' .": send 'termwinkey' to the job */
+ // "CTRL-W .": send CTRL-W to the job
+ // "'termwinkey' .": send 'termwinkey' to the job
raw_c = ctrl_to_raw_c(termwinkey == 0 ? Ctrl_W : termwinkey);
}
else if (c == Ctrl_BSL)
{
- /* "CTRL-W CTRL-\": send CTRL-\ to the job */
+ // "CTRL-W CTRL-\": send CTRL-\ to the job
raw_c = ctrl_to_raw_c(Ctrl_BSL);
}
else if (c == 'N')
{
- /* CTRL-W N : go to Terminal-Normal mode. */
+ // CTRL-W N : go to Terminal-Normal mode.
term_enter_normal_mode();
ret = FAIL;
goto theend;
@@ -2507,8 +2506,8 @@ terminal_loop(int blocking)
if (send_keys_to_term(curbuf->b_term, raw_c, mod_mask, TRUE) != OK)
{
if (raw_c == K_MOUSEMOVE)
- /* We are sure to come back here, don't reset the cursor color
- * and shape to avoid flickering. */
+ // We are sure to come back here, don't reset the cursor color
+ // and shape to avoid flickering.
restore_cursor = FALSE;
ret = OK;
@@ -2522,8 +2521,8 @@ theend:
if (restore_cursor)
prepare_restore_cursor_props();
- /* Move a snapshot of the screen contents to the buffer, so that completion
- * works in other buffers. */
+ // Move a snapshot of the screen contents to the buffer, so that completion
+ // works in other buffers.
if (curbuf->b_term != NULL && !curbuf->b_term->tl_normal_mode)
may_move_terminal_to_buffer(curbuf->b_term, FALSE);
@@ -2559,22 +2558,22 @@ color2index(VTermColor *color, int fg, int *boldp)
switch (color->ansi_index)
{
case 0: return 0;
- case 1: return lookup_color( 0, fg, boldp) + 1; /* black */
- case 2: return lookup_color( 4, fg, boldp) + 1; /* dark red */
- case 3: return lookup_color( 2, fg, boldp) + 1; /* dark green */
- case 4: return lookup_color( 6, fg, boldp) + 1; /* brown */
- case 5: return lookup_color( 1, fg, boldp) + 1; /* dark blue */
- case 6: return lookup_color( 5, fg, boldp) + 1; /* dark magenta */
- case 7: return lookup_color( 3, fg, boldp) + 1; /* dark cyan */
- case 8: return lookup_color( 8, fg, boldp) + 1; /* light grey */
- case 9: return lookup_color(12, fg, boldp) + 1; /* dark grey */
- case 10: return lookup_color(20, fg, boldp) + 1; /* red */
- case 11: return lookup_color(16, fg, boldp) + 1; /* green */
- case 12: return lookup_color(24, fg, boldp) + 1; /* yellow */
- case 13: return lookup_color(14, fg, boldp) + 1; /* blue */
- case 14: return lookup_color(22, fg, boldp) + 1; /* magenta */
- case 15: return lookup_color(18, fg, boldp) + 1; /* cyan */
- case 16: return lookup_color(26, fg, boldp) + 1; /* white */
+ case 1: return lookup_color( 0, fg, boldp) + 1; // black
+ case 2: return lookup_color( 4, fg, boldp) + 1; // dark red
+ case 3: return lookup_color( 2, fg, boldp) + 1; // dark green
+ case 4: return lookup_color( 6, fg, boldp) + 1; // brown
+ case 5: return lookup_color( 1, fg, boldp) + 1; // dark blue
+ case 6: return lookup_color( 5, fg, boldp) + 1; // dark magenta
+ case 7: return lookup_color( 3, fg, boldp) + 1; // dark cyan
+ case 8: return lookup_color( 8, fg, boldp) + 1; // light grey
+ case 9: return lookup_color(12, fg, boldp) + 1; // dark grey
+ case 10: return lookup_color(20, fg, boldp) + 1; // red
+ case 11: return lookup_color(16, fg, boldp) + 1; // green
+ case 12: return lookup_color(24, fg, boldp) + 1; // yellow
+ case 13: return lookup_color(14, fg, boldp) + 1; // blue
+ case 14: return lookup_color(22, fg, boldp) + 1; // magenta
+ case 15: return lookup_color(18, fg, boldp) + 1; // cyan
+ case 16: return lookup_color(26, fg, boldp) + 1; // white
}
}
@@ -2582,7 +2581,7 @@ color2index(VTermColor *color, int fg, int *boldp)
{
if (red == blue && red == green)
{
- /* 24-color greyscale plus white and black */
+ // 24-color greyscale plus white and black
static int cutoff[23] = {
0x0D, 0x17, 0x21, 0x2B, 0x35, 0x3F, 0x49, 0x53, 0x5D, 0x67,
0x71, 0x7B, 0x85, 0x8F, 0x99, 0xA3, 0xAD, 0xB7, 0xC1, 0xCB,
@@ -2590,8 +2589,8 @@ color2index(VTermColor *color, int fg, int *boldp)
int i;
if (red < 5)
- return 17; /* 00/00/00 */
- if (red > 245) /* ff/ff/ff */
+ return 17; // 00/00/00
+ if (red > 245) // ff/ff/ff
return 232;
for (i = 0; i < 23; ++i)
if (red < cutoff[i])
@@ -2602,7 +2601,7 @@ color2index(VTermColor *color, int fg, int *boldp)
static int cutoff[5] = {0x2F, 0x73, 0x9B, 0xC3, 0xEB};
int ri, gi, bi;
- /* 216-color cube */
+ // 216-color cube
for (ri = 0; ri < 5; ++ri)
if (red < cutoff[ri])
break;
@@ -2694,7 +2693,7 @@ cell2attr(VTermScreenCellAttrs cellattrs, VTermColor cellfg, VTermColor cellbg)
int fg = color2index(&cellfg, TRUE, &bold);
int bg = color2index(&cellbg, FALSE, &bold);
- /* Use the "Terminal" highlighting for the default colors. */
+ // Use the "Terminal" highlighting for the default colors.
if ((fg == 0 || bg == 0) && t_colors >= 16)
{
if (fg == 0 && term_default_cterm_fg >= 0)
@@ -2703,7 +2702,7 @@ cell2attr(VTermScreenCellAttrs cellattrs, VTermColor cellfg, VTermColor cellbg)
bg = term_default_cterm_bg + 1;
}
- /* with 8 colors set the bold attribute to get a bright foreground */
+ // with 8 colors set the bold attribute to get a bright foreground
if (bold == TRUE)
attr |= HL_BOLD;
return get_cterm_attr_idx(attr, fg, bg);
@@ -2718,7 +2717,7 @@ set_dirty_snapshot(term_T *term)
#ifdef FEAT_TIMERS
if (!term->tl_normal_mode)
{
- /* Update the snapshot after 100 msec of not getting updates. */
+ // Update the snapshot after 100 msec of not getting updates.
profile_setlimit(100L, &term->tl_timer_due);
term->tl_timer_set = TRUE;
}
@@ -2745,7 +2744,7 @@ term_scroll_up(term_T *term, int start_row, int count)
VTermScreenCellAttrs attr;
int clear_attr;
- /* Set the color to clear lines with. */
+ // Set the color to clear lines with.
vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm),
&fg, &bg);
vim_memset(&attr, 0, sizeof(attr));
@@ -2764,9 +2763,9 @@ handle_moverect(VTermRect dest, VTermRect src, void *user)
term_T *term = (term_T *)user;
int count = src.start_row - dest.start_row;
- /* Scrolling up is done much more efficiently by deleting lines instead of
- * redrawing the text. But avoid doing this multiple times, postpone until
- * the redraw happens. */
+ // Scrolling up is done much more efficiently by deleting lines instead of
+ // redrawing the text. But avoid doing this multiple times, postpone until
+ // the redraw happens.
if (dest.start_col == src.start_col
&& dest.end_col == src.end_col
&& dest.start_row < src.start_row)
@@ -2781,8 +2780,8 @@ handle_moverect(VTermRect dest, VTermRect src, void *user)
term->tl_dirty_row_end = MIN(term->tl_dirty_row_end, dest.end_row);
set_dirty_snapshot(term);
- /* Note sure if the scrolling will work correctly, let's do a complete
- * redraw later. */
+ // Note sure if the scrolling will work correctly, let's do a complete
+ // redraw later.
redraw_buf_later(term->tl_buffer, NOT_VALID);
return 1;
}
@@ -2885,14 +2884,14 @@ handle_settermprop(
break;
case VTERM_PROP_ALTSCREEN:
- /* TODO: do anything else? */
+ // TODO: do anything else?
term->tl_using_altscreen = value->boolean;
break;
default:
break;
}
- /* Always return 1, otherwise vterm doesn't store the value internally. */
+ // Always return 1, otherwise vterm doesn't store the value internally.
return 1;
}
@@ -2908,7 +2907,7 @@ handle_resize(int rows, int cols, void *user)
term->tl_rows = rows;
term->tl_cols = cols;
if (term->tl_vterm_size_changed)
- /* Size was set by vterm_set_size(), don't set the window size. */
+ // Size was set by vterm_set_size(), don't set the window size.
term->tl_vterm_size_changed = FALSE;
else
{
@@ -3057,7 +3056,7 @@ handle_pushline(int cols, const VTermScreenCell *cells, void *user)
}
++gap->ga_len;
}
- return 0; /* ignored */
+ return 0; // ignored
}
/*
@@ -3108,14 +3107,14 @@ handle_postponed_scrollback(term_T *term)
}
static VTermScreenCallbacks screen_callbacks = {
- handle_damage, /* damage */
- handle_moverect, /* moverect */
- handle_movecursor, /* movecursor */
- handle_settermprop, /* settermprop */
- NULL, /* bell */
- handle_resize, /* resize */
- handle_pushline, /* sb_pushline */
- NULL /* sb_popline */
+ handle_damage, // damage
+ handle_moverect, // moverect
+ handle_movecursor, // movecursor
+ handle_settermprop, // settermprop
+ NULL, // bell
+ handle_resize, // resize
+ handle_pushline, // sb_pushline
+ NULL // sb_popline
};
/*
@@ -3126,7 +3125,7 @@ static VTermScreenCallbacks screen_callbacks = {
static int
term_after_channel_closed(term_T *term)
{
- /* Unless in Terminal-Normal mode: clear the vterm. */
+ // Unless in Terminal-Normal mode: clear the vterm.
if (!term->tl_normal_mode)
{
int fnum = term->tl_buffer->b_fnum;
@@ -3167,7 +3166,7 @@ term_after_channel_closed(term_T *term)
{
char buf[50];
- /* TODO: use term_opencmd */
+ // TODO: use term_opencmd
ch_log(NULL, "terminal job finished, opening window");
vim_snprintf(buf, sizeof(buf),
term->tl_opencmd == NULL
@@ -3214,8 +3213,8 @@ term_channel_closed(channel_T *ch)
if (updating_screen)
{
- /* Cannot open or close windows now. Can happen when
- * 'lazyredraw' is set. */
+ // Cannot open or close windows now. Can happen when
+ // 'lazyredraw' is set.
term->tl_channel_recently_closed = TRUE;
continue;
}
@@ -3229,7 +3228,7 @@ term_channel_closed(channel_T *ch)
{
redraw_statuslines();
- /* Need to break out of vgetc(). */
+ // Need to break out of vgetc().
ins_char_typebuf(K_IGNORE);
typebuf_was_filled = TRUE;
@@ -3296,7 +3295,7 @@ term_line2screenline(VTermScreen *screen, VTermPos *pos, int max_col)
{
int i;
- /* composing chars */
+ // composing chars
for (i = 0; i < Screen_mco
&& i + 1 < VTERM_MAX_CHARS_PER_CELL; ++i)
{
@@ -3345,8 +3344,8 @@ term_line2screenline(VTermScreen *screen, VTermPos *pos, int max_col)
if (enc_utf8)
ScreenLinesUC[off] = NUL;
- /* don't set the second byte to NUL for a DBCS encoding, it
- * has been set above */
+ // don't set the second byte to NUL for a DBCS encoding, it
+ // has been set above
if (enc_utf8 || !has_mbyte)
ScreenLines[off] = NUL;
@@ -3367,7 +3366,7 @@ update_system_term(term_T *term)
return;
screen = vterm_obtain_screen(term->tl_vterm);
- /* Scroll up to make more room for terminal lines if needed. */
+ // Scroll up to make more room for terminal lines if needed.
while (term->tl_toprow > 0
&& (Rows - term->tl_toprow) < term->tl_dirty_row_end)
{
@@ -3433,8 +3432,8 @@ term_update_window(win_T *wp)
screen = vterm_obtain_screen(vterm);
state = vterm_obtain_state(vterm);
- /* We use NOT_VALID on a resize or scroll, redraw everything then. With
- * SOME_VALID only redraw what was marked dirty. */
+ // We use NOT_VALID on a resize or scroll, redraw everything then. With
+ // SOME_VALID only redraw what was marked dirty.
if (wp->w_redr_type > SOME_VALID)
{
term->tl_dirty_row_start = 0;
@@ -3442,8 +3441,8 @@ term_update_window(win_T *wp)
if (term->tl_postponed_scroll > 0
&& term->tl_postponed_scroll < term->tl_rows / 3)
- /* Scrolling is usually faster than redrawing, when there are only
- * a few lines to scroll. */
+ // Scrolling is usually faster than redrawing, when there are only
+ // a few lines to scroll.
term_scroll_up(term, 0, term->tl_postponed_scroll);
term->tl_postponed_scroll = 0;
}
@@ -3458,8 +3457,8 @@ term_update_window(win_T *wp)
newcols = 99999;
FOR_ALL_WINDOWS(twp)
{
- /* When more than one window shows the same terminal, use the
- * smallest size. */
+ // When more than one window shows the same terminal, use the
+ // smallest size.
if (twp->w_buffer == term->tl_buffer)
{
newrows = MIN(newrows, twp->w_height);
@@ -3485,7 +3484,7 @@ term_update_window(win_T *wp)
may_move_terminal_to_buffer(term, FALSE);
}
- /* The cursor may have been moved when resizing. */
+ // The cursor may have been moved when resizing.
vterm_state_get_cursorpos(state, &pos);
position_cursor(wp, &pos);
@@ -3546,8 +3545,8 @@ term_change_in_curbuf(void)
free_scrollback(term);
redraw_buf_later(term->tl_buffer, NOT_VALID);
- /* The buffer is now like a normal buffer, it cannot be easily
- * abandoned when changed. */
+ // The buffer is now like a normal buffer, it cannot be easily
+ // abandoned when changed.
set_string_option_direct((char_u *)"buftype", -1,
(char_u *)"", OPT_FREE|OPT_LOCAL, 0);
}
@@ -3602,8 +3601,8 @@ init_default_colors(term_T *term)
fg = &term->tl_default_color.fg;
bg = &term->tl_default_color.bg;
- /* Vterm uses a default black background. Set it to white when
- * 'background' is "light". */
+ // Vterm uses a default black background. Set it to white when
+ // 'background' is "light".
if (*p_bg == 'l')
{
fgval = 0;
@@ -3618,10 +3617,10 @@ init_default_colors(term_T *term)
bg->red = bg->green = bg->blue = bgval;
fg->ansi_index = bg->ansi_index = VTERM_ANSI_INDEX_DEFAULT;
- /* The "Terminal" highlight group overrules the defaults. */
+ // The "Terminal" highlight group overrules the defaults.
id = syn_name2id((char_u *)"Terminal");
- /* Use the actual color for the GUI and when 'termguicolors' is set. */
+ // Use the actual color for the GUI and when 'termguicolors' is set.
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
if (0
# ifdef FEAT_GUI
@@ -3630,7 +3629,7 @@ init_default_colors(term_T *term)
# ifdef FEAT_TERMGUICOLORS
|| p_tgc
# ifdef FEAT_VTP
- /* Finally get INVALCOLOR on this execution path */
+ // Finally get INVALCOLOR on this execution path
|| (!p_tgc && t_colors >= 256)
# endif
# endif
@@ -3694,7 +3693,7 @@ init_default_colors(term_T *term)
int tmp;
#endif
- /* In an MS-Windows console we know the normal colors. */
+ // In an MS-Windows console we know the normal colors.
if (cterm_normal_fg_color > 0)
{
cterm_color2vterm(cterm_normal_fg_color - 1, fg);
@@ -3826,7 +3825,7 @@ handle_drop_command(listitem_T *item)
{
if (wp->w_buffer->b_fnum == bufnr)
{
- /* buffer is in a window already, go there */
+ // buffer is in a window already, go there
goto_tabpage_win(tp, wp);
return;
}
@@ -3878,7 +3877,7 @@ handle_drop_command(listitem_T *item)
ea.force_bin = FORCE_NOBIN;
}
- /* open in new window, like ":split fname" */
+ // open in new window, like ":split fname"
if (ea.cmd == NULL)
ea.cmd = (char_u *)"split";
ea.arg = fname;
@@ -3951,9 +3950,9 @@ parse_osc(const char *command, size_t cmdlen, void *user)
channel_T *channel = term->tl_job == NULL ? NULL
: term->tl_job->jv_channel;
- /* We recognize only OSC 5 1 ; {command} */
+ // We recognize only OSC 5 1 ; {command}
if (cmdlen < 3 || STRNCMP(command, "51;", 3) != 0)
- return 0; /* not handled */
+ return 0; // not handled
reader.js_buf = vim_strnsave((char_u *)command + 3, (int)(cmdlen - 3));
if (reader.js_buf == NULL)
@@ -3972,8 +3971,8 @@ parse_osc(const char *command, size_t cmdlen, void *user)
{
char_u *cmd = tv_get_string(&item->li_tv);
- /* Make sure an invoked command doesn't delete the buffer (and the
- * terminal) under our fingers. */
+ // Make sure an invoked command doesn't delete the buffer (and the
+ // terminal) under our fingers.
++term->tl_buffer->b_locked;
item = item->li_next;
@@ -4112,7 +4111,7 @@ create_vterm(term_T *term, int rows, int cols)
}
vterm_screen_set_callbacks(screen, &screen_callbacks, term);
- /* TODO: depends on 'encoding'. */
+ // TODO: depends on 'encoding'.
vterm_set_utf8(vterm, 1);
init_default_colors(term);
@@ -4127,15 +4126,15 @@ create_vterm(term_T *term, int rows, int cols)
// the foreground color.
vterm_state_set_bold_highbright(vterm_obtain_state(vterm), 1);
- /* Required to initialize most things. */
+ // Required to initialize most things.
vterm_screen_reset(screen, 1 /* hard */);
- /* Allow using alternate screen. */
+ // Allow using alternate screen.
vterm_screen_enable_altscreen(screen, 1);
- /* For unix do not use a blinking cursor. In an xterm this causes the
- * cursor to blink if it's blinking in the xterm.
- * For Windows we respect the system wide setting. */
+ // For unix do not use a blinking cursor. In an xterm this causes the
+ // cursor to blink if it's blinking in the xterm.
+ // For Windows we respect the system wide setting.
#ifdef MSWIN
if (GetCaretBlinkTime() == INFINITE)
value.boolean = 0;
@@ -4225,7 +4224,7 @@ term_get_buf(typval_T *argvars, char *where)
{
buf_T *buf;
- (void)tv_get_number(&argvars[0]); /* issue errmsg if type error */
+ (void)tv_get_number(&argvars[0]); // issue errmsg if type error
++emsg_off;
buf = tv_get_buf(&argvars[0], FALSE);
--emsg_off;
@@ -4364,7 +4363,7 @@ f_term_dumpwrite(typval_T *argvars, typval_T *rettv UNUSED)
int c = cell.chars[i];
int pc = prev_cell.chars[i];
- /* For the first character NUL is the same as space. */
+ // For the first character NUL is the same as space.
if (i == 0)
{
c = (c == NUL) ? ' ' : c;
@@ -4408,9 +4407,9 @@ f_term_dumpwrite(typval_T *argvars, typval_T *rettv UNUSED)
}
}
- /* When only the characters differ we don't write anything, the
- * following "|", "@" or NL will indicate using the same
- * attributes. */
+ // When only the characters differ we don't write anything, the
+ // following "|", "@" or NL will indicate using the same
+ // attributes.
if (cell.width != prev_cell.width || !same_attr)
{
if (cell.width == 2)
@@ -4512,7 +4511,7 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
}
else if (c == '\n')
{
- /* End of a line: append it to the buffer. */
+ // End of a line: append it to the buffer.
if (ga_text.ga_data == NULL)
dump_is_corrupt(&ga_text);
if (ga_grow(&term->tl_scrollback, 1) == OK)
@@ -4545,12 +4544,12 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
if (c == '>')
{
if (cursor_pos->row != -1)
- dump_is_corrupt(&ga_text); /* duplicate cursor */
+ dump_is_corrupt(&ga_text); // duplicate cursor
cursor_pos->row = term->tl_scrollback.ga_len - start_row;
cursor_pos->col = ga_cell.ga_len;
}
- /* normal character(s) followed by "+", "*", "|", "@" or NL */
+ // normal character(s) followed by "+", "*", "|", "@" or NL
c = fgetc(fd);
if (c != EOF)
ga_append(&ga_text, c);
@@ -4563,7 +4562,7 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
ga_append(&ga_text, c);
}
- /* save the character for repeating it */
+ // save the character for repeating it
vim_free(prev_char);
if (ga_text.ga_data != NULL)
prev_char = vim_strnsave(((char_u *)ga_text.ga_data) + prev_len,
@@ -4571,7 +4570,7 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
if (c == '@' || c == '|' || c == '>' || c == '\n')
{
- /* use all attributes from previous cell */
+ // use all attributes from previous cell
}
else if (c == '+' || c == '*')
{
@@ -4582,12 +4581,12 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
c = fgetc(fd);
if (c == '&')
{
- /* use same attr as previous cell */
+ // use same attr as previous cell
c = fgetc(fd);
}
else if (isdigit(c))
{
- /* get the decimal attribute */
+ // get the decimal attribute
attr = 0;
while (isdigit(c))
{
@@ -4596,12 +4595,12 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
}
hl2vtermAttr(attr, &cell);
- /* is_bg == 0: fg, is_bg == 1: bg */
+ // is_bg == 0: fg, is_bg == 1: bg
for (is_bg = 0; is_bg <= 1; ++is_bg)
{
if (c == '&')
{
- /* use same color as previous cell */
+ // use same color as previous cell
c = fgetc(fd);
}
else if (c == '#')
@@ -4666,7 +4665,7 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
{
int count = 0;
- /* repeat previous character, get the count */
+ // repeat previous character, get the count
for (;;)
{
c = fgetc(fd);
@@ -4691,7 +4690,7 @@ read_dump_file(FILE *fd, VTermPos *cursor_pos)
if (ga_text.ga_len > 0)
{
- /* trailing characters after last NL */
+ // trailing characters after last NL
dump_is_corrupt(&ga_text);
ga_append(&ga_text, NUL);
ml_append(curbuf->b_ml.ml_line_count, ga_text.ga_data,
@@ -4726,16 +4725,16 @@ get_separator(int text_width, char_u *fname)
fname_size = vim_strsize(fname);
if (fname_size < width - 8)
{
- /* enough room, don't use the full window width */
+ // enough room, don't use the full window width
width = MAX(text_width, fname_size + 8);
}
else if (fname_size > width - 8)
{
- /* full name doesn't fit, use only the tail */
+ // full name doesn't fit, use only the tail
p = gettail(fname);
fname_size = vim_strsize(p);
}
- /* skip characters until the name fits */
+ // skip characters until the name fits
while (fname_size > width - 8)
{
p += (*mb_ptr2len)(p);
@@ -4773,7 +4772,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
FILE *fd2 = NULL;
char_u *textline = NULL;
- /* First open the files. If this fails bail out. */
+ // First open the files. If this fails bail out.
fname1 = tv_get_string_buf_chk(&argvars[0], buf1);
if (do_diff)
fname2 = tv_get_string_buf_chk(&argvars[1], buf2);
@@ -4854,20 +4853,20 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
rettv->vval.v_number = buf->b_fnum;
- /* read the files, fill the buffer with the diff */
+ // read the files, fill the buffer with the diff
width = read_dump_file(fd1, &cursor_pos1);
- /* position the cursor */
+ // position the cursor
if (cursor_pos1.row >= 0)
{
curwin->w_cursor.lnum = cursor_pos1.row + 1;
coladvance(cursor_pos1.col);
}
- /* Delete the empty line that was in the empty buffer. */
+ // Delete the empty line that was in the empty buffer.
ml_delete(1, FALSE);
- /* For term_dumpload() we are done here. */
+ // For term_dumpload() we are done here.
if (!do_diff)
goto theend;
@@ -4904,7 +4903,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
{
if (lnum + bot_lnum > curbuf->b_ml.ml_line_count)
{
- /* bottom part has fewer rows, fill with "-" */
+ // bottom part has fewer rows, fill with "-"
for (i = 0; i < width; ++i)
textline[i] = '-';
}
@@ -4920,7 +4919,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
cellattr_T *cellattr2 = (sb_line + lnum + bot_lnum - 1)
->sb_cells;
- /* Make a copy, getting the second line will invalidate it. */
+ // Make a copy, getting the second line will invalidate it.
line1 = vim_strsave(ml_get(lnum));
if (line1 == NULL)
break;
@@ -4935,19 +4934,19 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
textline[col] = ' ';
if (len1 != len2 || STRNCMP(p1, p2, len1) != 0)
- /* text differs */
+ // text differs
textline[col] = 'X';
else if (lnum == cursor_pos1.row + 1
&& col == cursor_pos1.col
&& (cursor_pos1.row != cursor_pos2.row
|| cursor_pos1.col != cursor_pos2.col))
- /* cursor in first but not in second */
+ // cursor in first but not in second
textline[col] = '>';
else if (lnum == cursor_pos2.row + 1
&& col == cursor_pos2.col
&& (cursor_pos1.row != cursor_pos2.row
|| cursor_pos1.col != cursor_pos2.col))
- /* cursor in second but not in first */
+ // cursor in second but not in first
textline[col] = '<';
else if (cellattr1 != NULL && cellattr2 != NULL)
{
@@ -4966,7 +4965,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
}
p1 += len1;
p2 += len2;
- /* TODO: handle different width */
+ // TODO: handle different width
}
while (col < width)
@@ -4996,7 +4995,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
while (lnum + bot_lnum <= curbuf->b_ml.ml_line_count)
{
- /* bottom part has more rows, fill with "+" */
+ // bottom part has more rows, fill with "+"
for (i = 0; i < width; ++i)
textline[i] = '+';
if (add_empty_scrollback(term, &term->tl_default_color,
@@ -5008,7 +5007,7 @@ term_load_dump(typval_T *argvars, typval_T *rettv, int do_diff)
term->tl_cols = width;
- /* looks better without wrapping */
+ // looks better without wrapping
curwin->w_p_wrap = 0;
}
@@ -5089,7 +5088,7 @@ term_swap_diff()
if (top_rows == bot_rows)
{
- /* rows counts are equal, can swap cell properties */
+ // rows counts are equal, can swap cell properties
for (lnum = 0; lnum < top_rows; ++lnum)
{
sb_line_T temp;
@@ -5104,7 +5103,7 @@ term_swap_diff()
size_t size = sizeof(sb_line_T) * term->tl_scrollback.ga_len;
sb_line_T *temp = alloc(size);
- /* need to copy cell properties into temp memory */
+ // need to copy cell properties into temp memory
if (temp != NULL)
{
mch_memmove(temp, term->tl_scrollback.ga_data, size);
@@ -5280,7 +5279,7 @@ f_term_getline(typval_T *argvars, typval_T *rettv)
{
linenr_T lnum = row + term->tl_scrollback_scrolled + 1;
- /* vterm is finished, get the text from the buffer */
+ // vterm is finished, get the text from the buffer
if (lnum > 0 && lnum <= buf->b_ml.ml_line_count)
rettv->vval.v_string = vim_strsave(ml_get_buf(buf, lnum, FALSE));
}
@@ -5362,9 +5361,9 @@ f_term_setsize(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
cols = tv_get_number(&argvars[2]);
cols = cols <= 0 ? term->tl_cols : cols;
vterm_set_size(term->tl_vterm, rows, cols);
- /* handle_resize() will resize the windows */
+ // handle_resize() will resize the windows
- /* Get and remember the size we ended up with. Update the pty. */
+ // Get and remember the size we ended up with. Update the pty.
vterm_get_size(term->tl_vterm, &term->tl_rows, &term->tl_cols);
term_report_winsize(term, term->tl_rows, term->tl_cols);
}
@@ -5520,7 +5519,7 @@ f_term_scrape(typval_T *argvars, typval_T *rettv)
cellattr_T *cellattr;
int len;
- /* vterm has finished, get the cell from scrollback */
+ // vterm has finished, get the cell from scrollback
if (pos.col >= line->sb_cols)
break;
cellattr = line->sb_cells + pos.col;
@@ -5783,16 +5782,16 @@ f_term_wait(typval_T *argvars, typval_T *rettv UNUSED)
return;
}
if (buf->b_term->tl_job->jv_channel == NULL)
- /* channel is closed, nothing to do */
+ // channel is closed, nothing to do
return;
- /* Get the job status, this will detect a job that finished. */
+ // Get the job status, this will detect a job that finished.
if (!buf->b_term->tl_job->jv_channel->ch_keep_open
&& STRCMP(job_status(buf->b_term->tl_job), "dead") == 0)
{
- /* The job is dead, keep reading channel I/O until the channel is
- * closed. buf->b_term may become NULL if the terminal was closed while
- * waiting. */
+ // The job is dead, keep reading channel I/O until the channel is
+ // closed. buf->b_term may become NULL if the terminal was closed while
+ // waiting.
ch_log(NULL, "term_wait(): waiting for channel to close");
while (buf->b_term != NULL && !buf->b_term->tl_channel_closed)
{
@@ -5800,8 +5799,8 @@ f_term_wait(typval_T *argvars, typval_T *rettv UNUSED)
ui_delay(10L, FALSE);
if (!buf_valid(buf))
- /* If the terminal is closed when the channel is closed the
- * buffer disappears. */
+ // If the terminal is closed when the channel is closed the
+ // buffer disappears.
break;
}
@@ -5813,13 +5812,13 @@ f_term_wait(typval_T *argvars, typval_T *rettv UNUSED)
term_flush_messages();
- /* Wait for some time for any channel I/O. */
+ // Wait for some time for any channel I/O.
if (argvars[1].v_type != VAR_UNKNOWN)
wait = tv_get_number(&argvars[1]);
ui_delay(wait, TRUE);
- /* Flushing messages on channels is hopefully sufficient.
- * TODO: is there a better way? */
+ // Flushing messages on channels is hopefully sufficient.
+ // TODO: is there a better way?
term_flush_messages();
}
}
@@ -5844,7 +5843,7 @@ term_send_eof(channel_T *ch)
}
# ifdef MSWIN
else
- /* Default: CTRL-D */
+ // Default: CTRL-D
channel_send(ch, PART_IN, (char_u *)"\004\r", 2, NULL);
# endif
}
@@ -5860,9 +5859,8 @@ term_getjob(term_T *term)
# if defined(MSWIN) || defined(PROTO)
-/**************************************
- * 2. MS-Windows implementation.
- */
+///////////////////////////////////////
+// 2. MS-Windows implementation.
#ifdef PROTO
typedef int COORD;
typedef int DWORD;
@@ -5987,8 +5985,8 @@ conpty_term_and_job_init(
if (cmd_wchar != NULL)
{
- /* Request by CreateProcessW */
- breq = wcslen(cmd_wchar) + 1 + 1; /* Addition of NUL by API */
+ // Request by CreateProcessW
+ breq = wcslen(cmd_wchar) + 1 + 1; // Addition of NUL by API
cmd_wchar_copy = ALLOC_MULT(WCHAR, breq);
wcsncpy(cmd_wchar_copy, cmd_wchar, breq - 1);
}
@@ -6016,7 +6014,7 @@ conpty_term_and_job_init(
term->tl_siex.StartupInfo.cb = sizeof(term->tl_siex);
- /* Set up pipe inheritance safely: Vista or later. */
+ // Set up pipe inheritance safely: Vista or later.
pInitializeProcThreadAttributeList(NULL, 1, 0, &breq);
term->tl_siex.lpAttributeList = alloc(breq);
if (!term->tl_siex.lpAttributeList)
@@ -6069,10 +6067,10 @@ conpty_term_and_job_init(
(sock_T)o_ours,
(sock_T)o_ours);
- /* Write lines with CR instead of NL. */
+ // Write lines with CR instead of NL.
channel->ch_write_text_mode = TRUE;
- /* Use to explicitly delete anonymous pipe handle. */
+ // Use to explicitly delete anonymous pipe handle.
channel->ch_anonymous_pipe = TRUE;
jo = CreateJobObject(NULL, NULL);
@@ -6081,7 +6079,7 @@ conpty_term_and_job_init(
if (!AssignProcessToJobObject(jo, proc_info.hProcess))
{
- /* Failed, switch the way to terminate process with TerminateProcess. */
+ // Failed, switch the way to terminate process with TerminateProcess.
CloseHandle(jo);
jo = NULL;
}
@@ -6115,9 +6113,9 @@ conpty_term_and_job_init(
++job->jv_refcount;
term->tl_job = job;
- /* Redirecting stdout and stderr doesn't work at the job level. Instead
- * open the file here and handle it in. opt->jo_io was changed in
- * setup_job_options(), use the original flags here. */
+ // Redirecting stdout and stderr doesn't work at the job level. Instead
+ // open the file here and handle it in. opt->jo_io was changed in
+ // setup_job_options(), use the original flags here.
if (orig_opt->jo_io[PART_OUT] == JIO_FILE)
{
char_u *fname = opt->jo_io_name[PART_OUT];
@@ -6256,11 +6254,11 @@ dyn_winpty_init(int verbose)
{NULL, NULL}
};
- /* No need to initialize twice. */
+ // No need to initialize twice.
if (hWinPtyDLL)
return OK;
- /* Load winpty.dll, prefer using the 'winptydll' option, fall back to just
- * winpty.dll. */
+ // Load winpty.dll, prefer using the 'winptydll' option, fall back to just
+ // winpty.dll.
if (*p_winptydll != NUL)
hWinPtyDLL = vimLoadLib((char *)p_winptydll);
if (!hWinPtyDLL)
@@ -6405,7 +6403,7 @@ winpty_term_and_job_init(
GENERIC_READ, 0, NULL,
OPEN_EXISTING, 0, NULL));
- /* Write lines with CR instead of NL. */
+ // Write lines with CR instead of NL.
channel->ch_write_text_mode = TRUE;
jo = CreateJobObject(NULL, NULL);
@@ -6414,7 +6412,7 @@ winpty_term_and_job_init(
if (!AssignProcessToJobObject(jo, child_process_handle))
{
- /* Failed, switch the way to terminate process with TerminateProcess. */
+ // Failed, switch the way to terminate process with TerminateProcess.
CloseHandle(jo);
jo = NULL;
}
@@ -6450,9 +6448,9 @@ winpty_term_and_job_init(
++job->jv_refcount;
term->tl_job = job;
- /* Redirecting stdout and stderr doesn't work at the job level. Instead
- * open the file here and handle it in. opt->jo_io was changed in
- * setup_job_options(), use the original flags here. */
+ // Redirecting stdout and stderr doesn't work at the job level. Instead
+ // open the file here and handle it in. opt->jo_io was changed in
+ // setup_job_options(), use the original flags here.
if (orig_opt->jo_io[PART_OUT] == JIO_FILE)
{
char_u *fname = opt->jo_io_name[PART_OUT];
@@ -6597,7 +6595,7 @@ create_pty_only(term_T *term, jobopt_T *options)
goto failed;
++term->tl_job->jv_refcount;
- /* behave like the job is already finished */
+ // behave like the job is already finished
term->tl_job->jv_status = JOB_FINISHED;
channel = add_channel();
@@ -6663,9 +6661,8 @@ terminal_enabled(void)
# else
-/**************************************
- * 3. Unix-like implementation.
- */
+///////////////////////////////////////
+// 3. Unix-like implementation.
/*
* Create a new terminal of "rows" by "cols" cells.
@@ -6694,7 +6691,7 @@ term_and_job_init(
init_vterm_ansi_colors(term->tl_vterm);
#endif
- /* This may change a string in "argvar". */
+ // This may change a string in "argvar".
term->tl_job = job_start(argvar, argv, opt, TRUE);
if (term->tl_job != NULL)
++term->tl_job->jv_refcount;
@@ -6715,7 +6712,7 @@ create_pty_only(term_T *term, jobopt_T *opt)
return FAIL;
++term->tl_job->jv_refcount;
- /* behave like the job is already finished */
+ // behave like the job is already finished
term->tl_job->jv_status = JOB_FINISHED;
return mch_create_pty_channel(term->tl_job, opt);
@@ -6738,7 +6735,7 @@ term_free_vterm(term_T *term)
static void
term_report_winsize(term_T *term, int rows, int cols)
{
- /* Use an ioctl() to report the new window size to the job. */
+ // Use an ioctl() to report the new window size to the job.
if (term->tl_job != NULL && term->tl_job->jv_channel != NULL)
{
int fd = -1;
@@ -6757,4 +6754,4 @@ term_report_winsize(term_T *term, int rows, int cols)
# endif
-#endif /* FEAT_TERMINAL */
+#endif // FEAT_TERMINAL