4 #include "recognize_extra.h"
6 static gint eval_filter(GList *s, gunichar2 arg)
8 GdkPoint *p0 = (GdkPoint*)g_list_first(s)->data;
9 GdkPoint *pn = (GdkPoint*)g_list_last(s)->data;
21 return ((p0->x + pn->x) >> 1);
23 return ((p0->y + pn->y) >> 1);
26 int dx = p0->x - pn->x;
27 int dy = p0->y - pn->y;
28 return abs(dx) + abs(dy);
34 static void get_sz(GList *strokes, gint *sz)
36 int xmin, ymin, xmax, ymax;
37 GdkPoint *pt = (GdkPoint*)(((GList*)strokes->data)->data);
41 for(s = g_list_first(strokes); s; s = g_list_next(s))
43 for(s1 = (GList*)s->data; s1; s1 = g_list_next(s1))
45 pt = (GdkPoint*)s1->data;
56 gint w = xmax - xmin, h = ymax - ymin;
57 *sz = (w > h) ? w : h;
60 gint pass_extra_filters(GList *strokes, gunichar2 *entry)
62 gunichar2 arg[2], fn, c;
66 gboolean must = False;
70 stroke[0] = stroke[1] = 0;
72 /* Simple parser for Filter strings. assumes a1-b1 structure,
73 * where a and b can be any single alphabetic cmd char, the
74 * numbers can be multiple digit, and b1 can optionally be
75 * followed by '!' to insist on the filter passing. There can
76 * be multiple filters but they have to be separated by '!' or
77 * space(s). The filter string is terminated by a null byte
78 * or an 8-bit char, the beginning of the next entry.
79 * Leading spaces and trailing spaces are ignored. -rwells, 970722.
82 for(c = *entry; True; entry++, c = *entry )
106 stroke[index] = stroke[index] * 10 + (c - '0');
121 if(index == 1) // second argument
123 gint n = g_list_length(strokes);
124 if((n > stroke[0]) || (n > stroke[1]))
126 val[0] = eval_filter(g_list_nth_data(strokes, stroke[0] - 1), arg[0]);
127 val[1] = eval_filter(g_list_nth_data(strokes, stroke[1] - 1), arg[1]);
129 get_sz(strokes, &sz);
132 sc = ((val[0] - val[1]) < 0) ? 1 : -1;
138 sc = ((val[0] - val[1]) > sz/4) ? 1 : -1;
144 sc = (abs(val[1] - val[0]) > sz/2) ? 1 : -1;
154 stroke[0] = stroke[1] = 0;
157 if( c == '\r' || c == '\0' )