mirror of
https://github.com/vim/vim
synced 2025-07-16 01:01:58 +00:00
patch 9.1.0871: getcellpixels() can be further improved
Problem: getcellpixels() can be further improved Solution: Fix floating point exception, implement getcellpixels() in the UI (mikoto2000) closes: #16059 Signed-off-by: mikoto2000 <mikoto2000@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
bd4614f43d
commit
a73dfc2f55
@ -61,6 +61,7 @@ static void f_funcref(typval_T *argvars, typval_T *rettv);
|
||||
static void f_function(typval_T *argvars, typval_T *rettv);
|
||||
static void f_garbagecollect(typval_T *argvars, typval_T *rettv);
|
||||
static void f_get(typval_T *argvars, typval_T *rettv);
|
||||
static void f_getcellpixels(typval_T *argvars, typval_T *rettv);
|
||||
static void f_getchangelist(typval_T *argvars, typval_T *rettv);
|
||||
static void f_getcharpos(typval_T *argvars, typval_T *rettv);
|
||||
static void f_getcharsearch(typval_T *argvars, typval_T *rettv);
|
||||
@ -2078,13 +2079,7 @@ static funcentry_T global_functions[] =
|
||||
{"getbufvar", 2, 3, FEARG_1, arg3_buffer_string_any,
|
||||
ret_any, f_getbufvar},
|
||||
{"getcellpixels", 0, 0, 0, NULL,
|
||||
ret_list_any,
|
||||
#if (defined(UNIX) || defined(VMS)) && (defined(FEAT_EVAL) || defined(PROTO))
|
||||
f_getcellpixels
|
||||
#else
|
||||
NULL
|
||||
#endif
|
||||
},
|
||||
ret_list_any, f_getcellpixels},
|
||||
{"getcellwidths", 0, 0, 0, NULL,
|
||||
ret_list_any, f_getcellwidths},
|
||||
{"getchangelist", 0, 1, FEARG_1, arg1_buffer,
|
||||
@ -5216,6 +5211,45 @@ f_get(typval_T *argvars, typval_T *rettv)
|
||||
copy_tv(tv, rettv);
|
||||
}
|
||||
|
||||
/*
|
||||
* "getcellpixels()" function
|
||||
*/
|
||||
static void
|
||||
f_getcellpixels(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
{
|
||||
if (rettv_list_alloc(rettv) == FAIL)
|
||||
return;
|
||||
|
||||
#if defined(FEAT_GUI)
|
||||
if (gui.in_use)
|
||||
{
|
||||
// success pixel size and no gui.
|
||||
list_append_number(rettv->vval.v_list, (varnumber_T)gui.char_width);
|
||||
list_append_number(rettv->vval.v_list, (varnumber_T)gui.char_height);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
struct cellsize cs;
|
||||
#if defined(UNIX)
|
||||
mch_calc_cell_size(&cs);
|
||||
#else
|
||||
// Non-Unix CUIs are not supported, so set this to -1x-1.
|
||||
cs.cs_xpixel = -1;
|
||||
cs.cs_ypixel = -1;
|
||||
#endif
|
||||
|
||||
// failed get pixel size.
|
||||
if (cs.cs_xpixel == -1)
|
||||
return;
|
||||
|
||||
// success pixel size and no gui.
|
||||
list_append_number(rettv->vval.v_list, (varnumber_T)cs.cs_xpixel);
|
||||
list_append_number(rettv->vval.v_list, (varnumber_T)cs.cs_ypixel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* "getchangelist()" function
|
||||
*/
|
||||
|
Reference in New Issue
Block a user