Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/chinese/bitchx/files/patch-source__input.c
16461 views
1
--- source/input.c~ Tue Aug 5 20:43:47 2003
2
+++ source/input.c Tue Aug 5 20:43:49 2003
3
@@ -94,6 +94,7 @@
4
#define MIN_CHAR INPUT_BUFFER[MIN_POS]
5
#define PREV_CHAR INPUT_BUFFER[THIS_POS-1]
6
#define NEXT_CHAR INPUT_BUFFER[THIS_POS+1]
7
+#define NTH_CHAR(offset) INPUT_BUFFER[THIS_POS+(offset)]
8
#define ADD_TO_INPUT(x) strmcat(INPUT_BUFFER, (x), INPUT_BUFFER_SIZE);
9
#define INPUT_ONSCREEN current_screen->input_visible
10
#define INPUT_VISIBLE INPUT_BUFFER[INPUT_ONSCREEN]
11
@@ -107,7 +108,11 @@
12
13
14
#define HOLDLAST current_screen->current_window->screen_hold
15
-
16
+
17
+#define MY_ROLE_ENG 0
18
+#define MY_ROLE_HI 1
19
+#define MY_ROLE_LO 2
20
+
21
Display *get_screen_hold(Window *win)
22
{
23
return win->screen_hold;
24
@@ -124,6 +129,24 @@
25
return i;
26
}
27
28
+static int check_my_role (int my_pos)
29
+{
30
+ int i = MIN_POS;
31
+ while (i <= my_pos) {
32
+ if ( is_big5_hi( INPUT_BUFFER[i] ) ) {
33
+ if ( i+1 <= my_pos ) {
34
+ if (is_big5( INPUT_BUFFER[i],INPUT_BUFFER[i+1]) ){
35
+ if (i+1 == my_pos) return MY_ROLE_LO;
36
+ else i+=1;
37
+ }
38
+ }
39
+ else return MY_ROLE_HI;
40
+ }
41
+ i+=1;
42
+ }
43
+ return MY_ROLE_ENG;
44
+}
45
+
46
/* cursor_to_input: move the cursor to the input line, if not there already */
47
extern void BX_cursor_to_input (void)
48
{
49
@@ -480,6 +503,13 @@
50
{
51
if (THIS_CHAR)
52
{
53
+#ifdef WANT_BIG5
54
+ if (NEXT_CHAR && is_big5(THIS_CHAR,NEXT_CHAR) )
55
+ {
56
+ THIS_POS++;
57
+ term_cursor_right();
58
+ }
59
+#endif /* WANT_BIG5 */
60
THIS_POS++;
61
term_cursor_right();
62
}
63
@@ -490,6 +520,13 @@
64
{
65
THIS_POS--;
66
term_cursor_left();
67
+#ifdef WANT_BIG5
68
+ if ( check_my_role(THIS_POS) == MY_ROLE_LO)
69
+ {
70
+ THIS_POS--;
71
+ term_cursor_left();
72
+ }
73
+#endif /* WANT_BIG5 */
74
}
75
}
76
update_input(NO_UPDATE);
77
@@ -584,15 +621,33 @@
78
BUILT_IN_KEYBINDING(input_delete_character)
79
{
80
int pos;
81
+#ifdef WANT_BIG5
82
+ int count=1 ;
83
+ int big5_delete=0 ;
84
+#endif
85
cursor_to_input();
86
in_completion = STATE_NORMAL;
87
if (!THIS_CHAR)
88
return;
89
+#ifdef WANT_BIG5
90
+ if ((THIS_CHAR && NEXT_CHAR) && is_big5(THIS_CHAR, NEXT_CHAR))
91
+ {
92
+ ov_strcpy(&THIS_CHAR, &NTH_CHAR(2));
93
+ big5_delete=1 ;
94
+ }
95
+ else
96
+ ov_strcpy(&THIS_CHAR, &NEXT_CHAR);
97
+#else
98
ov_strcpy(&THIS_CHAR, &NEXT_CHAR);
99
+#endif /* WANT_BIG5 */
100
if (!(termfeatures & TERM_CAN_DELETE))
101
update_input(UPDATE_FROM_CURSOR);
102
else
103
{
104
+#ifdef WANT_BIG5
105
+ if (big5_delete) count = 2 ;
106
+ while ( count -- > 0) {
107
+#endif
108
term_delete(1);
109
pos = INPUT_ONSCREEN + last_input_screen->co - 1;
110
if (pos < strlen(INPUT_BUFFER))
111
@@ -601,6 +656,9 @@
112
term_putchar(INPUT_BUFFER[pos]);
113
term_move_cursor(INPUT_CURSOR, INPUT_LINE);
114
}
115
+#ifdef WANT_BIG5
116
+ } /* while -- > 0 */
117
+#endif /* WANT_BIG5 */
118
update_input(NO_UPDATE);
119
}
120
}
121
@@ -614,6 +672,15 @@
122
char *ptr = NULL;
123
int pos;
124
125
+#ifdef WANT_BIG5
126
+ int count=1 ;
127
+#endif
128
+#ifdef WANT_BIG5
129
+ if ( check_my_role(THIS_POS -1 ) == MY_ROLE_LO)
130
+ count=2 ;
131
+
132
+ while (count-->0) {
133
+#endif
134
ptr = LOCAL_COPY(&THIS_CHAR);
135
strcpy(&(PREV_CHAR), ptr);
136
THIS_POS--;
137
@@ -650,6 +717,9 @@
138
update_input(UPDATE_FROM_CURSOR);
139
#endif
140
}
141
+#ifdef WANT_BIG5
142
+ } /* while (count-- > 0)*/
143
+#endif
144
}
145
if (THIS_POS == MIN_POS)
146
HOLDLAST = NULL;
147
@@ -688,6 +758,10 @@
148
{
149
cursor_to_input();
150
THIS_POS = strlen(INPUT_BUFFER);
151
+#ifdef WANT_BIG5
152
+ if (is_big5(PREV_CHAR,THIS_CHAR))
153
+ THIS_POS-- ;
154
+#endif
155
update_input(UPDATE_JUST_CURSOR);
156
}
157
158
@@ -791,11 +865,17 @@
159
THIS_CHAR = key;
160
NEXT_CHAR = 0;
161
ADD_TO_INPUT(ptr);
162
- if (termfeatures & TERM_CAN_INSERT)
163
- term_insert(key);
164
+ if (termfeatures & TERM_CAN_INSERT) {
165
+ if ( check_my_role(THIS_POS) == MY_ROLE_ENG) term_insert(key);
166
+ else if (check_my_role(THIS_POS) == MY_ROLE_LO) {term_cursor_left(); term_insert(PREV_CHAR); term_insert(key); }
167
+ if (NEXT_CHAR)
168
+ display_flag = UPDATE_FROM_CURSOR;
169
+ }
170
else
171
{
172
- term_putchar(key);
173
+ if ( check_my_role(THIS_POS) == MY_ROLE_ENG) term_putchar(key);
174
+ else if (check_my_role(THIS_POS) == MY_ROLE_LO) {term_cursor_left(); term_putchar(PREV_CHAR); term_putchar(key);}
175
+
176
if (NEXT_CHAR)
177
display_flag = UPDATE_FROM_CURSOR;
178
else
179
@@ -806,7 +886,8 @@
180
{
181
THIS_CHAR = key;
182
NEXT_CHAR = 0;
183
- term_putchar(key);
184
+ if ( check_my_role(THIS_POS) == MY_ROLE_ENG) term_putchar(key);
185
+ else if (check_my_role(THIS_POS) == MY_ROLE_LO) {term_cursor_left(); term_putchar(PREV_CHAR); term_putchar(key);}
186
}
187
}
188
else
189
@@ -814,7 +895,8 @@
190
if (THIS_CHAR == 0)
191
NEXT_CHAR = 0;
192
THIS_CHAR = key;
193
- term_putchar(key);
194
+ if ( check_my_role(THIS_POS) == MY_ROLE_ENG) term_putchar(key);
195
+ else if (check_my_role(THIS_POS) == MY_ROLE_LO) {term_cursor_left(); term_putchar(PREV_CHAR); term_putchar(key);}
196
}
197
198
if (!THIS_POS)
199
200