• R/O
  • SSH
  • HTTPS

bchan: 提交


Commit MetaInfo

修訂600 (tree)
時間2014-02-27 01:38:56
作者ornse01

Log Message

implement string filter for inserting text to editor.

Change Summary

差異

--- bchanf/trunk/src/control/test_texteditor_insertfilter.c (nonexistent)
+++ bchanf/trunk/src/control/test_texteditor_insertfilter.c (revision 600)
@@ -0,0 +1,175 @@
1+/*
2+ * test_texteditor_insertfilter.c
3+ *
4+ * Copyright (c) 2014 project bchan
5+ *
6+ * This software is provided 'as-is', without any express or implied
7+ * warranty. In no event will the authors be held liable for any damages
8+ * arising from the use of this software.
9+ *
10+ * Permission is granted to anyone to use this software for any purpose,
11+ * including commercial applications, and to alter it and redistribute it
12+ * freely, subject to the following restrictions:
13+ *
14+ * 1. The origin of this software must not be misrepresented; you must not
15+ * claim that you wrote the original software. If you use this software
16+ * in a product, an acknowledgment in the product documentation would be
17+ * appreciated but is not required.
18+ *
19+ * 2. Altered source versions must be plainly marked as such, and must not be
20+ * misrepresented as being the original software.
21+ *
22+ * 3. This notice may not be removed or altered from any source
23+ * distribution.
24+ *
25+ */
26+
27+#include "test_control.h"
28+
29+#include "texteditor_insertfilter.h"
30+
31+#include <basic.h>
32+#include <bstdio.h>
33+#include <bstdlib.h>
34+#include <bstring.h>
35+#include <tstring.h>
36+#include <tcode.h>
37+
38+#include <tad/tadlangcode.h>
39+
40+#include <unittest_driver.h>
41+
42+typedef struct {
43+ UB *data;
44+ W len;
45+} test_texteditor_insertfilter_expected;
46+
47+LOCAL UNITTEST_RESULT test_texteditor_insertfilter_common(tadlangcode lang, RATIO w_ratio, UB *data, W len, test_texteditor_insertfilter_expected *expected, W expected_len)
48+{
49+ texteditor_insertfilter_t filter;
50+ texteditor_insertfilter_result result;
51+ Bool cont;
52+ W i;
53+ UNITTEST_RESULT ret = UNITTEST_RESULT_PASS;
54+
55+ texteditor_insertfilter_initialize(&filter, &lang, w_ratio, data, len);
56+
57+ for (i = 0;; i++) {
58+ cont = texteditor_insertfilter_next(&filter, &result);
59+ if (cont == False) {
60+ break;
61+ }
62+ if (i >= expected_len) {
63+ continue;
64+ }
65+ if (result.len != expected[i].len) {
66+ printf("return length failure[%d]: expected = %d, result = %d\n", i, expected[i].len, result.len);
67+ ret = UNITTEST_RESULT_FAIL;
68+ continue;
69+ }
70+ if (memcmp(result.data, expected[i].data, result.len) != 0) {
71+ printf("return data failure[%d]\n", i);
72+ ret = UNITTEST_RESULT_FAIL;
73+ }
74+ }
75+ if (i != expected_len) {
76+ printf("iteration number failure: expected = %d, result = %d\n", expected_len, i);
77+ ret = UNITTEST_RESULT_FAIL;
78+ }
79+
80+ texteditor_insertfilter_finalize(&filter);
81+
82+ return ret;
83+}
84+
85+LOCAL UNITTEST_RESULT test_texteditor_insertfilter_1()
86+{
87+ tadlangcode lang = (tadlangcode){0, 0x21};
88+ RATIO w_ratio = 0x0101;
89+ UB *data = (UB*)(TC[]){TK_A, TK_B, TK_C};
90+ W len = 6;
91+ test_texteditor_insertfilter_expected expected[] = {
92+ { (UB*)(TC[]){TK_A}, 2 },
93+ { (UB*)(TC[]){TK_B}, 2 },
94+ { (UB*)(TC[]){TK_C}, 2 },
95+ };
96+ W expected_len = 3;
97+ return test_texteditor_insertfilter_common(lang, w_ratio, data, len, expected, expected_len);
98+}
99+
100+LOCAL UNITTEST_RESULT test_texteditor_insertfilter_2()
101+{
102+ tadlangcode lang = (tadlangcode){0, 0x22};
103+ RATIO w_ratio = 0x0101;
104+ UB *data = (UB*)(TC[]){TK_A, TK_B, TK_C};
105+ W len = 6;
106+ test_texteditor_insertfilter_expected expected[] = {
107+ { (UB*)(TC[]){0xFE21}, 2 },
108+ { (UB*)(TC[]){TK_A}, 2 },
109+ { (UB*)(TC[]){TK_B}, 2 },
110+ { (UB*)(TC[]){TK_C}, 2 },
111+ { (UB*)(TC[]){0xFE22}, 2 },
112+ };
113+ W expected_len = 5;
114+ return test_texteditor_insertfilter_common(lang, w_ratio, data, len, expected, expected_len);
115+}
116+
117+LOCAL UNITTEST_RESULT test_texteditor_insertfilter_3()
118+{
119+ tadlangcode lang = (tadlangcode){0, 0x21};
120+ RATIO w_ratio = 0x0102;
121+ UB *data = (UB*)(TC[]){TK_A, TK_B, TK_C};
122+ W len = 6;
123+ test_texteditor_insertfilter_expected expected[] = {
124+ { (UB*)(TC[]){ 0xFFA2, 0x0006, 0x0300, 0x0101, 0x0101 }, 10 },
125+ { (UB*)(TC[]){TK_A}, 2 },
126+ { (UB*)(TC[]){TK_B}, 2 },
127+ { (UB*)(TC[]){TK_C}, 2 },
128+ { (UB*)(TC[]){ 0xFFA2, 0x0006, 0x0300, 0x0101, 0x0102 }, 10 },
129+ };
130+ W expected_len = 5;
131+ return test_texteditor_insertfilter_common(lang, w_ratio, data, len, expected, expected_len);
132+}
133+
134+LOCAL UNITTEST_RESULT test_texteditor_insertfilter_4()
135+{
136+ tadlangcode lang = (tadlangcode){0, 0x21};
137+ RATIO w_ratio = 0x0101;
138+ UB *data = (UB*)(TC[]){TK_A, TK_B, 0xFE22, TK_C};
139+ W len = 8;
140+ test_texteditor_insertfilter_expected expected[] = {
141+ { (UB*)(TC[]){TK_A}, 2 },
142+ { (UB*)(TC[]){TK_B}, 2 },
143+ { (UB*)(TC[]){0xFE22}, 2 },
144+ { (UB*)(TC[]){TK_C}, 2 },
145+ { (UB*)(TC[]){0xFE21}, 2 },
146+ };
147+ W expected_len = 5;
148+ return test_texteditor_insertfilter_common(lang, w_ratio, data, len, expected, expected_len);
149+}
150+
151+LOCAL UNITTEST_RESULT test_texteditor_insertfilter_5()
152+{
153+ tadlangcode lang = (tadlangcode){0, 0x21};
154+ RATIO w_ratio = 0x0101;
155+ UB *data = (UB*)(TC[]){TK_A, TK_B, 0xFFA2, 0x0006, 0x0300, 0x0101, 0x0102, TK_C};
156+ W len = 16;
157+ test_texteditor_insertfilter_expected expected[] = {
158+ { (UB*)(TC[]){TK_A}, 2 },
159+ { (UB*)(TC[]){TK_B}, 2 },
160+ { (UB*)(TC[]){ 0xFFA2, 0x0006, 0x0300, 0x0101, 0x0102 }, 10 },
161+ { (UB*)(TC[]){TK_C}, 2 },
162+ { (UB*)(TC[]){ 0xFFA2, 0x0006, 0x0300, 0x0101, 0x0101 }, 10 },
163+ };
164+ W expected_len = 5;
165+ return test_texteditor_insertfilter_common(lang, w_ratio, data, len, expected, expected_len);
166+}
167+
168+EXPORT VOID test_texteditor_insertfilter_main(unittest_driver_t *driver)
169+{
170+ UNITTEST_DRIVER_REGIST(driver, test_texteditor_insertfilter_1);
171+ UNITTEST_DRIVER_REGIST(driver, test_texteditor_insertfilter_2);
172+ UNITTEST_DRIVER_REGIST(driver, test_texteditor_insertfilter_3);
173+ UNITTEST_DRIVER_REGIST(driver, test_texteditor_insertfilter_4);
174+ UNITTEST_DRIVER_REGIST(driver, test_texteditor_insertfilter_5);
175+}
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
--- bchanf/trunk/src/control/texteditor_insertfilter.c (nonexistent)
+++ bchanf/trunk/src/control/texteditor_insertfilter.c (revision 600)
@@ -0,0 +1,414 @@
1+/*
2+ * texteditor_insertfilter.c
3+ *
4+ * Copyright (c) 2014 project bchan
5+ *
6+ * This software is provided 'as-is', without any express or implied
7+ * warranty. In no event will the authors be held liable for any damages
8+ * arising from the use of this software.
9+ *
10+ * Permission is granted to anyone to use this software for any purpose,
11+ * including commercial applications, and to alter it and redistribute it
12+ * freely, subject to the following restrictions:
13+ *
14+ * 1. The origin of this software must not be misrepresented; you must not
15+ * claim that you wrote the original software. If you use this software
16+ * in a product, an acknowledgment in the product documentation would be
17+ * appreciated but is not required.
18+ *
19+ * 2. Altered source versions must be plainly marked as such, and must not be
20+ * misrepresented as being the original software.
21+ *
22+ * 3. This notice may not be removed or altered from any source
23+ * distribution.
24+ *
25+ */
26+
27+#include "texteditor_insertfilter.h"
28+
29+#include <bstdio.h>
30+
31+#include <tad/taditerator.h>
32+#include <tad/tadstack.h>
33+
34+#ifdef BCHAN_CONFIG_DEBUG
35+# define DP(arg) printf arg
36+# define DP_ER(msg, err) printf("%s (%d/%x)\n", msg, err>>16, err)
37+#else
38+# define DP(arg) /**/
39+# define DP_ER(msg, err) /**/
40+#endif
41+
42+#if 0
43+#define DP_STATE(s) printf("%s\n", s)
44+#else
45+#define DP_STATE(s) /**/
46+#endif
47+
48+LOCAL Bool texteditor_insertfilter_stackfilter(texteditor_insertfilter_t *filter, taditerator_result *result)
49+{
50+ W nestlevel;
51+ TADSTACK_DATATYPE type;
52+
53+ for (;;) {
54+ taditerator_next2(&filter->iterator, result);
55+ if (result->type == TADITERATOR_RESULTTYPE_END) {
56+ break;
57+ }
58+
59+ if (result->type == TADITERATOR_RESULTTYPE_CHARCTOR) {
60+ tadstack_inputcharactor(&filter->tadstack, result->segment);
61+ } else if (result->type == TADITERATOR_RESULTTYPE_SEGMENT) {
62+ tadstack_inputvsegment(&filter->tadstack, result->segment, result->data, result->segsize);
63+ }
64+
65+ nestlevel = tadstack_nestlevel(&filter->tadstack);
66+ if (nestlevel > 0) {
67+ continue;
68+ }
69+ type = tadstack_currentdata(&filter->tadstack);
70+ if (type != TADSTACK_DATATYPE_TEXT) {
71+ continue;
72+ }
73+
74+ return True;
75+ }
76+
77+ return False;
78+}
79+
80+struct texteditor_insertfilter_innerresult_ {
81+ enum {
82+ INNERRESULT_VARIABLE,
83+ INNERRESULT_STRING,
84+ INNERRESULT_LANGCODE,
85+ } type;
86+ UB *data;
87+ W len;
88+ struct {
89+ UB segid;
90+ UW len;
91+ UB *data;
92+ } variable;
93+};
94+typedef struct texteditor_insertfilter_innerresult_ texteditor_insertfilter_innerresult;
95+
96+LOCAL Bool texteditor_insertfilter_langcode(texteditor_insertfilter_t *filter, texteditor_insertfilter_innerresult *result)
97+{
98+ taditerator_result iter_result;
99+ Bool reading_lang = False, cont;
100+ TC *lang_start = NULL;
101+
102+ for (;;) {
103+ cont = texteditor_insertfilter_stackfilter(filter, &iter_result);
104+ if (cont == False) {
105+ break;
106+ }
107+
108+ if (reading_lang != False) {
109+ if (iter_result.type != TADITERATOR_RESULTTYPE_CHARCTOR) {
110+ /* format error */
111+ break;
112+ }
113+ if (lang_start == NULL) {
114+ break;
115+ }
116+ if (iter_result.segment == 0xFEFE) {
117+ continue;
118+ }
119+ result->type = INNERRESULT_LANGCODE;
120+ result->data = (UB*)lang_start;
121+ result->len = (iter_result.pos - lang_start + 1) * sizeof(TC);
122+ TCtotadlangcode((TC*)result->data, result->len / sizeof(TC), &filter->current.lang);
123+ reading_lang = False;
124+ lang_start = NULL;
125+ }
126+
127+ if (iter_result.type == TADITERATOR_RESULTTYPE_CHARCTOR) {
128+ if ((iter_result.segment & 0xFF00) == 0xFE00) {
129+ if (iter_result.segment == 0xFEFE) {
130+ reading_lang = True;
131+ lang_start = iter_result.pos;
132+ } else {
133+ result->type = INNERRESULT_LANGCODE;
134+ result->data = (UB*)iter_result.pos;
135+ result->len = sizeof(TC);
136+ TCtotadlangcode((TC*)result->data, result->len / sizeof(TC), &filter->current.lang);
137+ return True;
138+ }
139+ } else {
140+ result->type = INNERRESULT_STRING;
141+ result->data = (UB*)iter_result.pos;
142+ result->len = sizeof(TC);
143+ return True;
144+ }
145+ } else if (iter_result.type == TADITERATOR_RESULTTYPE_SEGMENT) {
146+ result->type = INNERRESULT_VARIABLE;
147+ result->data = (UB*)iter_result.pos;
148+ if (iter_result.vseg.l->len == 0xFFFF) {
149+ result->len = 2 + 2 + 4 + iter_result.vseg.l->llen;
150+ } else {
151+ result->len = 2 + 2 + iter_result.vseg.l->len;
152+ }
153+ result->variable.segid = iter_result.segment & 0xFF;
154+ result->variable.len = iter_result.segsize;
155+ result->variable.data = iter_result.data;
156+ return True;
157+ }
158+ }
159+
160+ return False;
161+}
162+
163+LOCAL Bool texteditor_insertfilter_chratio(texteditor_insertfilter_t *filter, texteditor_insertfilter_innerresult *result)
164+{
165+ Bool cont;
166+ UB subid;
167+
168+ for (;;) {
169+ cont = texteditor_insertfilter_langcode(filter, result);
170+ if (cont == False) {
171+ break;
172+ }
173+
174+ if (result->type != INNERRESULT_VARIABLE) {
175+ return True;
176+ }
177+
178+ if (result->variable.segid != TS_TFONT) {
179+ continue;
180+ }
181+ if (result->variable.len < 6) {
182+ continue;
183+ }
184+ subid = *(UH*)result->variable.data >> 8;
185+ if (subid != 3) {
186+ continue;
187+ }
188+
189+ filter->current.w_ratio = *((UH*)result->variable.data + 5);
190+
191+ return True;
192+ }
193+
194+ return False;
195+}
196+
197+/* */
198+
199+LOCAL Bool texteditor_insertfilter_w_ratio_isZenkaku(RATIO w_ratio)
200+{
201+ UB a,b;
202+
203+ a = w_ratio >> 8;
204+ b = w_ratio & 0xFF;
205+
206+ if (b == 0) {
207+ return True;
208+ }
209+ if (a == b) {
210+ return True;
211+ }
212+ return False;
213+}
214+
215+LOCAL Bool texteditor_insertfilter_w_ratio_isSystemScript(tadlangcode *lang)
216+{
217+ return tadlangcodecmpTC((TC[]){0xFE21}, 1, lang);
218+}
219+
220+/* */
221+
222+LOCAL TC texteditor_insertfilter_systemlangcode[] = { 0xFE21 };
223+#define TEXTEDITOR_INSERTFILTER_SYSTEMLANGCODE_LENGTH 1
224+
225+LOCAL TC textediter_insertfilter_zenkakufusen[] = { 0xFFA2, 0x0006, 0x0300, 0x0101, 0x0101 };
226+LOCAL TC textediter_insertfilter_hankakufusen[] = { 0xFFA2, 0x0006, 0x0300, 0x0101, 0x0102 };
227+#define TEXTEDITOR_INSERTFILTER_FUSEN_LENGTH 5
228+
229+LOCAL VOID texteditor_insertfilter_setresult_systemlangcode(texteditor_insertfilter_result *result)
230+{
231+ result->data = (UB*)texteditor_insertfilter_systemlangcode;
232+ result->len = TEXTEDITOR_INSERTFILTER_SYSTEMLANGCODE_LENGTH * sizeof(TC);
233+}
234+
235+LOCAL VOID texteditor_insertfilter_setresult_firstlangcode(texteditor_insertfilter_t *filter, texteditor_insertfilter_result *result)
236+{
237+ result->len = tadlangcodetoTC(&filter->first.lang, filter->buffer, TEXTEDITOR_INSERTFILTER_TEXTBUFFER_SIZE) * sizeof(TC);
238+ result->data = (UB*)filter->buffer;
239+}
240+
241+LOCAL VOID texteditor_insertfilter_setresult_zenkakufusen(texteditor_insertfilter_result *result)
242+{
243+ result->data = (UB*)textediter_insertfilter_zenkakufusen;
244+ result->len = TEXTEDITOR_INSERTFILTER_FUSEN_LENGTH * sizeof(TC);
245+}
246+
247+LOCAL VOID texteditor_insertfilter_setresult_hankakufusen(texteditor_insertfilter_result *result)
248+{
249+ result->data = (UB*)textediter_insertfilter_hankakufusen;
250+ result->len = TEXTEDITOR_INSERTFILTER_FUSEN_LENGTH * sizeof(TC);
251+}
252+
253+/* */
254+
255+LOCAL Bool texteditor_insertfilter_next_terminate(texteditor_insertfilter_t *filter, texteditor_insertfilter_result *result)
256+{
257+ Bool ok, zen;
258+
259+ if (filter->first.w_ratio != filter->current.w_ratio) {
260+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_LAST_LANGCODE;
261+ zen = texteditor_insertfilter_w_ratio_isZenkaku(filter->first.w_ratio);
262+ if (zen == False) {
263+ texteditor_insertfilter_setresult_hankakufusen(result);
264+ } else {
265+ texteditor_insertfilter_setresult_zenkakufusen(result);
266+ }
267+ return True;
268+ }
269+ ok = tadlangcodecmp(&filter->first.lang, &filter->current.lang);
270+ if (ok == False) {
271+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_LAST;
272+ texteditor_insertfilter_setresult_firstlangcode(filter, result);
273+ return True;
274+ }
275+
276+ return False;
277+}
278+
279+LOCAL Bool texteditor_insertfilter_next_state_start(texteditor_insertfilter_t *filter, texteditor_insertfilter_result *result)
280+{
281+ texteditor_insertfilter_innerresult inner_result;
282+ Bool cont, ok;
283+
284+ ok = texteditor_insertfilter_w_ratio_isZenkaku(filter->first.w_ratio);
285+ if (ok == False) {
286+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_FIRST_LANGCODE;
287+ texteditor_insertfilter_setresult_zenkakufusen(result);
288+ return True;
289+ }
290+ ok = texteditor_insertfilter_w_ratio_isSystemScript(&filter->first.lang);
291+ if (ok == False) {
292+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_RUNNING;
293+ texteditor_insertfilter_setresult_systemlangcode(result);
294+ return True;
295+ }
296+
297+ cont = texteditor_insertfilter_chratio(filter, &inner_result);
298+ if (cont == False) {
299+ return texteditor_insertfilter_next_terminate(filter, result);
300+ }
301+
302+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_RUNNING;
303+ result->data = inner_result.data;
304+ result->len = inner_result.len;
305+
306+ return True;
307+}
308+
309+LOCAL Bool texteditor_insertfilter_next_state_langcode(texteditor_insertfilter_t *filter, texteditor_insertfilter_result *result)
310+{
311+ texteditor_insertfilter_innerresult inner_result;
312+ Bool cont, ok;
313+
314+ ok = texteditor_insertfilter_w_ratio_isSystemScript(&filter->first.lang);
315+ if (ok == False) {
316+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_RUNNING;
317+ texteditor_insertfilter_setresult_systemlangcode(result);
318+ return True;
319+ }
320+
321+ cont = texteditor_insertfilter_chratio(filter, &inner_result);
322+ if (cont == False) {
323+ return texteditor_insertfilter_next_terminate(filter, result);
324+ }
325+
326+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_RUNNING;
327+ result->data = inner_result.data;
328+ result->len = inner_result.len;
329+
330+ return True;
331+}
332+
333+LOCAL Bool texteditor_insertfilter_next_state_running(texteditor_insertfilter_t *filter, texteditor_insertfilter_result *result)
334+{
335+ texteditor_insertfilter_innerresult inner_result;
336+ Bool cont;
337+
338+ cont = texteditor_insertfilter_chratio(filter, &inner_result);
339+ if (cont == False) {
340+ return texteditor_insertfilter_next_terminate(filter, result);
341+ }
342+
343+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_RUNNING;
344+ result->data = inner_result.data;
345+ result->len = inner_result.len;
346+
347+ return True;
348+}
349+
350+LOCAL Bool texteditor_insertfilter_next_state_last_langcode(texteditor_insertfilter_t *filter, texteditor_insertfilter_result *result)
351+{
352+ Bool ok;
353+
354+ ok = tadlangcodecmp(&filter->first.lang, &filter->current.lang);
355+ if (ok == False) {
356+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_LAST;
357+ texteditor_insertfilter_setresult_firstlangcode(filter, result);
358+ return True;
359+ }
360+
361+ return False;
362+}
363+
364+LOCAL Bool texteditor_insertfilter_next_state_last(texteditor_insertfilter_t *filter, texteditor_insertfilter_result *result)
365+{
366+ return False;
367+}
368+
369+EXPORT Bool texteditor_insertfilter_next(texteditor_insertfilter_t *filter, texteditor_insertfilter_result *result)
370+{
371+ Bool cont = False;
372+
373+ switch (filter->state) {
374+ case TEXTEDITOR_INSTERTFILTER_STATE_START:
375+ DP_STATE("STATE_START");
376+ cont = texteditor_insertfilter_next_state_start(filter, result);
377+ break;
378+ case TEXTEDITOR_INSTERTFILTER_STATE_FIRST_LANGCODE:
379+ DP_STATE("STATE_FIRST_LANGCODE");
380+ cont = texteditor_insertfilter_next_state_langcode(filter, result);
381+ break;
382+ case TEXTEDITOR_INSTERTFILTER_STATE_RUNNING:
383+ DP_STATE("STATE_RUNNING");
384+ cont = texteditor_insertfilter_next_state_running(filter, result);
385+ break;
386+ case TEXTEDITOR_INSTERTFILTER_STATE_LAST_LANGCODE:
387+ DP_STATE("STATE_LAST_LANGCODE");
388+ cont = texteditor_insertfilter_next_state_last_langcode(filter, result);
389+ break;
390+ case TEXTEDITOR_INSTERTFILTER_STATE_LAST:
391+ DP_STATE("STATE_LAST");
392+ cont = texteditor_insertfilter_next_state_last(filter, result);
393+ break;
394+ }
395+
396+ return cont;
397+}
398+
399+EXPORT VOID texteditor_insertfilter_initialize(texteditor_insertfilter_t *filter, tadlangcode *lang, RATIO w_ratio, UB *data, W len)
400+{
401+ filter->state = TEXTEDITOR_INSTERTFILTER_STATE_START;
402+ filter->first.lang = *lang;
403+ filter->first.w_ratio = w_ratio;
404+ filter->current.lang = (tadlangcode){0, 0x21};
405+ filter->current.w_ratio = 0x0101;
406+ tadstack_initialize(&filter->tadstack);
407+ taditerator_initialize(&filter->iterator, (TC*)data, len / sizeof(TC));
408+}
409+
410+EXPORT VOID texteditor_insertfilter_finalize(texteditor_insertfilter_t *filter)
411+{
412+ taditerator_finalize(&filter->iterator);
413+ tadstack_finalize(&filter->tadstack);
414+}
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
--- bchanf/trunk/src/control/texteditor_insertfilter.h (nonexistent)
+++ bchanf/trunk/src/control/texteditor_insertfilter.h (revision 600)
@@ -0,0 +1,76 @@
1+/*
2+ * texteditor_insertfilter.h
3+ *
4+ * Copyright (c) 2014 project bchan
5+ *
6+ * This software is provided 'as-is', without any express or implied
7+ * warranty. In no event will the authors be held liable for any damages
8+ * arising from the use of this software.
9+ *
10+ * Permission is granted to anyone to use this software for any purpose,
11+ * including commercial applications, and to alter it and redistribute it
12+ * freely, subject to the following restrictions:
13+ *
14+ * 1. The origin of this software must not be misrepresented; you must not
15+ * claim that you wrote the original software. If you use this software
16+ * in a product, an acknowledgment in the product documentation would be
17+ * appreciated but is not required.
18+ *
19+ * 2. Altered source versions must be plainly marked as such, and must not be
20+ * misrepresented as being the original software.
21+ *
22+ * 3. This notice may not be removed or altered from any source
23+ * distribution.
24+ *
25+ */
26+
27+#include <basic.h>
28+
29+#include <tad/tadstack.h>
30+#include <tad/taditerator.h>
31+#include <tad/tadlangcode.h>
32+
33+#ifndef __TEXTEDITOR_INSERTFILTER_H__
34+#define __TEXTEDITOR_INSERTFILTER_H__
35+
36+#define TEXTEDITOR_INSERTFILTER_TEXTBUFFER_SIZE 10
37+
38+/* Functionality name: texteditor */
39+/* Detail name: insertfilter */
40+struct texteditor_insertfilter_t_ {
41+ enum {
42+ TEXTEDITOR_INSTERTFILTER_STATE_START,
43+ TEXTEDITOR_INSTERTFILTER_STATE_FIRST_LANGCODE,
44+ TEXTEDITOR_INSTERTFILTER_STATE_RUNNING,
45+ TEXTEDITOR_INSTERTFILTER_STATE_LAST_LANGCODE,
46+ TEXTEDITOR_INSTERTFILTER_STATE_LAST,
47+ } state;
48+ struct {
49+ tadlangcode lang;
50+ RATIO w_ratio;
51+ } first;
52+ struct {
53+ tadlangcode lang;
54+ RATIO w_ratio;
55+ } current;
56+ tadstack_t tadstack;
57+ taditerator_t iterator;
58+ TC buffer[TEXTEDITOR_INSERTFILTER_TEXTBUFFER_SIZE];
59+};
60+typedef struct texteditor_insertfilter_t_ texteditor_insertfilter_t;
61+
62+/* Functionality name: texteditor */
63+/* Detail name: insertfilter */
64+/* Data structure identifier: result */
65+struct texteditor_insertfilter_result_ {
66+ UB *data;
67+ W len;
68+};
69+typedef struct texteditor_insertfilter_result_ texteditor_insertfilter_result;
70+
71+IMPORT VOID texteditor_insertfilter_initialize(texteditor_insertfilter_t *filter, tadlangcode *lang, RATIO w_ratio, UB *data, W len);
72+IMPORT VOID texteditor_insertfilter_finalize(texteditor_insertfilter_t *filter);
73+
74+IMPORT Bool texteditor_insertfilter_next(texteditor_insertfilter_t *filter, texteditor_insertfilter_result *result);
75+
76+#endif
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
Show on old repository browser