Mercurial > vim
comparison src/edit.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 | 4dba3e4f3b01 |
children | 3ca08bf99396 |
comparison
equal
deleted
inserted
replaced
12476:2516383741e6 | 12477:68d7bc045dbe |
---|---|
1358 case K_KENTER: /* <Enter> */ | 1358 case K_KENTER: /* <Enter> */ |
1359 c = CAR; | 1359 c = CAR; |
1360 /* FALLTHROUGH */ | 1360 /* FALLTHROUGH */ |
1361 case CAR: | 1361 case CAR: |
1362 case NL: | 1362 case NL: |
1363 #if defined(FEAT_WINDOWS) && defined(FEAT_QUICKFIX) | 1363 #if defined(FEAT_QUICKFIX) |
1364 /* In a quickfix window a <CR> jumps to the error under the | 1364 /* In a quickfix window a <CR> jumps to the error under the |
1365 * cursor. */ | 1365 * cursor. */ |
1366 if (bt_quickfix(curbuf) && c == CAR) | 1366 if (bt_quickfix(curbuf) && c == CAR) |
1367 { | 1367 { |
1368 if (curwin->w_llist_ref == NULL) /* quickfix window */ | 1368 if (curwin->w_llist_ref == NULL) /* quickfix window */ |
4043 * Returns the buffer to scan, if any, otherwise returns curbuf -- Acevedo | 4043 * Returns the buffer to scan, if any, otherwise returns curbuf -- Acevedo |
4044 */ | 4044 */ |
4045 static buf_T * | 4045 static buf_T * |
4046 ins_compl_next_buf(buf_T *buf, int flag) | 4046 ins_compl_next_buf(buf_T *buf, int flag) |
4047 { | 4047 { |
4048 #ifdef FEAT_WINDOWS | |
4049 static win_T *wp; | 4048 static win_T *wp; |
4050 #endif | |
4051 | 4049 |
4052 if (flag == 'w') /* just windows */ | 4050 if (flag == 'w') /* just windows */ |
4053 { | 4051 { |
4054 #ifdef FEAT_WINDOWS | |
4055 if (buf == curbuf) /* first call for this flag/expansion */ | 4052 if (buf == curbuf) /* first call for this flag/expansion */ |
4056 wp = curwin; | 4053 wp = curwin; |
4057 while ((wp = (wp->w_next != NULL ? wp->w_next : firstwin)) != curwin | 4054 while ((wp = (wp->w_next != NULL ? wp->w_next : firstwin)) != curwin |
4058 && wp->w_buffer->b_scanned) | 4055 && wp->w_buffer->b_scanned) |
4059 ; | 4056 ; |
4060 buf = wp->w_buffer; | 4057 buf = wp->w_buffer; |
4061 #else | |
4062 buf = curbuf; | |
4063 #endif | |
4064 } | 4058 } |
4065 else | 4059 else |
4066 /* 'b' (just loaded buffers), 'u' (just non-loaded buffers) or 'U' | 4060 /* 'b' (just loaded buffers), 'u' (just non-loaded buffers) or 'U' |
4067 * (unlisted buffers) | 4061 * (unlisted buffers) |
4068 * When completing whole lines skip unloaded buffers. */ | 4062 * When completing whole lines skip unloaded buffers. */ |
8538 #ifdef FEAT_GUI | 8532 #ifdef FEAT_GUI |
8539 /* may show different cursor shape or color */ | 8533 /* may show different cursor shape or color */ |
8540 if (gui.in_use) | 8534 if (gui.in_use) |
8541 gui_update_cursor(TRUE, FALSE); | 8535 gui_update_cursor(TRUE, FALSE); |
8542 #endif | 8536 #endif |
8543 #if defined(FEAT_WINDOWS) && defined(FEAT_KEYMAP) | 8537 #if defined(FEAT_KEYMAP) |
8544 /* Show/unshow value of 'keymap' in status lines. */ | 8538 /* Show/unshow value of 'keymap' in status lines. */ |
8545 status_redraw_curbuf(); | 8539 status_redraw_curbuf(); |
8546 #endif | 8540 #endif |
8547 } | 8541 } |
8548 | 8542 |
9380 | 9374 |
9381 undisplay_dollar(); | 9375 undisplay_dollar(); |
9382 tpos = curwin->w_cursor; | 9376 tpos = curwin->w_cursor; |
9383 if (do_mouse(NULL, c, BACKWARD, 1L, 0)) | 9377 if (do_mouse(NULL, c, BACKWARD, 1L, 0)) |
9384 { | 9378 { |
9385 #ifdef FEAT_WINDOWS | |
9386 win_T *new_curwin = curwin; | 9379 win_T *new_curwin = curwin; |
9387 | 9380 |
9388 if (curwin != old_curwin && win_valid(old_curwin)) | 9381 if (curwin != old_curwin && win_valid(old_curwin)) |
9389 { | 9382 { |
9390 /* Mouse took us to another window. We need to go back to the | 9383 /* Mouse took us to another window. We need to go back to the |
9391 * previous one to stop insert there properly. */ | 9384 * previous one to stop insert there properly. */ |
9392 curwin = old_curwin; | 9385 curwin = old_curwin; |
9393 curbuf = curwin->w_buffer; | 9386 curbuf = curwin->w_buffer; |
9394 } | 9387 } |
9395 #endif | |
9396 start_arrow(curwin == old_curwin ? &tpos : NULL); | 9388 start_arrow(curwin == old_curwin ? &tpos : NULL); |
9397 #ifdef FEAT_WINDOWS | |
9398 if (curwin != new_curwin && win_valid(new_curwin)) | 9389 if (curwin != new_curwin && win_valid(new_curwin)) |
9399 { | 9390 { |
9400 curwin = new_curwin; | 9391 curwin = new_curwin; |
9401 curbuf = curwin->w_buffer; | 9392 curbuf = curwin->w_buffer; |
9402 } | 9393 } |
9403 #endif | |
9404 # ifdef FEAT_CINDENT | 9394 # ifdef FEAT_CINDENT |
9405 can_cindent = TRUE; | 9395 can_cindent = TRUE; |
9406 # endif | 9396 # endif |
9407 } | 9397 } |
9408 | 9398 |
9409 #ifdef FEAT_WINDOWS | |
9410 /* redraw status lines (in case another window became active) */ | 9399 /* redraw status lines (in case another window became active) */ |
9411 redraw_statuslines(); | 9400 redraw_statuslines(); |
9412 #endif | |
9413 } | 9401 } |
9414 | 9402 |
9415 static void | 9403 static void |
9416 ins_mousescroll(int dir) | 9404 ins_mousescroll(int dir) |
9417 { | 9405 { |
9418 pos_T tpos; | 9406 pos_T tpos; |
9419 # if defined(FEAT_WINDOWS) | |
9420 win_T *old_curwin = curwin, *wp; | 9407 win_T *old_curwin = curwin, *wp; |
9421 # endif | |
9422 # ifdef FEAT_INS_EXPAND | 9408 # ifdef FEAT_INS_EXPAND |
9423 int did_scroll = FALSE; | 9409 int did_scroll = FALSE; |
9424 # endif | 9410 # endif |
9425 | 9411 |
9426 tpos = curwin->w_cursor; | 9412 tpos = curwin->w_cursor; |
9427 | 9413 |
9428 # ifdef FEAT_WINDOWS | |
9429 if (mouse_row >= 0 && mouse_col >= 0) | 9414 if (mouse_row >= 0 && mouse_col >= 0) |
9430 { | 9415 { |
9431 int row, col; | 9416 int row, col; |
9432 | 9417 |
9433 row = mouse_row; | 9418 row = mouse_row; |
9439 return; | 9424 return; |
9440 curwin = wp; | 9425 curwin = wp; |
9441 curbuf = curwin->w_buffer; | 9426 curbuf = curwin->w_buffer; |
9442 } | 9427 } |
9443 if (curwin == old_curwin) | 9428 if (curwin == old_curwin) |
9444 # endif | |
9445 undisplay_dollar(); | 9429 undisplay_dollar(); |
9446 | 9430 |
9447 # ifdef FEAT_INS_EXPAND | 9431 # ifdef FEAT_INS_EXPAND |
9448 /* Don't scroll the window in which completion is being done. */ | 9432 /* Don't scroll the window in which completion is being done. */ |
9449 if (!pum_visible() | 9433 if (!pum_visible() || curwin != old_curwin) |
9450 # if defined(FEAT_WINDOWS) | |
9451 || curwin != old_curwin | |
9452 # endif | |
9453 ) | |
9454 # endif | 9434 # endif |
9455 { | 9435 { |
9456 if (dir == MSCR_DOWN || dir == MSCR_UP) | 9436 if (dir == MSCR_DOWN || dir == MSCR_UP) |
9457 { | 9437 { |
9458 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) | 9438 if (mod_mask & (MOD_MASK_SHIFT | MOD_MASK_CTRL)) |
9477 # ifdef FEAT_INS_EXPAND | 9457 # ifdef FEAT_INS_EXPAND |
9478 did_scroll = TRUE; | 9458 did_scroll = TRUE; |
9479 # endif | 9459 # endif |
9480 } | 9460 } |
9481 | 9461 |
9482 # ifdef FEAT_WINDOWS | |
9483 curwin->w_redr_status = TRUE; | 9462 curwin->w_redr_status = TRUE; |
9484 | 9463 |
9485 curwin = old_curwin; | 9464 curwin = old_curwin; |
9486 curbuf = curwin->w_buffer; | 9465 curbuf = curwin->w_buffer; |
9487 # endif | |
9488 | 9466 |
9489 # ifdef FEAT_INS_EXPAND | 9467 # ifdef FEAT_INS_EXPAND |
9490 /* The popup menu may overlay the window, need to redraw it. | 9468 /* The popup menu may overlay the window, need to redraw it. |
9491 * TODO: Would be more efficient to only redraw the windows that are | 9469 * TODO: Would be more efficient to only redraw the windows that are |
9492 * overlapped by the popup menu. */ | 9470 * overlapped by the popup menu. */ |
9881 { | 9859 { |
9882 pos_T tpos; | 9860 pos_T tpos; |
9883 | 9861 |
9884 undisplay_dollar(); | 9862 undisplay_dollar(); |
9885 | 9863 |
9886 #ifdef FEAT_WINDOWS | |
9887 if (mod_mask & MOD_MASK_CTRL) | 9864 if (mod_mask & MOD_MASK_CTRL) |
9888 { | 9865 { |
9889 /* <C-PageUp>: tab page back */ | 9866 /* <C-PageUp>: tab page back */ |
9890 if (first_tabpage->tp_next != NULL) | 9867 if (first_tabpage->tp_next != NULL) |
9891 { | 9868 { |
9892 start_arrow(&curwin->w_cursor); | 9869 start_arrow(&curwin->w_cursor); |
9893 goto_tabpage(-1); | 9870 goto_tabpage(-1); |
9894 } | 9871 } |
9895 return; | 9872 return; |
9896 } | 9873 } |
9897 #endif | |
9898 | 9874 |
9899 tpos = curwin->w_cursor; | 9875 tpos = curwin->w_cursor; |
9900 if (onepage(BACKWARD, 1L) == OK) | 9876 if (onepage(BACKWARD, 1L) == OK) |
9901 { | 9877 { |
9902 start_arrow(&tpos); | 9878 start_arrow(&tpos); |
9944 { | 9920 { |
9945 pos_T tpos; | 9921 pos_T tpos; |
9946 | 9922 |
9947 undisplay_dollar(); | 9923 undisplay_dollar(); |
9948 | 9924 |
9949 #ifdef FEAT_WINDOWS | |
9950 if (mod_mask & MOD_MASK_CTRL) | 9925 if (mod_mask & MOD_MASK_CTRL) |
9951 { | 9926 { |
9952 /* <C-PageDown>: tab page forward */ | 9927 /* <C-PageDown>: tab page forward */ |
9953 if (first_tabpage->tp_next != NULL) | 9928 if (first_tabpage->tp_next != NULL) |
9954 { | 9929 { |
9955 start_arrow(&curwin->w_cursor); | 9930 start_arrow(&curwin->w_cursor); |
9956 goto_tabpage(0); | 9931 goto_tabpage(0); |
9957 } | 9932 } |
9958 return; | 9933 return; |
9959 } | 9934 } |
9960 #endif | |
9961 | 9935 |
9962 tpos = curwin->w_cursor; | 9936 tpos = curwin->w_cursor; |
9963 if (onepage(FORWARD, 1L) == OK) | 9937 if (onepage(FORWARD, 1L) == OK) |
9964 { | 9938 { |
9965 start_arrow(&tpos); | 9939 start_arrow(&tpos); |