Mercurial > vim
diff src/move.c @ 2178:c6f1aa1e9f32 vim73
Add 'relativenumber' patch from Markus Heidelberg.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sun, 16 May 2010 15:46:46 +0200 |
parents | 7c8c7c95a865 |
children | 8c6a66e2b3cc |
line wrap: on
line diff
--- a/src/move.c +++ b/src/move.c @@ -916,14 +916,14 @@ validate_cursor_col() } /* - * Compute offset of a window, occupied by line number, fold column and sign - * column (these don't move when scrolling horizontally). + * Compute offset of a window, occupied by absolute or relative line number, + * fold column and sign column (these don't move when scrolling horizontally). */ int win_col_off(wp) win_T *wp; { - return ((wp->w_p_nu ? number_width(wp) + 1 : 0) + return (((wp->w_p_nu || wp->w_p_rnu) ? number_width(wp) + 1 : 0) #ifdef FEAT_CMDWIN + (cmdwin_type == 0 || wp != curwin ? 0 : 1) #endif @@ -949,13 +949,14 @@ curwin_col_off() /* * Return the difference in column offset for the second screen line of a - * wrapped line. It's 8 if 'number' is on and 'n' is in 'cpoptions'. + * wrapped line. It's 8 if 'number' or 'relativenumber' is on and 'n' is in + * 'cpoptions'. */ int win_col_off2(wp) win_T *wp; { - if (wp->w_p_nu && vim_strchr(p_cpo, CPO_NUMCOL) != NULL) + if ((wp->w_p_nu || wp->w_p_rnu) && vim_strchr(p_cpo, CPO_NUMCOL) != NULL) return number_width(wp) + 1; return 0; } @@ -1218,17 +1219,22 @@ curs_columns(scroll) if (prev_skipcol != curwin->w_skipcol) redraw_later(NOT_VALID); + /* Redraw when w_row changes and 'relativenumber' is set */ + if (((curwin->w_valid & VALID_WROW) == 0 && (curwin->w_p_rnu #ifdef FEAT_SYN_HL - /* Redraw when w_virtcol changes and 'cursorcolumn' is set, or when w_row - * changes and 'cursorline' is set. */ - if (((curwin->w_p_cuc && (curwin->w_valid & VALID_VIRTCOL) == 0) - || (curwin->w_p_cul && (curwin->w_valid & VALID_WROW) == 0)) + /* or when w_row changes and 'cursorline' is set. */ + || curwin->w_p_cul +#endif + )) +#ifdef FEAT_SYN_HL + /* or when w_virtcol changes and 'cursorcolumn' is set */ + || (curwin->w_p_cuc && (curwin->w_valid & VALID_VIRTCOL) == 0) +#endif + ) # ifdef FEAT_INS_EXPAND - && !pum_visible() + if (!pum_visible()) # endif - ) - redraw_later(SOME_VALID); -#endif + redraw_later(SOME_VALID); curwin->w_valid |= VALID_WCOL|VALID_WROW|VALID_VIRTCOL; }