vim-patch:7.4.1981 (#6192)

Problem:    No testing for Farsi code.
Solution:   Add a minimal test.  Clean up Farsi code.

ee2615af64
This commit is contained in:
lonerover 2017-03-02 19:47:35 +08:00 committed by Justin M. Keyes
parent 286aacb2aa
commit 8a10497ce6
6 changed files with 306 additions and 223 deletions

View File

@ -486,7 +486,8 @@ char_u* transchar(int c)
c = K_SECOND(c);
}
if ((!chartab_initialized && (((c >= ' ') && (c <= '~')) || F_ischar(c)))
if ((!chartab_initialized && (((c >= ' ') && (c <= '~'))
|| (p_altkeymap && F_ischar(c))))
|| ((c < 256) && vim_isprintc_strict(c))) {
// printable character
transchar_buf[i] = (char_u)c;

View File

@ -131,7 +131,7 @@ static char_u toF_Xor_X_(int c)
/// @param c The character to convert.
///
/// @return Character converted to the Farsi capital leter.
char_u toF_TyA(char_u c)
static char_u toF_TyA(char_u c)
{
char_u tempc;
@ -1557,7 +1557,7 @@ static char_u toF_ending(char_u c)
}
/// Convert the Farsi 3342 standard into Farsi VIM.
void conv_to_pvim(void)
static void conv_to_pvim(void)
{
char_u *ptr;
int lnum, llen, i;
@ -1588,8 +1588,8 @@ void conv_to_pvim(void)
}
// Following lines contains Farsi encoded character.
do_cmdline_cmd("%s/\202\231/\232/g");
do_cmdline_cmd("%s/\201\231/\370\334/g");
do_cmdline_cmd("%s/\202\231/\232/ge");
do_cmdline_cmd("%s/\201\231/\370\334/ge");
// Assume the screen has been messed up: clear it and redraw.
redraw_later(CLEAR);
@ -1597,14 +1597,14 @@ void conv_to_pvim(void)
}
/// Convert the Farsi VIM into Farsi 3342 standard.
void conv_to_pstd(void)
static void conv_to_pstd(void)
{
char_u *ptr;
int lnum, llen, i;
// Following line contains Farsi encoded character.
do_cmdline_cmd("%s/\232/\202\231/g");
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) {
do_cmdline_cmd("%s/\232/\202\231/ge");
for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) {
ptr = ml_get((linenr_T)lnum);
llen = (int)STRLEN(ptr);
for (i = 0; i < llen; i++) {
@ -2036,34 +2036,31 @@ bool F_ischar(int c)
return c >= TEE_ && c <= YE_;
}
void farsi_fkey(cmdarg_T *cap)
void farsi_f8(cmdarg_T *cap FUNC_ATTR_UNUSED)
{
int c = cap->cmdchar;
if (c == K_F8) {
if (p_altkeymap) {
if (curwin->w_farsi & W_R_L) {
p_fkmap = 0;
do_cmdline_cmd("set norl");
MSG("");
} else {
p_fkmap = 1;
do_cmdline_cmd("set rl");
MSG("");
}
curwin->w_farsi = curwin->w_farsi ^ W_R_L;
if (p_altkeymap) {
if (curwin->w_farsi & W_R_L) {
p_fkmap = 0;
do_cmdline_cmd("set norl");
MSG("");
} else {
p_fkmap = 1;
do_cmdline_cmd("set rl");
MSG("");
}
}
if (c == K_F9) {
if (p_altkeymap && curwin->w_p_rl) {
curwin->w_farsi = curwin->w_farsi ^ W_CONV;
if (curwin->w_farsi & W_CONV) {
conv_to_pvim();
} else {
conv_to_pstd();
}
curwin->w_farsi = curwin->w_farsi ^ W_R_L;
}
}
void farsi_f9(cmdarg_T *cap FUNC_ATTR_UNUSED)
{
if (p_altkeymap && curwin->w_p_rl) {
curwin->w_farsi = curwin->w_farsi ^ W_CONV;
if (curwin->w_farsi & W_CONV) {
conv_to_pvim();
} else {
conv_to_pstd();
}
}
}

View File

@ -152,196 +152,196 @@ static const struct nv_cmd {
short cmd_arg; /* value for ca.arg */
} nv_cmds[] =
{
{NUL, nv_error, 0, 0},
{Ctrl_A, nv_addsub, 0, 0},
{Ctrl_B, nv_page, NV_STS, BACKWARD},
{Ctrl_C, nv_esc, 0, true},
{Ctrl_D, nv_halfpage, 0, 0},
{Ctrl_E, nv_scroll_line, 0, true},
{Ctrl_F, nv_page, NV_STS, FORWARD},
{Ctrl_G, nv_ctrlg, 0, 0},
{Ctrl_H, nv_ctrlh, 0, 0},
{Ctrl_I, nv_pcmark, 0, 0},
{NL, nv_down, 0, false},
{Ctrl_K, nv_error, 0, 0},
{Ctrl_L, nv_clear, 0, 0},
{Ctrl_M, nv_down, 0, true},
{Ctrl_N, nv_down, NV_STS, false},
{Ctrl_O, nv_ctrlo, 0, 0},
{Ctrl_P, nv_up, NV_STS, false},
{Ctrl_Q, nv_visual, 0, false},
{Ctrl_R, nv_redo, 0, 0},
{Ctrl_S, nv_ignore, 0, 0},
{Ctrl_T, nv_tagpop, NV_NCW, 0},
{Ctrl_U, nv_halfpage, 0, 0},
{Ctrl_V, nv_visual, 0, false},
{'V', nv_visual, 0, false},
{'v', nv_visual, 0, false},
{Ctrl_W, nv_window, 0, 0},
{Ctrl_X, nv_addsub, 0, 0},
{Ctrl_Y, nv_scroll_line, 0, false},
{Ctrl_Z, nv_suspend, 0, 0},
{ESC, nv_esc, 0, false},
{Ctrl_BSL, nv_normal, NV_NCH_ALW, 0},
{Ctrl_RSB, nv_ident, NV_NCW, 0},
{Ctrl_HAT, nv_hat, NV_NCW, 0},
{Ctrl__, nv_error, 0, 0},
{' ', nv_right, 0, 0},
{'!', nv_operator, 0, 0},
{'"', nv_regname, NV_NCH_NOP|NV_KEEPREG, 0},
{'#', nv_ident, 0, 0},
{'$', nv_dollar, 0, 0},
{'%', nv_percent, 0, 0},
{'&', nv_optrans, 0, 0},
{'\'', nv_gomark, NV_NCH_ALW, true},
{'(', nv_brace, 0, BACKWARD},
{')', nv_brace, 0, FORWARD},
{'*', nv_ident, 0, 0},
{'+', nv_down, 0, true},
{',', nv_csearch, 0, true},
{'-', nv_up, 0, true},
{'.', nv_dot, NV_KEEPREG, 0},
{'/', nv_search, 0, false},
{'0', nv_beginline, 0, 0},
{'1', nv_ignore, 0, 0},
{'2', nv_ignore, 0, 0},
{'3', nv_ignore, 0, 0},
{'4', nv_ignore, 0, 0},
{'5', nv_ignore, 0, 0},
{'6', nv_ignore, 0, 0},
{'7', nv_ignore, 0, 0},
{'8', nv_ignore, 0, 0},
{'9', nv_ignore, 0, 0},
{':', nv_colon, 0, 0},
{';', nv_csearch, 0, false},
{'<', nv_operator, NV_RL, 0},
{'=', nv_operator, 0, 0},
{'>', nv_operator, NV_RL, 0},
{'?', nv_search, 0, false},
{'@', nv_at, NV_NCH_NOP, false},
{'A', nv_edit, 0, 0},
{'B', nv_bck_word, 0, 1},
{'C', nv_abbrev, NV_KEEPREG, 0},
{'D', nv_abbrev, NV_KEEPREG, 0},
{'E', nv_wordcmd, 0, true},
{'F', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD},
{'G', nv_goto, 0, true},
{'H', nv_scroll, 0, 0},
{'I', nv_edit, 0, 0},
{'J', nv_join, 0, 0},
{'K', nv_ident, 0, 0},
{'L', nv_scroll, 0, 0},
{'M', nv_scroll, 0, 0},
{'N', nv_next, 0, SEARCH_REV},
{'O', nv_open, 0, 0},
{'P', nv_put, 0, 0},
{'Q', nv_exmode, NV_NCW, 0},
{'R', nv_Replace, 0, false},
{'S', nv_subst, NV_KEEPREG, 0},
{'T', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD},
{'U', nv_Undo, 0, 0},
{'W', nv_wordcmd, 0, true},
{'X', nv_abbrev, NV_KEEPREG, 0},
{'Y', nv_abbrev, NV_KEEPREG, 0},
{'Z', nv_Zet, NV_NCH_NOP|NV_NCW, 0},
{'[', nv_brackets, NV_NCH_ALW, BACKWARD},
{'\\', nv_error, 0, 0},
{']', nv_brackets, NV_NCH_ALW, FORWARD},
{'^', nv_beginline, 0, BL_WHITE | BL_FIX},
{'_', nv_lineop, 0, 0},
{'`', nv_gomark, NV_NCH_ALW, false},
{'a', nv_edit, NV_NCH, 0},
{'b', nv_bck_word, 0, 0},
{'c', nv_operator, 0, 0},
{'d', nv_operator, 0, 0},
{'e', nv_wordcmd, 0, false},
{'f', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD},
{'g', nv_g_cmd, NV_NCH_ALW, false},
{'h', nv_left, NV_RL, 0},
{'i', nv_edit, NV_NCH, 0},
{'j', nv_down, 0, false},
{'k', nv_up, 0, false},
{'l', nv_right, NV_RL, 0},
{'m', nv_mark, NV_NCH_NOP, 0},
{'n', nv_next, 0, 0},
{'o', nv_open, 0, 0},
{'p', nv_put, 0, 0},
{'q', nv_record, NV_NCH, 0},
{'r', nv_replace, NV_NCH_NOP|NV_LANG, 0},
{'s', nv_subst, NV_KEEPREG, 0},
{'t', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD},
{'u', nv_undo, 0, 0},
{'w', nv_wordcmd, 0, false},
{'x', nv_abbrev, NV_KEEPREG, 0},
{'y', nv_operator, 0, 0},
{'z', nv_zet, NV_NCH_ALW, 0},
{'{', nv_findpar, 0, BACKWARD},
{'|', nv_pipe, 0, 0},
{'}', nv_findpar, 0, FORWARD},
{'~', nv_tilde, 0, 0},
{ NUL, nv_error, 0, 0 },
{ Ctrl_A, nv_addsub, 0, 0 },
{ Ctrl_B, nv_page, NV_STS, BACKWARD },
{ Ctrl_C, nv_esc, 0, true },
{ Ctrl_D, nv_halfpage, 0, 0 },
{ Ctrl_E, nv_scroll_line, 0, true },
{ Ctrl_F, nv_page, NV_STS, FORWARD },
{ Ctrl_G, nv_ctrlg, 0, 0 },
{ Ctrl_H, nv_ctrlh, 0, 0 },
{ Ctrl_I, nv_pcmark, 0, 0 },
{ NL, nv_down, 0, false },
{ Ctrl_K, nv_error, 0, 0 },
{ Ctrl_L, nv_clear, 0, 0 },
{ Ctrl_M, nv_down, 0, true },
{ Ctrl_N, nv_down, NV_STS, false },
{ Ctrl_O, nv_ctrlo, 0, 0 },
{ Ctrl_P, nv_up, NV_STS, false },
{ Ctrl_Q, nv_visual, 0, false },
{ Ctrl_R, nv_redo, 0, 0 },
{ Ctrl_S, nv_ignore, 0, 0 },
{ Ctrl_T, nv_tagpop, NV_NCW, 0 },
{ Ctrl_U, nv_halfpage, 0, 0 },
{ Ctrl_V, nv_visual, 0, false },
{ 'V', nv_visual, 0, false },
{ 'v', nv_visual, 0, false },
{ Ctrl_W, nv_window, 0, 0 },
{ Ctrl_X, nv_addsub, 0, 0 },
{ Ctrl_Y, nv_scroll_line, 0, false },
{ Ctrl_Z, nv_suspend, 0, 0 },
{ ESC, nv_esc, 0, false },
{ Ctrl_BSL, nv_normal, NV_NCH_ALW, 0 },
{ Ctrl_RSB, nv_ident, NV_NCW, 0 },
{ Ctrl_HAT, nv_hat, NV_NCW, 0 },
{ Ctrl__, nv_error, 0, 0 },
{ ' ', nv_right, 0, 0 },
{ '!', nv_operator, 0, 0 },
{ '"', nv_regname, NV_NCH_NOP|NV_KEEPREG, 0 },
{ '#', nv_ident, 0, 0 },
{ '$', nv_dollar, 0, 0 },
{ '%', nv_percent, 0, 0 },
{ '&', nv_optrans, 0, 0 },
{ '\'', nv_gomark, NV_NCH_ALW, true },
{ '(', nv_brace, 0, BACKWARD },
{ ')', nv_brace, 0, FORWARD },
{ '*', nv_ident, 0, 0 },
{ '+', nv_down, 0, true },
{ ',', nv_csearch, 0, true },
{ '-', nv_up, 0, true },
{ '.', nv_dot, NV_KEEPREG, 0 },
{ '/', nv_search, 0, false },
{ '0', nv_beginline, 0, 0 },
{ '1', nv_ignore, 0, 0 },
{ '2', nv_ignore, 0, 0 },
{ '3', nv_ignore, 0, 0 },
{ '4', nv_ignore, 0, 0 },
{ '5', nv_ignore, 0, 0 },
{ '6', nv_ignore, 0, 0 },
{ '7', nv_ignore, 0, 0 },
{ '8', nv_ignore, 0, 0 },
{ '9', nv_ignore, 0, 0 },
{ ':', nv_colon, 0, 0 },
{ ';', nv_csearch, 0, false },
{ '<', nv_operator, NV_RL, 0 },
{ '=', nv_operator, 0, 0 },
{ '>', nv_operator, NV_RL, 0 },
{ '?', nv_search, 0, false },
{ '@', nv_at, NV_NCH_NOP, false },
{ 'A', nv_edit, 0, 0 },
{ 'B', nv_bck_word, 0, 1 },
{ 'C', nv_abbrev, NV_KEEPREG, 0 },
{ 'D', nv_abbrev, NV_KEEPREG, 0 },
{ 'E', nv_wordcmd, 0, true },
{ 'F', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD },
{ 'G', nv_goto, 0, true },
{ 'H', nv_scroll, 0, 0 },
{ 'I', nv_edit, 0, 0 },
{ 'J', nv_join, 0, 0 },
{ 'K', nv_ident, 0, 0 },
{ 'L', nv_scroll, 0, 0 },
{ 'M', nv_scroll, 0, 0 },
{ 'N', nv_next, 0, SEARCH_REV },
{ 'O', nv_open, 0, 0 },
{ 'P', nv_put, 0, 0 },
{ 'Q', nv_exmode, NV_NCW, 0 },
{ 'R', nv_Replace, 0, false },
{ 'S', nv_subst, NV_KEEPREG, 0 },
{ 'T', nv_csearch, NV_NCH_ALW|NV_LANG, BACKWARD },
{ 'U', nv_Undo, 0, 0 },
{ 'W', nv_wordcmd, 0, true },
{ 'X', nv_abbrev, NV_KEEPREG, 0 },
{ 'Y', nv_abbrev, NV_KEEPREG, 0 },
{ 'Z', nv_Zet, NV_NCH_NOP|NV_NCW, 0 },
{ '[', nv_brackets, NV_NCH_ALW, BACKWARD },
{ '\\', nv_error, 0, 0 },
{ ']', nv_brackets, NV_NCH_ALW, FORWARD },
{ '^', nv_beginline, 0, BL_WHITE | BL_FIX },
{ '_', nv_lineop, 0, 0 },
{ '`', nv_gomark, NV_NCH_ALW, false },
{ 'a', nv_edit, NV_NCH, 0 },
{ 'b', nv_bck_word, 0, 0 },
{ 'c', nv_operator, 0, 0 },
{ 'd', nv_operator, 0, 0 },
{ 'e', nv_wordcmd, 0, false },
{ 'f', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD },
{ 'g', nv_g_cmd, NV_NCH_ALW, false },
{ 'h', nv_left, NV_RL, 0 },
{ 'i', nv_edit, NV_NCH, 0 },
{ 'j', nv_down, 0, false },
{ 'k', nv_up, 0, false },
{ 'l', nv_right, NV_RL, 0 },
{ 'm', nv_mark, NV_NCH_NOP, 0 },
{ 'n', nv_next, 0, 0 },
{ 'o', nv_open, 0, 0 },
{ 'p', nv_put, 0, 0 },
{ 'q', nv_record, NV_NCH, 0 },
{ 'r', nv_replace, NV_NCH_NOP|NV_LANG, 0 },
{ 's', nv_subst, NV_KEEPREG, 0 },
{ 't', nv_csearch, NV_NCH_ALW|NV_LANG, FORWARD },
{ 'u', nv_undo, 0, 0 },
{ 'w', nv_wordcmd, 0, false },
{ 'x', nv_abbrev, NV_KEEPREG, 0 },
{ 'y', nv_operator, 0, 0 },
{ 'z', nv_zet, NV_NCH_ALW, 0 },
{ '{', nv_findpar, 0, BACKWARD },
{ '|', nv_pipe, 0, 0 },
{ '}', nv_findpar, 0, FORWARD },
{ '~', nv_tilde, 0, 0 },
/* pound sign */
{POUND, nv_ident, 0, 0},
{K_MOUSEUP, nv_mousescroll, 0, MSCR_UP},
{K_MOUSEDOWN, nv_mousescroll, 0, MSCR_DOWN},
{K_MOUSELEFT, nv_mousescroll, 0, MSCR_LEFT},
{K_MOUSERIGHT, nv_mousescroll, 0, MSCR_RIGHT},
{K_LEFTMOUSE, nv_mouse, 0, 0},
{K_LEFTMOUSE_NM, nv_mouse, 0, 0},
{K_LEFTDRAG, nv_mouse, 0, 0},
{K_LEFTRELEASE, nv_mouse, 0, 0},
{K_LEFTRELEASE_NM, nv_mouse, 0, 0},
{K_MIDDLEMOUSE, nv_mouse, 0, 0},
{K_MIDDLEDRAG, nv_mouse, 0, 0},
{K_MIDDLERELEASE, nv_mouse, 0, 0},
{K_RIGHTMOUSE, nv_mouse, 0, 0},
{K_RIGHTDRAG, nv_mouse, 0, 0},
{K_RIGHTRELEASE, nv_mouse, 0, 0},
{K_X1MOUSE, nv_mouse, 0, 0},
{K_X1DRAG, nv_mouse, 0, 0},
{K_X1RELEASE, nv_mouse, 0, 0},
{K_X2MOUSE, nv_mouse, 0, 0},
{K_X2DRAG, nv_mouse, 0, 0},
{K_X2RELEASE, nv_mouse, 0, 0},
{K_IGNORE, nv_ignore, NV_KEEPREG, 0},
{K_NOP, nv_nop, 0, 0},
{K_INS, nv_edit, 0, 0},
{K_KINS, nv_edit, 0, 0},
{K_BS, nv_ctrlh, 0, 0},
{K_UP, nv_up, NV_SSS|NV_STS, false},
{K_S_UP, nv_page, NV_SS, BACKWARD},
{K_DOWN, nv_down, NV_SSS|NV_STS, false},
{K_S_DOWN, nv_page, NV_SS, FORWARD},
{K_LEFT, nv_left, NV_SSS|NV_STS|NV_RL, 0},
{K_S_LEFT, nv_bck_word, NV_SS|NV_RL, 0},
{K_C_LEFT, nv_bck_word, NV_SSS|NV_RL|NV_STS, 1},
{K_RIGHT, nv_right, NV_SSS|NV_STS|NV_RL, 0},
{K_S_RIGHT, nv_wordcmd, NV_SS|NV_RL, false},
{K_C_RIGHT, nv_wordcmd, NV_SSS|NV_RL|NV_STS, true},
{K_PAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD},
{K_KPAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD},
{K_PAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD},
{K_KPAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD},
{K_END, nv_end, NV_SSS|NV_STS, false},
{K_KEND, nv_end, NV_SSS|NV_STS, false},
{K_S_END, nv_end, NV_SS, false},
{K_C_END, nv_end, NV_SSS|NV_STS, true},
{K_HOME, nv_home, NV_SSS|NV_STS, 0},
{K_KHOME, nv_home, NV_SSS|NV_STS, 0},
{K_S_HOME, nv_home, NV_SS, 0},
{K_C_HOME, nv_goto, NV_SSS|NV_STS, false},
{K_DEL, nv_abbrev, 0, 0},
{K_KDEL, nv_abbrev, 0, 0},
{K_UNDO, nv_kundo, 0, 0},
{K_HELP, nv_help, NV_NCW, 0},
{K_F1, nv_help, NV_NCW, 0},
{K_XF1, nv_help, NV_NCW, 0},
{K_SELECT, nv_select, 0, 0},
{K_F8, farsi_fkey, 0, 0},
{K_F9, farsi_fkey, 0, 0},
{K_EVENT, nv_event, NV_KEEPREG, 0},
{K_FOCUSGAINED, nv_focusgained, NV_KEEPREG, 0},
{K_FOCUSLOST, nv_focuslost, NV_KEEPREG, 0},
// pound sign
{ POUND, nv_ident, 0, 0 },
{ K_MOUSEUP, nv_mousescroll, 0, MSCR_UP },
{ K_MOUSEDOWN, nv_mousescroll, 0, MSCR_DOWN },
{ K_MOUSELEFT, nv_mousescroll, 0, MSCR_LEFT },
{ K_MOUSERIGHT, nv_mousescroll, 0, MSCR_RIGHT },
{ K_LEFTMOUSE, nv_mouse, 0, 0 },
{ K_LEFTMOUSE_NM, nv_mouse, 0, 0 },
{ K_LEFTDRAG, nv_mouse, 0, 0 },
{ K_LEFTRELEASE, nv_mouse, 0, 0 },
{ K_LEFTRELEASE_NM, nv_mouse, 0, 0 },
{ K_MIDDLEMOUSE, nv_mouse, 0, 0 },
{ K_MIDDLEDRAG, nv_mouse, 0, 0 },
{ K_MIDDLERELEASE, nv_mouse, 0, 0 },
{ K_RIGHTMOUSE, nv_mouse, 0, 0 },
{ K_RIGHTDRAG, nv_mouse, 0, 0 },
{ K_RIGHTRELEASE, nv_mouse, 0, 0 },
{ K_X1MOUSE, nv_mouse, 0, 0 },
{ K_X1DRAG, nv_mouse, 0, 0 },
{ K_X1RELEASE, nv_mouse, 0, 0 },
{ K_X2MOUSE, nv_mouse, 0, 0 },
{ K_X2DRAG, nv_mouse, 0, 0 },
{ K_X2RELEASE, nv_mouse, 0, 0 },
{ K_IGNORE, nv_ignore, NV_KEEPREG, 0 },
{ K_NOP, nv_nop, 0, 0 },
{ K_INS, nv_edit, 0, 0 },
{ K_KINS, nv_edit, 0, 0 },
{ K_BS, nv_ctrlh, 0, 0 },
{ K_UP, nv_up, NV_SSS|NV_STS, false },
{ K_S_UP, nv_page, NV_SS, BACKWARD },
{ K_DOWN, nv_down, NV_SSS|NV_STS, false },
{ K_S_DOWN, nv_page, NV_SS, FORWARD },
{ K_LEFT, nv_left, NV_SSS|NV_STS|NV_RL, 0 },
{ K_S_LEFT, nv_bck_word, NV_SS|NV_RL, 0 },
{ K_C_LEFT, nv_bck_word, NV_SSS|NV_RL|NV_STS, 1 },
{ K_RIGHT, nv_right, NV_SSS|NV_STS|NV_RL, 0 },
{ K_S_RIGHT, nv_wordcmd, NV_SS|NV_RL, false },
{ K_C_RIGHT, nv_wordcmd, NV_SSS|NV_RL|NV_STS, true },
{ K_PAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD },
{ K_KPAGEUP, nv_page, NV_SSS|NV_STS, BACKWARD },
{ K_PAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD },
{ K_KPAGEDOWN, nv_page, NV_SSS|NV_STS, FORWARD },
{ K_END, nv_end, NV_SSS|NV_STS, false },
{ K_KEND, nv_end, NV_SSS|NV_STS, false },
{ K_S_END, nv_end, NV_SS, false },
{ K_C_END, nv_end, NV_SSS|NV_STS, true },
{ K_HOME, nv_home, NV_SSS|NV_STS, 0 },
{ K_KHOME, nv_home, NV_SSS|NV_STS, 0 },
{ K_S_HOME, nv_home, NV_SS, 0 },
{ K_C_HOME, nv_goto, NV_SSS|NV_STS, false },
{ K_DEL, nv_abbrev, 0, 0 },
{ K_KDEL, nv_abbrev, 0, 0 },
{ K_UNDO, nv_kundo, 0, 0 },
{ K_HELP, nv_help, NV_NCW, 0 },
{ K_F1, nv_help, NV_NCW, 0 },
{ K_XF1, nv_help, NV_NCW, 0 },
{ K_SELECT, nv_select, 0, 0 },
{ K_F8, farsi_f8, 0, 0 },
{ K_F9, farsi_f9, 0, 0 },
{ K_EVENT, nv_event, NV_KEEPREG, 0 },
{ K_FOCUSGAINED, nv_focusgained, NV_KEEPREG, 0 },
{ K_FOCUSLOST, nv_focuslost, NV_KEEPREG, 0 },
};
/* Number of commands in nv_cmds[]. */

View File

@ -34,6 +34,7 @@ NEW_TESTS ?= \
test_cscope.res \
test_digraph.res \
test_diffmode.res \
test_farsi.res \
test_filter_map.res \
test_gn.res \
test_hardcopy.res \

View File

@ -0,0 +1,84 @@
" Simplistic testing of Farsi mode.
if !has('farsi') || has('nvim') " Not supported in Nvim. #6192
finish
endif
" Farsi uses a single byte encoding.
set enc=latin1
func Test_farsi_toggle()
new
set altkeymap
call assert_equal(0, &fkmap)
call assert_equal(0, &rl)
call feedkeys("\<F8>", 'x')
call assert_equal(1, &fkmap)
call assert_equal(1, &rl)
call feedkeys("\<F8>", 'x')
call assert_equal(0, &fkmap)
call assert_equal(0, &rl)
set rl
" conversion from Farsi 3342 to Farsi VIM.
call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), ''))
call feedkeys("\<F9>", 'x')
let exp = [0xfc, 0xf8, 0xc1, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
\ 0xc8, 0xc9, 0xca, 0xd0, 0xd1, 0xd2, 0xd3, 0xd6,
\ 0xd6, 0xd6, 0xd7, 0xd7, 0xd7, 0xd8, 0xd9, 0xda,
\ 0xdb, 0xdc, 0xdc, 0xc1, 0xdd, 0xde, 0xe0, 0xe0,
\ 0xe1, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
\ 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae,
\ 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
\ 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe,
\ 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6,
\ 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce,
\ 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6,
\ 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
\ 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
\ 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xfb, 0xfb, 0xfe,
\ 0xfe, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
\ 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xe1,
\ ]
call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1))
" conversion from Farsi VIM to Farsi 3342.
call setline(1, join(map(range(0x80, 0xff), 'nr2char(v:val)'), ''))
call feedkeys("\<F9>", 'x')
let exp = [0xfc, 0xf8, 0xc1, 0x83, 0x84, 0x85, 0x86, 0x87,
\ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x90,
\ 0x90, 0x90, 0x92, 0x93, 0x93, 0x95, 0x96, 0x97,
\ 0x98, 0xdc, 0x9a, 0x9b, 0x9c, 0x9e, 0x9e, 0xff,
\ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
\ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
\ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
\ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
\ 0xc0, 0xc1, 0xc2, 0x83, 0x84, 0x85, 0x86, 0x87,
\ 0x88, 0x89, 0x8a, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
\ 0x8b, 0x8c, 0x8d, 0x8e, 0xd4, 0xd5, 0x90, 0x93,
\ 0x95, 0x96, 0x97, 0x98, 0x99, 0x9b, 0x9c, 0xdf,
\ 0x9d, 0xff, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
\ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xec, 0xee, 0xef,
\ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
\ 0xf8, 0xf9, 0xfa, 0xec, 0x80, 0xfd, 0xee, 0xff,
\ ]
call assert_equal(join(map(exp, 'nr2char(v:val)'), ''), getline(1))
bwipe!
endfunc
func Test_farsi_map()
new
set altkeymap
set rl
" RHS of mapping is reversed.
imap xyz abc
call feedkeys("axyz\<Esc>", 'tx')
call assert_equal('cba', getline(1))
set norl
iunmap xyz
set noaltkeymap
bwipe!
endfunc

View File

@ -459,7 +459,7 @@ static int included_patches[] = {
1984,
// 1983 NA
// 1982 NA
// 1981,
1981,
1980,
// 1979,
// 1978,