# HG changeset patch # User Christian Brabandt # Date 1467477005 -7200 # Node ID 43b8570abbec749f2609b30e8867e4aa4e99be85 # Parent 8a735bf153d098907f00e827bc57ac3e4c2fdae2 commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b Author: Bram Moolenaar Date: Sat Jul 2 18:25:34 2016 +0200 patch 7.4.1981 Problem: No testing for Farsi code. Solution: Add a minimal test. Clean up Farsi code. diff --git a/src/Makefile b/src/Makefile --- a/src/Makefile +++ b/src/Makefile @@ -2022,6 +2022,7 @@ test_arglist \ test_expand_dllpath \ test_expr \ test_expr_utf8 \ + test_farsi \ test_feedkeys \ test_file_perm \ test_fnamemodify \ diff --git a/src/charset.c b/src/charset.c --- a/src/charset.c +++ b/src/charset.c @@ -571,7 +571,7 @@ transchar(int c) (c >= ' ' && c <= '~') #endif #ifdef FEAT_FKMAP - || F_ischar(c) + || (p_altkeymap && F_ischar(c)) #endif )) || (c < 256 && vim_isprintc_strict(c))) { diff --git a/src/farsi.c b/src/farsi.c --- a/src/farsi.c +++ b/src/farsi.c @@ -35,7 +35,7 @@ static int toF_ending(int c); static void lrswapbuf(char_u *buf, int len); /* -** Convert the given Farsi character into a _X or _X_ type + * Convert the given Farsi character into a _X or _X_ type */ static int toF_Xor_X_(int c) @@ -44,61 +44,35 @@ toF_Xor_X_(int c) switch (c) { - case BE: - return _BE; - case PE: - return _PE; - case TE: - return _TE; - case SE: - return _SE; - case JIM: - return _JIM; - case CHE: - return _CHE; - case HE_J: - return _HE_J; - case XE: - return _XE; - case SIN: - return _SIN; - case SHIN: - return _SHIN; - case SAD: - return _SAD; - case ZAD: - return _ZAD; - case AYN: - return _AYN; - case AYN_: - return _AYN_; - case GHAYN: - return _GHAYN; - case GHAYN_: - return _GHAYN_; - case FE: - return _FE; - case GHAF: - return _GHAF; - case KAF: - return _KAF; - case GAF: - return _GAF; - case LAM: - return _LAM; - case MIM: - return _MIM; - case NOON: - return _NOON; + case BE: return _BE; + case PE: return _PE; + case TE: return _TE; + case SE: return _SE; + case JIM: return _JIM; + case CHE: return _CHE; + case HE_J: return _HE_J; + case XE: return _XE; + case SIN: return _SIN; + case SHIN: return _SHIN; + case SAD: return _SAD; + case ZAD: return _ZAD; + case AYN: return _AYN; + case AYN_: return _AYN_; + case GHAYN: return _GHAYN; + case GHAYN_: return _GHAYN_; + case FE: return _FE; + case GHAF: return _GHAF; + case KAF: return _KAF; + case GAF: return _GAF; + case LAM: return _LAM; + case MIM: return _MIM; + case NOON: return _NOON; case YE: - case YE_: - return _YE; + case YE_: return _YE; case YEE: - case YEE_: - return _YEE; + case YEE_: return _YEE; case IE: - case IE_: - return _IE; + case IE_: return _IE; case F_HE: tempc = _HE; @@ -128,86 +102,58 @@ toF_Xor_X_(int c) } /* -** Convert the given Farsi character into Farsi capital character . + * Convert the given Farsi character into Farsi capital character. */ - int -toF_TyA(int c ) + static int +toF_TyA(int c) { switch (c) { - case ALEF_: - return ALEF; - case ALEF_U_H_: - return ALEF_U_H; - case _BE: - return BE; - case _PE: - return PE; - case _TE: - return TE; - case _SE: - return SE; - case _JIM: - return JIM; - case _CHE: - return CHE; - case _HE_J: - return HE_J; - case _XE: - return XE; - case _SIN: - return SIN; - case _SHIN: - return SHIN; - case _SAD: - return SAD; - case _ZAD: - return ZAD; + case ALEF_: return ALEF; + case ALEF_U_H_: return ALEF_U_H; + case _BE: return BE; + case _PE: return PE; + case _TE: return TE; + case _SE: return SE; + case _JIM: return JIM; + case _CHE: return CHE; + case _HE_J: return HE_J; + case _XE: return XE; + case _SIN: return SIN; + case _SHIN: return SHIN; + case _SAD: return SAD; + case _ZAD: return ZAD; case _AYN: case AYN_: - case _AYN_: - return AYN; + case _AYN_: return AYN; case _GHAYN: case GHAYN_: - case _GHAYN_: - return GHAYN; - case _FE: - return FE; - case _GHAF: - return GHAF; -/* I am not sure what it is !!! case _KAF_H: */ - case _KAF: - return KAF; - case _GAF: - return GAF; - case _LAM: - return LAM; - case _MIM: - return MIM; - case _NOON: - return NOON; + case _GHAYN_: return GHAYN; + case _FE: return FE; + case _GHAF: return GHAF; + /* I am not sure what it is !!! case _KAF_H: */ + case _KAF: return KAF; + case _GAF: return GAF; + case _LAM: return LAM; + case _MIM: return MIM; + case _NOON: return NOON; case _YE: - case YE_: - return YE; + case YE_: return YE; case _YEE: - case YEE_: - return YEE; - case TEE_: - return TEE; + case YEE_: return YEE; + case TEE_: return TEE; case _IE: - case IE_: - return IE; + case IE_: return IE; case _HE: - case _HE_: - return F_HE; + case _HE_: return F_HE; } return c; } /* -** Is the character under the cursor+offset in the given buffer a join type. -** That is a character that is combined with the others. -** Note: the offset is used only for command line buffer. + * Is the character under the cursor+offset in the given buffer a join type. + * That is a character that is combined with the others. + * Note: the offset is used only for command line buffer. */ static int F_is_TyB_TyC_TyD(int src, int offset) @@ -258,7 +204,7 @@ F_is_TyB_TyC_TyD(int src, int offset) } /* -** Is the Farsi character one of the terminating only type. + * Is the Farsi character one of the terminating only type. */ static int F_is_TyE(int c) @@ -281,7 +227,7 @@ F_is_TyE(int c) } /* -** Is the Farsi character one of the none leading type. + * Is the Farsi character one of the none leading type. */ static int F_is_TyC_TyD(int c) @@ -305,7 +251,7 @@ F_is_TyC_TyD(int c) } /* -** Convert a none leading Farsi char into a leading type. + * Convert a none leading Farsi char into a leading type. */ static int toF_TyB(int c) @@ -313,7 +259,7 @@ toF_TyB(int c) switch (c) { case ALEF_: return ALEF; - case ALEF_U_H_: return ALEF_U_H; + case ALEF_U_H_: return ALEF_U_H; case _AYN_: return _AYN; case AYN_: return AYN; /* exception - there are many of them */ case _GHAYN_: return _GHAYN; @@ -328,7 +274,7 @@ toF_TyB(int c) } /* -** Overwrite the current redo and cursor characters + left adjust + * Overwrite the current redo and cursor characters + left adjust. */ static void put_curr_and_l_to_X(int c) @@ -373,7 +319,7 @@ put_and_redo(int c) } /* -** Change the char. under the cursor to a X_ or X type + * Change the char. under the cursor to a X_ or X type */ static void chg_c_toX_orX(void) @@ -497,7 +443,7 @@ chg_c_toX_orX(void) } /* -** Change the char. under the cursor to a _X_ or X_ type + * Change the char. under the cursor to a _X_ or X_ type */ static void @@ -549,7 +495,7 @@ chg_c_to_X_orX_(void) } /* -** Change the char. under the cursor to a _X_ or _X type + * Change the char. under the cursor to a _X_ or _X type */ static void chg_c_to_X_or_X (void) @@ -580,10 +526,10 @@ chg_c_to_X_or_X (void) } /* -** Change the character left to the cursor to a _X_ or X_ type + * Change the character left to the cursor to a _X_ or X_ type */ static void -chg_l_to_X_orX_ (void) +chg_l_to_X_orX_(void) { int tempc; @@ -648,7 +594,7 @@ chg_l_to_X_orX_ (void) } /* -** Change the character left to the cursor to a X or _X type + * Change the character left to the cursor to a X or _X type */ static void @@ -717,7 +663,7 @@ chg_l_toXor_X (void) } /* -** Change the character right to the cursor to a _X or _X_ type + * Change the character right to the cursor to a _X or _X_ type */ static void @@ -742,7 +688,7 @@ chg_r_to_Xor_X_(void) } /* -** Map Farsi keyboard when in fkmap mode. + * Map Farsi keyboard when in fkmap mode. */ int @@ -899,8 +845,8 @@ fkmap(int c) if (p_ri && c == NL && curwin->w_cursor.col) { /* - ** If the char before the cursor is _X_ or X_ do not change - ** the one under the cursor with X type. + * If the char before the cursor is _X_ or X_ do not change + * the one under the cursor with X type. */ dec_cursor(); @@ -914,8 +860,7 @@ fkmap(int c) inc_cursor(); } - if (!p_ri) - if (!curwin->w_cursor.col) + if (!p_ri && !curwin->w_cursor.col) { switch (c) { @@ -1154,43 +1099,42 @@ fkmap(int c) case 'a': tempc = _SHIN; - break; + break; case 'A': tempc = WAW_H; - break; + break; case 'b': tempc = ZAL; - break; + break; case 'c': tempc = ZE; - break; + break; case 'C': tempc = JE; - break; + break; case 'd': tempc = _YE; - break; + break; case 'D': tempc = _YEE; - break; + break; case 'e': tempc = _SE; - break; + break; case 'f': tempc = _BE; - break; + break; case 'g': tempc = _LAM; - break; + break; case 'G': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { + { if (gchar_cursor() == _LAM) chg_c_toX_orX (); - else - if (p_ri) - chg_c_to_X_or_X (); + else if (p_ri) + chg_c_to_X_or_X (); } if (!p_ri) @@ -1204,16 +1148,15 @@ fkmap(int c) { chg_c_toX_orX (); chg_l_toXor_X (); - tempc = ALEF_U_H; + tempc = ALEF_U_H; + } + else if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) + { + tempc = ALEF_U_H_; + chg_l_toXor_X (); } else - if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - { - tempc = ALEF_U_H_; - chg_l_toXor_X (); - } - else - tempc = ALEF_U_H; + tempc = ALEF_U_H; if (!p_ri) inc_cursor(); @@ -1249,11 +1192,11 @@ fkmap(int c) { if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { - tempc = ALEF_; + tempc = ALEF_; chg_l_toXor_X (); } else - tempc = ALEF; + tempc = ALEF; } if (!p_ri) @@ -1261,8 +1204,8 @@ fkmap(int c) return tempc; case 'i': - if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { + if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) + { if (!p_ri && !F_is_TyE(tempc)) chg_c_to_X_orX_ (); if (p_ri) @@ -1277,9 +1220,9 @@ fkmap(int c) dec_cursor(); if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) - tempc = _HE_; + tempc = _HE_; else - tempc = _HE; + tempc = _HE; if (!p_ri) inc_cursor(); @@ -1289,7 +1232,7 @@ fkmap(int c) break; case 'J': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { + { if (p_ri) chg_c_to_X_or_X (); @@ -1304,11 +1247,11 @@ fkmap(int c) if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) { - tempc = TEE_; + tempc = TEE_; chg_l_toXor_X (); } else - tempc = TEE; + tempc = TEE; if (!p_ri) inc_cursor(); @@ -1385,7 +1328,7 @@ fkmap(int c) break; case 'y': if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { + { if (!p_ri && !F_is_TyE(tempc)) chg_c_to_X_orX_ (); if (p_ri) @@ -1434,7 +1377,7 @@ fkmap(int c) if ((F_isalpha(tempc) || F_isdigit(tempc))) { if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) - { + { if (!p_ri && !F_is_TyE(tempc)) chg_c_to_X_orX_ (); if (p_ri) @@ -1461,7 +1404,7 @@ fkmap(int c) } /* -** Convert a none leading Farsi char into a leading type. + * Convert a none leading Farsi char into a leading type. */ static int toF_leading(int c) @@ -1515,7 +1458,7 @@ toF_leading(int c) } /* -** Convert a given Farsi char into right joining type. + * Convert a given Farsi char into right joining type. */ static int toF_Rjoin(int c) @@ -1571,7 +1514,7 @@ toF_Rjoin(int c) } /* -** Can a given Farsi character join via its left edj. + * Can a given Farsi character join via its left edj. */ static int canF_Ljoin(int c) @@ -1645,7 +1588,7 @@ canF_Ljoin(int c) } /* -** Can a given Farsi character join via its right edj. + * Can a given Farsi character join via its right edj. */ static int canF_Rjoin(int c) @@ -1673,7 +1616,7 @@ canF_Rjoin(int c) } /* -** is a given Farsi character a terminating type. + * is a given Farsi character a terminating type. */ static int F_isterm(int c) @@ -1700,86 +1643,54 @@ F_isterm(int c) } /* -** Convert the given Farsi character into a ending type . + * Convert the given Farsi character into a ending type . */ static int toF_ending(int c) { - switch (c) { - case _BE: - return BE; - case _PE: - return PE; - case _TE: - return TE; - case _SE: - return SE; - case _JIM: - return JIM; - case _CHE: - return CHE; - case _HE_J: - return HE_J; - case _XE: - return XE; - case _SIN: - return SIN; - case _SHIN: - return SHIN; - case _SAD: - return SAD; - case _ZAD: - return ZAD; - case _AYN: - return AYN; - case _AYN_: - return AYN_; - case _GHAYN: - return GHAYN; - case _GHAYN_: - return GHAYN_; - case _FE: - return FE; - case _GHAF: - return GHAF; + case _BE: return BE; + case _PE: return PE; + case _TE: return TE; + case _SE: return SE; + case _JIM: return JIM; + case _CHE: return CHE; + case _HE_J: return HE_J; + case _XE: return XE; + case _SIN: return SIN; + case _SHIN: return SHIN; + case _SAD: return SAD; + case _ZAD: return ZAD; + case _AYN: return AYN; + case _AYN_: return AYN_; + case _GHAYN: return GHAYN; + case _GHAYN_: return GHAYN_; + case _FE: return FE; + case _GHAF: return GHAF; case _KAF_H: - case _KAF: - return KAF; - case _GAF: - return GAF; - case _LAM: - return LAM; - case _MIM: - return MIM; - case _NOON: - return NOON; - case _YE: - return YE_; - case YE_: - return YE; - case _YEE: - return YEE_; - case YEE_: - return YEE; - case TEE: - return TEE_; - case _IE: - return IE_; - case IE_: - return IE; + case _KAF: return KAF; + case _GAF: return GAF; + case _LAM: return LAM; + case _MIM: return MIM; + case _NOON: return NOON; + case _YE: return YE_; + case YE_: return YE; + case _YEE: return YEE_; + case YEE_: return YEE; + case TEE: return TEE_; + case _IE: return IE_; + case IE_: return IE; case _HE: - case _HE_: - return F_HE; + case _HE_: return F_HE; } return c; } /* -** Convert the Farsi 3342 standard into Farsi VIM. + * Convert the Farsi 3342 standard into Farsi VIM. */ - void + static void conv_to_pvim(void) { char_u *ptr; @@ -1791,7 +1702,7 @@ conv_to_pvim(void) llen = (int)STRLEN(ptr); - for ( i = 0; i < llen-1; i++) + for (i = 0; i < llen-1; i++) { if (canF_Ljoin(ptr[i]) && canF_Rjoin(ptr[i+1])) { @@ -1817,8 +1728,8 @@ conv_to_pvim(void) * Following lines contains Farsi encoded character. */ - do_cmdline_cmd((char_u *)"%s/\202\231/\232/g"); - do_cmdline_cmd((char_u *)"%s/\201\231/\370\334/g"); + do_cmdline_cmd((char_u *)"%s/\202\231/\232/ge"); + do_cmdline_cmd((char_u *)"%s/\201\231/\370\334/ge"); /* Assume the screen has been messed up: clear it and redraw. */ redraw_later(CLEAR); @@ -1828,7 +1739,7 @@ conv_to_pvim(void) /* * Convert the Farsi VIM into Farsi 3342 standard. */ - void + static void conv_to_pstd(void) { char_u *ptr; @@ -1837,20 +1748,15 @@ conv_to_pstd(void) /* * Following line contains Farsi encoded character. */ - - do_cmdline_cmd((char_u *)"%s/\232/\202\231/g"); + do_cmdline_cmd((char_u *)"%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++) - { + for (i = 0; i < llen; i++) ptr[i] = toF_TyA(ptr[i]); - - } } /* Assume the screen has been messed up: clear it and redraw. */ @@ -2148,7 +2054,7 @@ cmdl_fkmap(int c) case 'f': return _BE; case 'g': return _LAM; case 'G': - if (cmd_gchar(AT_CURSOR) == _LAM ) + if (cmd_gchar(AT_CURSOR) == _LAM) { cmd_pchar(LAM, AT_CURSOR); return ALEF_U_H; @@ -2159,7 +2065,7 @@ cmdl_fkmap(int c) else return ALEF_U_H; case 'h': - if (cmd_gchar(AT_CURSOR) == _LAM ) + if (cmd_gchar(AT_CURSOR) == _LAM) { cmd_pchar(LA, AT_CURSOR); redrawcmdline(); @@ -2215,9 +2121,9 @@ cmdl_fkmap(int c) case ',': return WAW; case '[': return _JIM; case ']': return _CHE; - } + } - return c; + return c; } /* @@ -2226,7 +2132,7 @@ cmdl_fkmap(int c) int F_isalpha(int c) { - return (( c >= TEE_ && c <= _YE) + return ((c >= TEE_ && c <= _YE) || (c >= ALEF_A && c <= YE) || (c >= _IE && c <= YE_)); } @@ -2246,45 +2152,40 @@ F_isdigit(int c) int F_ischar(int c) { - return (c >= TEE_ && c <= YE_); + return (c >= TEE_ && c <= YE_); } void -farsi_fkey( - cmdarg_T *cap) +farsi_f8(cmdarg_T *cap UNUSED) { - int c = cap->cmdchar; - - if (c == K_F8) + if (p_altkeymap) { - if (p_altkeymap) + if (curwin->w_farsi & W_R_L) { - if (curwin->w_farsi & W_R_L) - { - p_fkmap = 0; - do_cmdline_cmd((char_u *)"set norl"); - MSG(""); - } - else - { - p_fkmap = 1; - do_cmdline_cmd((char_u *)"set rl"); - MSG(""); - } + p_fkmap = 0; + do_cmdline_cmd((char_u *)"set norl"); + MSG(""); + } + else + { + p_fkmap = 1; + do_cmdline_cmd((char_u *)"set rl"); + MSG(""); + } - curwin->w_farsi = curwin->w_farsi ^ W_R_L; - } - } - - 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 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(); + } +} diff --git a/src/normal.c b/src/normal.c --- a/src/normal.c +++ b/src/normal.c @@ -414,8 +414,8 @@ static const struct nv_cmd {K_TABMENU, nv_tabmenu, 0, 0}, #endif #ifdef FEAT_FKMAP - {K_F8, farsi_fkey, 0, 0}, - {K_F9, farsi_fkey, 0, 0}, + {K_F8, farsi_f8, 0, 0}, + {K_F9, farsi_f9, 0, 0}, #endif #ifdef FEAT_NETBEANS_INTG {K_F21, nv_nbcmd, NV_NCH_ALW, 0}, diff --git a/src/proto/main.pro b/src/proto/main.pro --- a/src/proto/main.pro +++ b/src/proto/main.pro @@ -10,10 +10,7 @@ void time_msg(char *mesg, void *tv_start void server_to_input_buf(char_u *str); char_u *eval_client_expr_to_string(char_u *expr); char_u *serverConvert(char_u *client_enc, char_u *data, char_u **tofree); -int toF_TyA(int c); int fkmap(int c); -void conv_to_pvim(void); -void conv_to_pstd(void); char_u *lrswap(char_u *ibuf); char_u *lrFswap(char_u *cmdbuf, int len); char_u *lrF_sub(char_u *ibuf); @@ -21,6 +18,7 @@ int cmdl_fkmap(int c); int F_isalpha(int c); int F_isdigit(int c); int F_ischar(int c); -void farsi_fkey(cmdarg_T *cap); +void farsi_f8(cmdarg_T *cap); +void farsi_f9(cmdarg_T *cap); int arabic_shape(int c, int *ccp, int *c1p, int prev_c, int prev_c1, int next_c); /* vim: set ft=c : */ diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak --- a/src/testdir/Make_all.mak +++ b/src/testdir/Make_all.mak @@ -168,6 +168,7 @@ NEW_TESTS = test_arglist.res \ test_cdo.res \ test_channel.res \ test_cmdline.res \ + test_farsi.res \ test_hardcopy.res \ test_history.res \ test_increment.res \ diff --git a/src/testdir/test_farsi.vim b/src/testdir/test_farsi.vim new file mode 100644 --- /dev/null +++ b/src/testdir/test_farsi.vim @@ -0,0 +1,84 @@ +" Simplistic testing of Farsi mode. + +if !has('farsi') + 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("\", 'x') + call assert_equal(1, &fkmap) + call assert_equal(1, &rl) + call feedkeys("\", '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("\", '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("\", '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\", 'tx') + call assert_equal('cba', getline(1)) + + set norl + iunmap xyz + set noaltkeymap + bwipe! +endfunc diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1981, +/**/ 1980, /**/ 1979,