aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/ex_cmds2.c35
-rw-r--r--src/nvim/fold.c12
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/mark.c31
-rw-r--r--src/nvim/normal.c5
-rw-r--r--src/nvim/ops.c10
-rw-r--r--src/nvim/option.c10
-rw-r--r--src/nvim/quickfix.c65
-rw-r--r--src/nvim/screen.c80
-rw-r--r--src/nvim/syntax.c17
-rw-r--r--src/nvim/undo.c8
-rw-r--r--src/nvim/window.c17
12 files changed, 138 insertions, 154 deletions
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index ac91b2a6ac..fdf225c073 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -1206,7 +1206,6 @@ check_changed_any (
int bufcount = 0;
int *bufnrs;
tabpage_T *tp;
- win_T *wp;
FOR_ALL_BUFFERS(buf) {
++bufcount;
@@ -1220,15 +1219,21 @@ check_changed_any (
/* curbuf */
bufnrs[bufnum++] = curbuf->b_fnum;
/* buf in curtab */
- FOR_ALL_WINDOWS(wp)
- if (wp->w_buffer != curbuf)
- add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_buffer != curbuf) {
+ add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
+ }
+ }
/* buf in other tab */
- for (tp = first_tabpage; tp != NULL; tp = tp->tp_next)
- if (tp != curtab)
- for (wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next)
+ for (tp = first_tabpage; tp != NULL; tp = tp->tp_next) {
+ if (tp != curtab) {
+ for (wint_T *wp = tp->tp_firstwin; wp != NULL; wp = wp->w_next) {
add_bufnum(bufnrs, &bufnum, wp->w_buffer->b_fnum);
+ }
+ }
+ }
+
/* any other buf */
FOR_ALL_BUFFERS(buf) {
add_bufnum(bufnrs, &bufnum, buf->b_fnum);
@@ -1278,14 +1283,16 @@ check_changed_any (
/* Try to find a window that contains the buffer. */
if (buf != curbuf)
- FOR_ALL_TAB_WINDOWS(tp, wp)
- if (wp->w_buffer == buf) {
- goto_tabpage_win(tp, wp);
- /* Paranoia: did autocms wipe out the buffer with changes? */
- if (!buf_valid(buf)) {
- goto theend;
+ wint_T *wp;
+ FOR_ALL_TAB_WINDOWS(tp, wp) {
+ if (wp->w_buffer == buf) {
+ goto_tabpage_win(tp, wp);
+ /* Paranoia: did autocms wipe out the buffer with changes? */
+ if (!buf_valid(buf)) {
+ goto theend;
+ }
+ goto buf_found;
}
- goto buf_found;
}
buf_found:
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index f65bbc0875..186e75981e 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -460,13 +460,10 @@ void newFoldLevel(void)
newFoldLevelWin(curwin);
if (foldmethodIsDiff(curwin) && curwin->w_p_scb) {
- win_T *wp;
-
/*
* Set the same foldlevel in other windows in diff mode.
*/
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) {
wp->w_p_fdl = curwin->w_p_fdl;
newFoldLevelWin(wp);
@@ -1140,19 +1137,18 @@ setManualFold (
)
{
if (foldmethodIsDiff(curwin) && curwin->w_p_scb) {
- win_T *wp;
linenr_T dlnum;
/*
* Do the same operation in other windows in diff mode. Calculate the
* line number from the diffs.
*/
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) {
dlnum = diff_lnum_win(curwin->w_cursor.lnum, wp);
- if (dlnum != 0)
+ if (dlnum != 0) {
(void)setManualFoldWin(wp, dlnum, opening, recurse, NULL);
+ }
}
}
}
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index 1ff8887598..3b9a9ae64b 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -519,7 +519,7 @@ EXTERN win_T *firstwin; /* first window */
EXTERN win_T *lastwin; /* last window */
EXTERN win_T *prevwin INIT(= NULL); /* previous window */
# define W_NEXT(wp) ((wp)->w_next)
-# define FOR_ALL_WINDOWS(wp) for (wp = firstwin; wp != NULL; wp = wp->w_next)
+# define FOR_ALL_WINDOWS(wp) for (win_T *wp = firstwin; wp != NULL; wp = wp->w_next)
/*
* When using this macro "break" only breaks out of the inner loop. Use "goto"
* to break out of the tabpage loop.
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index 43469cab45..6339cf8275 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -500,7 +500,6 @@ void fmarks_check_names(buf_T *buf)
{
char_u *name;
int i;
- win_T *wp;
if (buf->b_ffname == NULL)
return;
@@ -512,10 +511,10 @@ void fmarks_check_names(buf_T *buf)
for (i = 0; i < NMARKS + EXTRA_MARKS; ++i)
fmarks_check_one(&namedfm[i], name, buf);
- FOR_ALL_WINDOWS(wp)
- {
- for (i = 0; i < wp->w_jumplistlen; ++i)
+ FOR_ALL_WINDOWS(wp) {
+ for (i = 0; i < wp->w_jumplistlen; ++i) {
fmarks_check_one(&wp->w_jumplist[i], name, buf);
+ }
}
free(name);
@@ -1042,7 +1041,6 @@ void mark_col_adjust(linenr_T lnum, colnr_T mincol, long lnum_amount, long col_a
{
int i;
int fnum = curbuf->b_fnum;
- win_T *win;
pos_T *posp;
if ((col_amount == 0L && lnum_amount == 0L) || cmdmod.lockmarks)
@@ -1085,22 +1083,26 @@ void mark_col_adjust(linenr_T lnum, colnr_T mincol, long lnum_amount, long col_a
/*
* Adjust items in all windows related to the current buffer.
*/
- FOR_ALL_WINDOWS(win)
- {
+ FOR_ALL_WINDOWS(win) {
/* marks in the jumplist */
- for (i = 0; i < win->w_jumplistlen; ++i)
- if (win->w_jumplist[i].fmark.fnum == fnum)
+ for (i = 0; i < win->w_jumplistlen; ++i) {
+ if (win->w_jumplist[i].fmark.fnum == fnum) {
col_adjust(&(win->w_jumplist[i].fmark.mark));
+ }
+ }
if (win->w_buffer == curbuf) {
/* marks in the tag stack */
- for (i = 0; i < win->w_tagstacklen; i++)
- if (win->w_tagstack[i].fmark.fnum == fnum)
+ for (i = 0; i < win->w_tagstacklen; i++) {
+ if (win->w_tagstack[i].fmark.fnum == fnum) {
col_adjust(&(win->w_tagstack[i].fmark.mark));
+ }
+ }
/* cursor position for other windows with the same buffer */
- if (win != curwin)
+ if (win != curwin) {
col_adjust(&win->w_cursor);
+ }
}
}
}
@@ -1526,10 +1528,7 @@ void copy_viminfo_marks(vir_T *virp, FILE *fp_out, int count, int eof, int flags
fputs((char *)line, fp_out);
}
if (load_marks) {
- win_T *wp;
-
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
if (wp->w_buffer == curbuf)
wp->w_changelistidx = curbuf->b_changelistlen;
}
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 55b86f61dd..cc82630548 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -4008,12 +4008,9 @@ dozet:
/* Redraw when 'foldenable' changed */
if (old_fen != curwin->w_p_fen) {
- win_T *wp;
-
if (foldmethodIsDiff(curwin) && curwin->w_p_scb) {
/* Adjust 'foldenable' in diff-synced windows. */
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
if (wp != curwin && foldmethodIsDiff(wp) && wp->w_p_scb) {
wp->w_p_fen = curwin->w_p_fen;
changed_window_setting_win(wp);
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index f1cb34577b..317d773748 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -3698,17 +3698,15 @@ op_format (
}
if (oap->is_VIsual) {
- win_T *wp;
-
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
if (wp->w_old_cursor_lnum != 0) {
/* When lines have been inserted or deleted, adjust the end of
* the Visual area to be redrawn. */
- if (wp->w_old_cursor_lnum > wp->w_old_visual_lnum)
+ if (wp->w_old_cursor_lnum > wp->w_old_visual_lnum) {
wp->w_old_cursor_lnum += old_line_count;
- else
+ } else {
wp->w_old_visual_lnum += old_line_count;
+ }
}
}
}
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 6eac1033c4..273e4cf0c0 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -4306,7 +4306,6 @@ did_set_string_option (
/* When 'spelllang' or 'spellfile' is set and there is a window for this
* buffer in which 'spell' is set load the wordlists. */
else if (varp == &(curbuf->b_s.b_p_spl) || varp == &(curbuf->b_s.b_p_spf)) {
- win_T *wp;
int l;
if (varp == &(curbuf->b_s.b_p_spf)) {
@@ -4317,10 +4316,11 @@ did_set_string_option (
}
if (errmsg == NULL) {
- FOR_ALL_WINDOWS(wp)
- if (wp->w_buffer == curbuf && wp->w_p_spell) {
- errmsg = did_set_spelllang(wp);
- break;
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_buffer == curbuf && wp->w_p_spell) {
+ errmsg = did_set_spelllang(wp);
+ break;
+ }
}
}
}
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 876d4e73d1..bbd837fda9 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -1294,7 +1294,7 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit)
int len;
int old_KeyTyped = KeyTyped; /* getting file may reset it */
int ok = OK;
- int usable_win;
+ bool usable_win;
if (qi == NULL)
qi = &ql_info;
@@ -1433,26 +1433,29 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit)
if (qf_ptr->qf_fnum == 0)
goto theend;
- usable_win = 0;
+ usable_win = false;
ll_ref = curwin->w_llist_ref;
if (ll_ref != NULL) {
/* Find a window using the same location list that is not a
* quickfix window. */
- FOR_ALL_WINDOWS(usable_win_ptr)
- if (usable_win_ptr->w_llist == ll_ref
- && usable_win_ptr->w_buffer->b_p_bt[0] != 'q') {
- usable_win = 1;
- break;
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_llist == ll_ref
+ && wp->w_buffer->b_p_bt[0] != 'q') {
+ usable_win = true;
+ usable_win_ptr = wp;
+ break;
+ }
}
}
if (!usable_win) {
/* Locate a window showing a normal buffer */
- FOR_ALL_WINDOWS(win)
- if (win->w_buffer->b_p_bt[0] == NUL) {
- usable_win = 1;
- break;
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_buffer->b_p_bt[0] == NUL) {
+ usable_win = true;
+ break;
+ }
}
}
@@ -1468,7 +1471,7 @@ void qf_jump(qf_info_T *qi, int dir, int errornr, int forceit)
{
if (wp->w_buffer->b_fnum == qf_ptr->qf_fnum) {
goto_tabpage_win(tp, wp);
- usable_win = 1;
+ usable_win = true;
goto win_found;
}
}
@@ -1501,9 +1504,12 @@ win_found:
win = usable_win_ptr;
if (win == NULL) {
/* Find the window showing the selected file */
- FOR_ALL_WINDOWS(win)
- if (win->w_buffer->b_fnum == qf_ptr->qf_fnum)
- break;
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_buffer->b_fnum == qf_ptr->qf_fnum) {
+ win = wp;
+ break;
+ }
+ }
if (win == NULL) {
/* Find a previous usable window */
win = curwin;
@@ -2212,13 +2218,13 @@ static int is_qf_win(win_T *win, qf_info_T *qi)
*/
static win_T *qf_find_win(qf_info_T *qi)
{
- win_T *win;
-
- FOR_ALL_WINDOWS(win)
- if (is_qf_win(win, qi))
- break;
+ FOR_ALL_WINDOWS(win) {
+ if (is_qf_win(win, qi)) {
+ return win;
+ }
+ }
- return win;
+ return NULL;
}
/*
@@ -3478,7 +3484,6 @@ void ex_helpgrep(exarg_T *eap)
char_u *lang;
qf_info_T *qi = &ql_info;
int new_qi = FALSE;
- win_T *wp;
char_u *au_name = NULL;
/* Check for a specified language */
@@ -3501,16 +3506,16 @@ void ex_helpgrep(exarg_T *eap)
p_cpo = empty_option;
if (eap->cmdidx == CMD_lhelpgrep) {
- /* Find an existing help window */
- FOR_ALL_WINDOWS(wp)
- if (wp->w_buffer != NULL && wp->w_buffer->b_help)
- break;
+ qi = NULL;
- if (wp == NULL) /* Help window not found */
- qi = NULL;
- else
- qi = wp->w_llist;
+ /* Find an existing help window */
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_buffer != NULL && wp->w_buffer->b_help) {
+ qi = wp->w_llist;
+ }
+ }
+ /* Help window not found */
if (qi == NULL) {
/* Allocate a new location list for help text matches */
qi = ll_new_list();
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 91db983525..c7d9ce28af 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -206,10 +206,7 @@ void redraw_later_clear(void)
*/
void redraw_all_later(int type)
{
- win_T *wp;
-
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
redraw_win_later(wp, type);
}
}
@@ -224,12 +221,10 @@ void redraw_curbuf_later(int type)
void redraw_buf_later(buf_T *buf, int type)
{
- win_T *wp;
-
- FOR_ALL_WINDOWS(wp)
- {
- if (wp->w_buffer == buf)
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_buffer == buf) {
redraw_win_later(wp, type);
+ }
}
}
@@ -390,7 +385,6 @@ void update_curbuf(int type)
*/
void update_screen(int type)
{
- win_T *wp;
static int did_intro = FALSE;
int did_one;
@@ -438,8 +432,7 @@ void update_screen(int type)
check_for_delay(FALSE);
if (screen_ins_lines(0, 0, msg_scrolled, (int)Rows, NULL) == FAIL)
type = CLEAR;
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
if (wp->w_winrow < msg_scrolled) {
if (wp->w_winrow + wp->w_height > msg_scrolled
&& wp->w_redr_type < REDRAW_TOP
@@ -450,8 +443,9 @@ void update_screen(int type)
} else {
wp->w_redr_type = NOT_VALID;
if (wp->w_winrow + wp->w_height + wp->w_status_height
- <= msg_scrolled)
+ <= msg_scrolled) {
wp->w_redr_status = TRUE;
+ }
}
}
}
@@ -512,8 +506,7 @@ void update_screen(int type)
* Correct stored syntax highlighting info for changes in each displayed
* buffer. Each buffer must only be done once.
*/
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
if (wp->w_buffer->b_mod_set) {
win_T *wwp;
@@ -534,8 +527,7 @@ void update_screen(int type)
*/
did_one = FALSE;
search_hl.rm.regprog = NULL;
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
if (wp->w_redr_type != 0) {
cursor_off();
if (!did_one) {
@@ -558,8 +550,9 @@ void update_screen(int type)
/* Reset b_mod_set flags. Going through all windows is probably faster
* than going through all buffers (there could be many buffers). */
- for (wp = firstwin; wp != NULL; wp = wp->w_next)
+ FOR_ALL_WINDOWS(wp) {
wp->w_buffer->b_mod_set = FALSE;
+ }
updating_screen = FALSE;
@@ -662,31 +655,28 @@ static void update_finish(void)
void update_debug_sign(buf_T *buf, linenr_T lnum)
{
- win_T *wp;
int doit = FALSE;
win_foldinfo.fi_level = 0;
/* update/delete a specific mark */
- FOR_ALL_WINDOWS(wp)
- {
- if (buf != NULL && lnum > 0) {
- if (wp->w_buffer == buf && lnum >= wp->w_topline
- && lnum < wp->w_botline)
- {
- if (wp->w_redraw_top == 0 || wp->w_redraw_top > lnum) {
- wp->w_redraw_top = lnum;
- }
- if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < lnum) {
- wp->w_redraw_bot = lnum;
- }
- redraw_win_later(wp, VALID);
- }
- } else {
- redraw_win_later(wp, VALID);
- }
- if (wp->w_redr_type != 0) {
- doit = TRUE;
+ FOR_ALL_WINDOWS(wp) {
+ if (buf != NULL && lnum > 0) {
+ if (wp->w_buffer == buf && lnum >= wp->w_topline
+ && lnum < wp->w_botline) {
+ if (wp->w_redraw_top == 0 || wp->w_redraw_top > lnum) {
+ wp->w_redraw_top = lnum;
+ }
+ if (wp->w_redraw_bot == 0 || wp->w_redraw_bot < lnum) {
+ wp->w_redraw_bot = lnum;
+ }
+ redraw_win_later(wp, VALID);
}
+ } else {
+ redraw_win_later(wp, VALID);
+ }
+ if (wp->w_redr_type != 0) {
+ doit = TRUE;
+ }
}
/* Return when there is nothing to do, screen updating is already
@@ -698,13 +688,13 @@ void update_debug_sign(buf_T *buf, linenr_T lnum)
/* update all windows that need updating */
update_prepare();
- for (wp = firstwin; wp; wp = wp->w_next) {
- if (wp->w_redr_type != 0) {
- win_update(wp);
- }
- if (wp->w_redr_status) {
- win_redr_status(wp);
- }
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_redr_type != 0) {
+ win_update(wp);
+ }
+ if (wp->w_redr_status) {
+ win_redr_status(wp);
+ }
}
update_finish();
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 5f6e09925e..5001d6498e 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -984,16 +984,13 @@ static void syn_stack_free_block(synblock_T *block)
*/
void syn_stack_free_all(synblock_T *block)
{
- win_T *wp;
-
syn_stack_free_block(block);
-
/* When using "syntax" fold method, must update all folds. */
- FOR_ALL_WINDOWS(wp)
- {
- if (wp->w_s == block && foldmethodIsSyntax(wp))
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_s == block && foldmethodIsSyntax(wp)) {
foldUpdateAll(wp);
+ }
}
}
@@ -1075,14 +1072,12 @@ static void syn_stack_alloc(void)
*/
void syn_stack_apply_changes(buf_T *buf)
{
- win_T *wp;
-
syn_stack_apply_changes_block(&buf->b_s, buf);
- FOR_ALL_WINDOWS(wp)
- {
- if ((wp->w_buffer == buf) && (wp->w_s != &buf->b_s))
+ FOR_ALL_WINDOWS(wp) {
+ if ((wp->w_buffer == buf) && (wp->w_s != &buf->b_s)) {
syn_stack_apply_changes_block(wp->w_s, buf);
+ }
}
}
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index d7a691aa83..9fbe21aeb0 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -2191,12 +2191,10 @@ u_undo_end (
u_add_time(msgbuf, sizeof(msgbuf), uhp->uh_time);
{
- win_T *wp;
-
- FOR_ALL_WINDOWS(wp)
- {
- if (wp->w_buffer == curbuf && wp->w_p_cole > 0)
+ FOR_ALL_WINDOWS(wp) {
+ if (wp->w_buffer == curbuf && wp->w_p_cole > 0) {
redraw_win_later(wp, NOT_VALID);
+ }
}
}
diff --git a/src/nvim/window.c b/src/nvim/window.c
index becc21be89..234788c415 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1677,20 +1677,19 @@ static int last_window(void)
* Return TRUE if there is only one window other than "aucmd_win" in the
* current tab page.
*/
-int one_window(void)
+bool one_window(void)
{
- win_T *wp;
- int seen_one = FALSE;
+ bool seen_one = false;
- FOR_ALL_WINDOWS(wp)
- {
+ FOR_ALL_WINDOWS(wp) {
if (wp != aucmd_win) {
- if (seen_one)
- return FALSE;
- seen_one = TRUE;
+ if (seen_one) {
+ return false;
+ }
+ seen_one = true;
}
}
- return TRUE;
+ return true;
}
/*