mirror of
https://github.com/neovim/neovim.git
synced 2024-12-27 14:21:31 -07:00
Merge pull request #923 from splinterofchaos/normal-bool
Use bool in normal.h and .c.
This commit is contained in:
commit
b027e1ed0c
@ -740,7 +740,7 @@ char_u *get_key_name(int i)
|
|||||||
* Look up the given mouse code to return the relevant information in the other
|
* Look up the given mouse code to return the relevant information in the other
|
||||||
* arguments. Return which button is down or was released.
|
* arguments. Return which button is down or was released.
|
||||||
*/
|
*/
|
||||||
int get_mouse_button(int code, int *is_click, int *is_drag)
|
int get_mouse_button(int code, bool *is_click, bool *is_drag)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
#ifndef NVIM_NORMAL_H
|
#ifndef NVIM_NORMAL_H
|
||||||
#define NVIM_NORMAL_H
|
#define NVIM_NORMAL_H
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include "nvim/pos.h"
|
#include "nvim/pos.h"
|
||||||
#include "nvim/buffer_defs.h" // for win_T
|
#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 regname; /* register to use for the operator */
|
||||||
int motion_type; /* type of the current cursor motion */
|
int motion_type; /* type of the current cursor motion */
|
||||||
int motion_force; /* force motion type: 'v', 'V' or CTRL-V */
|
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 */
|
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 */
|
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()) */
|
do_format()) */
|
||||||
pos_T start; /* start of the operator */
|
pos_T start; /* start of the operator */
|
||||||
pos_T end; /* end 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
|
long line_count; /* number of lines from op_start to op_end
|
||||||
(inclusive) */
|
(inclusive) */
|
||||||
int empty; /* op_start and op_end the same (only used by
|
bool empty; /* op_start and op_end the same (only used by
|
||||||
do_change()) */
|
op_change()) */
|
||||||
int is_VIsual; /* operator on Visual area */
|
bool is_VIsual; /* operator on Visual area */
|
||||||
int block_mode; /* current operator is Visual block mode */
|
bool block_mode; /* current operator is Visual block mode */
|
||||||
colnr_T start_vcol; /* start col for block mode operator */
|
colnr_T start_vcol; /* start col for block mode operator */
|
||||||
colnr_T end_vcol; /* end col for block mode operator */
|
colnr_T end_vcol; /* end col for block mode operator */
|
||||||
long prev_opcount; /* ca.opcount saved for K_CURSORHOLD */
|
long prev_opcount; /* ca.opcount saved for K_CURSORHOLD */
|
||||||
|
@ -1549,7 +1549,8 @@ int op_delete(oparg_T *oap)
|
|||||||
|
|
||||||
/* Break a tab only when it's included in the area. */
|
/* Break a tab only when it's included in the area. */
|
||||||
if (gchar_pos(&oap->end) == '\t'
|
if (gchar_pos(&oap->end) == '\t'
|
||||||
&& (int)oap->end.coladd < oap->inclusive) {
|
&& oap->end.coladd == 0
|
||||||
|
&& oap->inclusive) {
|
||||||
/* save last line for undo */
|
/* save last line for undo */
|
||||||
if (u_save((linenr_T)(oap->end.lnum - 1),
|
if (u_save((linenr_T)(oap->end.lnum - 1),
|
||||||
(linenr_T)(oap->end.lnum + 1)) == FAIL)
|
(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. */
|
/* Make 'sbr' empty for a moment to get the correct size. */
|
||||||
p_sbr = empty_option;
|
p_sbr = empty_option;
|
||||||
oparg.is_VIsual = 1;
|
oparg.is_VIsual = true;
|
||||||
oparg.block_mode = TRUE;
|
oparg.block_mode = true;
|
||||||
oparg.op_type = OP_NOP;
|
oparg.op_type = OP_NOP;
|
||||||
getvcols(curwin, &min_pos, &max_pos,
|
getvcols(curwin, &min_pos, &max_pos,
|
||||||
&oparg.start_vcol, &oparg.end_vcol);
|
&oparg.start_vcol, &oparg.end_vcol);
|
||||||
|
@ -1137,7 +1137,7 @@ int do_search(
|
|||||||
goto end_do_search;
|
goto end_do_search;
|
||||||
}
|
}
|
||||||
if (spats[0].off.end && oap != NULL)
|
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 */
|
retval = 1; /* pattern found */
|
||||||
|
|
||||||
@ -1324,9 +1324,9 @@ int searchc(cmdarg_T *cap, int t_cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dir == BACKWARD)
|
if (dir == BACKWARD)
|
||||||
cap->oap->inclusive = FALSE;
|
cap->oap->inclusive = false;
|
||||||
else
|
else
|
||||||
cap->oap->inclusive = TRUE;
|
cap->oap->inclusive = true;
|
||||||
|
|
||||||
p = get_cursor_line_ptr();
|
p = get_cursor_line_ptr();
|
||||||
col = curwin->w_cursor.col;
|
col = curwin->w_cursor.col;
|
||||||
@ -2185,9 +2185,9 @@ found:
|
|||||||
* If 'both' is TRUE also stop at '}'.
|
* If 'both' is TRUE also stop at '}'.
|
||||||
* Return TRUE if the next paragraph or section was found.
|
* Return TRUE if the next paragraph or section was found.
|
||||||
*/
|
*/
|
||||||
int
|
bool
|
||||||
findpar (
|
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,
|
int dir,
|
||||||
long count,
|
long count,
|
||||||
int what,
|
int what,
|
||||||
@ -2195,27 +2195,27 @@ findpar (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
linenr_T curr;
|
linenr_T curr;
|
||||||
int did_skip; /* TRUE after separating lines have been skipped */
|
bool did_skip; /* true after separating lines have been skipped */
|
||||||
int first; /* TRUE on first line */
|
bool first; /* true on first line */
|
||||||
int posix = (vim_strchr(p_cpo, CPO_PARA) != NULL);
|
int posix = (vim_strchr(p_cpo, CPO_PARA) != NULL);
|
||||||
linenr_T fold_first; /* first line of a closed fold */
|
linenr_T fold_first; /* first line of a closed fold */
|
||||||
linenr_T fold_last; /* last 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
|
bool fold_skipped; /* true if a closed fold was skipped this
|
||||||
iteration */
|
iteration */
|
||||||
|
|
||||||
curr = curwin->w_cursor.lnum;
|
curr = curwin->w_cursor.lnum;
|
||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
did_skip = FALSE;
|
did_skip = false;
|
||||||
for (first = TRUE;; first = FALSE) {
|
for (first = true;; first = false) {
|
||||||
if (*ml_get(curr) != NUL)
|
if (*ml_get(curr) != NUL)
|
||||||
did_skip = TRUE;
|
did_skip = true;
|
||||||
|
|
||||||
/* skip folded lines */
|
/* skip folded lines */
|
||||||
fold_skipped = FALSE;
|
fold_skipped = false;
|
||||||
if (first && hasFolding(curr, &fold_first, &fold_last)) {
|
if (first && hasFolding(curr, &fold_first, &fold_last)) {
|
||||||
curr = ((dir > 0) ? fold_last : fold_first) + dir;
|
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
|
/* POSIX has it's own ideas of what a paragraph boundary is and it
|
||||||
@ -2230,7 +2230,7 @@ findpar (
|
|||||||
curr -= dir;
|
curr -= dir;
|
||||||
if ((curr += dir) < 1 || curr > curbuf->b_ml.ml_line_count) {
|
if ((curr += dir) < 1 || curr > curbuf->b_ml.ml_line_count) {
|
||||||
if (count)
|
if (count)
|
||||||
return FALSE;
|
return false;
|
||||||
curr -= dir;
|
curr -= dir;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2243,11 +2243,11 @@ findpar (
|
|||||||
if (curr == curbuf->b_ml.ml_line_count && what != '}') {
|
if (curr == curbuf->b_ml.ml_line_count && what != '}') {
|
||||||
if ((curwin->w_cursor.col = (colnr_T)STRLEN(ml_get(curr))) != 0) {
|
if ((curwin->w_cursor.col = (colnr_T)STRLEN(ml_get(curr))) != 0) {
|
||||||
--curwin->w_cursor.col;
|
--curwin->w_cursor.col;
|
||||||
*pincl = TRUE;
|
*pincl = true;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2654,7 +2654,7 @@ current_word (
|
|||||||
{
|
{
|
||||||
pos_T start_pos;
|
pos_T start_pos;
|
||||||
pos_T pos;
|
pos_T pos;
|
||||||
int inclusive = TRUE;
|
bool inclusive = true;
|
||||||
int include_white = FALSE;
|
int include_white = FALSE;
|
||||||
|
|
||||||
cls_bigword = bigword;
|
cls_bigword = bigword;
|
||||||
@ -2702,7 +2702,7 @@ current_word (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (VIsual_active) {
|
if (VIsual_active) {
|
||||||
/* should do something when inclusive == FALSE ! */
|
/* should do something when inclusive == false ! */
|
||||||
VIsual = start_pos;
|
VIsual = start_pos;
|
||||||
redraw_curbuf_later(INVERTED); /* update the inversion */
|
redraw_curbuf_later(INVERTED); /* update the inversion */
|
||||||
} else {
|
} else {
|
||||||
@ -2716,7 +2716,7 @@ current_word (
|
|||||||
* When count is still > 0, extend with more objects.
|
* When count is still > 0, extend with more objects.
|
||||||
*/
|
*/
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
inclusive = TRUE;
|
inclusive = true;
|
||||||
if (VIsual_active && lt(curwin->w_cursor, VIsual)) {
|
if (VIsual_active && lt(curwin->w_cursor, VIsual)) {
|
||||||
/*
|
/*
|
||||||
* In Visual mode, with cursor at start: move cursor back.
|
* In Visual mode, with cursor at start: move cursor back.
|
||||||
@ -2746,7 +2746,7 @@ current_word (
|
|||||||
* Put cursor on last char of white.
|
* Put cursor on last char of white.
|
||||||
*/
|
*/
|
||||||
if (oneleft() == FAIL)
|
if (oneleft() == FAIL)
|
||||||
inclusive = FALSE;
|
inclusive = false;
|
||||||
} else {
|
} else {
|
||||||
if (end_word(1L, bigword, TRUE, TRUE) == FAIL)
|
if (end_word(1L, bigword, TRUE, TRUE) == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -2938,9 +2938,9 @@ extend:
|
|||||||
} else {
|
} else {
|
||||||
/* include a newline after the sentence, if there is one */
|
/* include a newline after the sentence, if there is one */
|
||||||
if (incl(&curwin->w_cursor) == -1)
|
if (incl(&curwin->w_cursor) == -1)
|
||||||
oap->inclusive = TRUE;
|
oap->inclusive = true;
|
||||||
else
|
else
|
||||||
oap->inclusive = FALSE;
|
oap->inclusive = false;
|
||||||
oap->start = start_pos;
|
oap->start = start_pos;
|
||||||
oap->motion_type = MCHAR;
|
oap->motion_type = MCHAR;
|
||||||
}
|
}
|
||||||
@ -3065,12 +3065,12 @@ current_block (
|
|||||||
} else {
|
} else {
|
||||||
oap->start = start_pos;
|
oap->start = start_pos;
|
||||||
oap->motion_type = MCHAR;
|
oap->motion_type = MCHAR;
|
||||||
oap->inclusive = FALSE;
|
oap->inclusive = false;
|
||||||
if (sol)
|
if (sol)
|
||||||
incl(&curwin->w_cursor);
|
incl(&curwin->w_cursor);
|
||||||
else if (ltoreq(start_pos, curwin->w_cursor))
|
else if (ltoreq(start_pos, curwin->w_cursor))
|
||||||
/* Include the character under the cursor. */
|
/* Include the character under the cursor. */
|
||||||
oap->inclusive = TRUE;
|
oap->inclusive = true;
|
||||||
else
|
else
|
||||||
/* End is before the start (no text in between <>, [], etc.): don't
|
/* End is before the start (no text in between <>, [], etc.): don't
|
||||||
* operate on any text. */
|
* operate on any text. */
|
||||||
@ -3307,9 +3307,9 @@ again:
|
|||||||
/* End is before the start: there is no text between tags; operate
|
/* End is before the start: there is no text between tags; operate
|
||||||
* on an empty area. */
|
* on an empty area. */
|
||||||
curwin->w_cursor = start_pos;
|
curwin->w_cursor = start_pos;
|
||||||
oap->inclusive = FALSE;
|
oap->inclusive = false;
|
||||||
} else
|
} else
|
||||||
oap->inclusive = TRUE;
|
oap->inclusive = true;
|
||||||
}
|
}
|
||||||
retval = OK;
|
retval = OK;
|
||||||
|
|
||||||
@ -3554,7 +3554,7 @@ current_quote (
|
|||||||
char_u *line = get_cursor_line_ptr();
|
char_u *line = get_cursor_line_ptr();
|
||||||
int col_end;
|
int col_end;
|
||||||
int col_start = curwin->w_cursor.col;
|
int col_start = curwin->w_cursor.col;
|
||||||
int inclusive = FALSE;
|
bool inclusive = false;
|
||||||
int vis_empty = TRUE; /* Visual selection <= 1 char */
|
int vis_empty = TRUE; /* Visual selection <= 1 char */
|
||||||
int vis_bef_curs = FALSE; /* Visual starts before cursor */
|
int vis_bef_curs = FALSE; /* Visual starts before cursor */
|
||||||
int inside_quotes = FALSE; /* Looks like "i'" done before */
|
int inside_quotes = FALSE; /* Looks like "i'" done before */
|
||||||
@ -3717,7 +3717,7 @@ current_quote (
|
|||||||
/* After vi" another i" must include the ". */
|
/* After vi" another i" must include the ". */
|
||||||
|| (!vis_empty && inside_quotes)
|
|| (!vis_empty && inside_quotes)
|
||||||
) && inc_cursor() == 2)
|
) && inc_cursor() == 2)
|
||||||
inclusive = TRUE;
|
inclusive = true;
|
||||||
if (VIsual_active) {
|
if (VIsual_active) {
|
||||||
if (vis_empty || vis_bef_curs) {
|
if (vis_empty || vis_bef_curs) {
|
||||||
/* decrement cursor when 'selection' is not exclusive */
|
/* decrement cursor when 'selection' is not exclusive */
|
||||||
|
@ -307,7 +307,7 @@ int check_row(int row)
|
|||||||
int
|
int
|
||||||
jump_to_mouse (
|
jump_to_mouse (
|
||||||
int flags,
|
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 */
|
int which_button /* MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -575,10 +575,10 @@ retnomove:
|
|||||||
curwin->w_set_curswant = FALSE; /* May still have been TRUE */
|
curwin->w_set_curswant = FALSE; /* May still have been TRUE */
|
||||||
if (coladvance(col) == FAIL) { /* Mouse click beyond end of line */
|
if (coladvance(col) == FAIL) { /* Mouse click beyond end of line */
|
||||||
if (inclusive != NULL)
|
if (inclusive != NULL)
|
||||||
*inclusive = TRUE;
|
*inclusive = true;
|
||||||
mouse_past_eol = true;
|
mouse_past_eol = true;
|
||||||
} else if (inclusive != NULL)
|
} else if (inclusive != NULL)
|
||||||
*inclusive = FALSE;
|
*inclusive = false;
|
||||||
|
|
||||||
count = IN_BUFFER;
|
count = IN_BUFFER;
|
||||||
if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum
|
if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum
|
||||||
|
Loading…
Reference in New Issue
Block a user