aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/normal.c88
-rw-r--r--src/nvim/normal.h15
-rw-r--r--src/nvim/ops.c7
-rw-r--r--src/nvim/search.c58
-rw-r--r--src/nvim/ui.c6
5 files changed, 88 insertions, 86 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 5d9af0cf34..7338cb91a5 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1122,7 +1122,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
/* If the motion was linewise, "inclusive" will not have been set.
* Use "exclusive" to be consistent. Makes "dvj" work nice. */
if (oap->motion_type == MLINE)
- oap->inclusive = FALSE;
+ oap->inclusive = false;
/* If the motion already was characterwise, toggle "inclusive" */
else if (oap->motion_type == MCHAR)
oap->inclusive = !oap->inclusive;
@@ -1285,7 +1285,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
if (VIsual_mode == Ctrl_V) { /* block mode */
colnr_T start, end;
- oap->block_mode = TRUE;
+ oap->block_mode = true;
getvvcol(curwin, &(oap->start),
&oap->start_vcol, NULL, &oap->end_vcol);
@@ -1389,12 +1389,12 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
}
/*
- * oap->inclusive defaults to TRUE.
+ * oap->inclusive defaults to true.
* If oap->end is on a NUL (empty line) oap->inclusive becomes
- * FALSE. This makes "d}P" and "v}dP" work the same.
+ * false. This makes "d}P" and "v}dP" work the same.
*/
if (oap->motion_force == NUL || oap->motion_type == MLINE)
- oap->inclusive = TRUE;
+ oap->inclusive = true;
if (VIsual_mode == 'V')
oap->motion_type = MLINE;
else {
@@ -1402,7 +1402,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
if (VIsual_mode != Ctrl_V && *ml_get_pos(&(oap->end)) == NUL
&& (include_line_break || !virtual_op)
) {
- oap->inclusive = FALSE;
+ oap->inclusive = false;
/* Try to include the newline, unless it's an operator
* that works on lines only. */
if (*p_sel != 'o' && !op_on_lines(oap->op_type)) {
@@ -1415,7 +1415,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
/* Cannot move below the last line, make the op
* inclusive to tell the operation to include the
* line break. */
- oap->inclusive = TRUE;
+ oap->inclusive = true;
}
}
}
@@ -1484,19 +1484,19 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
/*
* If the end of an operator is in column one while oap->motion_type
- * is MCHAR and oap->inclusive is FALSE, we put op_end after the last
+ * is MCHAR and oap->inclusive is false, we put op_end after the last
* character in the previous line. If op_start is on or before the
* first non-blank in the line, the operator becomes linewise
* (strange, but that's the way vi does it).
*/
if ( oap->motion_type == MCHAR
- && oap->inclusive == FALSE
+ && oap->inclusive == false
&& !(cap->retval & CA_NO_ADJ_OP_END)
&& oap->end.col == 0
&& (!oap->is_VIsual || *p_sel == 'o')
&& !oap->block_mode
&& oap->line_count > 1) {
- oap->end_adjusted = TRUE; /* remember that we did this */
+ oap->end_adjusted = true; /* remember that we did this */
--oap->line_count;
--oap->end.lnum;
if (inindent(0))
@@ -1505,11 +1505,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
oap->end.col = (colnr_T)STRLEN(ml_get(oap->end.lnum));
if (oap->end.col) {
--oap->end.col;
- oap->inclusive = TRUE;
+ oap->inclusive = true;
}
}
} else
- oap->end_adjusted = FALSE;
+ oap->end_adjusted = false;
switch (oap->op_type) {
case OP_LSHIFT:
@@ -1708,7 +1708,7 @@ void do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
} else {
curwin->w_cursor = old_cursor;
}
- oap->block_mode = FALSE;
+ oap->block_mode = false;
clearop(oap);
}
}
@@ -2808,7 +2808,7 @@ static void clearop(oparg_T *oap)
oap->op_type = OP_NOP;
oap->regname = 0;
oap->motion_force = NUL;
- oap->use_reg_one = FALSE;
+ oap->use_reg_one = false;
}
static void clearopbeep(oparg_T *oap)
@@ -3285,7 +3285,7 @@ find_decl (
bool save_p_ws;
int save_p_scs;
int retval = OK;
- int incll;
+ bool incll;
pat = xmalloc(len + 7);
@@ -4059,7 +4059,7 @@ static void nv_colon(cmdarg_T *cap)
if (cap->oap->op_type != OP_NOP) {
/* Using ":" as a movement is characterwise exclusive. */
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
} else if (cap->count0) {
/* translate "count:" into ":.,.+(count - 1)" */
stuffcharReadbuff('.');
@@ -4535,7 +4535,7 @@ static void nv_right(cmdarg_T *cap)
}
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
PAST_LINE = (VIsual_active && *p_sel != 'o');
/*
@@ -4567,13 +4567,13 @@ static void nv_right(cmdarg_T *cap)
if ( cap->oap->op_type != OP_NOP
&& !cap->oap->inclusive
&& !lineempty(curwin->w_cursor.lnum))
- cap->oap->inclusive = TRUE;
+ cap->oap->inclusive = true;
else {
++curwin->w_cursor.lnum;
curwin->w_cursor.col = 0;
curwin->w_cursor.coladd = 0;
curwin->w_set_curswant = TRUE;
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
}
continue;
}
@@ -4583,7 +4583,7 @@ static void nv_right(cmdarg_T *cap)
beep_flush();
} else {
if (!lineempty(curwin->w_cursor.lnum))
- cap->oap->inclusive = TRUE;
+ cap->oap->inclusive = true;
}
break;
} else if (PAST_LINE) {
@@ -4622,7 +4622,7 @@ static void nv_left(cmdarg_T *cap)
}
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
for (n = cap->count1; n > 0; --n) {
if (oneleft() == FAIL) {
/* <BS> and <Del> wrap to previous line if 'whichwrap' has 'b'.
@@ -4778,7 +4778,7 @@ static void nv_end(cmdarg_T *cap)
static void nv_dollar(cmdarg_T *cap)
{
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = TRUE;
+ cap->oap->inclusive = true;
/* In virtual mode when off the edge of a line and an operator
* is pending (whew!) keep the cursor where it is.
* Otherwise, send it to the end of the line. */
@@ -4843,8 +4843,8 @@ normal_search (
int i;
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = FALSE;
- cap->oap->use_reg_one = TRUE;
+ cap->oap->inclusive = false;
+ cap->oap->use_reg_one = true;
curwin->w_set_curswant = TRUE;
i = do_search(cap->oap, dir, pat, cap->count1,
@@ -4915,7 +4915,7 @@ static void nv_brackets(cmdarg_T *cap)
int c;
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
old_pos = curwin->w_cursor;
curwin->w_cursor.coladd = 0; /* TODO: don't do this for an error. */
@@ -5199,7 +5199,7 @@ static void nv_percent(cmdarg_T *cap)
pos_T *pos;
linenr_T lnum = curwin->w_cursor.lnum;
- cap->oap->inclusive = TRUE;
+ cap->oap->inclusive = true;
if (cap->count0) { /* {cnt}% : goto {cnt} percentage in file */
if (cap->count0 > 100)
clearopbeep(cap->oap);
@@ -5220,7 +5220,7 @@ static void nv_percent(cmdarg_T *cap)
}
} else { /* "%" : go to matching paren */
cap->oap->motion_type = MCHAR;
- cap->oap->use_reg_one = TRUE;
+ cap->oap->use_reg_one = true;
if ((pos = findmatch(cap->oap, NUL)) == NULL)
clearopbeep(cap->oap);
else {
@@ -5245,9 +5245,9 @@ static void nv_percent(cmdarg_T *cap)
static void nv_brace(cmdarg_T *cap)
{
cap->oap->motion_type = MCHAR;
- cap->oap->use_reg_one = TRUE;
+ cap->oap->use_reg_one = true;
/* The motion used to be inclusive for "(", but that is not what Vi does. */
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
curwin->w_set_curswant = TRUE;
if (findsent(cap->arg, cap->count1) == FAIL)
@@ -5279,8 +5279,8 @@ static void nv_mark(cmdarg_T *cap)
static void nv_findpar(cmdarg_T *cap)
{
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = FALSE;
- cap->oap->use_reg_one = TRUE;
+ cap->oap->inclusive = false;
+ cap->oap->use_reg_one = true;
curwin->w_set_curswant = TRUE;
if (!findpar(&cap->oap->inclusive, cap->arg, cap->count1, NUL, FALSE))
clearopbeep(cap->oap);
@@ -5653,8 +5653,8 @@ static void nv_cursormark(cmdarg_T *cap, int flag, pos_T *pos)
}
cap->oap->motion_type = flag ? MLINE : MCHAR;
if (cap->cmdchar == '`')
- cap->oap->use_reg_one = TRUE;
- cap->oap->inclusive = FALSE; /* ignored if not MCHAR */
+ cap->oap->use_reg_one = true;
+ cap->oap->inclusive = false; /* ignored if not MCHAR */
curwin->w_set_curswant = TRUE;
}
@@ -6173,7 +6173,7 @@ static void nv_g_cmd(cmdarg_T *cap)
case K_HOME:
case K_KHOME:
oap->motion_type = MCHAR;
- oap->inclusive = FALSE;
+ oap->inclusive = false;
if (curwin->w_p_wrap
&& curwin->w_width != 0
) {
@@ -6206,7 +6206,7 @@ static void nv_g_cmd(cmdarg_T *cap)
/* "g_": to the last non-blank character in the line or <count> lines
* downward. */
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = TRUE;
+ cap->oap->inclusive = true;
curwin->w_curswant = MAXCOL;
if (cursor_down((long)(cap->count1 - 1),
cap->oap->op_type == OP_NOP) == FAIL)
@@ -6234,7 +6234,7 @@ static void nv_g_cmd(cmdarg_T *cap)
int col_off = curwin_col_off();
oap->motion_type = MCHAR;
- oap->inclusive = TRUE;
+ oap->inclusive = true;
if (curwin->w_p_wrap
&& curwin->w_width != 0
) {
@@ -6297,7 +6297,7 @@ static void nv_g_cmd(cmdarg_T *cap)
case 'E':
oap->motion_type = MCHAR;
curwin->w_set_curswant = TRUE;
- oap->inclusive = TRUE;
+ oap->inclusive = true;
if (bckend_word(cap->count1, cap->nchar == 'E', FALSE) == FAIL)
clearopbeep(oap);
break;
@@ -6682,7 +6682,7 @@ static void nv_home(cmdarg_T *cap)
static void nv_pipe(cmdarg_T *cap)
{
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
beginline(0);
if (cap->count0 > 0) {
coladvance((colnr_T)(cap->count0 - 1));
@@ -6701,7 +6701,7 @@ static void nv_pipe(cmdarg_T *cap)
static void nv_bck_word(cmdarg_T *cap)
{
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
curwin->w_set_curswant = TRUE;
if (bck_word(cap->count1, cap->arg, FALSE) == FAIL)
clearopbeep(cap->oap);
@@ -6743,7 +6743,7 @@ static void nv_wordcmd(cmdarg_T *cap)
* in 'cpoptions'.
*/
if (cap->count1 == 1 && vim_strchr(p_cpo, CPO_CW) != NULL) {
- cap->oap->inclusive = TRUE;
+ cap->oap->inclusive = true;
cap->oap->motion_type = MCHAR;
return;
}
@@ -6759,7 +6759,7 @@ static void nv_wordcmd(cmdarg_T *cap)
* will change only one character! This is done by setting
* flag.
*/
- cap->oap->inclusive = TRUE;
+ cap->oap->inclusive = true;
word_end = true;
flag = TRUE;
}
@@ -6807,7 +6807,7 @@ static void adjust_cursor(oparg_T *oap)
/* prevent cursor from moving on the trail byte */
if (has_mbyte)
mb_adjust_cursor();
- oap->inclusive = TRUE;
+ oap->inclusive = true;
}
}
@@ -6818,7 +6818,7 @@ static void adjust_cursor(oparg_T *oap)
static void nv_beginline(cmdarg_T *cap)
{
cap->oap->motion_type = MCHAR;
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
beginline(cap->arg);
if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
foldOpenCursor();
@@ -6837,7 +6837,7 @@ static void adjust_for_sel(cmdarg_T *cap)
inc_cursor();
else
++curwin->w_cursor.col;
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
}
}
diff --git a/src/nvim/normal.h b/src/nvim/normal.h
index 599f4771b9..b71487c30c 100644
--- a/src/nvim/normal.h
+++ b/src/nvim/normal.h
@@ -1,6 +1,7 @@
#ifndef NVIM_NORMAL_H
#define NVIM_NORMAL_H
+#include <stdbool.h>
#include "nvim/pos.h"
#include "nvim/buffer_defs.h" // for win_T
@@ -17,11 +18,11 @@ typedef struct oparg_S {
int regname; /* register to use for the operator */
int motion_type; /* type of the current cursor motion */
int motion_force; /* force motion type: 'v', 'V' or CTRL-V */
- int use_reg_one; /* TRUE if delete uses reg 1 even when not
+ bool use_reg_one; /* true if delete uses reg 1 even when not
linewise */
- int inclusive; /* TRUE if char motion is inclusive (only
+ bool inclusive; /* true if char motion is inclusive (only
valid when motion_type is MCHAR */
- int end_adjusted; /* backuped b_op_end one char (only used by
+ bool end_adjusted; /* backuped b_op_end one char (only used by
do_format()) */
pos_T start; /* start of the operator */
pos_T end; /* end of the operator */
@@ -29,10 +30,10 @@ typedef struct oparg_S {
long line_count; /* number of lines from op_start to op_end
(inclusive) */
- int empty; /* op_start and op_end the same (only used by
- do_change()) */
- int is_VIsual; /* operator on Visual area */
- int block_mode; /* current operator is Visual block mode */
+ bool empty; /* op_start and op_end the same (only used by
+ op_change()) */
+ bool is_VIsual; /* operator on Visual area */
+ bool block_mode; /* current operator is Visual block mode */
colnr_T start_vcol; /* start col for block mode operator */
colnr_T end_vcol; /* end col for block mode operator */
long prev_opcount; /* ca.opcount saved for K_CURSORHOLD */
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index e7079e02d0..2523e21c42 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -1549,7 +1549,8 @@ int op_delete(oparg_T *oap)
/* Break a tab only when it's included in the area. */
if (gchar_pos(&oap->end) == '\t'
- && (int)oap->end.coladd < oap->inclusive) {
+ && oap->end.coladd == 0
+ && oap->inclusive) {
/* save last line for undo */
if (u_save((linenr_T)(oap->end.lnum - 1),
(linenr_T)(oap->end.lnum + 1)) == FAIL)
@@ -5058,8 +5059,8 @@ void cursor_pos_info(void)
/* Make 'sbr' empty for a moment to get the correct size. */
p_sbr = empty_option;
- oparg.is_VIsual = 1;
- oparg.block_mode = TRUE;
+ oparg.is_VIsual = true;
+ oparg.block_mode = true;
oparg.op_type = OP_NOP;
getvcols(curwin, &min_pos, &max_pos,
&oparg.start_vcol, &oparg.end_vcol);
diff --git a/src/nvim/search.c b/src/nvim/search.c
index b0a782a515..1e275e9753 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -1137,7 +1137,7 @@ int do_search(
goto end_do_search;
}
if (spats[0].off.end && oap != NULL)
- oap->inclusive = TRUE; /* 'e' includes last character */
+ oap->inclusive = true; /* 'e' includes last character */
retval = 1; /* pattern found */
@@ -1324,9 +1324,9 @@ int searchc(cmdarg_T *cap, int t_cmd)
}
if (dir == BACKWARD)
- cap->oap->inclusive = FALSE;
+ cap->oap->inclusive = false;
else
- cap->oap->inclusive = TRUE;
+ cap->oap->inclusive = true;
p = get_cursor_line_ptr();
col = curwin->w_cursor.col;
@@ -2185,9 +2185,9 @@ found:
* If 'both' is TRUE also stop at '}'.
* Return TRUE if the next paragraph or section was found.
*/
-int
+bool
findpar (
- int *pincl, /* Return: TRUE if last char is to be included */
+ bool *pincl, /* Return: true if last char is to be included */
int dir,
long count,
int what,
@@ -2195,27 +2195,27 @@ findpar (
)
{
linenr_T curr;
- int did_skip; /* TRUE after separating lines have been skipped */
- int first; /* TRUE on first line */
+ bool did_skip; /* true after separating lines have been skipped */
+ bool first; /* true on first line */
int posix = (vim_strchr(p_cpo, CPO_PARA) != NULL);
linenr_T fold_first; /* first line of a closed fold */
linenr_T fold_last; /* last line of a closed fold */
- int fold_skipped; /* TRUE if a closed fold was skipped this
- iteration */
+ bool fold_skipped; /* true if a closed fold was skipped this
+ iteration */
curr = curwin->w_cursor.lnum;
while (count--) {
- did_skip = FALSE;
- for (first = TRUE;; first = FALSE) {
+ did_skip = false;
+ for (first = true;; first = false) {
if (*ml_get(curr) != NUL)
- did_skip = TRUE;
+ did_skip = true;
/* skip folded lines */
- fold_skipped = FALSE;
+ fold_skipped = false;
if (first && hasFolding(curr, &fold_first, &fold_last)) {
curr = ((dir > 0) ? fold_last : fold_first) + dir;
- fold_skipped = TRUE;
+ fold_skipped = true;
}
/* POSIX has it's own ideas of what a paragraph boundary is and it
@@ -2230,7 +2230,7 @@ findpar (
curr -= dir;
if ((curr += dir) < 1 || curr > curbuf->b_ml.ml_line_count) {
if (count)
- return FALSE;
+ return false;
curr -= dir;
break;
}
@@ -2243,11 +2243,11 @@ findpar (
if (curr == curbuf->b_ml.ml_line_count && what != '}') {
if ((curwin->w_cursor.col = (colnr_T)STRLEN(ml_get(curr))) != 0) {
--curwin->w_cursor.col;
- *pincl = TRUE;
+ *pincl = true;
}
} else
curwin->w_cursor.col = 0;
- return TRUE;
+ return true;
}
/*
@@ -2654,7 +2654,7 @@ current_word (
{
pos_T start_pos;
pos_T pos;
- int inclusive = TRUE;
+ bool inclusive = true;
int include_white = FALSE;
cls_bigword = bigword;
@@ -2702,7 +2702,7 @@ current_word (
}
if (VIsual_active) {
- /* should do something when inclusive == FALSE ! */
+ /* should do something when inclusive == false ! */
VIsual = start_pos;
redraw_curbuf_later(INVERTED); /* update the inversion */
} else {
@@ -2716,7 +2716,7 @@ current_word (
* When count is still > 0, extend with more objects.
*/
while (count > 0) {
- inclusive = TRUE;
+ inclusive = true;
if (VIsual_active && lt(curwin->w_cursor, VIsual)) {
/*
* In Visual mode, with cursor at start: move cursor back.
@@ -2746,7 +2746,7 @@ current_word (
* Put cursor on last char of white.
*/
if (oneleft() == FAIL)
- inclusive = FALSE;
+ inclusive = false;
} else {
if (end_word(1L, bigword, TRUE, TRUE) == FAIL)
return FAIL;
@@ -2938,9 +2938,9 @@ extend:
} else {
/* include a newline after the sentence, if there is one */
if (incl(&curwin->w_cursor) == -1)
- oap->inclusive = TRUE;
+ oap->inclusive = true;
else
- oap->inclusive = FALSE;
+ oap->inclusive = false;
oap->start = start_pos;
oap->motion_type = MCHAR;
}
@@ -3065,12 +3065,12 @@ current_block (
} else {
oap->start = start_pos;
oap->motion_type = MCHAR;
- oap->inclusive = FALSE;
+ oap->inclusive = false;
if (sol)
incl(&curwin->w_cursor);
else if (ltoreq(start_pos, curwin->w_cursor))
/* Include the character under the cursor. */
- oap->inclusive = TRUE;
+ oap->inclusive = true;
else
/* End is before the start (no text in between <>, [], etc.): don't
* operate on any text. */
@@ -3307,9 +3307,9 @@ again:
/* End is before the start: there is no text between tags; operate
* on an empty area. */
curwin->w_cursor = start_pos;
- oap->inclusive = FALSE;
+ oap->inclusive = false;
} else
- oap->inclusive = TRUE;
+ oap->inclusive = true;
}
retval = OK;
@@ -3554,7 +3554,7 @@ current_quote (
char_u *line = get_cursor_line_ptr();
int col_end;
int col_start = curwin->w_cursor.col;
- int inclusive = FALSE;
+ bool inclusive = false;
int vis_empty = TRUE; /* Visual selection <= 1 char */
int vis_bef_curs = FALSE; /* Visual starts before cursor */
int inside_quotes = FALSE; /* Looks like "i'" done before */
@@ -3717,7 +3717,7 @@ current_quote (
/* After vi" another i" must include the ". */
|| (!vis_empty && inside_quotes)
) && inc_cursor() == 2)
- inclusive = TRUE;
+ inclusive = true;
if (VIsual_active) {
if (vis_empty || vis_bef_curs) {
/* decrement cursor when 'selection' is not exclusive */
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 2c5f7158f6..d6269897d7 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -307,7 +307,7 @@ int check_row(int row)
int
jump_to_mouse (
int flags,
- int *inclusive, /* used for inclusive operator, can be NULL */
+ bool *inclusive, /* used for inclusive operator, can be NULL */
int which_button /* MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE */
)
{
@@ -575,10 +575,10 @@ retnomove:
curwin->w_set_curswant = FALSE; /* May still have been TRUE */
if (coladvance(col) == FAIL) { /* Mouse click beyond end of line */
if (inclusive != NULL)
- *inclusive = TRUE;
+ *inclusive = true;
mouse_past_eol = true;
} else if (inclusive != NULL)
- *inclusive = FALSE;
+ *inclusive = false;
count = IN_BUFFER;
if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum