Patch 9.0.0881
Problem: Cannot get the currently showing mouse shape.
Solution: Add getmouseshape().
Files: runtime/doc/builtin.txt, runtime/doc/usr_41.txt, src/evalfunc.c,
src/misc2.c, src/proto/misc2.pro, src/testdir/test_functions.vim
*** ../vim-9.0.0880/runtime/doc/builtin.txt 2022-11-12 16:07:01.777944369
+0000
--- runtime/doc/builtin.txt 2022-11-14 19:47:43.442229750 +0000
***************
*** 246,251 ****
--- 246,252 ----
getmarklist([{buf}]) List list of global/local marks
getmatches([{win}]) List list of current matches
getmousepos() Dict last known mouse position
+ getmouseshape() String current mouse shape name
getpid() Number process ID of Vim
getpos({expr}) List position of cursor, mark, etc.
getqflist() List list of quickfix items
***************
*** 3879,3884 ****
--- 3880,3891 ----
When using |getchar()| the Vim variables |v:mouse_lnum|,
|v:mouse_col| and |v:mouse_winid| also provide these values.
+ getmouseshape()
*getmouseshape()*
+ Returns the name of the currently showing mouse pointer.
+ When the |+mouseshape| feature is not supported or the shape
+ is unknown an empty string is returned.
+ This function is mainly intended for testing.
+
*getpid()*
getpid() Return a Number which is the process ID of the Vim process.
On Unix and MS-Windows this is a unique number, until Vim
*** ../vim-9.0.0880/runtime/doc/usr_41.txt 2022-10-07 14:31:04.320852668
+0100
--- runtime/doc/usr_41.txt 2022-11-14 19:43:32.730012439 +0000
***************
*** 1109,1114 ****
--- 1110,1116 ----
getcharstr() get a character from the user as a string
getcharmod() get modifiers for the last typed character
getmousepos() get last known mouse position
+ getmouseshape() get name of the current mouse shape
echoraw() output characters as-is
feedkeys() put characters in the typeahead queue
input() get a line from the user
*** ../vim-9.0.0880/src/evalfunc.c 2022-11-12 16:07:01.777944369 +0000
--- src/evalfunc.c 2022-11-14 19:26:16.489449370 +0000
***************
*** 1983,1988 ****
--- 1983,1990 ----
ret_list_dict_any, f_getmatches},
{"getmousepos", 0, 0, 0, NULL,
ret_dict_number, f_getmousepos},
+ {"getmouseshape", 0, 0, 0, NULL,
+ ret_string, f_getmouseshape},
{"getpid", 0, 0, 0, NULL,
ret_number, f_getpid},
{"getpos", 1, 1, FEARG_1, arg1_string,
*** ../vim-9.0.0880/src/misc2.c 2022-10-14 20:09:00.895207512 +0100
--- src/misc2.c 2022-11-14 19:39:36.393873297 +0000
***************
*** 2027,2038 ****
{0, 0, 0, 100L, 100L, 100L, 0, 0, "sm", SHAPE_CURSOR},
};
! #ifdef FEAT_MOUSESHAPE
/*
* Table with names for mouse shapes. Keep in sync with all the tables for
* mch_set_mouse_shape()!.
*/
! static char * mshape_names[] =
{
"arrow", // default, must be the first one
"blank", // hidden
--- 2027,2038 ----
{0, 0, 0, 100L, 100L, 100L, 0, 0, "sm", SHAPE_CURSOR},
};
! # ifdef FEAT_MOUSESHAPE
/*
* Table with names for mouse shapes. Keep in sync with all the tables for
* mch_set_mouse_shape()!.
*/
! static char *mshape_names[] =
{
"arrow", // default, must be the first one
"blank", // hidden
***************
*** 2052,2058 ****
"up-arrow",
NULL
};
! #endif
/*
* Parse the 'guicursor' option ("what" is SHAPE_CURSOR) or 'mouseshape'
--- 2052,2060 ----
"up-arrow",
NULL
};
!
! # define MSHAPE_NAMES_COUNT (ARRAY_LENGTH(mshape_names) - 1)
! # endif
/*
* Parse the 'guicursor' option ("what" is SHAPE_CURSOR) or 'mouseshape'
***************
*** 2355,2361 ****
#endif
# if defined(FEAT_MOUSESHAPE) || defined(PROTO)
! static int old_mouse_shape = 0;
/*
* Set the mouse shape:
--- 2357,2363 ----
#endif
# if defined(FEAT_MOUSESHAPE) || defined(PROTO)
! static int current_mouse_shape = 0;
/*
* Set the mouse shape:
***************
*** 2389,2406 ****
shape_idx = -2;
if (shape_idx == -2
! && old_mouse_shape != shape_table[SHAPE_IDX_CLINE].mshape
! && old_mouse_shape != shape_table[SHAPE_IDX_STATUS].mshape
! && old_mouse_shape != shape_table[SHAPE_IDX_VSEP].mshape)
return;
if (shape_idx < 0)
new_mouse_shape = shape_table[get_shape_idx(TRUE)].mshape;
else
new_mouse_shape = shape_table[shape_idx].mshape;
! if (new_mouse_shape != old_mouse_shape)
{
mch_set_mouse_shape(new_mouse_shape);
! old_mouse_shape = new_mouse_shape;
}
postponed_mouseshape = FALSE;
}
--- 2391,2408 ----
shape_idx = -2;
if (shape_idx == -2
! && current_mouse_shape != shape_table[SHAPE_IDX_CLINE].mshape
! && current_mouse_shape != shape_table[SHAPE_IDX_STATUS].mshape
! && current_mouse_shape != shape_table[SHAPE_IDX_VSEP].mshape)
return;
if (shape_idx < 0)
new_mouse_shape = shape_table[get_shape_idx(TRUE)].mshape;
else
new_mouse_shape = shape_table[shape_idx].mshape;
! if (new_mouse_shape != current_mouse_shape)
{
mch_set_mouse_shape(new_mouse_shape);
! current_mouse_shape = new_mouse_shape;
}
postponed_mouseshape = FALSE;
}
***************
*** 2408,2413 ****
--- 2410,2434 ----
#endif // CURSOR_SHAPE
+ #if defined(FEAT_EVAL) || defined(PROTO)
+ /*
+ * Mainly for tests: get the name of the current mouse shape.
+ */
+ void
+ f_getmouseshape(typval_T *argvars UNUSED, typval_T *rettv)
+ {
+ rettv->v_type = VAR_STRING;
+ rettv->vval.v_string = NULL;
+ # if defined(FEAT_MOUSESHAPE) || defined(PROTO)
+ if (current_mouse_shape >= 0
+ && current_mouse_shape < (int)MSHAPE_NAMES_COUNT)
+ rettv->vval.v_string = vim_strsave(
+ (char_u *)mshape_names[current_mouse_shape]);
+ # endif
+ }
+ #endif
+
+
/*
* Change directory to "new_dir". Search 'cdpath' for relative directory
*** ../vim-9.0.0880/src/proto/misc2.pro 2022-06-27 23:15:16.000000000 +0100
--- src/proto/misc2.pro 2022-11-14 19:37:37.181807901 +0000
***************
*** 3,10 ****
int getviscol(void);
int coladvance_force(colnr_T wcol);
int getviscol2(colnr_T col, colnr_T coladd);
! int coladvance(colnr_T wcol);
! int getvpos(pos_T *pos, colnr_T wcol);
int inc_cursor(void);
int inc(pos_T *lp);
int incl(pos_T *lp);
--- 3,10 ----
int getviscol(void);
int coladvance_force(colnr_T wcol);
int getviscol2(colnr_T col, colnr_T coladd);
! int coladvance(colnr_T wantcol);
! int getvpos(pos_T *pos, colnr_T wantcol);
int inc_cursor(void);
int inc(pos_T *lp);
int incl(pos_T *lp);
***************
*** 47,52 ****
--- 47,53 ----
char *parse_shape_opt(int what);
int get_shape_idx(int mouse);
void update_mouseshape(int shape_idx);
+ void f_getmouseshape(typval_T *argvars, typval_T *rettv);
int vim_chdir(char_u *new_dir);
int get_user_name(char_u *buf, int len);
void free_username(void);
*** ../vim-9.0.0880/src/testdir/test_functions.vim 2022-11-13
22:13:29.848975595 +0000
--- src/testdir/test_functions.vim 2022-11-14 19:45:52.198137195 +0000
***************
*** 2890,2895 ****
--- 2890,2901 ----
bwipe!
endfunc
+ func Test_getmouseshape()
+ CheckFeature mouseshape
+
+ call assert_equal('arrow', getmouseshape())
+ endfunc
+
" Test for glob()
func Test_glob()
call assert_equal('', glob(test_null_string()))
*** ../vim-9.0.0880/src/version.c 2022-11-14 15:31:04.045587449 +0000
--- src/version.c 2022-11-14 19:26:55.673468896 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 881,
/**/
--
hundred-and-one symptoms of being an internet addict:
66. You create a homepage with the impression to cure the afflicted...but
your hidden agenda is to receive more e-mail.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20221114194949.E47061C0473%40moolenaar.net.