diff options
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r-- | src/nvim/window.c | 93 |
1 files changed, 44 insertions, 49 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index 67bad9f8cf..ff5b39eb84 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -59,8 +59,6 @@ #endif - - #define NOWIN (win_T *)-1 // non-existing window #define ROWS_AVAIL (Rows - p_ch - tabline_height()) @@ -94,7 +92,7 @@ void do_window(int nchar, long Prenum, int xchar) #define CHECK_CMDWIN \ do { \ if (cmdwin_type != 0) { \ - EMSG(_(e_cmdwin)); \ + emsg(_(e_cmdwin)); \ return; \ } \ } while (0) @@ -135,9 +133,9 @@ void do_window(int nchar, long Prenum, int xchar) if (buflist_findnr(Prenum == 0 ? curwin->w_alt_fnum : Prenum) == NULL) { if (Prenum == 0) { - EMSG(_(e_noalt)); + emsg(_(e_noalt)); } else { - EMSGN(_("E92: Buffer %" PRId64 " not found"), Prenum); + semsg(_("E92: Buffer %" PRId64 " not found"), (int64_t)Prenum); } break; } @@ -201,7 +199,7 @@ newwindow: } } if (wp == NULL) { - EMSG(_("E441: There is no preview window")); + emsg(_("E441: There is no preview window")); } else { win_goto(wp); } @@ -294,7 +292,7 @@ newwindow: // move window to new tab page case 'T': if (one_window()) { - MSG(_(m_onlyone)); + msg(_(m_onlyone)); } else { tabpage_T *oldtab = curtab; tabpage_T *newtab; @@ -552,7 +550,7 @@ wingotofile: config.external = true; Error err = ERROR_INIT; if (!win_new_float(curwin, config, &err)) { - EMSG(err.msg); + emsg(err.msg); api_clear_error(&err); beep_flush(); } @@ -921,7 +919,7 @@ int win_split(int size, int flags) // Add flags from ":vertical", ":topleft" and ":botright". flags |= cmdmod.split; if ((flags & WSP_TOP) && (flags & WSP_BOT)) { - EMSG(_("E442: Can't split topleft and botright at the same time")); + emsg(_("E442: Can't split topleft and botright at the same time")); return FAIL; } @@ -974,7 +972,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) // add a status line when p_ls == 1 and splitting the first window if (one_nonfloat() && p_ls == 1 && oldwin->w_status_height == 0) { if (oldwin->w_height <= p_wmh && new_in_layout) { - EMSG(_(e_noroom)); + emsg(_(e_noroom)); return FAIL; } need_status = STATUS_HEIGHT; @@ -1023,7 +1021,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) needed += minwidth; } if (available < needed && new_in_layout) { - EMSG(_(e_noroom)); + emsg(_(e_noroom)); return FAIL; } if (new_size == 0) { @@ -1103,7 +1101,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) needed += minheight; } if (available < needed && new_in_layout) { - EMSG(_(e_noroom)); + emsg(_(e_noroom)); return FAIL; } oldwin_height = oldwin->w_height; @@ -1659,7 +1657,7 @@ static void win_exchange(long Prenum) int temp; if (curwin->w_floating) { - EMSG(e_floatexchange); + emsg(e_floatexchange); return; } @@ -1746,7 +1744,7 @@ static void win_rotate(bool upwards, int count) int n; if (curwin->w_floating) { - EMSG(e_floatexchange); + emsg(e_floatexchange); return; } @@ -1759,7 +1757,7 @@ static void win_rotate(bool upwards, int count) // Check if all frames in this row/col have one window. FOR_ALL_FRAMES(frp, curwin->w_frame->fr_parent->fr_child) { if (frp->fr_win == NULL) { - EMSG(_("E443: Cannot rotate when another window is split")); + emsg(_("E443: Cannot rotate when another window is split")); return; } } @@ -1776,7 +1774,6 @@ static void win_rotate(bool upwards, int count) // find last frame and append removed window/frame after it for (; frp->fr_next != NULL; frp = frp->fr_next) { - ; } win_append(frp->fr_win, wp1); frame_append(frp, wp1->w_frame); @@ -1786,7 +1783,6 @@ static void win_rotate(bool upwards, int count) // find last window/frame in the list and remove it for (frp = curwin->w_frame; frp->fr_next != NULL; frp = frp->fr_next) { - ; } wp1 = frp->fr_win; wp2 = wp1->w_prev; // will become last window @@ -2399,7 +2395,7 @@ int win_close(win_T *win, bool free_buf) const bool had_diffmode = win->w_p_diff; if (last_window() && !win->w_floating) { - EMSG(_("E444: Cannot close last window")); + emsg(_("E444: Cannot close last window")); return FAIL; } @@ -2408,17 +2404,17 @@ int win_close(win_T *win, bool free_buf) return FAIL; // window is already being closed } if (win == aucmd_win) { - EMSG(_(e_autocmd_close)); + emsg(_(e_autocmd_close)); return FAIL; } if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) { - EMSG(_("E814: Cannot close window, only autocmd window would remain")); + emsg(_("E814: Cannot close window, only autocmd window would remain")); return FAIL; } if ((firstwin == win && lastwin_nofloating() == win) && lastwin->w_floating) { // TODO(bfredl): we might close the float also instead - EMSG(e_floatonly); + emsg(e_floatonly); return FAIL; } @@ -2710,7 +2706,6 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) // Careful: Autocommands may have closed the tab page or made it the // current tab page. for (ptp = first_tabpage; ptp != NULL && ptp != tp; ptp = ptp->tp_next) { - ; } if (ptp == NULL || tp == curtab) { return; @@ -3048,7 +3043,6 @@ static tabpage_T *alt_tabpage(void) // Find the last but one tab page. for (tp = first_tabpage; tp->tp_next != curtab; tp = tp->tp_next) { - ; } return tp; } @@ -3153,12 +3147,14 @@ static void frame_new_height(frame_T *topfrp, int height, bool topfirst, bool wf break; } if (topfirst) { - do + do{ frp = frp->fr_next; + } while (wfh && frp != NULL && frame_fixed_height(frp)); } else { - do + do{ frp = frp->fr_prev; + } while (wfh && frp != NULL && frame_fixed_height(frp)); } // Increase "height" if we could not reduce enough frames. @@ -3351,12 +3347,14 @@ static void frame_new_width(frame_T *topfrp, int width, bool leftfirst, bool wfw break; } if (leftfirst) { - do + do{ frp = frp->fr_next; + } while (wfw && frp != NULL && frame_fixed_width(frp)); } else { - do + do{ frp = frp->fr_prev; + } while (wfw && frp != NULL && frame_fixed_width(frp)); } // Increase "width" if we could not reduce enough frames. @@ -3526,7 +3524,7 @@ void close_others(int message, int forceit) if (curwin->w_floating) { if (message && !autocmd_busy) { - EMSG(e_floatonly); + emsg(e_floatonly); } return; } @@ -3534,7 +3532,7 @@ void close_others(int message, int forceit) if (one_window() && !lastwin->w_floating) { if (message && !autocmd_busy) { - MSG(_(m_onlyone)); + msg(_(m_onlyone)); } return; } @@ -3568,7 +3566,7 @@ void close_others(int message, int forceit) } if (message && !ONE_WINDOW) { - EMSG(_("E445: Other window contains changes")); + emsg(_("E445: Other window contains changes")); } } @@ -4123,14 +4121,12 @@ void goto_tabpage(int n) for (i = n; i < 0; ++i) { for (tp = first_tabpage; tp->tp_next != ttp && tp->tp_next != NULL; tp = tp->tp_next) { - ; } ttp = tp; } } else if (n == 9999) { // Go to last tab page. for (tp = first_tabpage; tp->tp_next != NULL; tp = tp->tp_next) { - ; } } else { // Go to tab page "n". @@ -5009,7 +5005,6 @@ void do_autocmd_winscrolled(win_T *wp) * Save the size of all windows in "gap". */ void win_size_save(garray_T *gap) - { ga_init(gap, (int)sizeof(int), 1); ga_grow(gap, win_count() * 2 + 1); @@ -5523,7 +5518,7 @@ void win_setminheight(void) } p_wmh--; if (first) { - EMSG(_(e_noroom)); + emsg(_(e_noroom)); first = false; } } @@ -5543,7 +5538,7 @@ void win_setminwidth(void) } p_wmw--; if (first) { - EMSG(_(e_noroom)); + emsg(_(e_noroom)); first = false; } } @@ -6038,7 +6033,7 @@ void command_height(void) if (p_ch > old_p_ch) { // p_ch got bigger while (p_ch > old_p_ch) { if (frp == NULL) { - EMSG(_(e_noroom)); + emsg(_(e_noroom)); p_ch = old_p_ch; curtab->tp_ch_used = p_ch; cmdline_row = Rows - p_ch; @@ -6160,7 +6155,7 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u } if (*ptr == NUL) { // nothing found if (options & FNAME_MESS) { - EMSG(_("E446: No file name under cursor")); + emsg(_("E446: No file name under cursor")); } return NULL; } @@ -6273,7 +6268,7 @@ static void last_status_rec(frame_T *fr, bool statusline) fp = fr; while (fp->fr_height <= frame_minheight(fp, NULL)) { if (fp == topframe) { - EMSG(_(e_noroom)); + emsg(_(e_noroom)); return; } // In a column of frames: go to frame above. If already at @@ -6303,7 +6298,6 @@ static void last_status_rec(frame_T *fr, bool statusline) } else { // horizontally split window, set status line for last one for (fp = fr->fr_child; fp->fr_next != NULL; fp = fp->fr_next) { - ; } last_status_rec(fp, statusline); } @@ -6684,16 +6678,16 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, int prio, return -1; } if (id < -1 || id == 0) { - EMSGN(_("E799: Invalid ID: %" PRId64 + semsg(_("E799: Invalid ID: %" PRId64 " (must be greater than or equal to 1)"), - id); + (int64_t)id); return -1; } if (id != -1) { cur = wp->w_match_head; while (cur != NULL) { if (cur->id == id) { - EMSGN(_("E801: ID already taken: %" PRId64), id); + semsg(_("E801: ID already taken: %" PRId64), (int64_t)id); return -1; } cur = cur->next; @@ -6703,7 +6697,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, int prio, return -1; } if (pat != NULL && (regprog = vim_regcomp((char_u *)pat, RE_MAGIC)) == NULL) { - EMSG2(_(e_invarg2), pat); + semsg(_(e_invarg2), pat); return -1; } @@ -6749,7 +6743,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, int prio, const list_T *const subl = TV_LIST_ITEM_TV(li)->vval.v_list; const listitem_T *subli = tv_list_first(subl); if (subli == NULL) { - emsgf(_("E5030: Empty list at position %d"), + semsg(_("E5030: Empty list at position %d"), (int)tv_list_idx_of_item(pos_list, li)); goto fail; } @@ -6791,7 +6785,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, int prio, m->pos.pos[i].col = 0; m->pos.pos[i].len = 0; } else { - emsgf(_("E5031: List or number required at position %d"), + semsg(_("E5031: List or number required at position %d"), (int)tv_list_idx_of_item(pos_list, li)); goto fail; } @@ -6863,9 +6857,9 @@ int match_delete(win_T *wp, int id, bool perr) if (id < 1) { if (perr) { - EMSGN(_("E802: Invalid ID: %" PRId64 + semsg(_("E802: Invalid ID: %" PRId64 " (must be greater than or equal to 1)"), - id); + (int64_t)id); } return -1; } @@ -6875,7 +6869,7 @@ int match_delete(win_T *wp, int id, bool perr) } if (cur == NULL) { if (perr) { - EMSGN(_("E803: ID not found: %" PRId64), id); + semsg(_("E803: ID not found: %" PRId64), (int64_t)id); } return -1; } @@ -7163,7 +7157,8 @@ void win_ui_flush(void) } } -win_T *lastwin_nofloating(void) { +win_T *lastwin_nofloating(void) +{ win_T *res = lastwin; while (res->w_floating) { res = res->w_prev; |