Permalink
Browse files

patch 8.0.1136: W_WIDTH() is always the same

Problem:    W_WIDTH() is always the same.
Solution:   Expand the macro.
  • Loading branch information...
brammool committed Sep 22, 2017
1 parent 53f8174 commit 0263146b5dbbb6c120ce2e7720256503b864425d
Showing with 142 additions and 142 deletions.
  1. +10 −10 src/charset.c
  2. +6 −6 src/edit.c
  3. +1 −1 src/evalfunc.c
  4. +1 −1 src/ex_cmds.c
  5. +1 −1 src/ex_docmd.c
  6. +3 −3 src/getchar.c
  7. +3 −3 src/gui.c
  8. +1 −1 src/gui_beval.c
  9. +1 −1 src/gui_mac.c
  10. +1 −1 src/if_lua.c
  11. +1 −1 src/if_mzsch.c
  12. +1 −1 src/if_py_both.h
  13. +1 −1 src/if_ruby.c
  14. +3 −3 src/misc1.c
  15. +3 −3 src/misc2.c
  16. +11 −11 src/move.c
  17. +11 −11 src/normal.c
  18. +2 −2 src/popupmnu.c
  19. +1 −1 src/quickfix.c
  20. +69 −69 src/screen.c
  21. +1 −1 src/search.c
  22. +1 −2 src/structs.h
  23. +4 −4 src/ui.c
  24. +2 −0 src/version.c
  25. +0 −1 src/vim.h
  26. +3 −3 src/window.c
