Mercurial > vim
annotate src/arabic.c @ 34681:bfb2f74221b9
Added tag v9.1.0221 for changeset 2fd4ce2a50586046d91c7dff36a7fe5eabfaf113
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 28 Mar 2024 12:00:04 +0100 |
parents | 7334bf933510 |
children |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
9403
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 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 * arabic.c: functions for Arabic language | |
12 * | |
13 * Author: Nadim Shaikli & Isam Bayazidi | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
14 * Farsi support and restructuring to make adding new letters easier by Ali |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
15 * Gholami Rudi. Further work by Ameretat Reith. |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
16 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
17 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
18 /* |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
19 * Sorted list of unicode Arabic characters. Each entry holds the |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
20 * presentation forms of a letter. |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
21 * |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
22 * Arabic characters are categorized into following types: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
23 * |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
24 * Isolated - iso-8859-6 form |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
25 * Initial - unicode form-B start |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
26 * Medial - unicode form-B middle |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
27 * Final - unicode form-B final |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
28 * Stand-Alone - unicode form-B isolated |
7 | 29 */ |
30 | |
9403
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
31 #include "vim.h" |
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
32 |
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
33 #if defined(FEAT_ARABIC) || defined(PROTO) |
9b048dced116
commit https://github.com/vim/vim/commit/75464dc434c43efac60e8bfd9bec2a8b736407e9
Christian Brabandt <cb@256bit.org>
parents:
7817
diff
changeset
|
34 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
35 // Unicode values for Arabic characters. |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
36 #define a_HAMZA 0x0621 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
37 #define a_ALEF_MADDA 0x0622 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
38 #define a_ALEF_HAMZA_ABOVE 0x0623 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
39 #define a_WAW_HAMZA 0x0624 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
40 #define a_ALEF_HAMZA_BELOW 0x0625 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
41 #define a_YEH_HAMZA 0x0626 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
42 #define a_ALEF 0x0627 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
43 #define a_BEH 0x0628 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
44 #define a_TEH_MARBUTA 0x0629 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
45 #define a_TEH 0x062a |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
46 #define a_THEH 0x062b |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
47 #define a_JEEM 0x062c |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
48 #define a_HAH 0x062d |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
49 #define a_KHAH 0x062e |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
50 #define a_DAL 0x062f |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
51 #define a_THAL 0x0630 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
52 #define a_REH 0x0631 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
53 #define a_ZAIN 0x0632 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
54 #define a_SEEN 0x0633 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
55 #define a_SHEEN 0x0634 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
56 #define a_SAD 0x0635 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
57 #define a_DAD 0x0636 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
58 #define a_TAH 0x0637 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
59 #define a_ZAH 0x0638 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
60 #define a_AIN 0x0639 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
61 #define a_GHAIN 0x063a |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
62 #define a_TATWEEL 0x0640 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
63 #define a_FEH 0x0641 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
64 #define a_QAF 0x0642 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
65 #define a_KAF 0x0643 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
66 #define a_LAM 0x0644 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
67 #define a_MEEM 0x0645 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
68 #define a_NOON 0x0646 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
69 #define a_HEH 0x0647 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
70 #define a_WAW 0x0648 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
71 #define a_ALEF_MAKSURA 0x0649 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
72 #define a_YEH 0x064a |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
73 #define a_FATHATAN 0x064b |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
74 #define a_DAMMATAN 0x064c |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
75 #define a_KASRATAN 0x064d |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
76 #define a_FATHA 0x064e |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
77 #define a_DAMMA 0x064f |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
78 #define a_KASRA 0x0650 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
79 #define a_SHADDA 0x0651 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
80 #define a_SUKUN 0x0652 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
81 #define a_MADDA_ABOVE 0x0653 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
82 #define a_HAMZA_ABOVE 0x0654 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
83 #define a_HAMZA_BELOW 0x0655 |
7 | 84 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
85 #define a_PEH 0x067e |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
86 #define a_TCHEH 0x0686 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
87 #define a_JEH 0x0698 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
88 #define a_FKAF 0x06a9 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
89 #define a_GAF 0x06af |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
90 #define a_FYEH 0x06cc |
7 | 91 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
92 #define a_s_LAM_ALEF_MADDA_ABOVE 0xfef5 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
93 #define a_f_LAM_ALEF_MADDA_ABOVE 0xfef6 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
94 #define a_s_LAM_ALEF_HAMZA_ABOVE 0xfef7 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
95 #define a_f_LAM_ALEF_HAMZA_ABOVE 0xfef8 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
96 #define a_s_LAM_ALEF_HAMZA_BELOW 0xfef9 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
97 #define a_f_LAM_ALEF_HAMZA_BELOW 0xfefa |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
98 #define a_s_LAM_ALEF 0xfefb |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
99 #define a_f_LAM_ALEF 0xfefc |
7 | 100 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
101 static struct achar { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
102 unsigned c; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
103 unsigned isolated; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
104 unsigned initial; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
105 unsigned medial; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
106 unsigned final; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
107 } achars[] = { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
108 {a_HAMZA, 0xfe80, 0, 0, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
109 {a_ALEF_MADDA, 0xfe81, 0, 0, 0xfe82}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
110 {a_ALEF_HAMZA_ABOVE, 0xfe83, 0, 0, 0xfe84}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
111 {a_WAW_HAMZA, 0xfe85, 0, 0, 0xfe86}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
112 {a_ALEF_HAMZA_BELOW, 0xfe87, 0, 0, 0xfe88}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
113 {a_YEH_HAMZA, 0xfe89, 0xfe8b, 0xfe8c, 0xfe8a}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
114 {a_ALEF, 0xfe8d, 0, 0, 0xfe8e}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
115 {a_BEH, 0xfe8f, 0xfe91, 0xfe92, 0xfe90}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
116 {a_TEH_MARBUTA, 0xfe93, 0, 0, 0xfe94}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
117 {a_TEH, 0xfe95, 0xfe97, 0xfe98, 0xfe96}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
118 {a_THEH, 0xfe99, 0xfe9b, 0xfe9c, 0xfe9a}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
119 {a_JEEM, 0xfe9d, 0xfe9f, 0xfea0, 0xfe9e}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
120 {a_HAH, 0xfea1, 0xfea3, 0xfea4, 0xfea2}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
121 {a_KHAH, 0xfea5, 0xfea7, 0xfea8, 0xfea6}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
122 {a_DAL, 0xfea9, 0, 0, 0xfeaa}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
123 {a_THAL, 0xfeab, 0, 0, 0xfeac}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
124 {a_REH, 0xfead, 0, 0, 0xfeae}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
125 {a_ZAIN, 0xfeaf, 0, 0, 0xfeb0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
126 {a_SEEN, 0xfeb1, 0xfeb3, 0xfeb4, 0xfeb2}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
127 {a_SHEEN, 0xfeb5, 0xfeb7, 0xfeb8, 0xfeb6}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
128 {a_SAD, 0xfeb9, 0xfebb, 0xfebc, 0xfeba}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
129 {a_DAD, 0xfebd, 0xfebf, 0xfec0, 0xfebe}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
130 {a_TAH, 0xfec1, 0xfec3, 0xfec4, 0xfec2}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
131 {a_ZAH, 0xfec5, 0xfec7, 0xfec8, 0xfec6}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
132 {a_AIN, 0xfec9, 0xfecb, 0xfecc, 0xfeca}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
133 {a_GHAIN, 0xfecd, 0xfecf, 0xfed0, 0xfece}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
134 {a_TATWEEL, 0, 0x0640, 0x0640, 0x0640}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
135 {a_FEH, 0xfed1, 0xfed3, 0xfed4, 0xfed2}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
136 {a_QAF, 0xfed5, 0xfed7, 0xfed8, 0xfed6}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
137 {a_KAF, 0xfed9, 0xfedb, 0xfedc, 0xfeda}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
138 {a_LAM, 0xfedd, 0xfedf, 0xfee0, 0xfede}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
139 {a_MEEM, 0xfee1, 0xfee3, 0xfee4, 0xfee2}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
140 {a_NOON, 0xfee5, 0xfee7, 0xfee8, 0xfee6}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
141 {a_HEH, 0xfee9, 0xfeeb, 0xfeec, 0xfeea}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
142 {a_WAW, 0xfeed, 0, 0, 0xfeee}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
143 {a_ALEF_MAKSURA, 0xfeef, 0, 0, 0xfef0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
144 {a_YEH, 0xfef1, 0xfef3, 0xfef4, 0xfef2}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
145 {a_FATHATAN, 0xfe70, 0, 0, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
146 {a_DAMMATAN, 0xfe72, 0, 0, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
147 {a_KASRATAN, 0xfe74, 0, 0, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
148 {a_FATHA, 0xfe76, 0, 0xfe77, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
149 {a_DAMMA, 0xfe78, 0, 0xfe79, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
150 {a_KASRA, 0xfe7a, 0, 0xfe7b, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
151 {a_SHADDA, 0xfe7c, 0, 0xfe7c, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
152 {a_SUKUN, 0xfe7e, 0, 0xfe7f, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
153 {a_MADDA_ABOVE, 0, 0, 0, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
154 {a_HAMZA_ABOVE, 0, 0, 0, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
155 {a_HAMZA_BELOW, 0, 0, 0, 0}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
156 {a_PEH, 0xfb56, 0xfb58, 0xfb59, 0xfb57}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
157 {a_TCHEH, 0xfb7a, 0xfb7c, 0xfb7d, 0xfb7b}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
158 {a_JEH, 0xfb8a, 0, 0, 0xfb8b}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
159 {a_FKAF, 0xfb8e, 0xfb90, 0xfb91, 0xfb8f}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
160 {a_GAF, 0xfb92, 0xfb94, 0xfb95, 0xfb93}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
161 {a_FYEH, 0xfbfc, 0xfbfe, 0xfbff, 0xfbfd}, |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
162 }; |
7 | 163 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
164 #define a_BYTE_ORDER_MARK 0xfeff |
7 | 165 |
166 /* | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
167 * Find the struct achar pointer to the given Arabic char. |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
168 * Returns NULL if not found. |
7 | 169 */ |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
170 static struct achar * |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
171 find_achar(int c) |
7 | 172 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
173 int h, m, l; |
7 | 174 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
175 // using binary search to find c |
24768
7334bf933510
patch 8.2.2922: computing array length is done in various ways
Bram Moolenaar <Bram@vim.org>
parents:
16160
diff
changeset
|
176 h = ARRAY_LENGTH(achars); |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
177 l = 0; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
178 while (l < h) |
7 | 179 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
180 m = (h + l) / 2; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
181 if (achars[m].c == (unsigned)c) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
182 return &achars[m]; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
183 if ((unsigned)c < achars[m].c) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
184 h = m; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
185 else |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
186 l = m + 1; |
7 | 187 } |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
188 return NULL; |
7 | 189 } |
190 | |
191 /* | |
192 * Change shape - from Combination (2 char) to an Isolated | |
193 */ | |
194 static int | |
7817
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
195 chg_c_laa2i(int hid_c) |
7 | 196 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
197 int tempc; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
198 |
7 | 199 switch (hid_c) |
200 { | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
201 case a_ALEF_MADDA: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
202 tempc = a_s_LAM_ALEF_MADDA_ABOVE; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
203 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
204 case a_ALEF_HAMZA_ABOVE: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
205 tempc = a_s_LAM_ALEF_HAMZA_ABOVE; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
206 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
207 case a_ALEF_HAMZA_BELOW: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
208 tempc = a_s_LAM_ALEF_HAMZA_BELOW; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
209 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
210 case a_ALEF: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
211 tempc = a_s_LAM_ALEF; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
212 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
213 default: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
214 tempc = 0; |
7 | 215 } |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
216 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
217 return tempc; |
7 | 218 } |
219 | |
220 /* | |
221 * Change shape - from Combination-Isolated to Final | |
222 */ | |
223 static int | |
7817
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
224 chg_c_laa2f(int hid_c) |
7 | 225 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
226 int tempc; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
227 |
7 | 228 switch (hid_c) |
229 { | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
230 case a_ALEF_MADDA: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
231 tempc = a_f_LAM_ALEF_MADDA_ABOVE; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
232 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
233 case a_ALEF_HAMZA_ABOVE: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
234 tempc = a_f_LAM_ALEF_HAMZA_ABOVE; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
235 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
236 case a_ALEF_HAMZA_BELOW: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
237 tempc = a_f_LAM_ALEF_HAMZA_BELOW; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
238 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
239 case a_ALEF: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
240 tempc = a_f_LAM_ALEF; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
241 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
242 default: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
243 tempc = 0; |
7 | 244 } |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
245 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
246 return tempc; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
247 } |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
248 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
249 /* |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
250 * Returns whether it is possible to join the given letters |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
251 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
252 static int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
253 can_join(int c1, int c2) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
254 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
255 struct achar *a1 = find_achar(c1); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
256 struct achar *a2 = find_achar(c2); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
257 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
258 return a1 && a2 && (a1->initial || a1->medial) && (a2->final || a2->medial); |
7 | 259 } |
260 | |
261 /* | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
262 * Check whether we are dealing with a character that could be regarded as an |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
263 * Arabic combining character, need to check the character before this. |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
264 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
265 int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
266 arabic_maycombine(int two) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
267 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
268 if (p_arshape && !p_tbidi) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
269 return (two == a_ALEF_MADDA |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
270 || two == a_ALEF_HAMZA_ABOVE |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
271 || two == a_ALEF_HAMZA_BELOW |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
272 || two == a_ALEF); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
273 return FALSE; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
274 } |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
275 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
276 /* |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
277 * Check whether we are dealing with Arabic combining characters. |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
278 * Note: these are NOT really composing characters! |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
279 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
280 int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
281 arabic_combine( |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
282 int one, // first character |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
283 int two) // character just after "one" |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
284 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
285 if (one == a_LAM) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
286 return arabic_maycombine(two); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
287 return FALSE; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
288 } |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
289 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
290 /* |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
291 * A_is_iso returns true if 'c' is an Arabic ISO-8859-6 character |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
292 * (alphabet/number/punctuation) |
7 | 293 */ |
294 static int | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
295 A_is_iso(int c) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
296 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
297 return find_achar(c) != NULL; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
298 } |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
299 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
300 /* |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
301 * A_is_ok returns true if 'c' is an Arabic 10646 (8859-6 or Form-B) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
302 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
303 static int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
304 A_is_ok(int c) |
7 | 305 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
306 return (A_is_iso(c) || c == a_BYTE_ORDER_MARK); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
307 } |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
308 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
309 /* |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
310 * A_is_valid returns true if 'c' is an Arabic 10646 (8859-6 or Form-B) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
311 * with some exceptions/exclusions |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
312 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
313 static int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
314 A_is_valid(int c) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
315 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
316 return (A_is_ok(c) && c != a_HAMZA); |
7 | 317 } |
318 | |
319 /* | |
320 * Do Arabic shaping on character "c". Returns the shaped character. | |
321 * out: "ccp" points to the first byte of the character to be shaped. | |
322 * in/out: "c1p" points to the first composing char for "c". | |
323 * in: "prev_c" is the previous character (not shaped) | |
324 * in: "prev_c1" is the first composing char for the previous char | |
325 * (not shaped) | |
326 * in: "next_c" is the next character (not shaped). | |
327 */ | |
328 int | |
7817
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
329 arabic_shape( |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
330 int c, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
331 int *ccp, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
332 int *c1p, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
333 int prev_c, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
334 int prev_c1, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
335 int next_c) |
7 | 336 { |
337 int curr_c; | |
338 int curr_laa; | |
339 int prev_laa; | |
340 | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
341 // Deal only with Arabic characters, pass back all others |
7 | 342 if (!A_is_ok(c)) |
343 return c; | |
344 | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
345 curr_laa = arabic_combine(c, *c1p); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
346 prev_laa = arabic_combine(prev_c, prev_c1); |
7 | 347 |
348 if (curr_laa) | |
349 { | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
350 if (A_is_valid(prev_c) && can_join(prev_c, a_LAM) && !prev_laa) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
351 curr_c = chg_c_laa2f(*c1p); |
7 | 352 else |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
353 curr_c = chg_c_laa2i(*c1p); |
7 | 354 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
355 // Remove the composing character |
7 | 356 *c1p = 0; |
357 } | |
358 else | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
359 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
360 struct achar *curr_a = find_achar(c); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
361 int backward_combine = !prev_laa && can_join(prev_c, c); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
362 int forward_combine = can_join(c, next_c); |
7 | 363 |
16160
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
364 if (backward_combine) |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
365 { |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
366 if (forward_combine) |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
367 curr_c = curr_a->medial; |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
368 else |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
369 curr_c = curr_a->final; |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
370 } |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
371 else |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
372 { |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
373 if (forward_combine) |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
374 curr_c = curr_a->initial; |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
375 else |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
376 curr_c = curr_a->isolated; |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
377 } |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
378 } |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
379 |
16160
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
380 // Character missing from the table means using original character. |
7 | 381 if (curr_c == NUL) |
382 curr_c = c; | |
383 | |
384 if (curr_c != c && ccp != NULL) | |
385 { | |
3549 | 386 char_u buf[MB_MAXBYTES + 1]; |
7 | 387 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
388 // Update the first byte of the character. |
7 | 389 (*mb_char2bytes)(curr_c, buf); |
390 *ccp = buf[0]; | |
391 } | |
392 | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
393 // Return the shaped character |
7 | 394 return curr_c; |
395 } | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
396 #endif // FEAT_ARABIC |