Mercurial > vim
annotate src/arabic.c @ 20637:6c5b11458f31 v8.2.0872
patch 8.2.0872: XIM code is mixed with multi-byte code
Commit: https://github.com/vim/vim/commit/f15c8b6eb32fcfea88fd9ca42ef87bbee2c8fe2b
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 1 14:34:43 2020 +0200
patch 8.2.0872: XIM code is mixed with multi-byte code
Problem: XIM code is mixed with multi-byte code.
Solution: Move the XIM code to a separate file. (Yegappan Lakshmanan,
closes #6177)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 01 Jun 2020 14:45:05 +0200 |
parents | 061cf939f7ce |
children | 7334bf933510 |
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 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
166 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) |
7 | 167 |
168 /* | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
169 * 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
|
170 * Returns NULL if not found. |
7 | 171 */ |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
172 static struct achar * |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
173 find_achar(int c) |
7 | 174 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
175 int h, m, l; |
7 | 176 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
177 // using binary search to find c |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
178 h = ARRAY_SIZE(achars); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
179 l = 0; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
180 while (l < h) |
7 | 181 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
182 m = (h + l) / 2; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
183 if (achars[m].c == (unsigned)c) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
184 return &achars[m]; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
185 if ((unsigned)c < achars[m].c) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
186 h = m; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
187 else |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
188 l = m + 1; |
7 | 189 } |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
190 return NULL; |
7 | 191 } |
192 | |
193 /* | |
194 * Change shape - from Combination (2 char) to an Isolated | |
195 */ | |
196 static int | |
7817
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
197 chg_c_laa2i(int hid_c) |
7 | 198 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
199 int tempc; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
200 |
7 | 201 switch (hid_c) |
202 { | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
203 case a_ALEF_MADDA: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
204 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
|
205 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
206 case a_ALEF_HAMZA_ABOVE: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
207 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
|
208 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
209 case a_ALEF_HAMZA_BELOW: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
210 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
|
211 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
212 case a_ALEF: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
213 tempc = a_s_LAM_ALEF; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
214 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
215 default: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
216 tempc = 0; |
7 | 217 } |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
218 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
219 return tempc; |
7 | 220 } |
221 | |
222 /* | |
223 * Change shape - from Combination-Isolated to Final | |
224 */ | |
225 static int | |
7817
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
226 chg_c_laa2f(int hid_c) |
7 | 227 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
228 int tempc; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
229 |
7 | 230 switch (hid_c) |
231 { | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
232 case a_ALEF_MADDA: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
233 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
|
234 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
235 case a_ALEF_HAMZA_ABOVE: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
236 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
|
237 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
238 case a_ALEF_HAMZA_BELOW: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
239 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
|
240 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
241 case a_ALEF: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
242 tempc = a_f_LAM_ALEF; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
243 break; |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
244 default: |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
245 tempc = 0; |
7 | 246 } |
16066
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 return tempc; |
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 |
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 * 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
|
253 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
254 static int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
255 can_join(int c1, int c2) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
256 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
257 struct achar *a1 = find_achar(c1); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
258 struct achar *a2 = find_achar(c2); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
259 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
260 return a1 && a2 && (a1->initial || a1->medial) && (a2->final || a2->medial); |
7 | 261 } |
262 | |
263 /* | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
264 * 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
|
265 * 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
|
266 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
267 int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
268 arabic_maycombine(int two) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
269 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
270 if (p_arshape && !p_tbidi) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
271 return (two == a_ALEF_MADDA |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
272 || two == a_ALEF_HAMZA_ABOVE |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
273 || two == a_ALEF_HAMZA_BELOW |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
274 || two == a_ALEF); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
275 return FALSE; |
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 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
278 /* |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
279 * 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
|
280 * 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
|
281 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
282 int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
283 arabic_combine( |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
284 int one, // first character |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
285 int two) // character just after "one" |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
286 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
287 if (one == a_LAM) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
288 return arabic_maycombine(two); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
289 return FALSE; |
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 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
292 /* |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
293 * 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
|
294 * (alphabet/number/punctuation) |
7 | 295 */ |
296 static int | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
297 A_is_iso(int c) |
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 return find_achar(c) != NULL; |
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 |
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 * 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
|
304 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
305 static int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
306 A_is_ok(int c) |
7 | 307 { |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
308 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
|
309 } |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
310 |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
311 /* |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
312 * 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
|
313 * with some exceptions/exclusions |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
314 */ |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
315 static int |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
316 A_is_valid(int c) |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
317 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
318 return (A_is_ok(c) && c != a_HAMZA); |
7 | 319 } |
320 | |
321 /* | |
322 * Do Arabic shaping on character "c". Returns the shaped character. | |
323 * out: "ccp" points to the first byte of the character to be shaped. | |
324 * in/out: "c1p" points to the first composing char for "c". | |
325 * in: "prev_c" is the previous character (not shaped) | |
326 * in: "prev_c1" is the first composing char for the previous char | |
327 * (not shaped) | |
328 * in: "next_c" is the next character (not shaped). | |
329 */ | |
330 int | |
7817
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
331 arabic_shape( |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
332 int c, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
333 int *ccp, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
334 int *c1p, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
335 int prev_c, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
336 int prev_c1, |
83861277e6a3
commit https://github.com/vim/vim/commit/7454a06e2642d2b37afad1c5e71cec68081ca4ff
Christian Brabandt <cb@256bit.org>
parents:
7799
diff
changeset
|
337 int next_c) |
7 | 338 { |
339 int curr_c; | |
340 int curr_laa; | |
341 int prev_laa; | |
342 | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
343 // Deal only with Arabic characters, pass back all others |
7 | 344 if (!A_is_ok(c)) |
345 return c; | |
346 | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
347 curr_laa = arabic_combine(c, *c1p); |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
348 prev_laa = arabic_combine(prev_c, prev_c1); |
7 | 349 |
350 if (curr_laa) | |
351 { | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
352 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
|
353 curr_c = chg_c_laa2f(*c1p); |
7 | 354 else |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
355 curr_c = chg_c_laa2i(*c1p); |
7 | 356 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
357 // Remove the composing character |
7 | 358 *c1p = 0; |
359 } | |
360 else | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
361 { |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
362 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
|
363 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
|
364 int forward_combine = can_join(c, next_c); |
7 | 365 |
16160
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
366 if (backward_combine) |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
367 { |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
368 if (forward_combine) |
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->medial; |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
370 else |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
371 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
|
372 } |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
373 else |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
374 { |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
375 if (forward_combine) |
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->initial; |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
377 else |
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
378 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
|
379 } |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
380 } |
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
381 |
16160
061cf939f7ce
patch 8.1.1085: compiler warning for possibly uninitialized variable
Bram Moolenaar <Bram@vim.org>
parents:
16066
diff
changeset
|
382 // Character missing from the table means using original character. |
7 | 383 if (curr_c == NUL) |
384 curr_c = c; | |
385 | |
386 if (curr_c != c && ccp != NULL) | |
387 { | |
3549 | 388 char_u buf[MB_MAXBYTES + 1]; |
7 | 389 |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
390 // Update the first byte of the character. |
7 | 391 (*mb_char2bytes)(curr_c, buf); |
392 *ccp = buf[0]; | |
393 } | |
394 | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
395 // Return the shaped character |
7 | 396 return curr_c; |
397 } | |
16066
473fbdb2717c
patch 8.1.1038: Arabic support excludes Farsi
Bram Moolenaar <Bram@vim.org>
parents:
16054
diff
changeset
|
398 #endif // FEAT_ARABIC |