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 $
33 /***************************************************************************
37 ***************************************************************************/
40 * These are the direction values that can appear in render runs and render
47 * These are the flags for cursor motion.
49 #define UCPGBA_CURSOR_VISUAL 0
50 #define UCPGBA_CURSOR_LOGICAL 1
53 * This structure is used to contain runs of text in a particular direction.
55 typedef struct _ucrun_t {
56 struct _ucrun_t *visual_prev; /* Pointer to the previous visual run. */
57 struct _ucrun_t *visual_next; /* Pointer to the next visual run. */
59 struct _ucrun_t *logical_prev; /* Pointer to the previous logical run. */
60 struct _ucrun_t *logical_next; /* Pointer to the next logical run. */
62 int direction; /* Direction of the run. */
64 long cursor; /* Position of "cursor" in the string. */
66 unsigned long *chars; /* List of characters for the run. */
67 unsigned long *positions; /* List of original positions in source. */
69 unsigned long *source; /* The source string. */
70 unsigned long start; /* Beginning offset in the source string. */
71 unsigned long end; /* Ending offset in the source string. */
75 * This represents a string of runs rendered up to a point that is not
78 typedef struct _ucstring_t {
79 int direction; /* Overall direction of the string. */
81 int cursor_motion; /* Logical or visual cursor motion flag. */
83 ucrun_t *cursor; /* The run containing the "cursor." */
85 ucrun_t *logical_first; /* First run in the logical order. */
86 ucrun_t *logical_last; /* Last run in the logical order. */
88 ucrun_t *visual_first; /* First run in the visual order. */
89 ucrun_t *visual_last; /* Last run in the visual order. */
91 unsigned long *source; /* The source string. */
92 unsigned long start; /* The beginning offset in the source. */
93 unsigned long end; /* The ending offset in the source. */
96 /***************************************************************************
100 ***************************************************************************/
103 * This creates and reorders the specified substring using the
104 * "Pretty Good Bidi Algorithm." A default direction is provided for cases
105 * of a string containing no strong direction characters and the default
106 * cursor motion should be provided.
108 LDAP_LUNICODE_F (ucstring_t *)
109 ucstring_create LDAP_P((unsigned long *source,
112 int default_direction,
115 * This releases the string.
117 LDAP_LUNICODE_F (void) ucstring_free LDAP_P((ucstring_t *string));
120 * This changes the cursor motion flag for the string.
122 LDAP_LUNICODE_F (int)
123 ucstring_set_cursor_motion LDAP_P((ucstring_t *string,
127 * This function will move the cursor to the right depending on the
128 * type of cursor motion that was specified for the string.
130 * A 0 is returned if no cursor motion is performed, otherwise a
133 LDAP_LUNICODE_F (int)
134 ucstring_cursor_right LDAP_P((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 LDAP_LUNICODE_F (int)
144 ucstring_cursor_left LDAP_P((ucstring_t *string, int count));
147 * This routine retrieves the direction of the run containing the cursor
148 * and the actual position in the original text string.
150 LDAP_LUNICODE_F (void)
151 ucstring_cursor_info LDAP_P((ucstring_t *string, int *direction,
152 unsigned long *position));
156 #endif /* _h_ucpgba */