Mercurial > vim
comparison src/mouse.c @ 28069:236b80af9833 v8.2.4559
patch 8.2.4559: getmousepos() returns the screen column
Commit: https://github.com/vim/vim/commit/533870a98501fac2b51ef4bc489fac3a055a41a9
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 13 15:52:44 2022 +0000
patch 8.2.4559: getmousepos() returns the screen column
Problem: getmousepos() returns the screen column. (Ernie Rael)
Solution: Return the text column, as documented.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 13 Mar 2022 17:00:03 +0100 |
parents | 050d49de7a66 |
children | f4115d080c1b |
comparison
equal
deleted
inserted
replaced
28068:1be25e090d52 | 28069:236b80af9833 |
---|---|
3063 int row = mouse_row; | 3063 int row = mouse_row; |
3064 int col = mouse_col; | 3064 int col = mouse_col; |
3065 varnumber_T winid = 0; | 3065 varnumber_T winid = 0; |
3066 varnumber_T winrow = 0; | 3066 varnumber_T winrow = 0; |
3067 varnumber_T wincol = 0; | 3067 varnumber_T wincol = 0; |
3068 linenr_T line = 0; | 3068 linenr_T lnum = 0; |
3069 varnumber_T column = 0; | 3069 varnumber_T column = 0; |
3070 | 3070 |
3071 if (rettv_dict_alloc(rettv) != OK) | 3071 if (rettv_dict_alloc(rettv) != OK) |
3072 return; | 3072 return; |
3073 d = rettv->vval.v_dict; | 3073 d = rettv->vval.v_dict; |
3097 wincol = col + 1; | 3097 wincol = col + 1; |
3098 row -= top_off; | 3098 row -= top_off; |
3099 col -= left_off; | 3099 col -= left_off; |
3100 if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width) | 3100 if (row >= 0 && row < wp->w_height && col >= 0 && col < wp->w_width) |
3101 { | 3101 { |
3102 int count; | 3102 if (!mouse_comp_pos(wp, &row, &col, &lnum, NULL)) |
3103 | 3103 col = vcol2col(wp, lnum, col); |
3104 mouse_comp_pos(wp, &row, &col, &line, NULL); | |
3105 | |
3106 // limit to text size plus one | |
3107 count = linetabsize(ml_get_buf(wp->w_buffer, line, FALSE)); | |
3108 if (col > count) | |
3109 col = count; | |
3110 column = col + 1; | 3104 column = col + 1; |
3111 } | 3105 } |
3112 } | 3106 } |
3113 } | 3107 } |
3114 dict_add_number(d, "winid", winid); | 3108 dict_add_number(d, "winid", winid); |
3115 dict_add_number(d, "winrow", winrow); | 3109 dict_add_number(d, "winrow", winrow); |
3116 dict_add_number(d, "wincol", wincol); | 3110 dict_add_number(d, "wincol", wincol); |
3117 dict_add_number(d, "line", (varnumber_T)line); | 3111 dict_add_number(d, "line", (varnumber_T)lnum); |
3118 dict_add_number(d, "column", column); | 3112 dict_add_number(d, "column", column); |
3119 } | 3113 } |
3120 #endif | 3114 #endif |