2 * Copyright 1999 Computing Research Labs, New Mexico State University
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
20 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * $Id: ucpgba.h,v 1.4 1999/11/19 15:24:30 mleisher Exp $
36 /***************************************************************************
40 ***************************************************************************/
43 * These are the direction values that can appear in render runs and render
50 * These are the flags for cursor motion.
52 #define UCPGBA_CURSOR_VISUAL 0
53 #define UCPGBA_CURSOR_LOGICAL 1
56 * This structure is used to contain runs of text in a particular direction.
58 typedef struct _ucrun_t {
59 struct _ucrun_t *visual_prev; /* Pointer to the previous visual run. */
60 struct _ucrun_t *visual_next; /* Pointer to the next visual run. */
62 struct _ucrun_t *logical_prev; /* Pointer to the previous logical run. */
63 struct _ucrun_t *logical_next; /* Pointer to the next logical run. */
65 int direction; /* Direction of the run. */
67 long cursor; /* Position of "cursor" in the string. */
69 unsigned long *chars; /* List of characters for the run. */
70 unsigned long *positions; /* List of original positions in source. */
72 unsigned long *source; /* The source string. */
73 unsigned long start; /* Beginning offset in the source string. */
74 unsigned long end; /* Ending offset in the source string. */
78 * This represents a string of runs rendered up to a point that is not
81 typedef struct _ucstring_t {
82 int direction; /* Overall direction of the string. */
84 int cursor_motion; /* Logical or visual cursor motion flag. */
86 ucrun_t *cursor; /* The run containing the "cursor." */
88 ucrun_t *logical_first; /* First run in the logical order. */
89 ucrun_t *logical_last; /* Last run in the logical order. */
91 ucrun_t *visual_first; /* First run in the visual order. */
92 ucrun_t *visual_last; /* Last run in the visual order. */
94 unsigned long *source; /* The source string. */
95 unsigned long start; /* The beginning offset in the source. */
96 unsigned long end; /* The ending offset in the source. */
99 /***************************************************************************
103 ***************************************************************************/
106 * This creates and reorders the specified substring using the
107 * "Pretty Good Bidi Algorithm." A default direction is provided for cases
108 * of a string containing no strong direction characters and the default
109 * cursor motion should be provided.
111 extern ucstring_t *ucstring_create __((unsigned long *source,
114 int default_direction,
117 * This releases the string.
119 extern void ucstring_free __((ucstring_t *string));
122 * This changes the cursor motion flag for the string.
124 extern int ucstring_set_cursor_motion __((ucstring_t *string,
128 * This function will move the cursor to the right depending on the
129 * type of cursor motion that was specified for the string.
131 * A 0 is returned if no cursor motion is performed, otherwise a
134 extern int ucstring_cursor_right __((ucstring_t *string, int count));
137 * This function will move the cursor to the left depending on the
138 * type of cursor motion that was specified for the string.
140 * A 0 is returned if no cursor motion is performed, otherwise a
143 extern int ucstring_cursor_left __((ucstring_t *string, int count));
146 * This routine retrieves the direction of the run containing the cursor
147 * and the actual position in the original text string.
149 extern void ucstring_cursor_info __((ucstring_t *string, int *direction,
150 unsigned long *position));
156 #endif /* _h_ucpgba */