mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.1.2000: plugin cannot get the current IME status
Problem: Plugin cannot get the current IME status. Solution: Add the getimstatus() function. (closes #4904)
This commit is contained in:
@@ -2468,6 +2468,7 @@ getfperm({fname}) String file permissions of file {fname}
|
|||||||
getfsize({fname}) Number size in bytes of file {fname}
|
getfsize({fname}) Number size in bytes of file {fname}
|
||||||
getftime({fname}) Number last modification time of file
|
getftime({fname}) Number last modification time of file
|
||||||
getftype({fname}) String description of type of file {fname}
|
getftype({fname}) String description of type of file {fname}
|
||||||
|
getimstatus() Number |TRUE| if the IME status is active
|
||||||
getjumplist([{winnr} [, {tabnr}]])
|
getjumplist([{winnr} [, {tabnr}]])
|
||||||
List list of jump list items
|
List list of jump list items
|
||||||
getline({lnum}) String line {lnum} of current buffer
|
getline({lnum}) String line {lnum} of current buffer
|
||||||
@@ -5202,6 +5203,11 @@ getftype({fname}) *getftype()*
|
|||||||
Can also be used as a |method|: >
|
Can also be used as a |method|: >
|
||||||
GetFilename()->getftype()
|
GetFilename()->getftype()
|
||||||
|
|
||||||
|
getimstatus() *getimstatus()*
|
||||||
|
The result is a Number, which is |TRUE| when the IME status is
|
||||||
|
active.
|
||||||
|
See 'imstatusfunc'.
|
||||||
|
|
||||||
getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
|
getjumplist([{winnr} [, {tabnr}]]) *getjumplist()*
|
||||||
Returns the |jumplist| for the specified window.
|
Returns the |jumplist| for the specified window.
|
||||||
|
|
||||||
|
@@ -507,6 +507,7 @@ static funcentry_T global_functions[] =
|
|||||||
{"getfsize", 1, 1, FEARG_1, f_getfsize},
|
{"getfsize", 1, 1, FEARG_1, f_getfsize},
|
||||||
{"getftime", 1, 1, FEARG_1, f_getftime},
|
{"getftime", 1, 1, FEARG_1, f_getftime},
|
||||||
{"getftype", 1, 1, FEARG_1, f_getftype},
|
{"getftype", 1, 1, FEARG_1, f_getftype},
|
||||||
|
{"getimstatus", 0, 0, 0, f_getimstatus},
|
||||||
{"getjumplist", 0, 2, FEARG_1, f_getjumplist},
|
{"getjumplist", 0, 2, FEARG_1, f_getjumplist},
|
||||||
{"getline", 1, 2, FEARG_1, f_getline},
|
{"getline", 1, 2, FEARG_1, f_getline},
|
||||||
{"getloclist", 1, 2, 0, f_getloclist},
|
{"getloclist", 1, 2, 0, f_getloclist},
|
||||||
|
12
src/mbyte.c
12
src/mbyte.c
@@ -6497,6 +6497,18 @@ im_set_position(int row UNUSED, int col UNUSED)
|
|||||||
|
|
||||||
#endif /* FEAT_XIM */
|
#endif /* FEAT_XIM */
|
||||||
|
|
||||||
|
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||||
|
/*
|
||||||
|
* "getimstatus()" function
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
f_getimstatus(typval_T *argvars UNUSED, typval_T *rettv)
|
||||||
|
{
|
||||||
|
# if defined(HAVE_INPUT_METHOD)
|
||||||
|
rettv->vval.v_number = im_get_status();
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup "vcp" for conversion from "from" to "to".
|
* Setup "vcp" for conversion from "from" to "to".
|
||||||
|
@@ -90,6 +90,7 @@ int preedit_get_status(void);
|
|||||||
int im_is_preediting(void);
|
int im_is_preediting(void);
|
||||||
void xim_set_status_area(void);
|
void xim_set_status_area(void);
|
||||||
int xim_get_status_area_height(void);
|
int xim_get_status_area_height(void);
|
||||||
|
void f_getimstatus(typval_T *argvars, typval_T *rettv);
|
||||||
int convert_setup(vimconv_T *vcp, char_u *from, char_u *to);
|
int convert_setup(vimconv_T *vcp, char_u *from, char_u *to);
|
||||||
int convert_setup_ext(vimconv_T *vcp, char_u *from, int from_unicode_is_utf8, char_u *to, int to_unicode_is_utf8);
|
int convert_setup_ext(vimconv_T *vcp, char_u *from, int from_unicode_is_utf8, char_u *to, int to_unicode_is_utf8);
|
||||||
int convert_input(char_u *ptr, int len, int maxlen);
|
int convert_input(char_u *ptr, int len, int maxlen);
|
||||||
|
@@ -2,17 +2,22 @@ source view_util.vim
|
|||||||
|
|
||||||
let s:imactivatefunc_called = 0
|
let s:imactivatefunc_called = 0
|
||||||
let s:imstatusfunc_called = 0
|
let s:imstatusfunc_called = 0
|
||||||
|
let s:imstatus_active = 0
|
||||||
|
|
||||||
func IM_activatefunc(active)
|
func IM_activatefunc(active)
|
||||||
let s:imactivatefunc_called = 1
|
let s:imactivatefunc_called = 1
|
||||||
|
let s:imstatus_active = a:active
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func IM_statusfunc()
|
func IM_statusfunc()
|
||||||
let s:imstatusfunc_called = 1
|
let s:imstatusfunc_called = 1
|
||||||
return 0
|
return s:imstatus_active
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_iminsert2()
|
func Test_iminsert2()
|
||||||
|
let s:imactivatefunc_called = 0
|
||||||
|
let s:imstatusfunc_called = 0
|
||||||
|
|
||||||
set imactivatefunc=IM_activatefunc
|
set imactivatefunc=IM_activatefunc
|
||||||
set imstatusfunc=IM_statusfunc
|
set imstatusfunc=IM_statusfunc
|
||||||
set iminsert=2
|
set iminsert=2
|
||||||
@@ -25,3 +30,29 @@ func Test_iminsert2()
|
|||||||
call assert_equal(expected, s:imactivatefunc_called)
|
call assert_equal(expected, s:imactivatefunc_called)
|
||||||
call assert_equal(expected, s:imstatusfunc_called)
|
call assert_equal(expected, s:imstatusfunc_called)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_imgetstatus()
|
||||||
|
if has('gui_running')
|
||||||
|
if !has('win32')
|
||||||
|
throw 'Skipped: running in the GUI, only works on MS-Windows'
|
||||||
|
endif
|
||||||
|
set imactivatefunc=
|
||||||
|
set imstatusfunc=
|
||||||
|
else
|
||||||
|
set imactivatefunc=IM_activatefunc
|
||||||
|
set imstatusfunc=IM_statusfunc
|
||||||
|
let s:imstatus_active = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
new
|
||||||
|
set iminsert=2
|
||||||
|
call feedkeys("i\<C-R>=getimstatus()\<CR>\<ESC>", 'nx')
|
||||||
|
call assert_equal('1', getline(1))
|
||||||
|
set iminsert=0
|
||||||
|
call feedkeys("o\<C-R>=getimstatus()\<CR>\<ESC>", 'nx')
|
||||||
|
call assert_equal('0', getline(2))
|
||||||
|
bw!
|
||||||
|
|
||||||
|
set imactivatefunc=
|
||||||
|
set imstatusfunc=
|
||||||
|
endfunc
|
||||||
|
Reference in New Issue
Block a user