View
@@ -1100,7 +1100,7 @@ win_lbr_chartabsize(
*/
numberextra = win_col_off(wp);
col2 = col;
colmax = (colnr_T)(W_WIDTH(wp) - numberextra - col_adj);
colmax = (colnr_T)(wp->w_width - numberextra - col_adj);
if (col >= colmax)
{
colmax += col_adj;
@@ -1151,10 +1151,10 @@ win_lbr_chartabsize(
numberextra = numberwidth;
col += numberextra + mb_added;
if (col >= (colnr_T)W_WIDTH(wp))
if (col >= (colnr_T)wp->w_width)
{
col -= W_WIDTH(wp);
numberextra = W_WIDTH(wp) - (numberextra - win_col_off2(wp));
col -= wp->w_width;
numberextra = wp->w_width - (numberextra - win_col_off2(wp));
if (col >= numberextra && numberextra > 0)
col %= numberextra;
if (*p_sbr != NUL)
@@ -1170,18 +1170,18 @@ win_lbr_chartabsize(
numberwidth -= win_col_off2(wp);
}
if (col == 0 || col + size + sbrlen > (colnr_T)W_WIDTH(wp))
if (col == 0 || col + size + sbrlen > (colnr_T)wp->w_width)
{
added = 0;
if (*p_sbr != NUL)
{
if (size + sbrlen + numberwidth > (colnr_T)W_WIDTH(wp))
if (size + sbrlen + numberwidth > (colnr_T)wp->w_width)
{
/* calculate effective window width */
int width = (colnr_T)W_WIDTH(wp) - sbrlen - numberwidth;
int prev_width = col ? ((colnr_T)W_WIDTH(wp) - (sbrlen + col)) : 0;
int width = (colnr_T)wp->w_width - sbrlen - numberwidth;
int prev_width = col ? ((colnr_T)wp->w_width - (sbrlen + col)) : 0;
if (width == 0)
width = (colnr_T)W_WIDTH(wp);
width = (colnr_T)wp->w_width;
added += ((size - prev_width) / width) * vim_strsize(p_sbr);
if ((size - prev_width) % width)
/* wrapped, add another length of 'sbr' */
@@ -1248,7 +1248,7 @@ in_win_border(win_T *wp, colnr_T vcol)
if (wp->w_width == 0) /* there is no border */
return FALSE;
width1 = W_WIDTH(wp) - win_col_off(wp);
width1 = wp->w_width - win_col_off(wp);
if ((int)vcol < width1 - 1)
return FALSE;
if ((int)vcol == width1 - 1)
View
@@ -1783,7 +1783,7 @@ edit_putchar(int c, int highlight)
#ifdef FEAT_RIGHTLEFT
if (curwin->w_p_rl)
{
pc_col += W_WIDTH(curwin) - 1 - curwin->w_wcol;
pc_col += curwin->w_width - 1 - curwin->w_wcol;
# ifdef FEAT_MBYTE
if (has_mbyte)
{
@@ -1865,7 +1865,7 @@ display_dollar(colnr_T col)
}
#endif
curs_columns(FALSE); /* recompute w_wrow and w_wcol */
if (curwin->w_wcol < W_WIDTH(curwin))
if (curwin->w_wcol < curwin->w_width)
{
edit_putchar('$', FALSE);
dollar_vcol = curwin->w_virtcol;
@@ -6820,7 +6820,7 @@ check_auto_format(
/*
* Find out textwidth to be used for formatting:
* if 'textwidth' option is set, use it
* else if 'wrapmargin' option is set, use W_WIDTH(curwin) - 'wrapmargin'
* else if 'wrapmargin' option is set, use curwin->w_width - 'wrapmargin'
* if invalid value, use 0.
* Set default to window width (maximum 79) for "gq" operator.
*/
@@ -6835,7 +6835,7 @@ comp_textwidth(
{
/* The width is the window width minus 'wrapmargin' minus all the
* things that add to the margin. */
textwidth = W_WIDTH(curwin) - curbuf->b_p_wm;
textwidth = curwin->w_width - curbuf->b_p_wm;
#ifdef FEAT_CMDWIN
if (cmdwin_type != 0)
textwidth -= 1;
@@ -6854,7 +6854,7 @@ comp_textwidth(
textwidth = 0;
if (ff && textwidth == 0)
{
textwidth = W_WIDTH(curwin) - 1;
textwidth = curwin->w_width - 1;
if (textwidth > 79)
textwidth = 79;
}
@@ -9447,7 +9447,7 @@ ins_mousescroll(int dir)
int val, step = 6;
if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL))
step = W_WIDTH(curwin);
step = curwin->w_width;
val = curwin->w_leftcol + (dir == MSCR_RIGHT ? -step : step);
if (val < 0)
val = 0;
View
@@ -13239,7 +13239,7 @@ f_winrestview(typval_T *argvars, typval_T *rettv UNUSED)
check_cursor();
win_new_height(curwin, curwin->w_height);
win_new_width(curwin, W_WIDTH(curwin));
win_new_width(curwin, curwin->w_width);
changed_window_setting();
if (curwin->w_topline <= 0)
View
@@ -177,7 +177,7 @@ ex_align(exarg_T *eap)
if (width <= 0)
width = curbuf->b_p_tw;
if (width == 0 && curbuf->b_p_wm > 0)
width = W_WIDTH(curwin) - curbuf->b_p_wm;
width = curwin->w_width - curbuf->b_p_wm;
if (width <= 0)
width = 80;
}
View
@@ -8486,7 +8486,7 @@ ex_resize(exarg_T *eap)
if (cmdmod.split & WSP_VERT)
{
if (*eap->arg == '-' || *eap->arg == '+')
n += W_WIDTH(curwin);
n += curwin->w_width;
else if (n == 0 && eap->arg[0] == NUL) /* default is very wide */
n = 9999;
win_setwidth_win((int)n, wp);
View
@@ -2666,8 +2666,8 @@ vgetorpeek(int advance)
++col;
}
curwin->w_wrow = curwin->w_cline_row
+ curwin->w_wcol / W_WIDTH(curwin);
curwin->w_wcol %= W_WIDTH(curwin);
+ curwin->w_wcol / curwin->w_width;
curwin->w_wcol %= curwin->w_width;
curwin->w_wcol += curwin_col_off();
#ifdef FEAT_MBYTE
col = 0; /* no correction needed */
@@ -2684,7 +2684,7 @@ vgetorpeek(int advance)
else if (curwin->w_p_wrap && curwin->w_wrow)
{
--curwin->w_wrow;
curwin->w_wcol = W_WIDTH(curwin) - 1;
curwin->w_wcol = curwin->w_width - 1;
#ifdef FEAT_MBYTE
col = curwin->w_cursor.col - 1;
#endif
View
@@ -4564,14 +4564,14 @@ gui_update_horiz_scrollbar(int force)
return;
}
size = W_WIDTH(curwin);
size = curwin->w_width;
if (curwin->w_p_wrap)
{
value = 0;
#ifdef SCROLL_PAST_END
max = 0;
#else
max = W_WIDTH(curwin) - 1;
max = curwin->w_width - 1;
#endif
}
else
@@ -4591,7 +4591,7 @@ gui_update_horiz_scrollbar(int force)
#endif
#ifndef SCROLL_PAST_END
max += W_WIDTH(curwin) - 1;
max += curwin->w_width - 1;
#endif
/* The line number isn't scrolled, thus there is less space when
* 'number' or 'relativenumber' is set (also for 'foldcolumn'). */
View
@@ -338,7 +338,7 @@ get_beval_info(
row = Y_2_ROW(beval->y);
col = X_2_COL(beval->x);
wp = mouse_find_win(&row, &col);
if (wp != NULL && row < wp->w_height && col < W_WIDTH(wp))
if (wp != NULL && row < wp->w_height && col < wp->w_width)
{
/* Found a window and the cursor is in the text. Now find the line
* number. */
View
@@ -1612,7 +1612,7 @@ gui_mac_scroll_action(ControlHandle theControl, short partCode)
else /* Bottom scrollbar */
{
sb_info = sb;
page = W_WIDTH(curwin) - 5;
page = curwin->w_width - 5;
}
switch (partCode)
View
@@ -1179,7 +1179,7 @@ luaV_window_index(lua_State *L)
else if (strncmp(s, "col", 3) == 0)
lua_pushinteger(L, w->w_cursor.col + 1);
else if (strncmp(s, "width", 5) == 0)
lua_pushinteger(L, W_WIDTH(w));
lua_pushinteger(L, w->w_width);
else if (strncmp(s, "height", 6) == 0)
lua_pushinteger(L, w->w_height);
/* methods */
View
@@ -2063,7 +2063,7 @@ get_window_width(void *data, int argc, Scheme_Object **argv)
Vim_Prim *prim = (Vim_Prim *)data;
vim_mz_window *win = get_window_arg(prim->name, 0, argc, argv);
return scheme_make_integer(W_WIDTH(win->win));
return scheme_make_integer(win->win->w_width);
}
/* (set-win-width {width} [window]) */
View
@@ -3875,7 +3875,7 @@ WindowAttr(WindowObject *self, char *name)
else if (strcmp(name, "row") == 0)
return PyLong_FromLong((long)(self->win->w_winrow));
else if (strcmp(name, "width") == 0)
return PyLong_FromLong((long)(W_WIDTH(self->win)));
return PyLong_FromLong((long)(self->win->w_width));
else if (strcmp(name, "col") == 0)
return PyLong_FromLong((long)(self->win->w_wincol));
else if (strcmp(name, "vars") == 0)
View
@@ -1470,7 +1470,7 @@ static VALUE window_set_height(VALUE self, VALUE height)
static VALUE window_width(VALUE self UNUSED)
{
return INT2NUM(W_WIDTH(get_win(self)));
return INT2NUM(get_win(self->w_width));
}
static VALUE window_set_width(VALUE self UNUSED, VALUE width)
View
@@ -495,7 +495,7 @@ get_breakindent_win(
static varnumber_T prev_tick = 0; /* changedtick of cached value */
int bri = 0;
/* window width minus window margin space, i.e. what rests for text */
const int eff_wwidth = W_WIDTH(wp)
const int eff_wwidth = wp->w_width
- ((wp->w_p_nu || wp->w_p_rnu)
&& (vim_strchr(p_cpo, CPO_NUMCOL) == NULL)
? number_width(wp) + 1 : 0);
@@ -2026,7 +2026,7 @@ plines_win_nofold(win_T *wp, linenr_T lnum)
/*
* Add column offset for 'number', 'relativenumber' and 'foldcolumn'.
*/
width = W_WIDTH(wp) - win_col_off(wp);
width = wp->w_width - win_col_off(wp);
if (width <= 0)
return 32000;
if (col <= width)
@@ -2083,7 +2083,7 @@ plines_win_col(win_T *wp, linenr_T lnum, long column)
/*
* Add column offset for 'number', 'relativenumber', 'foldcolumn', etc.
*/
width = W_WIDTH(wp) - win_col_off(wp);
width = wp->w_width - win_col_off(wp);
if (width <= 0)
return 9999;
View
@@ -165,7 +165,7 @@ coladvance2(
else
{
#ifdef FEAT_VIRTUALEDIT
int width = W_WIDTH(curwin) - win_col_off(curwin);
int width = curwin->w_width - win_col_off(curwin);
if (finetune
&& curwin->w_p_wrap
@@ -310,7 +310,7 @@ coladvance2(
int b = (int)wcol - (int)col;
/* The difference between wcol and col is used to set coladd. */
if (b > 0 && b < (MAXCOL - 2 * W_WIDTH(curwin)))
if (b > 0 && b < (MAXCOL - 2 * curwin->w_width))
pos->coladd = b;
col += b;
@@ -662,7 +662,7 @@ leftcol_changed(void)
int retval = FALSE;
changed_cline_bef_curs();
lastcol = curwin->w_leftcol + W_WIDTH(curwin) - curwin_col_off() - 1;
lastcol = curwin->w_leftcol + curwin->w_width - curwin_col_off() - 1;
validate_virtcol();
/*
View
@@ -855,14 +855,14 @@ validate_cursor_col(void)
col = curwin->w_virtcol;
off = curwin_col_off();
col += off;
width = W_WIDTH(curwin) - off + curwin_col_off2();
width = curwin->w_width - off + curwin_col_off2();
/* long line wrapping, adjust curwin->w_wrow */
if (curwin->w_p_wrap
&& col >= (colnr_T)W_WIDTH(curwin)
&& col >= (colnr_T)curwin->w_width
&& width > 0)
/* use same formula as what is used in curs_columns() */
col -= ((col - W_WIDTH(curwin)) / width + 1) * width;
col -= ((col - curwin->w_width) / width + 1) * width;
if (col > (int)curwin->w_leftcol)
col -= curwin->w_leftcol;
else
@@ -975,22 +975,22 @@ curs_columns(
*/
curwin->w_wrow = curwin->w_cline_row;
textwidth = W_WIDTH(curwin) - extra;
textwidth = curwin->w_width - extra;
if (textwidth <= 0)
{
/* No room for text, put cursor in last char of window. */
curwin->w_wcol = W_WIDTH(curwin) - 1;
curwin->w_wcol = curwin->w_width - 1;
curwin->w_wrow = curwin->w_height - 1;
}
else if (curwin->w_p_wrap && curwin->w_width != 0)
{
width = textwidth + curwin_col_off2();
/* long line wrapping, adjust curwin->w_wrow */
if (curwin->w_wcol >= W_WIDTH(curwin))
if (curwin->w_wcol >= curwin->w_width)
{
/* this same formula is used in validate_cursor_col() */
n = (curwin->w_wcol - W_WIDTH(curwin)) / width + 1;
n = (curwin->w_wcol - curwin->w_width) / width + 1;
curwin->w_wcol -= n * width;
curwin->w_wrow += n;
@@ -1021,7 +1021,7 @@ curs_columns(
* extra
*/
off_left = (int)startcol - (int)curwin->w_leftcol - p_siso;
off_right = (int)endcol - (int)(curwin->w_leftcol + W_WIDTH(curwin)
off_right = (int)endcol - (int)(curwin->w_leftcol + curwin->w_width
- p_siso) + 1;
if (off_left < 0 || off_right > 0)
{
@@ -1249,7 +1249,7 @@ scrolldown(
validate_virtcol();
validate_cheight();
wrow += curwin->w_cline_height - 1 -
curwin->w_virtcol / W_WIDTH(curwin);
curwin->w_virtcol / curwin->w_width;
}
while (wrow >= curwin->w_height && curwin->w_cursor.lnum > 1)
{
@@ -1454,7 +1454,7 @@ scrolldown_clamp(void)
validate_cheight();
validate_virtcol();
end_row += curwin->w_cline_height - 1 -
curwin->w_virtcol / W_WIDTH(curwin);
curwin->w_virtcol / curwin->w_width;
}
if (end_row < curwin->w_height - p_so)
{
@@ -1512,7 +1512,7 @@ scrollup_clamp(void)
if (curwin->w_p_wrap && curwin->w_width != 0)
{
validate_virtcol();
start_row -= curwin->w_virtcol / W_WIDTH(curwin);
start_row -= curwin->w_virtcol / curwin->w_width;
}
if (start_row >= p_so)
{
Oops, something went wrong.

0 comments on commit 0263146

Please sign in to comment.