Mercurial > vim
comparison src/ui.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 | 040a892d0eed |
children | 3f16cf18386c |
comparison
equal
deleted
inserted
replaced
12476:2516383741e6 | 12477:68d7bc045dbe |
---|---|
2608 int flags, | 2608 int flags, |
2609 int *inclusive, /* used for inclusive operator, can be NULL */ | 2609 int *inclusive, /* used for inclusive operator, can be NULL */ |
2610 int which_button) /* MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE */ | 2610 int which_button) /* MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE */ |
2611 { | 2611 { |
2612 static int on_status_line = 0; /* #lines below bottom of window */ | 2612 static int on_status_line = 0; /* #lines below bottom of window */ |
2613 #ifdef FEAT_WINDOWS | |
2614 static int on_sep_line = 0; /* on separator right of window */ | 2613 static int on_sep_line = 0; /* on separator right of window */ |
2615 #endif | |
2616 static int prev_row = -1; | 2614 static int prev_row = -1; |
2617 static int prev_col = -1; | 2615 static int prev_col = -1; |
2618 static win_T *dragwin = NULL; /* window being dragged */ | 2616 static win_T *dragwin = NULL; /* window being dragged */ |
2619 static int did_drag = FALSE; /* drag was noticed */ | 2617 static int did_drag = FALSE; /* drag was noticed */ |
2620 | 2618 |
2648 retnomove: | 2646 retnomove: |
2649 /* before moving the cursor for a left click which is NOT in a status | 2647 /* before moving the cursor for a left click which is NOT in a status |
2650 * line, stop Visual mode */ | 2648 * line, stop Visual mode */ |
2651 if (on_status_line) | 2649 if (on_status_line) |
2652 return IN_STATUS_LINE; | 2650 return IN_STATUS_LINE; |
2653 #ifdef FEAT_WINDOWS | |
2654 if (on_sep_line) | 2651 if (on_sep_line) |
2655 return IN_SEP_LINE; | 2652 return IN_SEP_LINE; |
2656 #endif | |
2657 if (flags & MOUSE_MAY_STOP_VIS) | 2653 if (flags & MOUSE_MAY_STOP_VIS) |
2658 { | 2654 { |
2659 end_visual_mode(); | 2655 end_visual_mode(); |
2660 redraw_curbuf_later(INVERTED); /* delete the inversion */ | 2656 redraw_curbuf_later(INVERTED); /* delete the inversion */ |
2661 } | 2657 } |
2689 if (!(flags & MOUSE_FOCUS)) | 2685 if (!(flags & MOUSE_FOCUS)) |
2690 { | 2686 { |
2691 if (row < 0 || col < 0) /* check if it makes sense */ | 2687 if (row < 0 || col < 0) /* check if it makes sense */ |
2692 return IN_UNKNOWN; | 2688 return IN_UNKNOWN; |
2693 | 2689 |
2694 #ifdef FEAT_WINDOWS | |
2695 /* find the window where the row is in */ | 2690 /* find the window where the row is in */ |
2696 wp = mouse_find_win(&row, &col); | 2691 wp = mouse_find_win(&row, &col); |
2697 if (wp == NULL) | 2692 if (wp == NULL) |
2698 return IN_UNKNOWN; | 2693 return IN_UNKNOWN; |
2699 #else | |
2700 wp = firstwin; | |
2701 #endif | |
2702 dragwin = NULL; | 2694 dragwin = NULL; |
2703 /* | 2695 /* |
2704 * winpos and height may change in win_enter()! | 2696 * winpos and height may change in win_enter()! |
2705 */ | 2697 */ |
2706 if (row >= wp->w_height) /* In (or below) status line */ | 2698 if (row >= wp->w_height) /* In (or below) status line */ |
2708 on_status_line = row - wp->w_height + 1; | 2700 on_status_line = row - wp->w_height + 1; |
2709 dragwin = wp; | 2701 dragwin = wp; |
2710 } | 2702 } |
2711 else | 2703 else |
2712 on_status_line = 0; | 2704 on_status_line = 0; |
2713 #ifdef FEAT_WINDOWS | |
2714 if (col >= wp->w_width) /* In separator line */ | 2705 if (col >= wp->w_width) /* In separator line */ |
2715 { | 2706 { |
2716 on_sep_line = col - wp->w_width + 1; | 2707 on_sep_line = col - wp->w_width + 1; |
2717 dragwin = wp; | 2708 dragwin = wp; |
2718 } | 2709 } |
2726 if (stl_connected(wp)) | 2717 if (stl_connected(wp)) |
2727 on_sep_line = 0; | 2718 on_sep_line = 0; |
2728 else | 2719 else |
2729 on_status_line = 0; | 2720 on_status_line = 0; |
2730 } | 2721 } |
2731 #endif | |
2732 | 2722 |
2733 /* Before jumping to another buffer, or moving the cursor for a left | 2723 /* Before jumping to another buffer, or moving the cursor for a left |
2734 * click, stop Visual mode. */ | 2724 * click, stop Visual mode. */ |
2735 if (VIsual_active | 2725 if (VIsual_active |
2736 && (wp->w_buffer != curwin->w_buffer | 2726 && (wp->w_buffer != curwin->w_buffer |
2737 || (!on_status_line | 2727 || (!on_status_line && !on_sep_line |
2738 #ifdef FEAT_WINDOWS | |
2739 && !on_sep_line | |
2740 #endif | |
2741 #ifdef FEAT_FOLDING | 2728 #ifdef FEAT_FOLDING |
2742 && ( | 2729 && ( |
2743 # ifdef FEAT_RIGHTLEFT | 2730 # ifdef FEAT_RIGHTLEFT |
2744 wp->w_p_rl ? col < W_WIDTH(wp) - wp->w_p_fdc : | 2731 wp->w_p_rl ? col < W_WIDTH(wp) - wp->w_p_fdc : |
2745 # endif | 2732 # endif |
2769 col += wp->w_wincol; | 2756 col += wp->w_wincol; |
2770 wp = curwin; | 2757 wp = curwin; |
2771 # endif | 2758 # endif |
2772 } | 2759 } |
2773 #endif | 2760 #endif |
2774 #ifdef FEAT_WINDOWS | |
2775 /* Only change window focus when not clicking on or dragging the | 2761 /* Only change window focus when not clicking on or dragging the |
2776 * status line. Do change focus when releasing the mouse button | 2762 * status line. Do change focus when releasing the mouse button |
2777 * (MOUSE_FOCUS was set above if we dragged first). */ | 2763 * (MOUSE_FOCUS was set above if we dragged first). */ |
2778 if (dragwin == NULL || (flags & MOUSE_RELEASED)) | 2764 if (dragwin == NULL || (flags & MOUSE_RELEASED)) |
2779 win_enter(wp, TRUE); /* can make wp invalid! */ | 2765 win_enter(wp, TRUE); /* can make wp invalid! */ |
2780 # ifdef CHECK_DOUBLE_CLICK | 2766 #ifdef CHECK_DOUBLE_CLICK |
2781 /* set topline, to be able to check for double click ourselves */ | 2767 /* set topline, to be able to check for double click ourselves */ |
2782 if (curwin != old_curwin) | 2768 if (curwin != old_curwin) |
2783 set_mouse_topline(curwin); | 2769 set_mouse_topline(curwin); |
2784 # endif | |
2785 #endif | 2770 #endif |
2786 if (on_status_line) /* In (or below) status line */ | 2771 if (on_status_line) /* In (or below) status line */ |
2787 { | 2772 { |
2788 /* Don't use start_arrow() if we're in the same window */ | 2773 /* Don't use start_arrow() if we're in the same window */ |
2789 if (curwin == old_curwin) | 2774 if (curwin == old_curwin) |
2790 return IN_STATUS_LINE; | 2775 return IN_STATUS_LINE; |
2791 else | 2776 else |
2792 return IN_STATUS_LINE | CURSOR_MOVED; | 2777 return IN_STATUS_LINE | CURSOR_MOVED; |
2793 } | 2778 } |
2794 #ifdef FEAT_WINDOWS | |
2795 if (on_sep_line) /* In (or below) status line */ | 2779 if (on_sep_line) /* In (or below) status line */ |
2796 { | 2780 { |
2797 /* Don't use start_arrow() if we're in the same window */ | 2781 /* Don't use start_arrow() if we're in the same window */ |
2798 if (curwin == old_curwin) | 2782 if (curwin == old_curwin) |
2799 return IN_SEP_LINE; | 2783 return IN_SEP_LINE; |
2800 else | 2784 else |
2801 return IN_SEP_LINE | CURSOR_MOVED; | 2785 return IN_SEP_LINE | CURSOR_MOVED; |
2802 } | 2786 } |
2803 #endif | |
2804 | 2787 |
2805 curwin->w_cursor.lnum = curwin->w_topline; | 2788 curwin->w_cursor.lnum = curwin->w_topline; |
2806 #ifdef FEAT_GUI | 2789 #ifdef FEAT_GUI |
2807 /* remember topline, needed for double click */ | 2790 /* remember topline, needed for double click */ |
2808 gui_prev_topline = curwin->w_topline; | 2791 gui_prev_topline = curwin->w_topline; |
2811 # endif | 2794 # endif |
2812 #endif | 2795 #endif |
2813 } | 2796 } |
2814 else if (on_status_line && which_button == MOUSE_LEFT) | 2797 else if (on_status_line && which_button == MOUSE_LEFT) |
2815 { | 2798 { |
2816 #ifdef FEAT_WINDOWS | |
2817 if (dragwin != NULL) | 2799 if (dragwin != NULL) |
2818 { | 2800 { |
2819 /* Drag the status line */ | 2801 /* Drag the status line */ |
2820 count = row - dragwin->w_winrow - dragwin->w_height + 1 | 2802 count = row - dragwin->w_winrow - dragwin->w_height + 1 |
2821 - on_status_line; | 2803 - on_status_line; |
2822 win_drag_status_line(dragwin, count); | 2804 win_drag_status_line(dragwin, count); |
2823 did_drag |= count; | 2805 did_drag |= count; |
2824 } | 2806 } |
2825 #endif | |
2826 return IN_STATUS_LINE; /* Cursor didn't move */ | 2807 return IN_STATUS_LINE; /* Cursor didn't move */ |
2827 } | 2808 } |
2828 #ifdef FEAT_WINDOWS | |
2829 else if (on_sep_line && which_button == MOUSE_LEFT) | 2809 else if (on_sep_line && which_button == MOUSE_LEFT) |
2830 { | 2810 { |
2831 if (dragwin != NULL) | 2811 if (dragwin != NULL) |
2832 { | 2812 { |
2833 /* Drag the separator column */ | 2813 /* Drag the separator column */ |
2836 win_drag_vsep_line(dragwin, count); | 2816 win_drag_vsep_line(dragwin, count); |
2837 did_drag |= count; | 2817 did_drag |= count; |
2838 } | 2818 } |
2839 return IN_SEP_LINE; /* Cursor didn't move */ | 2819 return IN_SEP_LINE; /* Cursor didn't move */ |
2840 } | 2820 } |
2841 #endif | |
2842 else /* keep_window_focus must be TRUE */ | 2821 else /* keep_window_focus must be TRUE */ |
2843 { | 2822 { |
2844 /* before moving the cursor for a left click, stop Visual mode */ | 2823 /* before moving the cursor for a left click, stop Visual mode */ |
2845 if (flags & MOUSE_MAY_STOP_VIS) | 2824 if (flags & MOUSE_MAY_STOP_VIS) |
2846 { | 2825 { |
2853 if (cmdwin_type != 0 && row < W_WINROW(curwin)) | 2832 if (cmdwin_type != 0 && row < W_WINROW(curwin)) |
2854 return IN_OTHER_WIN; | 2833 return IN_OTHER_WIN; |
2855 #endif | 2834 #endif |
2856 | 2835 |
2857 row -= W_WINROW(curwin); | 2836 row -= W_WINROW(curwin); |
2858 #ifdef FEAT_WINDOWS | |
2859 col -= W_WINCOL(curwin); | 2837 col -= W_WINCOL(curwin); |
2860 #endif | |
2861 | 2838 |
2862 /* | 2839 /* |
2863 * When clicking beyond the end of the window, scroll the screen. | 2840 * When clicking beyond the end of the window, scroll the screen. |
2864 * Scroll by however many rows outside the window we are. | 2841 * Scroll by however many rows outside the window we are. |
2865 */ | 2842 */ |
3098 *rowp = row; | 3075 *rowp = row; |
3099 *lnump = lnum; | 3076 *lnump = lnum; |
3100 return retval; | 3077 return retval; |
3101 } | 3078 } |
3102 | 3079 |
3103 #if defined(FEAT_WINDOWS) || defined(PROTO) | |
3104 /* | 3080 /* |
3105 * Find the window at screen position "*rowp" and "*colp". The positions are | 3081 * Find the window at screen position "*rowp" and "*colp". The positions are |
3106 * updated to become relative to the top-left of the window. | 3082 * updated to become relative to the top-left of the window. |
3107 * Returns NULL when something is wrong. | 3083 * Returns NULL when something is wrong. |
3108 */ | 3084 */ |
3142 FOR_ALL_WINDOWS(wp) | 3118 FOR_ALL_WINDOWS(wp) |
3143 if (wp == fp->fr_win) | 3119 if (wp == fp->fr_win) |
3144 return wp; | 3120 return wp; |
3145 return NULL; | 3121 return NULL; |
3146 } | 3122 } |
3147 #endif | |
3148 | 3123 |
3149 #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MAC) \ | 3124 #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MAC) \ |
3150 || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ | 3125 || defined(FEAT_GUI_ATHENA) || defined(FEAT_GUI_MSWIN) \ |
3151 || defined(FEAT_GUI_PHOTON) || defined(PROTO) | 3126 || defined(FEAT_GUI_PHOTON) || defined(PROTO) |
3152 /* | 3127 /* |
3160 int col = mouse_col; | 3135 int col = mouse_col; |
3161 | 3136 |
3162 if (row < 0 || col < 0) /* check if it makes sense */ | 3137 if (row < 0 || col < 0) /* check if it makes sense */ |
3163 return IN_UNKNOWN; | 3138 return IN_UNKNOWN; |
3164 | 3139 |
3165 #ifdef FEAT_WINDOWS | |
3166 /* find the window where the row is in */ | 3140 /* find the window where the row is in */ |
3167 wp = mouse_find_win(&row, &col); | 3141 wp = mouse_find_win(&row, &col); |
3168 if (wp == NULL) | 3142 if (wp == NULL) |
3169 return IN_UNKNOWN; | 3143 return IN_UNKNOWN; |
3170 #else | |
3171 wp = firstwin; | |
3172 #endif | |
3173 /* | 3144 /* |
3174 * winpos and height may change in win_enter()! | 3145 * winpos and height may change in win_enter()! |
3175 */ | 3146 */ |
3176 if (row >= wp->w_height) /* In (or below) status line */ | 3147 if (row >= wp->w_height) /* In (or below) status line */ |
3177 return IN_STATUS_LINE; | 3148 return IN_STATUS_LINE; |
3178 #ifdef FEAT_WINDOWS | |
3179 if (col >= wp->w_width) /* In vertical separator line */ | 3149 if (col >= wp->w_width) /* In vertical separator line */ |
3180 return IN_SEP_LINE; | 3150 return IN_SEP_LINE; |
3181 #endif | |
3182 | 3151 |
3183 if (wp != curwin) | 3152 if (wp != curwin) |
3184 return IN_UNKNOWN; | 3153 return IN_UNKNOWN; |
3185 | 3154 |
3186 /* compute the position in the buffer line from the posn on the screen */ | 3155 /* compute the position in the buffer line from the posn on the screen */ |