Mercurial > vim
annotate src/farsi.c @ 9598:dd6f3e98646b
Added tag v7.4.2076 for changeset 3ca0fd9709b197c4ee254f45f8604a518dde54da
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 19 Jul 2016 22:45:07 +0200 |
parents | 9b048dced116 |
children | 4aead6a9b7a9 |
rev | line source |
---|---|
7 | 1 /* vi:set ts=8 sts=4 sw=4: |
2 * | |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
11 * farsi.c: functions for Farsi language | |
12 */ | |
13 | |
9403
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
14 #include "vim.h" |
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
15 |
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
16 #if defined(FEAT_FKMAP) || defined(PROTO) |
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
17 |
7801
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
18 static int toF_Xor_X_(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
19 static int F_is_TyE(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
20 static int F_is_TyC_TyD(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
21 static int F_is_TyB_TyC_TyD(int src, int offset); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
22 static int toF_TyB(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
23 static void put_curr_and_l_to_X(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
24 static void put_and_redo(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
25 static void chg_c_toX_orX(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
26 static void chg_c_to_X_orX_(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
27 static void chg_c_to_X_or_X(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
28 static void chg_l_to_X_orX_(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
29 static void chg_l_toXor_X(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
30 static void chg_r_to_Xor_X_(void); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
31 static int toF_leading(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
32 static int toF_Rjoin(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
33 static int canF_Ljoin(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
34 static int canF_Rjoin(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
35 static int F_isterm(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
36 static int toF_ending(int c); |
a1e71a01dbd6
commit https://github.com/vim/vim/commit/d25c16e2f2776d50245bf31d6e4d5364f12d188e
Christian Brabandt <cb@256bit.org>
parents:
4352
diff
changeset
|
37 static void lrswapbuf(char_u *buf, int len); |
7 | 38 |
39 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
40 * Convert the given Farsi character into a _X or _X_ type |
7 | 41 */ |
42 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
43 toF_Xor_X_(int c) |
7 | 44 { |
45 int tempc; | |
46 | |
47 switch (c) | |
48 { | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
49 case BE: return _BE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
50 case PE: return _PE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
51 case TE: return _TE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
52 case SE: return _SE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
53 case JIM: return _JIM; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
54 case CHE: return _CHE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
55 case HE_J: return _HE_J; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
56 case XE: return _XE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
57 case SIN: return _SIN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
58 case SHIN: return _SHIN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
59 case SAD: return _SAD; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
60 case ZAD: return _ZAD; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
61 case AYN: return _AYN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
62 case AYN_: return _AYN_; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
63 case GHAYN: return _GHAYN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
64 case GHAYN_: return _GHAYN_; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
65 case FE: return _FE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
66 case GHAF: return _GHAF; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
67 case KAF: return _KAF; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
68 case GAF: return _GAF; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
69 case LAM: return _LAM; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
70 case MIM: return _MIM; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
71 case NOON: return _NOON; |
7 | 72 case YE: |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
73 case YE_: return _YE; |
7 | 74 case YEE: |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
75 case YEE_: return _YEE; |
7 | 76 case IE: |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
77 case IE_: return _IE; |
7 | 78 case F_HE: |
79 tempc = _HE; | |
80 | |
1880 | 81 if (p_ri && (curwin->w_cursor.col + 1 |
82 < (colnr_T)STRLEN(ml_get_curline()))) | |
7 | 83 { |
84 inc_cursor(); | |
85 | |
86 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
87 tempc = _HE_; | |
88 | |
89 dec_cursor(); | |
90 } | |
91 if (!p_ri && STRLEN(ml_get_curline())) | |
92 { | |
93 dec_cursor(); | |
94 | |
95 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
96 tempc = _HE_; | |
97 | |
98 inc_cursor(); | |
99 } | |
100 | |
101 return tempc; | |
102 } | |
103 return 0; | |
104 } | |
105 | |
106 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
107 * Convert the given Farsi character into Farsi capital character. |
7 | 108 */ |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
109 static int |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
110 toF_TyA(int c) |
7 | 111 { |
112 switch (c) | |
113 { | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
114 case ALEF_: return ALEF; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
115 case ALEF_U_H_: return ALEF_U_H; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
116 case _BE: return BE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
117 case _PE: return PE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
118 case _TE: return TE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
119 case _SE: return SE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
120 case _JIM: return JIM; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
121 case _CHE: return CHE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
122 case _HE_J: return HE_J; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
123 case _XE: return XE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
124 case _SIN: return SIN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
125 case _SHIN: return SHIN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
126 case _SAD: return SAD; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
127 case _ZAD: return ZAD; |
7 | 128 case _AYN: |
129 case AYN_: | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
130 case _AYN_: return AYN; |
7 | 131 case _GHAYN: |
132 case GHAYN_: | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
133 case _GHAYN_: return GHAYN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
134 case _FE: return FE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
135 case _GHAF: return GHAF; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
136 /* I am not sure what it is !!! case _KAF_H: */ |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
137 case _KAF: return KAF; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
138 case _GAF: return GAF; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
139 case _LAM: return LAM; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
140 case _MIM: return MIM; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
141 case _NOON: return NOON; |
7 | 142 case _YE: |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
143 case YE_: return YE; |
7 | 144 case _YEE: |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
145 case YEE_: return YEE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
146 case TEE_: return TEE; |
7 | 147 case _IE: |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
148 case IE_: return IE; |
7 | 149 case _HE: |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
150 case _HE_: return F_HE; |
7 | 151 } |
152 return c; | |
153 } | |
154 | |
155 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
156 * Is the character under the cursor+offset in the given buffer a join type. |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
157 * That is a character that is combined with the others. |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
158 * Note: the offset is used only for command line buffer. |
7 | 159 */ |
160 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
161 F_is_TyB_TyC_TyD(int src, int offset) |
7 | 162 { |
163 int c; | |
164 | |
165 if (src == SRC_EDT) | |
166 c = gchar_cursor(); | |
167 else | |
168 c = cmd_gchar(AT_CURSOR+offset); | |
169 | |
170 switch (c) | |
171 { | |
172 case _LAM: | |
173 case _BE: | |
174 case _PE: | |
175 case _TE: | |
176 case _SE: | |
177 case _JIM: | |
178 case _CHE: | |
179 case _HE_J: | |
180 case _XE: | |
181 case _SIN: | |
182 case _SHIN: | |
183 case _SAD: | |
184 case _ZAD: | |
185 case _TA: | |
186 case _ZA: | |
187 case _AYN: | |
188 case _AYN_: | |
189 case _GHAYN: | |
190 case _GHAYN_: | |
191 case _FE: | |
192 case _GHAF: | |
193 case _KAF: | |
194 case _KAF_H: | |
195 case _GAF: | |
196 case _MIM: | |
197 case _NOON: | |
198 case _YE: | |
199 case _YEE: | |
200 case _IE: | |
201 case _HE_: | |
202 case _HE: | |
203 return TRUE; | |
204 } | |
205 return FALSE; | |
206 } | |
207 | |
208 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
209 * Is the Farsi character one of the terminating only type. |
7 | 210 */ |
211 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
212 F_is_TyE(int c) |
7 | 213 { |
214 switch (c) | |
215 { | |
216 case ALEF_A: | |
217 case ALEF_D_H: | |
218 case DAL: | |
219 case ZAL: | |
220 case RE: | |
221 case ZE: | |
222 case JE: | |
223 case WAW: | |
224 case WAW_H: | |
225 case HAMZE: | |
226 return TRUE; | |
227 } | |
228 return FALSE; | |
229 } | |
230 | |
231 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
232 * Is the Farsi character one of the none leading type. |
7 | 233 */ |
234 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
235 F_is_TyC_TyD(int c) |
7 | 236 { |
237 switch (c) | |
238 { | |
239 case ALEF_: | |
240 case ALEF_U_H_: | |
241 case _AYN_: | |
242 case AYN_: | |
243 case _GHAYN_: | |
244 case GHAYN_: | |
245 case _HE_: | |
246 case YE_: | |
247 case IE_: | |
248 case TEE_: | |
249 case YEE_: | |
250 return TRUE; | |
251 } | |
252 return FALSE; | |
253 } | |
254 | |
255 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
256 * Convert a none leading Farsi char into a leading type. |
7 | 257 */ |
258 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
259 toF_TyB(int c) |
7 | 260 { |
261 switch (c) | |
262 { | |
263 case ALEF_: return ALEF; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
264 case ALEF_U_H_: return ALEF_U_H; |
7 | 265 case _AYN_: return _AYN; |
266 case AYN_: return AYN; /* exception - there are many of them */ | |
267 case _GHAYN_: return _GHAYN; | |
268 case GHAYN_: return GHAYN; /* exception - there are many of them */ | |
269 case _HE_: return _HE; | |
270 case YE_: return YE; | |
271 case IE_: return IE; | |
272 case TEE_: return TEE; | |
273 case YEE_: return YEE; | |
274 } | |
275 return c; | |
276 } | |
277 | |
278 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
279 * Overwrite the current redo and cursor characters + left adjust. |
7 | 280 */ |
281 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
282 put_curr_and_l_to_X(int c) |
7 | 283 { |
284 int tempc; | |
285 | |
286 if (curwin->w_p_rl && p_ri) | |
287 return; | |
288 | |
1880 | 289 if ((curwin->w_cursor.col < (colnr_T)STRLEN(ml_get_curline()))) |
7 | 290 { |
291 if ((p_ri && curwin->w_cursor.col) || !p_ri) | |
292 { | |
293 if (p_ri) | |
294 dec_cursor(); | |
295 else | |
296 inc_cursor(); | |
297 | |
298 if (F_is_TyC_TyD((tempc = gchar_cursor()))) | |
299 { | |
300 pchar_cursor(toF_TyB(tempc)); | |
301 AppendCharToRedobuff(K_BS); | |
302 AppendCharToRedobuff(tempc); | |
303 } | |
304 | |
305 if (p_ri) | |
306 inc_cursor(); | |
307 else | |
308 dec_cursor(); | |
309 } | |
310 } | |
311 | |
312 put_and_redo(c); | |
313 } | |
314 | |
315 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
316 put_and_redo(int c) |
7 | 317 { |
318 pchar_cursor(c); | |
319 AppendCharToRedobuff(K_BS); | |
320 AppendCharToRedobuff(c); | |
321 } | |
322 | |
323 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
324 * Change the char. under the cursor to a X_ or X type |
7 | 325 */ |
326 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
327 chg_c_toX_orX(void) |
7 | 328 { |
329 int tempc, curc; | |
330 | |
331 switch ((curc = gchar_cursor())) | |
332 { | |
333 case _BE: | |
334 tempc = BE; | |
335 break; | |
336 case _PE: | |
337 tempc = PE; | |
338 break; | |
339 case _TE: | |
340 tempc = TE; | |
341 break; | |
342 case _SE: | |
343 tempc = SE; | |
344 break; | |
345 case _JIM: | |
346 tempc = JIM; | |
347 break; | |
348 case _CHE: | |
349 tempc = CHE; | |
350 break; | |
351 case _HE_J: | |
352 tempc = HE_J; | |
353 break; | |
354 case _XE: | |
355 tempc = XE; | |
356 break; | |
357 case _SIN: | |
358 tempc = SIN; | |
359 break; | |
360 case _SHIN: | |
361 tempc = SHIN; | |
362 break; | |
363 case _SAD: | |
364 tempc = SAD; | |
365 break; | |
366 case _ZAD: | |
367 tempc = ZAD; | |
368 break; | |
369 case _FE: | |
370 tempc = FE; | |
371 break; | |
372 case _GHAF: | |
373 tempc = GHAF; | |
374 break; | |
375 case _KAF_H: | |
376 case _KAF: | |
377 tempc = KAF; | |
378 break; | |
379 case _GAF: | |
380 tempc = GAF; | |
381 break; | |
382 case _AYN: | |
383 tempc = AYN; | |
384 break; | |
385 case _AYN_: | |
386 tempc = AYN_; | |
387 break; | |
388 case _GHAYN: | |
389 tempc = GHAYN; | |
390 break; | |
391 case _GHAYN_: | |
392 tempc = GHAYN_; | |
393 break; | |
394 case _LAM: | |
395 tempc = LAM; | |
396 break; | |
397 case _MIM: | |
398 tempc = MIM; | |
399 break; | |
400 case _NOON: | |
401 tempc = NOON; | |
402 break; | |
403 case _HE: | |
404 case _HE_: | |
405 tempc = F_HE; | |
406 break; | |
407 case _YE: | |
408 case _IE: | |
409 case _YEE: | |
410 if (p_ri) | |
411 { | |
412 inc_cursor(); | |
413 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
414 tempc = (curc == _YE ? YE_ : | |
415 (curc == _IE ? IE_ : YEE_)); | |
416 else | |
417 tempc = (curc == _YE ? YE : | |
418 (curc == _IE ? IE : YEE)); | |
419 dec_cursor(); | |
420 } | |
421 else | |
422 { | |
423 if (curwin->w_cursor.col) | |
424 { | |
425 dec_cursor(); | |
426 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
427 tempc = (curc == _YE ? YE_ : | |
428 (curc == _IE ? IE_ : YEE_)); | |
429 else | |
430 tempc = (curc == _YE ? YE : | |
431 (curc == _IE ? IE : YEE)); | |
432 inc_cursor(); | |
433 } | |
434 else | |
435 tempc = (curc == _YE ? YE : | |
436 (curc == _IE ? IE : YEE)); | |
437 } | |
438 break; | |
439 default: | |
440 tempc = 0; | |
441 } | |
442 | |
443 if (tempc) | |
444 put_and_redo(tempc); | |
445 } | |
446 | |
447 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
448 * Change the char. under the cursor to a _X_ or X_ type |
7 | 449 */ |
450 | |
451 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
452 chg_c_to_X_orX_(void) |
7 | 453 { |
454 int tempc; | |
455 | |
456 switch (gchar_cursor()) | |
457 { | |
458 case ALEF: | |
459 tempc = ALEF_; | |
460 break; | |
461 case ALEF_U_H: | |
462 tempc = ALEF_U_H_; | |
463 break; | |
464 case _AYN: | |
465 tempc = _AYN_; | |
466 break; | |
467 case AYN: | |
468 tempc = AYN_; | |
469 break; | |
470 case _GHAYN: | |
471 tempc = _GHAYN_; | |
472 break; | |
473 case GHAYN: | |
474 tempc = GHAYN_; | |
475 break; | |
476 case _HE: | |
477 tempc = _HE_; | |
478 break; | |
479 case YE: | |
480 tempc = YE_; | |
481 break; | |
482 case IE: | |
483 tempc = IE_; | |
484 break; | |
485 case TEE: | |
486 tempc = TEE_; | |
487 break; | |
488 case YEE: | |
489 tempc = YEE_; | |
490 break; | |
491 default: | |
492 tempc = 0; | |
493 } | |
494 | |
495 if (tempc) | |
496 put_and_redo(tempc); | |
497 } | |
498 | |
499 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
500 * Change the char. under the cursor to a _X_ or _X type |
7 | 501 */ |
502 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
503 chg_c_to_X_or_X (void) |
7 | 504 { |
505 int tempc; | |
506 | |
507 tempc = gchar_cursor(); | |
508 | |
1880 | 509 if (curwin->w_cursor.col + 1 < (colnr_T)STRLEN(ml_get_curline())) |
7 | 510 { |
511 inc_cursor(); | |
512 | |
513 if ((tempc == F_HE) && (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR))) | |
514 { | |
515 tempc = _HE_; | |
516 | |
517 dec_cursor(); | |
518 | |
519 put_and_redo(tempc); | |
520 return; | |
521 } | |
522 | |
523 dec_cursor(); | |
524 } | |
525 | |
526 if ((tempc = toF_Xor_X_(tempc)) != 0) | |
527 put_and_redo(tempc); | |
528 } | |
529 | |
530 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
531 * Change the character left to the cursor to a _X_ or X_ type |
7 | 532 */ |
533 static void | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
534 chg_l_to_X_orX_(void) |
7 | 535 { |
536 int tempc; | |
537 | |
1880 | 538 if (curwin->w_cursor.col != 0 && |
539 (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) | |
7 | 540 return; |
541 | |
542 if (!curwin->w_cursor.col && p_ri) | |
543 return; | |
544 | |
545 if (p_ri) | |
546 dec_cursor(); | |
547 else | |
548 inc_cursor(); | |
549 | |
550 switch (gchar_cursor()) | |
551 { | |
552 case ALEF: | |
553 tempc = ALEF_; | |
554 break; | |
555 case ALEF_U_H: | |
556 tempc = ALEF_U_H_; | |
557 break; | |
558 case _AYN: | |
559 tempc = _AYN_; | |
560 break; | |
561 case AYN: | |
562 tempc = AYN_; | |
563 break; | |
564 case _GHAYN: | |
565 tempc = _GHAYN_; | |
566 break; | |
567 case GHAYN: | |
568 tempc = GHAYN_; | |
569 break; | |
570 case _HE: | |
571 tempc = _HE_; | |
572 break; | |
573 case YE: | |
574 tempc = YE_; | |
575 break; | |
576 case IE: | |
577 tempc = IE_; | |
578 break; | |
579 case TEE: | |
580 tempc = TEE_; | |
581 break; | |
582 case YEE: | |
583 tempc = YEE_; | |
584 break; | |
585 default: | |
586 tempc = 0; | |
587 } | |
588 | |
589 if (tempc) | |
590 put_and_redo(tempc); | |
591 | |
592 if (p_ri) | |
593 inc_cursor(); | |
594 else | |
595 dec_cursor(); | |
596 } | |
597 | |
598 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
599 * Change the character left to the cursor to a X or _X type |
7 | 600 */ |
601 | |
602 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
603 chg_l_toXor_X (void) |
7 | 604 { |
605 int tempc; | |
606 | |
1880 | 607 if (curwin->w_cursor.col != 0 && |
608 (curwin->w_cursor.col + 1 == (colnr_T)STRLEN(ml_get_curline()))) | |
7 | 609 return; |
610 | |
611 if (!curwin->w_cursor.col && p_ri) | |
612 return; | |
613 | |
614 if (p_ri) | |
615 dec_cursor(); | |
616 else | |
617 inc_cursor(); | |
618 | |
619 switch (gchar_cursor()) | |
620 { | |
621 case ALEF_: | |
622 tempc = ALEF; | |
623 break; | |
624 case ALEF_U_H_: | |
625 tempc = ALEF_U_H; | |
626 break; | |
627 case _AYN_: | |
628 tempc = _AYN; | |
629 break; | |
630 case AYN_: | |
631 tempc = AYN; | |
632 break; | |
633 case _GHAYN_: | |
634 tempc = _GHAYN; | |
635 break; | |
636 case GHAYN_: | |
637 tempc = GHAYN; | |
638 break; | |
639 case _HE_: | |
640 tempc = _HE; | |
641 break; | |
642 case YE_: | |
643 tempc = YE; | |
644 break; | |
645 case IE_: | |
646 tempc = IE; | |
647 break; | |
648 case TEE_: | |
649 tempc = TEE; | |
650 break; | |
651 case YEE_: | |
652 tempc = YEE; | |
653 break; | |
654 default: | |
655 tempc = 0; | |
656 } | |
657 | |
658 if (tempc) | |
659 put_and_redo(tempc); | |
660 | |
661 if (p_ri) | |
662 inc_cursor(); | |
663 else | |
664 dec_cursor(); | |
665 } | |
666 | |
667 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
668 * Change the character right to the cursor to a _X or _X_ type |
7 | 669 */ |
670 | |
671 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
672 chg_r_to_Xor_X_(void) |
7 | 673 { |
674 int tempc, c; | |
675 | |
676 if (curwin->w_cursor.col) | |
677 { | |
678 if (!p_ri) | |
679 dec_cursor(); | |
680 | |
681 tempc = gchar_cursor(); | |
682 | |
683 if ((c = toF_Xor_X_(tempc)) != 0) | |
684 put_and_redo(c); | |
685 | |
686 if (!p_ri) | |
687 inc_cursor(); | |
688 | |
689 } | |
690 } | |
691 | |
692 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
693 * Map Farsi keyboard when in fkmap mode. |
7 | 694 */ |
695 | |
696 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
697 fkmap(int c) |
7 | 698 { |
699 int tempc; | |
700 static int revins; | |
701 | |
702 if (IS_SPECIAL(c)) | |
703 return c; | |
704 | |
705 if (VIM_ISDIGIT(c) || ((c == '.' || c == '+' || c == '-' || | |
706 c == '^' || c == '%' || c == '#' || c == '=') && revins)) | |
707 { | |
708 if (!revins) | |
709 { | |
710 if (curwin->w_cursor.col) | |
711 { | |
712 if (!p_ri) | |
713 dec_cursor(); | |
714 | |
8238
d7e1526ae1b9
commit https://github.com/vim/vim/commit/68c85fcdf31c104db21c96cd5871724e458c95ff
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
715 chg_c_toX_orX (); |
d7e1526ae1b9
commit https://github.com/vim/vim/commit/68c85fcdf31c104db21c96cd5871724e458c95ff
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
716 chg_l_toXor_X (); |
7 | 717 |
718 if (!p_ri) | |
719 inc_cursor(); | |
720 } | |
721 } | |
722 | |
723 arrow_used = TRUE; | |
724 (void)stop_arrow(); | |
725 | |
726 if (!curwin->w_p_rl && revins) | |
727 inc_cursor(); | |
728 | |
729 ++revins; | |
730 p_ri=1; | |
731 } | |
732 else | |
733 { | |
734 if (revins) | |
735 { | |
736 arrow_used = TRUE; | |
737 (void)stop_arrow(); | |
738 | |
739 revins = 0; | |
740 if (curwin->w_p_rl) | |
741 { | |
742 while ((F_isdigit(gchar_cursor()) | |
743 || (gchar_cursor() == F_PERIOD | |
744 || gchar_cursor() == F_PLUS | |
745 || gchar_cursor() == F_MINUS | |
746 || gchar_cursor() == F_MUL | |
747 || gchar_cursor() == F_DIVIDE | |
748 || gchar_cursor() == F_PERCENT | |
749 || gchar_cursor() == F_EQUALS)) | |
750 && gchar_cursor() != NUL) | |
751 ++curwin->w_cursor.col; | |
752 } | |
753 else | |
754 { | |
755 if (curwin->w_cursor.col) | |
756 while ((F_isdigit(gchar_cursor()) | |
757 || (gchar_cursor() == F_PERIOD | |
758 || gchar_cursor() == F_PLUS | |
759 || gchar_cursor() == F_MINUS | |
760 || gchar_cursor() == F_MUL | |
761 || gchar_cursor() == F_DIVIDE | |
762 || gchar_cursor() == F_PERCENT | |
763 || gchar_cursor() == F_EQUALS)) | |
764 && --curwin->w_cursor.col) | |
765 ; | |
766 | |
767 if (!F_isdigit(gchar_cursor())) | |
768 ++curwin->w_cursor.col; | |
769 } | |
770 } | |
771 } | |
772 | |
773 if (!revins) | |
774 { | |
775 if (curwin->w_p_rl) | |
776 p_ri=0; | |
777 if (!curwin->w_p_rl) | |
778 p_ri=1; | |
779 } | |
780 | |
781 if ((c < 0x100) && (isalpha(c) || c == '&' || c == '^' || c == ';' || | |
782 c == '\''|| c == ',' || c == '[' || | |
783 c == ']' || c == '{' || c == '}' )) | |
784 chg_r_to_Xor_X_(); | |
785 | |
786 tempc = 0; | |
787 | |
788 switch (c) | |
789 { | |
790 case '`': | |
791 case ' ': | |
792 case '.': | |
793 case '!': | |
794 case '"': | |
795 case '$': | |
796 case '%': | |
797 case '^': | |
798 case '&': | |
799 case '/': | |
800 case '(': | |
801 case ')': | |
802 case '=': | |
803 case '\\': | |
804 case '?': | |
805 case '+': | |
806 case '-': | |
807 case '_': | |
808 case '*': | |
809 case ':': | |
810 case '#': | |
811 case '~': | |
812 case '@': | |
813 case '<': | |
814 case '>': | |
815 case '{': | |
816 case '}': | |
817 case '|': | |
818 case '0': | |
819 case '1': | |
820 case '2': | |
821 case '3': | |
822 case '4': | |
823 case '5': | |
824 case '6': | |
825 case '7': | |
826 case '8': | |
827 case '9': | |
828 case 'B': | |
829 case 'E': | |
830 case 'F': | |
831 case 'H': | |
832 case 'I': | |
833 case 'K': | |
834 case 'L': | |
835 case 'M': | |
836 case 'O': | |
837 case 'P': | |
838 case 'Q': | |
839 case 'R': | |
840 case 'T': | |
841 case 'U': | |
842 case 'W': | |
843 case 'Y': | |
844 case NL: | |
845 case TAB: | |
846 | |
847 if (p_ri && c == NL && curwin->w_cursor.col) | |
848 { | |
849 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
850 * If the char before the cursor is _X_ or X_ do not change |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
851 * the one under the cursor with X type. |
7 | 852 */ |
853 | |
854 dec_cursor(); | |
855 | |
856 if (F_isalpha(gchar_cursor())) | |
857 { | |
858 inc_cursor(); | |
859 return NL; | |
860 } | |
861 | |
862 inc_cursor(); | |
863 } | |
864 | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
865 if (!p_ri && !curwin->w_cursor.col) |
7 | 866 { |
867 switch (c) | |
868 { | |
869 case '0': return FARSI_0; | |
870 case '1': return FARSI_1; | |
871 case '2': return FARSI_2; | |
872 case '3': return FARSI_3; | |
873 case '4': return FARSI_4; | |
874 case '5': return FARSI_5; | |
875 case '6': return FARSI_6; | |
876 case '7': return FARSI_7; | |
877 case '8': return FARSI_8; | |
878 case '9': return FARSI_9; | |
879 case 'B': return F_PSP; | |
880 case 'E': return JAZR_N; | |
881 case 'F': return ALEF_D_H; | |
882 case 'H': return ALEF_A; | |
883 case 'I': return TASH; | |
884 case 'K': return F_LQUOT; | |
885 case 'L': return F_RQUOT; | |
886 case 'M': return HAMZE; | |
887 case 'O': return '['; | |
888 case 'P': return ']'; | |
889 case 'Q': return OO; | |
890 case 'R': return MAD_N; | |
891 case 'T': return OW; | |
892 case 'U': return MAD; | |
893 case 'W': return OW_OW; | |
894 case 'Y': return JAZR; | |
895 case '`': return F_PCN; | |
896 case '!': return F_EXCL; | |
897 case '@': return F_COMMA; | |
898 case '#': return F_DIVIDE; | |
899 case '$': return F_CURRENCY; | |
900 case '%': return F_PERCENT; | |
901 case '^': return F_MUL; | |
902 case '&': return F_BCOMMA; | |
903 case '*': return F_STAR; | |
904 case '(': return F_LPARENT; | |
905 case ')': return F_RPARENT; | |
906 case '-': return F_MINUS; | |
907 case '_': return F_UNDERLINE; | |
908 case '=': return F_EQUALS; | |
909 case '+': return F_PLUS; | |
910 case '\\': return F_BSLASH; | |
911 case '|': return F_PIPE; | |
912 case ':': return F_DCOLON; | |
913 case '"': return F_SEMICOLON; | |
914 case '.': return F_PERIOD; | |
915 case '/': return F_SLASH; | |
916 case '<': return F_LESS; | |
917 case '>': return F_GREATER; | |
918 case '?': return F_QUESTION; | |
919 case ' ': return F_BLANK; | |
920 } | |
921 break; | |
922 } | |
923 if (!p_ri) | |
924 dec_cursor(); | |
925 | |
926 switch ((tempc = gchar_cursor())) | |
927 { | |
928 case _BE: | |
929 case _PE: | |
930 case _TE: | |
931 case _SE: | |
932 case _JIM: | |
933 case _CHE: | |
934 case _HE_J: | |
935 case _XE: | |
936 case _SIN: | |
937 case _SHIN: | |
938 case _SAD: | |
939 case _ZAD: | |
940 case _FE: | |
941 case _GHAF: | |
942 case _KAF: | |
943 case _KAF_H: | |
944 case _GAF: | |
945 case _LAM: | |
946 case _MIM: | |
947 case _NOON: | |
948 case _HE: | |
949 case _HE_: | |
950 case _TA: | |
951 case _ZA: | |
952 put_curr_and_l_to_X(toF_TyA(tempc)); | |
953 break; | |
954 case _AYN: | |
955 case _AYN_: | |
956 | |
957 if (!p_ri) | |
958 if (!curwin->w_cursor.col) | |
959 { | |
960 put_curr_and_l_to_X(AYN); | |
961 break; | |
962 } | |
963 | |
964 if (p_ri) | |
965 inc_cursor(); | |
966 else | |
967 dec_cursor(); | |
968 | |
969 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
970 tempc = AYN_; | |
971 else | |
972 tempc = AYN; | |
973 | |
974 if (p_ri) | |
975 dec_cursor(); | |
976 else | |
977 inc_cursor(); | |
978 | |
979 put_curr_and_l_to_X(tempc); | |
980 | |
981 break; | |
982 case _GHAYN: | |
983 case _GHAYN_: | |
984 | |
985 if (!p_ri) | |
986 if (!curwin->w_cursor.col) | |
987 { | |
988 put_curr_and_l_to_X(GHAYN); | |
989 break; | |
990 } | |
991 | |
992 if (p_ri) | |
993 inc_cursor(); | |
994 else | |
995 dec_cursor(); | |
996 | |
997 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
998 tempc = GHAYN_; | |
999 else | |
1000 tempc = GHAYN; | |
1001 | |
1002 if (p_ri) | |
1003 dec_cursor(); | |
1004 else | |
1005 inc_cursor(); | |
1006 | |
1007 put_curr_and_l_to_X(tempc); | |
1008 break; | |
1009 case _YE: | |
1010 case _IE: | |
1011 case _YEE: | |
1012 if (!p_ri) | |
1013 if (!curwin->w_cursor.col) | |
1014 { | |
1015 put_curr_and_l_to_X((tempc == _YE ? YE : | |
1016 (tempc == _IE ? IE : YEE))); | |
1017 break; | |
1018 } | |
1019 | |
1020 if (p_ri) | |
1021 inc_cursor(); | |
1022 else | |
1023 dec_cursor(); | |
1024 | |
1025 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
1026 tempc = (tempc == _YE ? YE_ : | |
1027 (tempc == _IE ? IE_ : YEE_)); | |
1028 else | |
1029 tempc = (tempc == _YE ? YE : | |
1030 (tempc == _IE ? IE : YEE)); | |
1031 | |
1032 if (p_ri) | |
1033 dec_cursor(); | |
1034 else | |
1035 inc_cursor(); | |
1036 | |
1037 put_curr_and_l_to_X(tempc); | |
1038 break; | |
1039 } | |
1040 | |
1041 if (!p_ri) | |
1042 inc_cursor(); | |
1043 | |
1044 tempc = 0; | |
1045 | |
1046 switch (c) | |
1047 { | |
1048 case '0': return FARSI_0; | |
1049 case '1': return FARSI_1; | |
1050 case '2': return FARSI_2; | |
1051 case '3': return FARSI_3; | |
1052 case '4': return FARSI_4; | |
1053 case '5': return FARSI_5; | |
1054 case '6': return FARSI_6; | |
1055 case '7': return FARSI_7; | |
1056 case '8': return FARSI_8; | |
1057 case '9': return FARSI_9; | |
1058 case 'B': return F_PSP; | |
1059 case 'E': return JAZR_N; | |
1060 case 'F': return ALEF_D_H; | |
1061 case 'H': return ALEF_A; | |
1062 case 'I': return TASH; | |
1063 case 'K': return F_LQUOT; | |
1064 case 'L': return F_RQUOT; | |
1065 case 'M': return HAMZE; | |
1066 case 'O': return '['; | |
1067 case 'P': return ']'; | |
1068 case 'Q': return OO; | |
1069 case 'R': return MAD_N; | |
1070 case 'T': return OW; | |
1071 case 'U': return MAD; | |
1072 case 'W': return OW_OW; | |
1073 case 'Y': return JAZR; | |
1074 case '`': return F_PCN; | |
1075 case '!': return F_EXCL; | |
1076 case '@': return F_COMMA; | |
1077 case '#': return F_DIVIDE; | |
1078 case '$': return F_CURRENCY; | |
1079 case '%': return F_PERCENT; | |
1080 case '^': return F_MUL; | |
1081 case '&': return F_BCOMMA; | |
1082 case '*': return F_STAR; | |
1083 case '(': return F_LPARENT; | |
1084 case ')': return F_RPARENT; | |
1085 case '-': return F_MINUS; | |
1086 case '_': return F_UNDERLINE; | |
1087 case '=': return F_EQUALS; | |
1088 case '+': return F_PLUS; | |
1089 case '\\': return F_BSLASH; | |
1090 case '|': return F_PIPE; | |
1091 case ':': return F_DCOLON; | |
1092 case '"': return F_SEMICOLON; | |
1093 case '.': return F_PERIOD; | |
1094 case '/': return F_SLASH; | |
1095 case '<': return F_LESS; | |
1096 case '>': return F_GREATER; | |
1097 case '?': return F_QUESTION; | |
1098 case ' ': return F_BLANK; | |
1099 } | |
1100 break; | |
1101 | |
1102 case 'a': | |
1103 tempc = _SHIN; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1104 break; |
7 | 1105 case 'A': |
1106 tempc = WAW_H; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1107 break; |
7 | 1108 case 'b': |
1109 tempc = ZAL; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1110 break; |
7 | 1111 case 'c': |
1112 tempc = ZE; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1113 break; |
7 | 1114 case 'C': |
1115 tempc = JE; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1116 break; |
7 | 1117 case 'd': |
1118 tempc = _YE; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1119 break; |
7 | 1120 case 'D': |
1121 tempc = _YEE; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1122 break; |
7 | 1123 case 'e': |
1124 tempc = _SE; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1125 break; |
7 | 1126 case 'f': |
1127 tempc = _BE; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1128 break; |
7 | 1129 case 'g': |
1130 tempc = _LAM; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1131 break; |
7 | 1132 case 'G': |
1133 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1134 { |
7 | 1135 |
1136 if (gchar_cursor() == _LAM) | |
1137 chg_c_toX_orX (); | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1138 else if (p_ri) |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1139 chg_c_to_X_or_X (); |
7 | 1140 } |
1141 | |
1142 if (!p_ri) | |
1143 if (!curwin->w_cursor.col) | |
1144 return ALEF_U_H; | |
1145 | |
1146 if (!p_ri) | |
1147 dec_cursor(); | |
1148 | |
1149 if (gchar_cursor() == _LAM) | |
1150 { | |
1151 chg_c_toX_orX (); | |
1152 chg_l_toXor_X (); | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1153 tempc = ALEF_U_H; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1154 } |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1155 else if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1156 { |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1157 tempc = ALEF_U_H_; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1158 chg_l_toXor_X (); |
7 | 1159 } |
1160 else | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1161 tempc = ALEF_U_H; |
7 | 1162 |
1163 if (!p_ri) | |
1164 inc_cursor(); | |
1165 | |
1166 return tempc; | |
1167 case 'h': | |
1168 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | |
1169 { | |
1170 if (p_ri) | |
1171 chg_c_to_X_or_X (); | |
1172 | |
1173 } | |
1174 | |
1175 if (!p_ri) | |
1176 if (!curwin->w_cursor.col) | |
1177 return ALEF; | |
1178 | |
1179 if (!p_ri) | |
1180 dec_cursor(); | |
1181 | |
1182 if (gchar_cursor() == _LAM) | |
1183 { | |
1184 chg_l_toXor_X(); | |
1185 del_char(FALSE); | |
1186 AppendCharToRedobuff(K_BS); | |
1187 | |
1188 if (!p_ri) | |
1189 dec_cursor(); | |
1190 | |
8238
d7e1526ae1b9
commit https://github.com/vim/vim/commit/68c85fcdf31c104db21c96cd5871724e458c95ff
Christian Brabandt <cb@256bit.org>
parents:
7819
diff
changeset
|
1191 tempc = LA; |
7 | 1192 } |
1193 else | |
1194 { | |
1195 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
1196 { | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1197 tempc = ALEF_; |
7 | 1198 chg_l_toXor_X (); |
1199 } | |
1200 else | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1201 tempc = ALEF; |
7 | 1202 } |
1203 | |
1204 if (!p_ri) | |
1205 inc_cursor(); | |
1206 | |
1207 return tempc; | |
1208 case 'i': | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1209 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1210 { |
7 | 1211 if (!p_ri && !F_is_TyE(tempc)) |
1212 chg_c_to_X_orX_ (); | |
1213 if (p_ri) | |
1214 chg_c_to_X_or_X (); | |
1215 | |
1216 } | |
1217 | |
1218 if (!p_ri && !curwin->w_cursor.col) | |
1219 return _HE; | |
1220 | |
1221 if (!p_ri) | |
1222 dec_cursor(); | |
1223 | |
1224 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1225 tempc = _HE_; |
7 | 1226 else |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1227 tempc = _HE; |
7 | 1228 |
1229 if (!p_ri) | |
1230 inc_cursor(); | |
1231 break; | |
1232 case 'j': | |
1233 tempc = _TE; | |
1234 break; | |
1235 case 'J': | |
1236 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1237 { |
7 | 1238 if (p_ri) |
1239 chg_c_to_X_or_X (); | |
1240 | |
1241 } | |
1242 | |
1243 if (!p_ri) | |
1244 if (!curwin->w_cursor.col) | |
1245 return TEE; | |
1246 | |
1247 if (!p_ri) | |
1248 dec_cursor(); | |
1249 | |
1250 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
1251 { | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1252 tempc = TEE_; |
7 | 1253 chg_l_toXor_X (); |
1254 } | |
1255 else | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1256 tempc = TEE; |
7 | 1257 |
1258 if (!p_ri) | |
1259 inc_cursor(); | |
1260 | |
1261 return tempc; | |
1262 case 'k': | |
1263 tempc = _NOON; | |
1264 break; | |
1265 case 'l': | |
1266 tempc = _MIM; | |
1267 break; | |
1268 case 'm': | |
1269 tempc = _PE; | |
1270 break; | |
1271 case 'n': | |
1272 case 'N': | |
1273 tempc = DAL; | |
1274 break; | |
1275 case 'o': | |
1276 tempc = _XE; | |
1277 break; | |
1278 case 'p': | |
1279 tempc = _HE_J; | |
1280 break; | |
1281 case 'q': | |
1282 tempc = _ZAD; | |
1283 break; | |
1284 case 'r': | |
1285 tempc = _GHAF; | |
1286 break; | |
1287 case 's': | |
1288 tempc = _SIN; | |
1289 break; | |
1290 case 'S': | |
1291 tempc = _IE; | |
1292 break; | |
1293 case 't': | |
1294 tempc = _FE; | |
1295 break; | |
1296 case 'u': | |
1297 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | |
1298 { | |
1299 if (!p_ri && !F_is_TyE(tempc)) | |
1300 chg_c_to_X_orX_ (); | |
1301 if (p_ri) | |
1302 chg_c_to_X_or_X (); | |
1303 | |
1304 } | |
1305 | |
1306 if (!p_ri && !curwin->w_cursor.col) | |
1307 return _AYN; | |
1308 | |
1309 if (!p_ri) | |
1310 dec_cursor(); | |
1311 | |
1312 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
1313 tempc = _AYN_; | |
1314 else | |
1315 tempc = _AYN; | |
1316 | |
1317 if (!p_ri) | |
1318 inc_cursor(); | |
1319 break; | |
1320 case 'v': | |
1321 case 'V': | |
1322 tempc = RE; | |
1323 break; | |
1324 case 'w': | |
1325 tempc = _SAD; | |
1326 break; | |
1327 case 'x': | |
1328 case 'X': | |
1329 tempc = _TA; | |
1330 break; | |
1331 case 'y': | |
1332 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1333 { |
7 | 1334 if (!p_ri && !F_is_TyE(tempc)) |
1335 chg_c_to_X_orX_ (); | |
1336 if (p_ri) | |
1337 chg_c_to_X_or_X (); | |
1338 | |
1339 } | |
1340 | |
1341 if (!p_ri && !curwin->w_cursor.col) | |
1342 return _GHAYN; | |
1343 | |
1344 if (!p_ri) | |
1345 dec_cursor(); | |
1346 | |
1347 if (F_is_TyB_TyC_TyD(SRC_EDT, AT_CURSOR)) | |
1348 tempc = _GHAYN_; | |
1349 else | |
1350 tempc = _GHAYN; | |
1351 | |
1352 if (!p_ri) | |
1353 inc_cursor(); | |
1354 | |
1355 break; | |
1356 case 'z': | |
1357 tempc = _ZA; | |
1358 break; | |
1359 case 'Z': | |
1360 tempc = _KAF_H; | |
1361 break; | |
1362 case ';': | |
1363 tempc = _KAF; | |
1364 break; | |
1365 case '\'': | |
1366 tempc = _GAF; | |
1367 break; | |
1368 case ',': | |
1369 tempc = WAW; | |
1370 break; | |
1371 case '[': | |
1372 tempc = _JIM; | |
1373 break; | |
1374 case ']': | |
1375 tempc = _CHE; | |
1376 break; | |
1377 } | |
1378 | |
1379 if ((F_isalpha(tempc) || F_isdigit(tempc))) | |
1380 { | |
1381 if (!curwin->w_cursor.col && STRLEN(ml_get_curline())) | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1382 { |
7 | 1383 if (!p_ri && !F_is_TyE(tempc)) |
1384 chg_c_to_X_orX_ (); | |
1385 if (p_ri) | |
1386 chg_c_to_X_or_X (); | |
1387 } | |
1388 | |
1389 if (curwin->w_cursor.col) | |
1390 { | |
1391 if (!p_ri) | |
1392 dec_cursor(); | |
1393 | |
1394 if (F_is_TyE(tempc)) | |
1395 chg_l_toXor_X (); | |
1396 else | |
1397 chg_l_to_X_orX_ (); | |
1398 | |
1399 if (!p_ri) | |
1400 inc_cursor(); | |
1401 } | |
1402 } | |
1403 if (tempc) | |
1404 return tempc; | |
1405 return c; | |
1406 } | |
1407 | |
1408 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1409 * Convert a none leading Farsi char into a leading type. |
7 | 1410 */ |
1411 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1412 toF_leading(int c) |
7 | 1413 { |
1414 switch (c) | |
1415 { | |
1416 case ALEF_: return ALEF; | |
1417 case ALEF_U_H_: return ALEF_U_H; | |
1418 case BE: return _BE; | |
1419 case PE: return _PE; | |
1420 case TE: return _TE; | |
1421 case SE: return _SE; | |
1422 case JIM: return _JIM; | |
1423 case CHE: return _CHE; | |
1424 case HE_J: return _HE_J; | |
1425 case XE: return _XE; | |
1426 case SIN: return _SIN; | |
1427 case SHIN: return _SHIN; | |
1428 case SAD: return _SAD; | |
1429 case ZAD: return _ZAD; | |
1430 | |
1431 case AYN: | |
1432 case AYN_: | |
1433 case _AYN_: return _AYN; | |
1434 | |
1435 case GHAYN: | |
1436 case GHAYN_: | |
1437 case _GHAYN_: return _GHAYN; | |
1438 | |
1439 case FE: return _FE; | |
1440 case GHAF: return _GHAF; | |
1441 case KAF: return _KAF; | |
1442 case GAF: return _GAF; | |
1443 case LAM: return _LAM; | |
1444 case MIM: return _MIM; | |
1445 case NOON: return _NOON; | |
1446 | |
1447 case _HE_: | |
1448 case F_HE: return _HE; | |
1449 | |
1450 case YE: | |
1451 case YE_: return _YE; | |
1452 | |
1453 case IE_: | |
1454 case IE: return _IE; | |
1455 | |
1456 case YEE: | |
1457 case YEE_: return _YEE; | |
1458 } | |
1459 return c; | |
1460 } | |
1461 | |
1462 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1463 * Convert a given Farsi char into right joining type. |
7 | 1464 */ |
1465 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1466 toF_Rjoin(int c) |
7 | 1467 { |
1468 switch (c) | |
1469 { | |
1470 case ALEF: return ALEF_; | |
1471 case ALEF_U_H: return ALEF_U_H_; | |
1472 case BE: return _BE; | |
1473 case PE: return _PE; | |
1474 case TE: return _TE; | |
1475 case SE: return _SE; | |
1476 case JIM: return _JIM; | |
1477 case CHE: return _CHE; | |
1478 case HE_J: return _HE_J; | |
1479 case XE: return _XE; | |
1480 case SIN: return _SIN; | |
1481 case SHIN: return _SHIN; | |
1482 case SAD: return _SAD; | |
1483 case ZAD: return _ZAD; | |
1484 | |
1485 case AYN: | |
1486 case AYN_: | |
1487 case _AYN: return _AYN_; | |
1488 | |
1489 case GHAYN: | |
1490 case GHAYN_: | |
1491 case _GHAYN_: return _GHAYN_; | |
1492 | |
1493 case FE: return _FE; | |
1494 case GHAF: return _GHAF; | |
1495 case KAF: return _KAF; | |
1496 case GAF: return _GAF; | |
1497 case LAM: return _LAM; | |
1498 case MIM: return _MIM; | |
1499 case NOON: return _NOON; | |
1500 | |
1501 case _HE: | |
1502 case F_HE: return _HE_; | |
1503 | |
1504 case YE: | |
1505 case YE_: return _YE; | |
1506 | |
1507 case IE_: | |
1508 case IE: return _IE; | |
1509 | |
1510 case TEE: return TEE_; | |
1511 | |
1512 case YEE: | |
1513 case YEE_: return _YEE; | |
1514 } | |
1515 return c; | |
1516 } | |
1517 | |
1518 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1519 * Can a given Farsi character join via its left edj. |
7 | 1520 */ |
1521 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1522 canF_Ljoin(int c) |
7 | 1523 { |
1524 switch (c) | |
1525 { | |
1526 case _BE: | |
1527 case BE: | |
1528 case PE: | |
1529 case _PE: | |
1530 case TE: | |
1531 case _TE: | |
1532 case SE: | |
1533 case _SE: | |
1534 case JIM: | |
1535 case _JIM: | |
1536 case CHE: | |
1537 case _CHE: | |
1538 case HE_J: | |
1539 case _HE_J: | |
1540 case XE: | |
1541 case _XE: | |
1542 case SIN: | |
1543 case _SIN: | |
1544 case SHIN: | |
1545 case _SHIN: | |
1546 case SAD: | |
1547 case _SAD: | |
1548 case ZAD: | |
1549 case _ZAD: | |
1550 case _TA: | |
1551 case _ZA: | |
1552 case AYN: | |
1553 case _AYN: | |
1554 case _AYN_: | |
1555 case AYN_: | |
1556 case GHAYN: | |
1557 case GHAYN_: | |
1558 case _GHAYN_: | |
1559 case _GHAYN: | |
1560 case FE: | |
1561 case _FE: | |
1562 case GHAF: | |
1563 case _GHAF: | |
1564 case _KAF_H: | |
1565 case KAF: | |
1566 case _KAF: | |
1567 case GAF: | |
1568 case _GAF: | |
1569 case LAM: | |
1570 case _LAM: | |
1571 case MIM: | |
1572 case _MIM: | |
1573 case NOON: | |
1574 case _NOON: | |
1575 case IE: | |
1576 case _IE: | |
1577 case IE_: | |
1578 case YE: | |
1579 case _YE: | |
1580 case YE_: | |
1581 case YEE: | |
1582 case _YEE: | |
1583 case YEE_: | |
1584 case F_HE: | |
1585 case _HE: | |
1586 case _HE_: | |
1587 return TRUE; | |
1588 } | |
1589 return FALSE; | |
1590 } | |
1591 | |
1592 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1593 * Can a given Farsi character join via its right edj. |
7 | 1594 */ |
1595 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1596 canF_Rjoin(int c) |
7 | 1597 { |
1598 switch (c) | |
1599 { | |
1600 case ALEF: | |
1601 case ALEF_: | |
1602 case ALEF_U_H: | |
1603 case ALEF_U_H_: | |
1604 case DAL: | |
1605 case ZAL: | |
1606 case RE: | |
1607 case JE: | |
1608 case ZE: | |
1609 case TEE: | |
1610 case TEE_: | |
1611 case WAW: | |
1612 case WAW_H: | |
1613 return TRUE; | |
1614 } | |
1615 | |
1616 return canF_Ljoin(c); | |
1617 | |
1618 } | |
1619 | |
1620 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1621 * is a given Farsi character a terminating type. |
7 | 1622 */ |
1623 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1624 F_isterm(int c) |
7 | 1625 { |
1626 switch (c) | |
1627 { | |
1628 case ALEF: | |
1629 case ALEF_: | |
1630 case ALEF_U_H: | |
1631 case ALEF_U_H_: | |
1632 case DAL: | |
1633 case ZAL: | |
1634 case RE: | |
1635 case JE: | |
1636 case ZE: | |
1637 case WAW: | |
1638 case WAW_H: | |
1639 case TEE: | |
1640 case TEE_: | |
1641 return TRUE; | |
1642 } | |
1643 | |
1644 return FALSE; | |
1645 } | |
1646 | |
1647 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1648 * Convert the given Farsi character into a ending type . |
7 | 1649 */ |
1650 static int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1651 toF_ending(int c) |
7 | 1652 { |
1653 switch (c) | |
1654 { | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1655 case _BE: return BE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1656 case _PE: return PE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1657 case _TE: return TE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1658 case _SE: return SE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1659 case _JIM: return JIM; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1660 case _CHE: return CHE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1661 case _HE_J: return HE_J; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1662 case _XE: return XE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1663 case _SIN: return SIN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1664 case _SHIN: return SHIN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1665 case _SAD: return SAD; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1666 case _ZAD: return ZAD; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1667 case _AYN: return AYN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1668 case _AYN_: return AYN_; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1669 case _GHAYN: return GHAYN; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1670 case _GHAYN_: return GHAYN_; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1671 case _FE: return FE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1672 case _GHAF: return GHAF; |
7 | 1673 case _KAF_H: |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1674 case _KAF: return KAF; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1675 case _GAF: return GAF; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1676 case _LAM: return LAM; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1677 case _MIM: return MIM; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1678 case _NOON: return NOON; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1679 case _YE: return YE_; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1680 case YE_: return YE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1681 case _YEE: return YEE_; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1682 case YEE_: return YEE; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1683 case TEE: return TEE_; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1684 case _IE: return IE_; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1685 case IE_: return IE; |
7 | 1686 case _HE: |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1687 case _HE_: return F_HE; |
7 | 1688 } |
1689 return c; | |
1690 } | |
1691 | |
1692 /* | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1693 * Convert the Farsi 3342 standard into Farsi VIM. |
7 | 1694 */ |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1695 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1696 conv_to_pvim(void) |
7 | 1697 { |
1698 char_u *ptr; | |
1699 int lnum, llen, i; | |
1700 | |
1701 for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) | |
1702 { | |
1703 ptr = ml_get((linenr_T)lnum); | |
1704 | |
1705 llen = (int)STRLEN(ptr); | |
1706 | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1707 for (i = 0; i < llen-1; i++) |
7 | 1708 { |
1709 if (canF_Ljoin(ptr[i]) && canF_Rjoin(ptr[i+1])) | |
1710 { | |
1711 ptr[i] = toF_leading(ptr[i]); | |
1712 ++i; | |
1713 | |
3683 | 1714 while (canF_Rjoin(ptr[i]) && i < llen) |
7 | 1715 { |
1716 ptr[i] = toF_Rjoin(ptr[i]); | |
1717 if (F_isterm(ptr[i]) || !F_isalpha(ptr[i])) | |
1718 break; | |
1719 ++i; | |
1720 } | |
1721 if (!F_isalpha(ptr[i]) || !canF_Rjoin(ptr[i])) | |
1722 ptr[i-1] = toF_ending(ptr[i-1]); | |
1723 } | |
1724 else | |
1725 ptr[i] = toF_TyA(ptr[i]); | |
1726 } | |
1727 } | |
1728 | |
1729 /* | |
1730 * Following lines contains Farsi encoded character. | |
1731 */ | |
1732 | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1733 do_cmdline_cmd((char_u *)"%s/\202\231/\232/ge"); |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1734 do_cmdline_cmd((char_u *)"%s/\201\231/\370\334/ge"); |
7 | 1735 |
1736 /* Assume the screen has been messed up: clear it and redraw. */ | |
1737 redraw_later(CLEAR); | |
1738 MSG_ATTR(farsi_text_1, hl_attr(HLF_S)); | |
1739 } | |
1740 | |
1741 /* | |
4352 | 1742 * Convert the Farsi VIM into Farsi 3342 standard. |
7 | 1743 */ |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1744 static void |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1745 conv_to_pstd(void) |
7 | 1746 { |
1747 char_u *ptr; | |
1748 int lnum, llen, i; | |
1749 | |
1750 /* | |
1751 * Following line contains Farsi encoded character. | |
1752 */ | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1753 do_cmdline_cmd((char_u *)"%s/\232/\202\231/ge"); |
7 | 1754 |
1755 for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; ++lnum) | |
1756 { | |
1757 ptr = ml_get((linenr_T)lnum); | |
1758 llen = (int)STRLEN(ptr); | |
1759 | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
1760 for (i = 0; i < llen; i++) |
7 | 1761 ptr[i] = toF_TyA(ptr[i]); |
1762 } | |
1763 | |
1764 /* Assume the screen has been messed up: clear it and redraw. */ | |
1765 redraw_later(CLEAR); | |
1766 MSG_ATTR(farsi_text_2, hl_attr(HLF_S)); | |
1767 } | |
1768 | |
1769 /* | |
1770 * left-right swap the characters in buf[len]. | |
1771 */ | |
1772 static void | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1773 lrswapbuf(char_u *buf, int len) |
7 | 1774 { |
1775 char_u *s, *e; | |
1776 int c; | |
1777 | |
1778 s = buf; | |
1779 e = buf + len - 1; | |
1780 | |
1781 while (e > s) | |
1782 { | |
1783 c = *s; | |
1784 *s = *e; | |
1785 *e = c; | |
1786 ++s; | |
1787 --e; | |
1788 } | |
1789 } | |
1790 | |
1791 /* | |
1792 * swap all the characters in reverse direction | |
1793 */ | |
1794 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1795 lrswap(char_u *ibuf) |
7 | 1796 { |
1797 if (ibuf != NULL && *ibuf != NUL) | |
1798 lrswapbuf(ibuf, (int)STRLEN(ibuf)); | |
1799 return ibuf; | |
1800 } | |
1801 | |
1802 /* | |
1803 * swap all the Farsi characters in reverse direction | |
1804 */ | |
1805 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1806 lrFswap(char_u *cmdbuf, int len) |
7 | 1807 { |
1808 int i, cnt; | |
1809 | |
1810 if (cmdbuf == NULL) | |
1811 return cmdbuf; | |
1812 | |
1813 if (len == 0 && (len = (int)STRLEN(cmdbuf)) == 0) | |
1814 return cmdbuf; | |
1815 | |
1816 for (i = 0; i < len; i++) | |
1817 { | |
1818 for (cnt = 0; i + cnt < len | |
1819 && (F_isalpha(cmdbuf[i + cnt]) | |
1820 || F_isdigit(cmdbuf[i + cnt]) | |
1821 || cmdbuf[i + cnt] == ' '); ++cnt) | |
1822 ; | |
1823 | |
1824 lrswapbuf(cmdbuf + i, cnt); | |
1825 i += cnt; | |
1826 } | |
1827 return cmdbuf; | |
1828 } | |
1829 | |
1830 /* | |
1624 | 1831 * Reverse the characters in the search path and substitute section |
1832 * accordingly. | |
1833 * TODO: handle different separator characters. Use skip_regexp(). | |
7 | 1834 */ |
1835 char_u * | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1836 lrF_sub(char_u *ibuf) |
7 | 1837 { |
1838 char_u *p, *ep; | |
1839 int i, cnt; | |
1840 | |
1841 p = ibuf; | |
1842 | |
388 | 1843 /* Find the boundary of the search path */ |
396 | 1844 while (((p = vim_strchr(p + 1, '/')) != NULL) && p[-1] == '\\') |
7 | 1845 ; |
1846 | |
1847 if (p == NULL) | |
1848 return ibuf; | |
1849 | |
1850 /* Reverse the Farsi characters in the search path. */ | |
1851 lrFswap(ibuf, (int)(p-ibuf)); | |
1852 | |
388 | 1853 /* Now find the boundary of the substitute section */ |
7 | 1854 if ((ep = (char_u *)strrchr((char *)++p, '/')) != NULL) |
1855 cnt = (int)(ep - p); | |
1856 else | |
1857 cnt = (int)STRLEN(p); | |
1858 | |
1859 /* Reverse the characters in the substitute section and take care of '\' */ | |
1860 for (i = 0; i < cnt-1; i++) | |
1861 if (p[i] == '\\') | |
1862 { | |
1863 p[i] = p[i+1] ; | |
1864 p[++i] = '\\'; | |
1865 } | |
1866 | |
1867 lrswapbuf(p, cnt); | |
1868 | |
1869 return ibuf; | |
1870 } | |
1871 | |
1872 /* | |
1873 * Map Farsi keyboard when in cmd_fkmap mode. | |
1874 */ | |
1875 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
1876 cmdl_fkmap(int c) |
7 | 1877 { |
1878 int tempc; | |
1879 | |
1880 switch (c) | |
1881 { | |
1882 case '0': | |
1883 case '1': | |
1884 case '2': | |
1885 case '3': | |
1886 case '4': | |
1887 case '5': | |
1888 case '6': | |
1889 case '7': | |
1890 case '8': | |
1891 case '9': | |
1892 case '`': | |
1893 case ' ': | |
1894 case '.': | |
1895 case '!': | |
1896 case '"': | |
1897 case '$': | |
1898 case '%': | |
1899 case '^': | |
1900 case '&': | |
1901 case '/': | |
1902 case '(': | |
1903 case ')': | |
1904 case '=': | |
1905 case '\\': | |
1906 case '?': | |
1907 case '+': | |
1908 case '-': | |
1909 case '_': | |
1910 case '*': | |
1911 case ':': | |
1912 case '#': | |
1913 case '~': | |
1914 case '@': | |
1915 case '<': | |
1916 case '>': | |
1917 case '{': | |
1918 case '}': | |
1919 case '|': | |
1920 case 'B': | |
1921 case 'E': | |
1922 case 'F': | |
1923 case 'H': | |
1924 case 'I': | |
1925 case 'K': | |
1926 case 'L': | |
1927 case 'M': | |
1928 case 'O': | |
1929 case 'P': | |
1930 case 'Q': | |
1931 case 'R': | |
1932 case 'T': | |
1933 case 'U': | |
1934 case 'W': | |
1935 case 'Y': | |
1936 case NL: | |
1937 case TAB: | |
1938 | |
1939 switch ((tempc = cmd_gchar(AT_CURSOR))) | |
1940 { | |
1941 case _BE: | |
1942 case _PE: | |
1943 case _TE: | |
1944 case _SE: | |
1945 case _JIM: | |
1946 case _CHE: | |
1947 case _HE_J: | |
1948 case _XE: | |
1949 case _SIN: | |
1950 case _SHIN: | |
1951 case _SAD: | |
1952 case _ZAD: | |
1953 case _AYN: | |
1954 case _GHAYN: | |
1955 case _FE: | |
1956 case _GHAF: | |
1957 case _KAF: | |
1958 case _GAF: | |
1959 case _LAM: | |
1960 case _MIM: | |
1961 case _NOON: | |
1962 case _HE: | |
1963 case _HE_: | |
1964 cmd_pchar(toF_TyA(tempc), AT_CURSOR); | |
1965 break; | |
1966 case _AYN_: | |
1967 cmd_pchar(AYN_, AT_CURSOR); | |
1968 break; | |
1969 case _GHAYN_: | |
1970 cmd_pchar(GHAYN_, AT_CURSOR); | |
1971 break; | |
1972 case _IE: | |
1973 if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1)) | |
1974 cmd_pchar(IE_, AT_CURSOR); | |
1975 else | |
1976 cmd_pchar(IE, AT_CURSOR); | |
1977 break; | |
1978 case _YEE: | |
1979 if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1)) | |
1980 cmd_pchar(YEE_, AT_CURSOR); | |
1981 else | |
1982 cmd_pchar(YEE, AT_CURSOR); | |
1983 break; | |
1984 case _YE: | |
1985 if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR+1)) | |
1986 cmd_pchar(YE_, AT_CURSOR); | |
1987 else | |
1988 cmd_pchar(YE, AT_CURSOR); | |
1989 } | |
1990 | |
1991 switch (c) | |
1992 { | |
1993 case '0': return FARSI_0; | |
1994 case '1': return FARSI_1; | |
1995 case '2': return FARSI_2; | |
1996 case '3': return FARSI_3; | |
1997 case '4': return FARSI_4; | |
1998 case '5': return FARSI_5; | |
1999 case '6': return FARSI_6; | |
2000 case '7': return FARSI_7; | |
2001 case '8': return FARSI_8; | |
2002 case '9': return FARSI_9; | |
2003 case 'B': return F_PSP; | |
2004 case 'E': return JAZR_N; | |
2005 case 'F': return ALEF_D_H; | |
2006 case 'H': return ALEF_A; | |
2007 case 'I': return TASH; | |
2008 case 'K': return F_LQUOT; | |
2009 case 'L': return F_RQUOT; | |
2010 case 'M': return HAMZE; | |
2011 case 'O': return '['; | |
2012 case 'P': return ']'; | |
2013 case 'Q': return OO; | |
2014 case 'R': return MAD_N; | |
2015 case 'T': return OW; | |
2016 case 'U': return MAD; | |
2017 case 'W': return OW_OW; | |
2018 case 'Y': return JAZR; | |
2019 case '`': return F_PCN; | |
2020 case '!': return F_EXCL; | |
2021 case '@': return F_COMMA; | |
2022 case '#': return F_DIVIDE; | |
2023 case '$': return F_CURRENCY; | |
2024 case '%': return F_PERCENT; | |
2025 case '^': return F_MUL; | |
2026 case '&': return F_BCOMMA; | |
2027 case '*': return F_STAR; | |
2028 case '(': return F_LPARENT; | |
2029 case ')': return F_RPARENT; | |
2030 case '-': return F_MINUS; | |
2031 case '_': return F_UNDERLINE; | |
2032 case '=': return F_EQUALS; | |
2033 case '+': return F_PLUS; | |
2034 case '\\': return F_BSLASH; | |
2035 case '|': return F_PIPE; | |
2036 case ':': return F_DCOLON; | |
2037 case '"': return F_SEMICOLON; | |
2038 case '.': return F_PERIOD; | |
2039 case '/': return F_SLASH; | |
2040 case '<': return F_LESS; | |
2041 case '>': return F_GREATER; | |
2042 case '?': return F_QUESTION; | |
2043 case ' ': return F_BLANK; | |
2044 } | |
2045 | |
2046 break; | |
2047 | |
2048 case 'a': return _SHIN; | |
2049 case 'A': return WAW_H; | |
2050 case 'b': return ZAL; | |
2051 case 'c': return ZE; | |
2052 case 'C': return JE; | |
2053 case 'd': return _YE; | |
2054 case 'D': return _YEE; | |
2055 case 'e': return _SE; | |
2056 case 'f': return _BE; | |
2057 case 'g': return _LAM; | |
2058 case 'G': | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2059 if (cmd_gchar(AT_CURSOR) == _LAM) |
7 | 2060 { |
2061 cmd_pchar(LAM, AT_CURSOR); | |
2062 return ALEF_U_H; | |
2063 } | |
2064 | |
2065 if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) | |
2066 return ALEF_U_H_; | |
2067 else | |
2068 return ALEF_U_H; | |
2069 case 'h': | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2070 if (cmd_gchar(AT_CURSOR) == _LAM) |
7 | 2071 { |
2072 cmd_pchar(LA, AT_CURSOR); | |
2073 redrawcmdline(); | |
2074 return K_IGNORE; | |
2075 } | |
2076 | |
2077 if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) | |
2078 return ALEF_; | |
2079 else | |
2080 return ALEF; | |
2081 case 'i': | |
2082 if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) | |
2083 return _HE_; | |
2084 else | |
2085 return _HE; | |
2086 case 'j': return _TE; | |
2087 case 'J': | |
2088 if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) | |
2089 return TEE_; | |
2090 else | |
2091 return TEE; | |
2092 case 'k': return _NOON; | |
2093 case 'l': return _MIM; | |
2094 case 'm': return _PE; | |
2095 case 'n': | |
2096 case 'N': return DAL; | |
2097 case 'o': return _XE; | |
2098 case 'p': return _HE_J; | |
2099 case 'q': return _ZAD; | |
2100 case 'r': return _GHAF; | |
2101 case 's': return _SIN; | |
2102 case 'S': return _IE; | |
2103 case 't': return _FE; | |
2104 case 'u': | |
2105 if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) | |
2106 return _AYN_; | |
2107 else | |
2108 return _AYN; | |
2109 case 'v': | |
2110 case 'V': return RE; | |
2111 case 'w': return _SAD; | |
2112 case 'x': | |
2113 case 'X': return _TA; | |
2114 case 'y': | |
2115 if (F_is_TyB_TyC_TyD(SRC_CMD, AT_CURSOR)) | |
2116 return _GHAYN_; | |
2117 else | |
2118 return _GHAYN; | |
2119 case 'z': | |
2120 case 'Z': return _ZA; | |
2121 case ';': return _KAF; | |
2122 case '\'': return _GAF; | |
2123 case ',': return WAW; | |
2124 case '[': return _JIM; | |
2125 case ']': return _CHE; | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2126 } |
7 | 2127 |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2128 return c; |
7 | 2129 } |
2130 | |
2131 /* | |
2132 * F_isalpha returns TRUE if 'c' is a Farsi alphabet | |
2133 */ | |
2134 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2135 F_isalpha(int c) |
7 | 2136 { |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2137 return ((c >= TEE_ && c <= _YE) |
7 | 2138 || (c >= ALEF_A && c <= YE) |
2139 || (c >= _IE && c <= YE_)); | |
2140 } | |
2141 | |
2142 /* | |
2143 * F_isdigit returns TRUE if 'c' is a Farsi digit | |
2144 */ | |
2145 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2146 F_isdigit(int c) |
7 | 2147 { |
2148 return (c >= FARSI_0 && c <= FARSI_9); | |
2149 } | |
2150 | |
2151 /* | |
2152 * F_ischar returns TRUE if 'c' is a Farsi character. | |
2153 */ | |
2154 int | |
7819
f86adafb28d4
commit https://github.com/vim/vim/commit/78c0b7d43e5048fd71d12816659667834170c76d
Christian Brabandt <cb@256bit.org>
parents:
7801
diff
changeset
|
2155 F_ischar(int c) |
7 | 2156 { |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2157 return (c >= TEE_ && c <= YE_); |
7 | 2158 } |
2159 | |
2160 void | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2161 farsi_f8(cmdarg_T *cap UNUSED) |
7 | 2162 { |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2163 if (p_altkeymap) |
7 | 2164 { |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2165 if (curwin->w_farsi & W_R_L) |
7 | 2166 { |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2167 p_fkmap = 0; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2168 do_cmdline_cmd((char_u *)"set norl"); |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2169 MSG(""); |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2170 } |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2171 else |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2172 { |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2173 p_fkmap = 1; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2174 do_cmdline_cmd((char_u *)"set rl"); |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2175 MSG(""); |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2176 } |
7 | 2177 |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2178 curwin->w_farsi = curwin->w_farsi ^ W_R_L; |
7 | 2179 } |
2180 } | |
9399
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2181 |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2182 void |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2183 farsi_f9(cmdarg_T *cap UNUSED) |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2184 { |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2185 if (p_altkeymap && curwin->w_p_rl) |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2186 { |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2187 curwin->w_farsi = curwin->w_farsi ^ W_CONV; |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2188 if (curwin->w_farsi & W_CONV) |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2189 conv_to_pvim(); |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2190 else |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2191 conv_to_pstd(); |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2192 } |
43b8570abbec
commit https://github.com/vim/vim/commit/ee2615af64fdcee87d8e4b13b65356e77fbd969b
Christian Brabandt <cb@256bit.org>
parents:
8238
diff
changeset
|
2193 } |
9403
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
2194 |
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
9399
diff
changeset
|
2195 #endif /* FEAT_FKMAP */ |