diff options
Diffstat (limited to 'src/nvim/mouse.c')
-rw-r--r-- | src/nvim/mouse.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c index f393b0fd0f..884bc88d73 100644 --- a/src/nvim/mouse.c +++ b/src/nvim/mouse.c @@ -194,7 +194,11 @@ static void call_click_def_func(StlClickDefinition *click_defs, int col, int whi ? "r" : (which_button == MOUSE_MIDDLE ? "m" - : "?"))) + : (which_button == MOUSE_X1 + ? "x1" + : (which_button == MOUSE_X2 + ? "x2" + : "?"))))) }, }, { @@ -250,11 +254,17 @@ static int get_fpos_of_mouse(pos_T *mpos) } // winpos and height may change in win_enter()! - if (winrow >= wp->w_height_inner) { // In (or below) status line + if (winrow >= wp->w_height_inner + wp->w_status_height) { // Below window + if (mouse_grid <= 1 && mouse_row < Rows - p_ch + && mouse_row >= Rows - p_ch - global_stl_height()) { // In global status line + return IN_STATUS_LINE; + } + return IN_UNKNOWN; + } else if (winrow >= wp->w_height_inner) { // In window status line return IN_STATUS_LINE; } - if (winrow < 0 && winrow + wp->w_winbar_height >= 0) { + if (winrow < 0 && winrow + wp->w_winbar_height >= 0) { // In winbar return MOUSE_WINBAR; } @@ -688,6 +698,9 @@ popupexit: if (in_statuscol && wp->w_p_rl) { click_col = wp->w_width_inner - click_col - 1; } + if (in_statuscol && click_col >= (int)wp->w_statuscol_click_defs_size) { + return false; + } if (click_defs != NULL) { switch (click_defs[click_col].type) { @@ -1041,9 +1054,7 @@ void do_mousescroll(cmdarg_T *cap) // Horizontal scrolling int step = shift_or_ctrl ? curwin->w_width_inner : (int)p_mousescroll_hor; colnr_T leftcol = curwin->w_leftcol + (cap->arg == MSCR_RIGHT ? -step : +step); - if (leftcol < 0) { - leftcol = 0; - } + leftcol = MAX(leftcol, 0); do_mousescroll_horiz(leftcol); } } @@ -1610,11 +1621,8 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump) while (row > 0) { // Don't include filler lines in "count" if (win_may_fill(win)) { - if (lnum == win->w_topline) { - row -= win->w_topfill; - } else { - row -= win_get_fill(win, lnum); - } + row -= lnum == win->w_topline ? win->w_topfill + : win_get_fill(win, lnum); count = plines_win_nofill(win, lnum, false); } else { count = plines_win(win, lnum, false); @@ -1655,9 +1663,7 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump) if (!retval) { // Compute the column without wrapping. int off = win_col_off(win) - win_col_off2(win); - if (col < off) { - col = off; - } + col = MAX(col, off); col += row * (win->w_width_inner - off); // Add skip column for the topline. @@ -1672,9 +1678,7 @@ bool mouse_comp_pos(win_T *win, int *rowp, int *colp, linenr_T *lnump) // skip line number and fold column in front of the line col -= win_col_off(win); - if (col <= 0) { - col = 0; - } + col = MAX(col, 0); *colp = col; *rowp = row; |