comparison src/normal.c @ 12477:68d7bc045dbe v8.0.1118

patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs commit https://github.com/vim/vim/commit/4033c55eca575777718c0701e26635a0cc47d907 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 16 20:54:51 2017 +0200 patch 8.0.1118: FEAT_WINDOWS adds a lot of #ifdefs Problem: FEAT_WINDOWS adds a lot of #ifdefs while it is nearly always enabled and only adds 7% to the binary size of the tiny build. Solution: Graduate FEAT_WINDOWS.
author Christian Brabandt <cb@256bit.org>
date Sat, 16 Sep 2017 21:00:06 +0200
parents 66fe20238c1d
children 3f16cf18386c
comparison
equal deleted inserted replaced
12476:2516383741e6 12477:68d7bc045dbe
2325 int is_drag; /* If TRUE it's a drag event */ 2325 int is_drag; /* If TRUE it's a drag event */
2326 int jump_flags = 0; /* flags for jump_to_mouse() */ 2326 int jump_flags = 0; /* flags for jump_to_mouse() */
2327 pos_T start_visual; 2327 pos_T start_visual;
2328 int moved; /* Has cursor moved? */ 2328 int moved; /* Has cursor moved? */
2329 int in_status_line; /* mouse in status line */ 2329 int in_status_line; /* mouse in status line */
2330 #ifdef FEAT_WINDOWS
2331 static int in_tab_line = FALSE; /* mouse clicked in tab line */ 2330 static int in_tab_line = FALSE; /* mouse clicked in tab line */
2332 int in_sep_line; /* mouse in vertical separator line */ 2331 int in_sep_line; /* mouse in vertical separator line */
2333 #endif
2334 int c1, c2; 2332 int c1, c2;
2335 #if defined(FEAT_FOLDING) 2333 #if defined(FEAT_FOLDING)
2336 pos_T save_cursor; 2334 pos_T save_cursor;
2337 #endif 2335 #endif
2338 win_T *old_curwin = curwin; 2336 win_T *old_curwin = curwin;
2422 if (!got_click) /* didn't get click, ignore */ 2420 if (!got_click) /* didn't get click, ignore */
2423 return FALSE; 2421 return FALSE;
2424 if (!is_drag) /* release, reset got_click */ 2422 if (!is_drag) /* release, reset got_click */
2425 { 2423 {
2426 got_click = FALSE; 2424 got_click = FALSE;
2427 #ifdef FEAT_WINDOWS
2428 if (in_tab_line) 2425 if (in_tab_line)
2429 { 2426 {
2430 in_tab_line = FALSE; 2427 in_tab_line = FALSE;
2431 return FALSE; 2428 return FALSE;
2432 } 2429 }
2433 #endif
2434 } 2430 }
2435 } 2431 }
2436 2432
2437 /* 2433 /*
2438 * CTRL right mouse button does CTRL-T 2434 * CTRL right mouse button does CTRL-T
2568 if (!is_click) 2564 if (!is_click)
2569 jump_flags |= MOUSE_FOCUS | MOUSE_DID_MOVE; 2565 jump_flags |= MOUSE_FOCUS | MOUSE_DID_MOVE;
2570 2566
2571 start_visual.lnum = 0; 2567 start_visual.lnum = 0;
2572 2568
2573 #ifdef FEAT_WINDOWS
2574 /* Check for clicking in the tab page line. */ 2569 /* Check for clicking in the tab page line. */
2575 if (mouse_row == 0 && firstwin->w_winrow > 0) 2570 if (mouse_row == 0 && firstwin->w_winrow > 0)
2576 { 2571 {
2577 if (is_drag) 2572 if (is_drag)
2578 { 2573 {
2638 { 2633 {
2639 c1 = TabPageIdxs[mouse_col]; 2634 c1 = TabPageIdxs[mouse_col];
2640 tabpage_move(c1 <= 0 ? 9999 : c1 - 1); 2635 tabpage_move(c1 <= 0 ? 9999 : c1 - 1);
2641 return FALSE; 2636 return FALSE;
2642 } 2637 }
2643
2644 #endif
2645 2638
2646 /* 2639 /*
2647 * When 'mousemodel' is "popup" or "popup_setpos", translate mouse events: 2640 * When 'mousemodel' is "popup" or "popup_setpos", translate mouse events:
2648 * right button up -> pop-up menu 2641 * right button up -> pop-up menu
2649 * shift-left button -> right button 2642 * shift-left button -> right button
2801 */ 2794 */
2802 jump_flags = jump_to_mouse(jump_flags, 2795 jump_flags = jump_to_mouse(jump_flags,
2803 oap == NULL ? NULL : &(oap->inclusive), which_button); 2796 oap == NULL ? NULL : &(oap->inclusive), which_button);
2804 moved = (jump_flags & CURSOR_MOVED); 2797 moved = (jump_flags & CURSOR_MOVED);
2805 in_status_line = (jump_flags & IN_STATUS_LINE); 2798 in_status_line = (jump_flags & IN_STATUS_LINE);
2806 #ifdef FEAT_WINDOWS
2807 in_sep_line = (jump_flags & IN_SEP_LINE); 2799 in_sep_line = (jump_flags & IN_SEP_LINE);
2808 #endif
2809 2800
2810 #ifdef FEAT_NETBEANS_INTG 2801 #ifdef FEAT_NETBEANS_INTG
2811 if (isNetbeansBuffer(curbuf) 2802 if (isNetbeansBuffer(curbuf)
2812 && !(jump_flags & (IN_STATUS_LINE | IN_SEP_LINE))) 2803 && !(jump_flags & (IN_STATUS_LINE | IN_SEP_LINE)))
2813 { 2804 {
2982 if (restart_edit != 0) 2973 if (restart_edit != 0)
2983 where_paste_started = curwin->w_cursor; 2974 where_paste_started = curwin->w_cursor;
2984 do_put(regname, dir, count, fixindent | PUT_CURSEND); 2975 do_put(regname, dir, count, fixindent | PUT_CURSEND);
2985 } 2976 }
2986 2977
2987 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 2978 #if defined(FEAT_QUICKFIX)
2988 /* 2979 /*
2989 * Ctrl-Mouse click or double click in a quickfix window jumps to the 2980 * Ctrl-Mouse click or double click in a quickfix window jumps to the
2990 * error under the mouse pointer. 2981 * error under the mouse pointer.
2991 */ 2982 */
2992 else if (((mod_mask & MOD_MASK_CTRL) 2983 else if (((mod_mask & MOD_MASK_CTRL)
3037 drag_status_line = TRUE; 3028 drag_status_line = TRUE;
3038 update_mouseshape(-1); 3029 update_mouseshape(-1);
3039 } 3030 }
3040 #endif 3031 #endif
3041 } 3032 }
3042 #ifdef FEAT_WINDOWS
3043 else if (in_sep_line) 3033 else if (in_sep_line)
3044 { 3034 {
3045 # ifdef FEAT_MOUSESHAPE 3035 #ifdef FEAT_MOUSESHAPE
3046 if ((is_drag || is_click) && !drag_sep_line) 3036 if ((is_drag || is_click) && !drag_sep_line)
3047 { 3037 {
3048 drag_sep_line = TRUE; 3038 drag_sep_line = TRUE;
3049 update_mouseshape(-1); 3039 update_mouseshape(-1);
3050 } 3040 }
3051 # endif 3041 #endif
3052 } 3042 }
3053 #endif
3054 else if ((mod_mask & MOD_MASK_MULTI_CLICK) && (State & (NORMAL | INSERT)) 3043 else if ((mod_mask & MOD_MASK_MULTI_CLICK) && (State & (NORMAL | INSERT))
3055 && mouse_has(MOUSE_VISUAL)) 3044 && mouse_has(MOUSE_VISUAL))
3056 { 3045 {
3057 if (is_click || !VIsual_active) 3046 if (is_click || !VIsual_active)
3058 { 3047 {
4103 scrolldown(-y, FALSE); 4092 scrolldown(-y, FALSE);
4104 } 4093 }
4105 4094
4106 redraw_later(VALID); 4095 redraw_later(VALID);
4107 cursor_correct(); 4096 cursor_correct();
4108 #ifdef FEAT_WINDOWS
4109 curwin->w_redr_status = TRUE; 4097 curwin->w_redr_status = TRUE;
4110 #endif
4111 } 4098 }
4112 4099
4113 /* 4100 /*
4114 * do the horizontal scroll 4101 * do the horizontal scroll
4115 */ 4102 */
4195 static void 4182 static void
4196 nv_page(cmdarg_T *cap) 4183 nv_page(cmdarg_T *cap)
4197 { 4184 {
4198 if (!checkclearop(cap->oap)) 4185 if (!checkclearop(cap->oap))
4199 { 4186 {
4200 #ifdef FEAT_WINDOWS
4201 if (mod_mask & MOD_MASK_CTRL) 4187 if (mod_mask & MOD_MASK_CTRL)
4202 { 4188 {
4203 /* <C-PageUp>: tab page back; <C-PageDown>: tab page forward */ 4189 /* <C-PageUp>: tab page back; <C-PageDown>: tab page forward */
4204 if (cap->arg == BACKWARD) 4190 if (cap->arg == BACKWARD)
4205 goto_tabpage(-(int)cap->count1); 4191 goto_tabpage(-(int)cap->count1);
4206 else 4192 else
4207 goto_tabpage((int)cap->count0); 4193 goto_tabpage((int)cap->count0);
4208 } 4194 }
4209 else 4195 else
4210 #endif 4196 (void)onepage(cap->arg, cap->count1);
4211 (void)onepage(cap->arg, cap->count1);
4212 } 4197 }
4213 } 4198 }
4214 4199
4215 /* 4200 /*
4216 * Implementation of "gd" and "gD" command. 4201 * Implementation of "gd" and "gD" command.
4466 width1 = W_WIDTH(curwin) - col_off1; 4451 width1 = W_WIDTH(curwin) - col_off1;
4467 width2 = W_WIDTH(curwin) - col_off2; 4452 width2 = W_WIDTH(curwin) - col_off2;
4468 if (width2 == 0) 4453 if (width2 == 0)
4469 width2 = 1; /* avoid divide by zero */ 4454 width2 = 1; /* avoid divide by zero */
4470 4455
4471 #ifdef FEAT_WINDOWS
4472 if (curwin->w_width != 0) 4456 if (curwin->w_width != 0)
4473 #endif
4474 { 4457 {
4475 /* 4458 /*
4476 * Instead of sticking at the last character of the buffer line we 4459 * Instead of sticking at the last character of the buffer line we
4477 * try to stick in the last column of the screen. 4460 * try to stick in the last column of the screen.
4478 */ 4461 */
4605 * K_MOUSELEFT (cap->arg == -1) or K_MOUSERIGHT (cap->arg == -2) 4588 * K_MOUSELEFT (cap->arg == -1) or K_MOUSERIGHT (cap->arg == -2)
4606 */ 4589 */
4607 static void 4590 static void
4608 nv_mousescroll(cmdarg_T *cap) 4591 nv_mousescroll(cmdarg_T *cap)
4609 { 4592 {
4610 # ifdef FEAT_WINDOWS
4611 win_T *old_curwin = curwin, *wp; 4593 win_T *old_curwin = curwin, *wp;
4612 4594
4613 if (mouse_row >= 0 && mouse_col >= 0) 4595 if (mouse_row >= 0 && mouse_col >= 0)
4614 { 4596 {
4615 int row, col; 4597 int row, col;
4622 if (wp == NULL) 4604 if (wp == NULL)
4623 return; 4605 return;
4624 curwin = wp; 4606 curwin = wp;
4625 curbuf = curwin->w_buffer; 4607 curbuf = curwin->w_buffer;
4626 } 4608 }
4627 # endif
4628 4609
4629 if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN) 4610 if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN)
4630 { 4611 {
4631 # ifdef FEAT_TERMINAL 4612 # ifdef FEAT_TERMINAL
4632 if (term_use_loop()) 4613 if (term_use_loop())
4661 gui_do_horiz_scroll(val, TRUE); 4642 gui_do_horiz_scroll(val, TRUE);
4662 } 4643 }
4663 } 4644 }
4664 # endif 4645 # endif
4665 4646
4666 # ifdef FEAT_WINDOWS
4667 curwin->w_redr_status = TRUE; 4647 curwin->w_redr_status = TRUE;
4668 4648
4669 curwin = old_curwin; 4649 curwin = old_curwin;
4670 curbuf = curwin->w_buffer; 4650 curbuf = curwin->w_buffer;
4671 # endif
4672 } 4651 }
4673 4652
4674 /* 4653 /*
4675 * Mouse clicks and drags. 4654 * Mouse clicks and drags.
4676 */ 4655 */
5537 default: clearopbeep(cap->oap); 5516 default: clearopbeep(cap->oap);
5538 } 5517 }
5539 } 5518 }
5540 } 5519 }
5541 5520
5542 #if defined(FEAT_WINDOWS) || defined(PROTO)
5543 /* 5521 /*
5544 * Call nv_ident() as if "c1" was used, with "c2" as next character. 5522 * Call nv_ident() as if "c1" was used, with "c2" as next character.
5545 */ 5523 */
5546 void 5524 void
5547 do_nv_ident(int c1, int c2) 5525 do_nv_ident(int c1, int c2)
5554 ca.oap = &oa; 5532 ca.oap = &oa;
5555 ca.cmdchar = c1; 5533 ca.cmdchar = c1;
5556 ca.nchar = c2; 5534 ca.nchar = c2;
5557 nv_ident(&ca); 5535 nv_ident(&ca);
5558 } 5536 }
5559 #endif
5560 5537
5561 /* 5538 /*
5562 * Handle the commands that use the word under the cursor. 5539 * Handle the commands that use the word under the cursor.
5563 * [g] CTRL-] :ta to current identifier 5540 * [g] CTRL-] :ta to current identifier
5564 * [g] 'K' run program for current identifier 5541 * [g] 'K' run program for current identifier
6196 /* <S-Down> is page down */ 6173 /* <S-Down> is page down */
6197 cap->arg = FORWARD; 6174 cap->arg = FORWARD;
6198 nv_page(cap); 6175 nv_page(cap);
6199 } 6176 }
6200 else 6177 else
6201 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) 6178 #if defined(FEAT_QUICKFIX)
6202 /* In a quickfix window a <CR> jumps to the error under the cursor. */ 6179 /* In a quickfix window a <CR> jumps to the error under the cursor. */
6203 if (bt_quickfix(curbuf) && cap->cmdchar == CAR) 6180 if (bt_quickfix(curbuf) && cap->cmdchar == CAR)
6204 { 6181 {
6205 if (curwin->w_llist_ref == NULL) 6182 if (curwin->w_llist_ref == NULL)
6206 do_cmdline_cmd((char_u *)".cc"); /* quickfix window */ 6183 do_cmdline_cmd((char_u *)".cc"); /* quickfix window */
7844 * CTRL-W: Window commands 7821 * CTRL-W: Window commands
7845 */ 7822 */
7846 static void 7823 static void
7847 nv_window(cmdarg_T *cap) 7824 nv_window(cmdarg_T *cap)
7848 { 7825 {
7849 #ifdef FEAT_WINDOWS
7850 if (cap->nchar == ':') 7826 if (cap->nchar == ':')
7851 /* "CTRL-W :" is the same as typing ":"; useful in a terminal window */ 7827 /* "CTRL-W :" is the same as typing ":"; useful in a terminal window */
7852 nv_colon(cap); 7828 nv_colon(cap);
7853 else if (!checkclearop(cap->oap)) 7829 else if (!checkclearop(cap->oap))
7854 do_window(cap->nchar, cap->count0, NUL); /* everything is in window.c */ 7830 do_window(cap->nchar, cap->count0, NUL); /* everything is in window.c */
7855 #else
7856 (void)checkclearop(cap->oap);
7857 #endif
7858 } 7831 }
7859 7832
7860 /* 7833 /*
7861 * CTRL-Z: Suspend 7834 * CTRL-Z: Suspend
7862 */ 7835 */
8096 case 'm': 8069 case 'm':
8097 case K_HOME: 8070 case K_HOME:
8098 case K_KHOME: 8071 case K_KHOME:
8099 oap->motion_type = MCHAR; 8072 oap->motion_type = MCHAR;
8100 oap->inclusive = FALSE; 8073 oap->inclusive = FALSE;
8101 if (curwin->w_p_wrap 8074 if (curwin->w_p_wrap && curwin->w_width != 0)
8102 #ifdef FEAT_WINDOWS
8103 && curwin->w_width != 0
8104 #endif
8105 )
8106 { 8075 {
8107 int width1 = W_WIDTH(curwin) - curwin_col_off(); 8076 int width1 = W_WIDTH(curwin) - curwin_col_off();
8108 int width2 = width1 + curwin_col_off2(); 8077 int width2 = width1 + curwin_col_off2();
8109 8078
8110 validate_virtcol(); 8079 validate_virtcol();
8163 { 8132 {
8164 int col_off = curwin_col_off(); 8133 int col_off = curwin_col_off();
8165 8134
8166 oap->motion_type = MCHAR; 8135 oap->motion_type = MCHAR;
8167 oap->inclusive = TRUE; 8136 oap->inclusive = TRUE;
8168 if (curwin->w_p_wrap 8137 if (curwin->w_p_wrap && curwin->w_width != 0)
8169 #ifdef FEAT_WINDOWS
8170 && curwin->w_width != 0
8171 #endif
8172 )
8173 { 8138 {
8174 curwin->w_curswant = MAXCOL; /* so we stay at the end */ 8139 curwin->w_curswant = MAXCOL; /* so we stay at the end */
8175 if (cap->count1 == 1) 8140 if (cap->count1 == 1)
8176 { 8141 {
8177 int width1 = W_WIDTH(curwin) - col_off; 8142 int width1 = W_WIDTH(curwin) - col_off;
8438 cap->count1 = -cap->count1; 8403 cap->count1 = -cap->count1;
8439 nv_pcmark(cap); 8404 nv_pcmark(cap);
8440 break; 8405 break;
8441 #endif 8406 #endif
8442 8407
8443 #ifdef FEAT_WINDOWS
8444 case 't': 8408 case 't':
8445 if (!checkclearop(oap)) 8409 if (!checkclearop(oap))
8446 goto_tabpage((int)cap->count0); 8410 goto_tabpage((int)cap->count0);
8447 break; 8411 break;
8448 case 'T': 8412 case 'T':
8449 if (!checkclearop(oap)) 8413 if (!checkclearop(oap))
8450 goto_tabpage(-(int)cap->count1); 8414 goto_tabpage(-(int)cap->count1);
8451 break; 8415 break;
8452 #endif
8453 8416
8454 case '+': 8417 case '+':
8455 case '-': /* "g+" and "g-": undo or redo along the timeline */ 8418 case '-': /* "g+" and "g-": undo or redo along the timeline */
8456 if (!checkclearopq(oap)) 8419 if (!checkclearopq(oap))
8457 undo_time(cap->nchar == '-' ? -cap->count1 : cap->count1, 8420 undo_time(cap->nchar == '-' ? -cap->count1 : cap->count1,