Permalink
Browse files

patch 8.0.1566: too many #ifdefs

Problem:    Too many #ifdefs.
Solution:   Graduate FEAT_SCROLLBIND and FEAT_CURSORBIND.
  • Loading branch information...
brammool committed Mar 4, 2018
1 parent 107279c commit 8a3bb56230d220b8e1b4dcca517ed95f5341b8c7
Showing with 19 additions and 142 deletions.
  1. +1 −2 src/buffer.c
  2. +0 −16 src/diff.c
  3. +0 −4 src/edit.c
  4. +0 −4 src/evalfunc.c
  5. +0 −4 src/ex_cmds.c
  6. +1 −2 src/ex_cmds2.c
  7. +2 −6 src/ex_docmd.c
  8. +0 −2 src/globals.h
  9. +2 −8 src/gui.c
  10. +1 −13 src/macros.h
  11. +2 −2 src/main.c
  12. +0 −6 src/move.c
  13. +0 −6 src/normal.c
  14. +2 −33 src/option.c
  15. +0 −6 src/option.h
  16. +5 −11 src/structs.h
  17. +0 −2 src/term.c
  18. +2 −8 src/version.c
  19. +1 −7 src/window.c
@@ -1583,8 +1583,7 @@ do_buffer(
/* Go to the other buffer. */
set_curbuf(buf, action);
#if defined(FEAT_LISTCMDS) \
&& (defined(FEAT_SCROLLBIND) || defined(FEAT_CURSORBIND))
#if defined(FEAT_LISTCMDS)
if (action == DOBUF_SPLIT)
{
RESET_BINDING(curwin); /* reset 'scrollbind' and 'cursorbind' */
@@ -1160,16 +1160,12 @@ diff_win_options(
# endif
/* Use 'scrollbind' and 'cursorbind' when available */
#ifdef FEAT_SCROLLBIND
if (!wp->w_p_diff)
wp->w_p_scb_save = wp->w_p_scb;
wp->w_p_scb = TRUE;
#endif
#ifdef FEAT_CURSORBIND
if (!wp->w_p_diff)
wp->w_p_crb_save = wp->w_p_crb;
wp->w_p_crb = TRUE;
#endif
if (!wp->w_p_diff)
wp->w_p_wrap_save = wp->w_p_wrap;
wp->w_p_wrap = FALSE;
@@ -1199,10 +1195,8 @@ diff_win_options(
/* make sure topline is not halfway a fold */
changed_window_setting_win(wp);
# endif
#ifdef FEAT_SCROLLBIND
if (vim_strchr(p_sbo, 'h') == NULL)
do_cmdline_cmd((char_u *)"set sbo+=hor");
#endif
/* Save the current values, to be restored in ex_diffoff(). */
wp->w_p_diff_saved = TRUE;
@@ -1221,9 +1215,7 @@ diff_win_options(
ex_diffoff(exarg_T *eap)
{
win_T *wp;
#ifdef FEAT_SCROLLBIND
int diffwin = FALSE;
#endif
FOR_ALL_WINDOWS(wp)
{
@@ -1237,14 +1229,10 @@ ex_diffoff(exarg_T *eap)
if (wp->w_p_diff_saved)
{
#ifdef FEAT_SCROLLBIND
if (wp->w_p_scb)
wp->w_p_scb = wp->w_p_scb_save;
#endif
#ifdef FEAT_CURSORBIND
if (wp->w_p_crb)
wp->w_p_crb = wp->w_p_crb_save;
#endif
if (!wp->w_p_wrap)
wp->w_p_wrap = wp->w_p_wrap_save;
#ifdef FEAT_FOLDING
@@ -1276,20 +1264,16 @@ ex_diffoff(exarg_T *eap)
/* Note: 'sbo' is not restored, it's a global option. */
diff_buf_adjust(wp);
}
#ifdef FEAT_SCROLLBIND
diffwin |= wp->w_p_diff;
#endif
}
/* Also remove hidden buffers from the list. */
if (eap->forceit)
diff_buf_clear();
#ifdef FEAT_SCROLLBIND
/* Remove "hor" from from 'scrollopt' if there are no diff windows left. */
if (!diffwin && vim_strchr(p_sbo, 'h') != NULL)
do_cmdline_cmd((char_u *)"set sbo-=hor");
#endif
}
/*
@@ -764,15 +764,11 @@ edit(
*/
ins_redraw(TRUE);
#ifdef FEAT_SCROLLBIND
if (curwin->w_p_scb)
do_check_scrollbind(TRUE);
#endif
#ifdef FEAT_CURSORBIND
if (curwin->w_p_crb)
do_check_cursorbind();
#endif
update_curswant();
old_topline = curwin->w_topline;
#ifdef FEAT_DIFF
@@ -5852,9 +5852,7 @@ f_has(typval_T *argvars, typval_T *rettv)
#ifdef FEAT_CSCOPE
"cscope",
#endif
#ifdef FEAT_CURSORBIND
"cursorbind",
#endif
#ifdef CURSOR_SHAPE
"cursorshape",
#endif
@@ -6104,9 +6102,7 @@ f_has(typval_T *argvars, typval_T *rettv)
#if defined(FEAT_RUBY) && !defined(DYNAMIC_RUBY)
"ruby",
#endif
#ifdef FEAT_SCROLLBIND
"scrollbind",
#endif
#ifdef FEAT_CMDL_INFO
"showcmd",
"cmdline_info",
@@ -4318,9 +4318,7 @@ do_ecmd(
if (topline == 0 && command == NULL)
p_so = 999; /* force cursor halfway the window */
update_topline();
#ifdef FEAT_SCROLLBIND
curwin->w_scbind_pos = curwin->w_topline;
#endif
p_so = n;
redraw_curbuf_later(NOT_VALID); /* redraw this buffer later */
}
@@ -5270,10 +5268,8 @@ do_sub(exarg_T *eap)
setmouse(); /* disable mouse in xterm */
#endif
curwin->w_cursor.col = regmatch.startpos[0].col;
#ifdef FEAT_CURSORBIND
if (curwin->w_p_crb)
do_check_cursorbind();
#endif
/* When 'cpoptions' contains "u" don't sync undo when
* asking for confirmation. */
@@ -3232,11 +3232,10 @@ ex_listdo(exarg_T *eap)
if (eap->cmdidx == CMD_windo)
{
validate_cursor(); /* cursor may have moved */
#ifdef FEAT_SCROLLBIND
/* required when 'scrollbind' has been set */
if (curwin->w_p_scb)
do_check_scrollbind(TRUE);
#endif
}
if (eap->cmdidx == CMD_windo || eap->cmdidx == CMD_tabdo)
@@ -8263,20 +8263,18 @@ ex_splitview(exarg_T *eap)
else if (win_split(eap->addr_count > 0 ? (int)eap->line2 : 0,
*eap->cmd == 'v' ? WSP_VERT : 0) != FAIL)
{
# ifdef FEAT_SCROLLBIND
/* Reset 'scrollbind' when editing another file, but keep it when
* doing ":split" without arguments. */
if (*eap->arg != NUL
# ifdef FEAT_BROWSE
# ifdef FEAT_BROWSE
|| cmdmod.browse
# endif
# endif
)
{
RESET_BINDING(curwin);
}
else
do_check_scrollbind(FALSE);
# endif
do_exedit(eap, old_curwin);
}
@@ -8768,7 +8766,6 @@ ex_swapname(exarg_T *eap UNUSED)
static void
ex_syncbind(exarg_T *eap UNUSED)
{
#ifdef FEAT_SCROLLBIND
win_T *wp;
win_T *save_curwin = curwin;
buf_T *save_curbuf = curbuf;
@@ -8836,7 +8833,6 @@ ex_syncbind(exarg_T *eap UNUSED)
ins_typebuf(ctrl_o, REMAP_NONE, 0, TRUE, FALSE);
}
}
#endif
}
@@ -728,15 +728,13 @@ EXTERN colnr_T ai_col INIT(= 0);
EXTERN int end_comment_pending INIT(= NUL);
#endif
#ifdef FEAT_SCROLLBIND
/*
* This flag is set after a ":syncbind" to let the check_scrollbind() function
* know that it should not attempt to perform scrollbinding due to the scroll
* that was a result of the ":syncbind." (Otherwise, check_scrollbind() will
* undo some of the work done by ":syncbind.") -ralston
*/
EXTERN int did_syncbind INIT(= FALSE);
#endif
#ifdef FEAT_SMARTINDENT
/*
@@ -3959,9 +3959,7 @@ gui_drag_scrollbar(scrollbar_T *sb, long value, int still_dragging)
int sb_num;
#ifdef USE_ON_FLY_SCROLL
colnr_T old_leftcol = curwin->w_leftcol;
# ifdef FEAT_SCROLLBIND
linenr_T old_topline = curwin->w_topline;
# endif
# ifdef FEAT_DIFF
int old_topfill = curwin->w_topfill;
# endif
@@ -4126,16 +4124,15 @@ gui_drag_scrollbar(scrollbar_T *sb, long value, int still_dragging)
}
#ifdef USE_ON_FLY_SCROLL
# ifdef FEAT_SCROLLBIND
/*
* synchronize other windows, as necessary according to 'scrollbind'
*/
if (curwin->w_p_scb
&& ((sb->wp == NULL && curwin->w_leftcol != old_leftcol)
|| (sb->wp == curwin && (curwin->w_topline != old_topline
# ifdef FEAT_DIFF
# ifdef FEAT_DIFF
|| curwin->w_topfill != old_topfill
# endif
# endif
))))
{
do_check_scrollbind(TRUE);
@@ -4145,7 +4142,6 @@ gui_drag_scrollbar(scrollbar_T *sb, long value, int still_dragging)
updateWindow(wp);
setcursor();
}
# endif
out_flush_cursor(FALSE, TRUE);
#else
add_to_input_buf(bytes, byte_count);
@@ -4474,9 +4470,7 @@ gui_do_scroll(void)
}
if (old_cursor.lnum != wp->w_cursor.lnum)
coladvance(wp->w_curswant);
#ifdef FEAT_SCROLLBIND
wp->w_scbind_pos = wp->w_topline;
#endif
}
/* Make sure wp->w_leftcol and wp->w_skipcol are correct. */
@@ -294,19 +294,7 @@
# define DO_AUTOCHDIR
#endif
#if defined(FEAT_SCROLLBIND) && defined(FEAT_CURSORBIND)
# define RESET_BINDING(wp) (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE
#else
# if defined(FEAT_SCROLLBIND)
# define RESET_BINDING(wp) (wp)->w_p_scb = FALSE
# else
# if defined(FEAT_CURSORBIND)
# define RESET_BINDING(wp) (wp)->w_p_crb = FALSE
# else
# define RESET_BINDING(wp)
# endif
# endif
#endif
#define RESET_BINDING(wp) (wp)->w_p_scb = FALSE; (wp)->w_p_crb = FALSE
#ifdef FEAT_DIFF
# define PLINES_NOFILL(x) plines_nofill(x)
@@ -857,7 +857,7 @@ vim_main2(void)
}
#endif
#if defined(FEAT_DIFF) && defined(FEAT_SCROLLBIND)
#if defined(FEAT_DIFF)
/* When a startup script or session file setup for diff'ing and
* scrollbind, sync the scrollbind now. */
if (curwin->w_p_diff && curwin->w_p_scb)
@@ -1193,7 +1193,7 @@ main_loop(
curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
}
#if defined(FEAT_DIFF) && defined(FEAT_SCROLLBIND)
#if defined(FEAT_DIFF)
/* Scroll-binding for diff mode may have been postponed until
* here. Avoids doing it for every change. */
if (diff_need_scrollbind)
@@ -184,9 +184,7 @@ update_topline(void)
curwin->w_topline = curwin->w_cursor.lnum;
curwin->w_botline = curwin->w_topline;
curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
#ifdef FEAT_SCROLLBIND
curwin->w_scbind_pos = 1;
#endif
return;
}
@@ -215,9 +213,7 @@ update_topline(void)
curwin->w_topline = 1;
curwin->w_botline = 2;
curwin->w_valid |= VALID_BOTLINE|VALID_BOTLINE_AP;
#ifdef FEAT_SCROLLBIND
curwin->w_scbind_pos = 1;
#endif
}
/*
@@ -2773,7 +2769,6 @@ halfpage(int flag, linenr_T Prenum)
redraw_later(VALID);
}
#if defined(FEAT_CURSORBIND) || defined(PROTO)
void
do_check_cursorbind(void)
{
@@ -2846,4 +2841,3 @@ do_check_cursorbind(void)
curwin = old_curwin;
curbuf = old_curbuf;
}
#endif /* FEAT_CURSORBIND */
@@ -1275,21 +1275,17 @@ normal_cmd(
mb_adjust_cursor();
#endif
#ifdef FEAT_SCROLLBIND
if (curwin->w_p_scb && toplevel)
{
validate_cursor(); /* may need to update w_leftcol */
do_check_scrollbind(TRUE);
}
#endif
#ifdef FEAT_CURSORBIND
if (curwin->w_p_crb && toplevel)
{
validate_cursor(); /* may need to update w_leftcol */
do_check_cursorbind();
}
#endif
#ifdef FEAT_TERMINAL
/* don't go to Insert mode if a terminal has a running job */
@@ -3980,7 +3976,6 @@ display_showcmd(void)
}
#endif
#ifdef FEAT_SCROLLBIND
/*
* When "check" is FALSE, prepare for commands that scroll the window.
* When "check" is TRUE, take care of scroll-binding after the window has
@@ -4139,7 +4134,6 @@ check_scrollbind(linenr_T topline_diff, long leftcol_diff)
curwin = old_curwin;
curbuf = old_curbuf;
}
#endif /* #ifdef FEAT_SCROLLBIND */
/*
* Command character that's ignored.
Oops, something went wrong.

0 comments on commit 8a3bb56

Please sign in to comment.