]> git.sur5r.net Git - openldap/blob - libraries/liblunicode/ucdata/ucpgba.h
Error in exclusion set macros
[openldap] / libraries / liblunicode / ucdata / ucpgba.h
1 /*
2  * Copyright 1999 Computing Research Labs, New Mexico State University
3  *
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:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
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.
21  */
22 #ifndef _h_ucpgba
23 #define _h_ucpgba
24
25 #include "portable.h"
26
27 /*
28  * $Id: ucpgba.h,v 1.4 1999/11/19 15:24:30 mleisher Exp $
29  */
30
31 LDAP_BEGIN_DECL
32
33 /***************************************************************************
34  *
35  * Macros and types.
36  *
37  ***************************************************************************/
38
39 /*
40  * These are the direction values that can appear in render runs and render
41  * strings.
42  */
43 #define UCPGBA_LTR 0
44 #define UCPGBA_RTL 1
45
46 /*
47  * These are the flags for cursor motion.
48  */
49 #define UCPGBA_CURSOR_VISUAL  0
50 #define UCPGBA_CURSOR_LOGICAL 1
51
52 /*
53  * This structure is used to contain runs of text in a particular direction.
54  */
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.        */
58
59     struct _ucrun_t *logical_prev; /* Pointer to the previous logical run.   */
60     struct _ucrun_t *logical_next; /* Pointer to the next logical run.       */
61
62     int direction;                 /* Direction of the run.                  */
63
64     long cursor;                   /* Position of "cursor" in the string.    */
65
66     unsigned long *chars;          /* List of characters for the run.        */
67     unsigned long *positions;      /* List of original positions in source.  */
68
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.    */
72 } ucrun_t;
73
74 /*
75  * This represents a string of runs rendered up to a point that is not
76  * platform specific.
77  */
78 typedef struct _ucstring_t {
79     int direction;                /* Overall direction of the string.       */
80
81     int cursor_motion;            /* Logical or visual cursor motion flag.  */
82
83     ucrun_t *cursor;              /* The run containing the "cursor."       */
84
85     ucrun_t *logical_first;       /* First run in the logical order.        */
86     ucrun_t *logical_last;        /* Last run in the logical order.         */
87
88     ucrun_t *visual_first;        /* First run in the visual order.         */
89     ucrun_t *visual_last;         /* Last run in the visual order.          */
90
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.       */
94 } ucstring_t;
95
96 /***************************************************************************
97  *
98  * API
99  *
100  ***************************************************************************/
101
102 /*
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.
107  */
108 LDAP_LUNICODE_F (ucstring_t *)
109 ucstring_create LDAP_P((unsigned long *source,
110                         unsigned long start,
111                         unsigned long end,
112                         int default_direction,
113                         int cursor_motion));
114 /*
115  * This releases the string.
116  */
117 LDAP_LUNICODE_F (void) ucstring_free LDAP_P((ucstring_t *string));
118
119 /*
120  * This changes the cursor motion flag for the string.
121  */
122 LDAP_LUNICODE_F (int)
123 ucstring_set_cursor_motion LDAP_P((ucstring_t *string,
124                                    int cursor_motion));
125
126 /*
127  * This function will move the cursor to the right depending on the
128  * type of cursor motion that was specified for the string.
129  *
130  * A 0 is returned if no cursor motion is performed, otherwise a
131  * 1 is returned.
132  */
133 LDAP_LUNICODE_F (int)
134 ucstring_cursor_right LDAP_P((ucstring_t *string, int count));
135
136 /*
137  * This function will move the cursor to the left depending on the
138  * type of cursor motion that was specified for the string.
139  *
140  * A 0 is returned if no cursor motion is performed, otherwise a
141  * 1 is returned.
142  */
143 LDAP_LUNICODE_F (int)
144 ucstring_cursor_left LDAP_P((ucstring_t *string, int count));
145
146 /*
147  * This routine retrieves the direction of the run containing the cursor
148  * and the actual position in the original text string.
149  */
150 LDAP_LUNICODE_F (void)
151 ucstring_cursor_info LDAP_P((ucstring_t *string, int *direction,
152                              unsigned long *position));
153
154 LDAP_END_DECL
155
156 #endif /* _h_ucpgba */