forked from aniani/vim
patch 8.2.3226: new digraph functions use old naming scheme
Problem: New digraph functions use old naming scheme. Solution: Use the digraph_ prefix. (Hirohito Higashi, closes #8580)
This commit is contained in:
@@ -1781,7 +1781,7 @@ do_digraph(int c)
|
||||
else if (p_dg)
|
||||
{
|
||||
if (backspaced >= 0)
|
||||
c = getdigraph(backspaced, c, FALSE);
|
||||
c = digraph_get(backspaced, c, FALSE);
|
||||
backspaced = -1;
|
||||
if ((c == K_BS || c == Ctrl_H) && lastchar >= 0)
|
||||
backspaced = lastchar;
|
||||
@@ -1887,7 +1887,7 @@ get_digraph(
|
||||
--no_mapping;
|
||||
--allow_keys;
|
||||
if (cc != ESC) // ESC cancels CTRL-K
|
||||
return getdigraph(c, cc, TRUE);
|
||||
return digraph_get(c, cc, TRUE);
|
||||
}
|
||||
return NUL;
|
||||
}
|
||||
@@ -1981,7 +1981,7 @@ getexactdigraph(int char1, int char2, int meta_char)
|
||||
* Allow for both char1-char2 and char2-char1
|
||||
*/
|
||||
int
|
||||
getdigraph(int char1, int char2, int meta_char)
|
||||
digraph_get(int char1, int char2, int meta_char)
|
||||
{
|
||||
int retval;
|
||||
|
||||
@@ -2143,7 +2143,7 @@ listdigraphs(int use_headers)
|
||||
}
|
||||
|
||||
static void
|
||||
getdigraphlist_appendpair(digr_T *dp, list_T *l)
|
||||
digraph_getlist_appendpair(digr_T *dp, list_T *l)
|
||||
{
|
||||
char_u buf[30];
|
||||
char_u *p;
|
||||
@@ -2194,7 +2194,7 @@ getdigraphlist_appendpair(digr_T *dp, list_T *l)
|
||||
}
|
||||
|
||||
void
|
||||
getdigraphlist_common(int list_all, typval_T *rettv)
|
||||
digraph_getlist_common(int list_all, typval_T *rettv)
|
||||
{
|
||||
int i;
|
||||
digr_T *dp;
|
||||
@@ -2215,11 +2215,11 @@ getdigraphlist_common(int list_all, typval_T *rettv)
|
||||
tmp.result = getexactdigraph(tmp.char1, tmp.char2, FALSE);
|
||||
if (tmp.result != 0 && tmp.result != tmp.char2
|
||||
&& (has_mbyte || tmp.result <= 255))
|
||||
getdigraphlist_appendpair(&tmp, rettv->vval.v_list);
|
||||
digraph_getlist_appendpair(&tmp, rettv->vval.v_list);
|
||||
#else
|
||||
if (getexactdigraph(dp->char1, dp->char2, FALSE) == dp->result
|
||||
&& (has_mbyte || dp->result <= 255))
|
||||
getdigraphlist_appendpair(dp, rettv->vval.v_list);
|
||||
digraph_getlist_appendpair(dp, rettv->vval.v_list);
|
||||
#endif
|
||||
++dp;
|
||||
}
|
||||
@@ -2228,7 +2228,7 @@ getdigraphlist_common(int list_all, typval_T *rettv)
|
||||
dp = (digr_T *)user_digraphs.ga_data;
|
||||
for (i = 0; i < user_digraphs.ga_len && !got_int; ++i)
|
||||
{
|
||||
getdigraphlist_appendpair(dp, rettv->vval.v_list);
|
||||
digraph_getlist_appendpair(dp, rettv->vval.v_list);
|
||||
++dp;
|
||||
}
|
||||
}
|
||||
@@ -2363,7 +2363,7 @@ get_digraph_chars(typval_T *arg, int *char1, int *char2)
|
||||
}
|
||||
|
||||
static int
|
||||
setdigraph_common(typval_T *argchars, typval_T *argdigraph)
|
||||
digraph_set_common(typval_T *argchars, typval_T *argdigraph)
|
||||
{
|
||||
int char1, char2;
|
||||
char_u *digraph;
|
||||
@@ -2394,10 +2394,10 @@ setdigraph_common(typval_T *argchars, typval_T *argdigraph)
|
||||
|
||||
#if defined(FEAT_EVAL) || defined(PROTO)
|
||||
/*
|
||||
* "getdigraph()" function
|
||||
* "digraph_get()" function
|
||||
*/
|
||||
void
|
||||
f_getdigraph(typval_T *argvars, typval_T *rettv)
|
||||
f_digraph_get(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
# ifdef FEAT_DIGRAPHS
|
||||
int code;
|
||||
@@ -2415,7 +2415,7 @@ f_getdigraph(typval_T *argvars, typval_T *rettv)
|
||||
semsg(_(e_digraph_must_be_just_two_characters_str), digraphs);
|
||||
return;
|
||||
}
|
||||
code = getdigraph(digraphs[0], digraphs[1], FALSE);
|
||||
code = digraph_get(digraphs[0], digraphs[1], FALSE);
|
||||
|
||||
if (has_mbyte)
|
||||
buf[(*mb_char2bytes)(code, buf)] = NUL;
|
||||
@@ -2431,10 +2431,10 @@ f_getdigraph(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
|
||||
/*
|
||||
* "getdigraphlist()" function
|
||||
* "digraph_getlist()" function
|
||||
*/
|
||||
void
|
||||
f_getdigraphlist(typval_T *argvars, typval_T *rettv)
|
||||
f_digraph_getlist(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
# ifdef FEAT_DIGRAPHS
|
||||
int flag_list_all;
|
||||
@@ -2450,23 +2450,23 @@ f_getdigraphlist(typval_T *argvars, typval_T *rettv)
|
||||
flag_list_all = flag ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
getdigraphlist_common(flag_list_all, rettv);
|
||||
digraph_getlist_common(flag_list_all, rettv);
|
||||
# else
|
||||
emsg(_(e_no_digraphs_version));
|
||||
# endif
|
||||
}
|
||||
|
||||
/*
|
||||
* "setdigraph()" function
|
||||
* "digraph_set()" function
|
||||
*/
|
||||
void
|
||||
f_setdigraph(typval_T *argvars, typval_T *rettv)
|
||||
f_digraph_set(typval_T *argvars, typval_T *rettv)
|
||||
{
|
||||
# ifdef FEAT_DIGRAPHS
|
||||
rettv->v_type = VAR_BOOL;
|
||||
rettv->vval.v_number = VVAL_FALSE;
|
||||
|
||||
if (!setdigraph_common(&argvars[0], &argvars[1]))
|
||||
if (!digraph_set_common(&argvars[0], &argvars[1]))
|
||||
return;
|
||||
|
||||
rettv->vval.v_number = VVAL_TRUE;
|
||||
@@ -2476,10 +2476,10 @@ f_setdigraph(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
|
||||
/*
|
||||
* "setdigraphlist()" function
|
||||
* "digraph_setlist()" function
|
||||
*/
|
||||
void
|
||||
f_setdigraphlist(typval_T * argvars, typval_T *rettv)
|
||||
f_digraph_setlist(typval_T * argvars, typval_T *rettv)
|
||||
{
|
||||
# ifdef FEAT_DIGRAPHS
|
||||
list_T *pl, *l;
|
||||
@@ -2490,7 +2490,7 @@ f_setdigraphlist(typval_T * argvars, typval_T *rettv)
|
||||
|
||||
if (argvars[0].v_type != VAR_LIST)
|
||||
{
|
||||
emsg(_(e_setdigraphlist_argument_must_be_list_of_lists_with_two_items));
|
||||
emsg(_(e_digraph_setlist_argument_must_be_list_of_lists_with_two_items));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2506,18 +2506,18 @@ f_setdigraphlist(typval_T * argvars, typval_T *rettv)
|
||||
{
|
||||
if (pli->li_tv.v_type != VAR_LIST)
|
||||
{
|
||||
emsg(_(e_setdigraphlist_argument_must_be_list_of_lists_with_two_items));
|
||||
emsg(_(e_digraph_setlist_argument_must_be_list_of_lists_with_two_items));
|
||||
return;
|
||||
}
|
||||
|
||||
l = pli->li_tv.vval.v_list;
|
||||
if (l == NULL || l->lv_len != 2)
|
||||
{
|
||||
emsg(_(e_setdigraphlist_argument_must_be_list_of_lists_with_two_items));
|
||||
emsg(_(e_digraph_setlist_argument_must_be_list_of_lists_with_two_items));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!setdigraph_common(&l->lv_first->li_tv,
|
||||
if (!digraph_set_common(&l->lv_first->li_tv,
|
||||
&l->lv_first->li_next->li_tv))
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5219,7 +5219,7 @@ ins_digraph(void)
|
||||
if (cc != ESC)
|
||||
{
|
||||
AppendToRedobuff((char_u *)CTRL_V_STR);
|
||||
c = getdigraph(c, cc, TRUE);
|
||||
c = digraph_get(c, cc, TRUE);
|
||||
#ifdef FEAT_CMDL_INFO
|
||||
clear_showcmd();
|
||||
#endif
|
||||
|
||||
@@ -610,8 +610,8 @@ EXTERN char e_digraph_must_be_just_two_characters_str[]
|
||||
INIT(= N_("E1214: Digraph must be just two characters: %s"));
|
||||
EXTERN char e_digraph_argument_must_be_one_character_str[]
|
||||
INIT(= N_("E1215: Digraph must be one character: %s"));
|
||||
EXTERN char e_setdigraphlist_argument_must_be_list_of_lists_with_two_items[]
|
||||
INIT(= N_("E1216: setdigraphlist() argument must be a list of lists with two items"));
|
||||
EXTERN char e_digraph_setlist_argument_must_be_list_of_lists_with_two_items[]
|
||||
INIT(= N_("E1216: digraph_setlist() argument must be a list of lists with two items"));
|
||||
#endif
|
||||
EXTERN char e_chan_or_job_required_for_argument_nr[]
|
||||
INIT(= N_("E1217: Channel or Job required for argument %d"));
|
||||
|
||||
@@ -1292,6 +1292,14 @@ static funcentry_T global_functions[] =
|
||||
ret_number, f_diff_filler},
|
||||
{"diff_hlID", 2, 2, FEARG_1, arg2_lnum_number,
|
||||
ret_number, f_diff_hlID},
|
||||
{"digraph_get", 1, 1, FEARG_1, arg1_string,
|
||||
ret_string, f_digraph_get},
|
||||
{"digraph_getlist",0, 1, FEARG_1, arg1_number,
|
||||
ret_list_string_items, f_digraph_getlist},
|
||||
{"digraph_set", 2, 2, FEARG_1, arg2_string_number,
|
||||
ret_bool, f_digraph_set},
|
||||
{"digraph_setlist",1, 1, FEARG_1, arg1_list_string,
|
||||
ret_bool, f_digraph_setlist},
|
||||
{"echoraw", 1, 1, FEARG_1, arg1_string,
|
||||
ret_void, f_echoraw},
|
||||
{"empty", 1, 1, FEARG_1, NULL,
|
||||
@@ -1406,10 +1414,6 @@ static funcentry_T global_functions[] =
|
||||
ret_list_number, f_getcursorcharpos},
|
||||
{"getcwd", 0, 2, FEARG_1, arg2_number,
|
||||
ret_string, f_getcwd},
|
||||
{"getdigraph", 1, 1, FEARG_1, arg1_string,
|
||||
ret_string, f_getdigraph},
|
||||
{"getdigraphlist", 0, 1, FEARG_1, arg1_number,
|
||||
ret_list_string_items, f_getdigraphlist},
|
||||
{"getenv", 1, 1, FEARG_1, arg1_string,
|
||||
ret_any, f_getenv},
|
||||
{"getfontname", 0, 1, 0, arg1_string,
|
||||
@@ -1870,10 +1874,6 @@ static funcentry_T global_functions[] =
|
||||
ret_number_bool, f_setcmdpos},
|
||||
{"setcursorcharpos", 1, 3, FEARG_1, arg13_cursor,
|
||||
ret_number_bool, f_setcursorcharpos},
|
||||
{"setdigraph", 2, 2, FEARG_1, arg2_string_number,
|
||||
ret_bool, f_setdigraph},
|
||||
{"setdigraphlist", 1, 1, FEARG_1, arg1_list_string,
|
||||
ret_bool, f_setdigraphlist},
|
||||
{"setenv", 2, 2, FEARG_2, arg2_string_any,
|
||||
ret_void, f_setenv},
|
||||
{"setfperm", 2, 2, FEARG_1, arg2_string,
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
int do_digraph(int c);
|
||||
char_u *get_digraph_for_char(int val_arg);
|
||||
int get_digraph(int cmdline);
|
||||
int getdigraph(int char1, int char2, int meta_char);
|
||||
int digraph_get(int char1, int char2, int meta_char);
|
||||
int check_digraph_chars_valid(int char1, int char2);
|
||||
void putdigraph(char_u *str);
|
||||
void listdigraphs(int use_headers);
|
||||
void getdigraphlist_common(int list_all, typval_T *rettv);
|
||||
void f_getdigraph(typval_T *argvars, typval_T *rettv);
|
||||
void f_getdigraphlist(typval_T *argvars, typval_T *rettv);
|
||||
void f_setdigraph(typval_T *argvars, typval_T *rettv);
|
||||
void f_setdigraphlist(typval_T *argvars, typval_T *rettv);
|
||||
void digraph_getlist_common(int list_all, typval_T *rettv);
|
||||
void f_digraph_get(typval_T *argvars, typval_T *rettv);
|
||||
void f_digraph_getlist(typval_T *argvars, typval_T *rettv);
|
||||
void f_digraph_set(typval_T *argvars, typval_T *rettv);
|
||||
void f_digraph_setlist(typval_T *argvars, typval_T *rettv);
|
||||
char *keymap_init(void);
|
||||
void ex_loadkeymap(exarg_T *eap);
|
||||
void keymap_clear(garray_T *kmap);
|
||||
|
||||
@@ -515,81 +515,81 @@ func Test_entering_digraph()
|
||||
call StopVimInTerminal(buf)
|
||||
endfunc
|
||||
|
||||
func Test_setdigraph_function()
|
||||
func Test_digraph_set_function()
|
||||
new
|
||||
call setdigraph('aa', 'あ')
|
||||
call digraph_set('aa', 'あ')
|
||||
call Put_Dig('aa')
|
||||
call assert_equal('あ', getline('$'))
|
||||
call setdigraph(' i', 'い')
|
||||
call digraph_set(' i', 'い')
|
||||
call Put_Dig(' i')
|
||||
call assert_equal('い', getline('$'))
|
||||
call setdigraph(' ', 'う')
|
||||
call digraph_set(' ', 'う')
|
||||
call Put_Dig(' ')
|
||||
call assert_equal('う', getline('$'))
|
||||
|
||||
eval 'aa'->setdigraph('え')
|
||||
eval 'aa'->digraph_set('え')
|
||||
call Put_Dig('aa')
|
||||
call assert_equal('え', getline('$'))
|
||||
|
||||
call assert_fails('call setdigraph("aaa", "あ")', 'E1214: Digraph must be just two characters: aaa')
|
||||
call assert_fails('call setdigraph("b", "あ")', 'E1214: Digraph must be just two characters: b')
|
||||
call assert_fails('call setdigraph("あ", "あ")', 'E1214: Digraph must be just two characters: あ')
|
||||
call assert_fails('call setdigraph("aa", "ああ")', 'E1215: Digraph must be one character: ああ')
|
||||
call assert_fails('call setdigraph("aa", "か" .. nr2char(0x3099))', 'E1215: Digraph must be one character: か' .. nr2char(0x3099))
|
||||
call assert_fails('call digraph_set("aaa", "あ")', 'E1214: Digraph must be just two characters: aaa')
|
||||
call assert_fails('call digraph_set("b", "あ")', 'E1214: Digraph must be just two characters: b')
|
||||
call assert_fails('call digraph_set("あ", "あ")', 'E1214: Digraph must be just two characters: あ')
|
||||
call assert_fails('call digraph_set("aa", "ああ")', 'E1215: Digraph must be one character: ああ')
|
||||
call assert_fails('call digraph_set("aa", "か" .. nr2char(0x3099))', 'E1215: Digraph must be one character: か' .. nr2char(0x3099))
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_getdigraph_function()
|
||||
func Test_digraph_get_function()
|
||||
" Built-in digraphs
|
||||
call assert_equal('∞', getdigraph('00'))
|
||||
call assert_equal('∞', digraph_get('00'))
|
||||
|
||||
" User-defined digraphs
|
||||
call setdigraph('aa', 'あ')
|
||||
call setdigraph(' i', 'い')
|
||||
call setdigraph(' ', 'う')
|
||||
call assert_equal('あ', getdigraph('aa'))
|
||||
call assert_equal('あ', 'aa'->getdigraph())
|
||||
call assert_equal('い', getdigraph(' i'))
|
||||
call assert_equal('う', getdigraph(' '))
|
||||
call assert_fails('call getdigraph("aaa")', 'E1214: Digraph must be just two characters: aaa')
|
||||
call assert_fails('call getdigraph("b")', 'E1214: Digraph must be just two characters: b')
|
||||
call digraph_set('aa', 'あ')
|
||||
call digraph_set(' i', 'い')
|
||||
call digraph_set(' ', 'う')
|
||||
call assert_equal('あ', digraph_get('aa'))
|
||||
call assert_equal('あ', 'aa'->digraph_get())
|
||||
call assert_equal('い', digraph_get(' i'))
|
||||
call assert_equal('う', digraph_get(' '))
|
||||
call assert_fails('call digraph_get("aaa")', 'E1214: Digraph must be just two characters: aaa')
|
||||
call assert_fails('call digraph_get("b")', 'E1214: Digraph must be just two characters: b')
|
||||
endfunc
|
||||
|
||||
func Test_getdigraph_function_encode()
|
||||
func Test_digraph_get_function_encode()
|
||||
CheckFeature iconv
|
||||
let testcases = {
|
||||
\'00': '∞',
|
||||
\'aa': 'あ',
|
||||
\}
|
||||
for [key, ch] in items(testcases)
|
||||
call setdigraph(key, ch)
|
||||
call digraph_set(key, ch)
|
||||
set encoding=japan
|
||||
call assert_equal(iconv(ch, 'utf-8', 'japan'), getdigraph(key))
|
||||
call assert_equal(iconv(ch, 'utf-8', 'japan'), digraph_get(key))
|
||||
set encoding&
|
||||
endfor
|
||||
endfunc
|
||||
|
||||
func Test_setdigraphlist_function()
|
||||
call setdigraphlist([['aa', 'き'], ['bb', 'く']])
|
||||
call assert_equal('き', getdigraph('aa'))
|
||||
call assert_equal('く', getdigraph('bb'))
|
||||
func Test_digraph_setlist_function()
|
||||
call digraph_setlist([['aa', 'き'], ['bb', 'く']])
|
||||
call assert_equal('き', digraph_get('aa'))
|
||||
call assert_equal('く', digraph_get('bb'))
|
||||
|
||||
call assert_fails('call setdigraphlist([[]])', 'E1216:')
|
||||
call assert_fails('call setdigraphlist([["aa", "b", "cc"]])', '1216:')
|
||||
call assert_fails('call setdigraphlist([["あ", "あ"]])', 'E1214: Digraph must be just two characters: あ')
|
||||
call assert_fails('call digraph_setlist([[]])', 'E1216:')
|
||||
call assert_fails('call digraph_setlist([["aa", "b", "cc"]])', '1216:')
|
||||
call assert_fails('call digraph_setlist([["あ", "あ"]])', 'E1214: Digraph must be just two characters: あ')
|
||||
endfunc
|
||||
|
||||
func Test_getdigraphlist_function()
|
||||
func Test_digraph_getlist_function()
|
||||
" Make sure user-defined digraphs are defined
|
||||
call setdigraphlist([['aa', 'き'], ['bb', 'く']])
|
||||
call digraph_setlist([['aa', 'き'], ['bb', 'く']])
|
||||
|
||||
for pair in getdigraphlist(1)
|
||||
call assert_equal(getdigraph(pair[0]), pair[1])
|
||||
for pair in digraph_getlist(1)
|
||||
call assert_equal(digraph_get(pair[0]), pair[1])
|
||||
endfor
|
||||
|
||||
" We don't know how many digraphs are registered before, so check the number
|
||||
" of digraphs returned.
|
||||
call assert_equal(getdigraphlist()->len(), getdigraphlist(0)->len())
|
||||
call assert_notequal((getdigraphlist()->len()), getdigraphlist(1)->len())
|
||||
call assert_equal(digraph_getlist()->len(), digraph_getlist(0)->len())
|
||||
call assert_notequal((digraph_getlist()->len()), digraph_getlist(1)->len())
|
||||
endfunc
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
||||
@@ -755,6 +755,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3226,
|
||||
/**/
|
||||
3225,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user