Back to index

openldap  2.4.31
ucpgba.h
Go to the documentation of this file.
00001 /* $OpenLDAP$ */
00002 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00003  *
00004  * Copyright 1998-2012 The OpenLDAP Foundation.
00005  * All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted only as authorized by the OpenLDAP
00009  * Public License.
00010  *
00011  * A copy of this license is available in file LICENSE in the
00012  * top-level directory of the distribution or, alternatively, at
00013  * <http://www.OpenLDAP.org/license.html>.
00014  */
00015 /* Copyright 1999 Computing Research Labs, New Mexico State University
00016  *
00017  * Permission is hereby granted, free of charge, to any person obtaining a
00018  * copy of this software and associated documentation files (the "Software"),
00019  * to deal in the Software without restriction, including without limitation
00020  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00021  * and/or sell copies of the Software, and to permit persons to whom the
00022  * Software is furnished to do so, subject to the following conditions:
00023  *
00024  * The above copyright notice and this permission notice shall be included in
00025  * all copies or substantial portions of the Software.
00026  *
00027  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00028  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00029  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00030  * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
00031  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
00032  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
00033  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00034  */
00035 /* $Id: ucpgba.h,v 1.4 1999/11/19 15:24:30 mleisher Exp $ */
00036 
00037 #ifndef _h_ucpgba
00038 #define _h_ucpgba
00039 
00040 #include "portable.h"
00041 
00042 LDAP_BEGIN_DECL
00043 
00044 /***************************************************************************
00045  *
00046  * Macros and types.
00047  *
00048  ***************************************************************************/
00049 
00050 /*
00051  * These are the direction values that can appear in render runs and render
00052  * strings.
00053  */
00054 #define UCPGBA_LTR 0
00055 #define UCPGBA_RTL 1
00056 
00057 /*
00058  * These are the flags for cursor motion.
00059  */
00060 #define UCPGBA_CURSOR_VISUAL  0
00061 #define UCPGBA_CURSOR_LOGICAL 1
00062 
00063 /*
00064  * This structure is used to contain runs of text in a particular direction.
00065  */
00066 typedef struct _ucrun_t {
00067     struct _ucrun_t *visual_prev;  /* Pointer to the previous visual run.    */
00068     struct _ucrun_t *visual_next;  /* Pointer to the next visual run.        */
00069 
00070     struct _ucrun_t *logical_prev; /* Pointer to the previous logical run.   */
00071     struct _ucrun_t *logical_next; /* Pointer to the next logical run.       */
00072 
00073     int direction;                 /* Direction of the run.                  */
00074 
00075     long cursor;                   /* Position of "cursor" in the string.    */
00076 
00077     unsigned long *chars;          /* List of characters for the run.        */
00078     unsigned long *positions;      /* List of original positions in source.  */
00079 
00080     unsigned long *source;         /* The source string.                     */
00081     unsigned long start;           /* Beginning offset in the source string. */
00082     unsigned long end;             /* Ending offset in the source string.    */
00083 } ucrun_t;
00084 
00085 /*
00086  * This represents a string of runs rendered up to a point that is not
00087  * platform specific.
00088  */
00089 typedef struct _ucstring_t {
00090     int direction;                /* Overall direction of the string.       */
00091 
00092     int cursor_motion;            /* Logical or visual cursor motion flag.  */
00093 
00094     ucrun_t *cursor;              /* The run containing the "cursor."       */
00095 
00096     ucrun_t *logical_first;       /* First run in the logical order.        */
00097     ucrun_t *logical_last;        /* Last run in the logical order.         */
00098 
00099     ucrun_t *visual_first;        /* First run in the visual order.         */
00100     ucrun_t *visual_last;         /* Last run in the visual order.          */
00101 
00102     unsigned long *source;        /* The source string.                     */
00103     unsigned long start;          /* The beginning offset in the source.    */
00104     unsigned long end;            /* The ending offset in the source.       */
00105 } ucstring_t;
00106 
00107 /***************************************************************************
00108  *
00109  * API
00110  *
00111  ***************************************************************************/
00112 
00113 /*
00114  * This creates and reorders the specified substring using the
00115  * "Pretty Good Bidi Algorithm."  A default direction is provided for cases
00116  * of a string containing no strong direction characters and the default
00117  * cursor motion should be provided.
00118  */
00119 LDAP_LUNICODE_F (ucstring_t *)
00120 ucstring_create LDAP_P((unsigned long *source,
00121                       unsigned long start,
00122                       unsigned long end,
00123                       int default_direction,
00124                       int cursor_motion));
00125 /*
00126  * This releases the string.
00127  */
00128 LDAP_LUNICODE_F (void) ucstring_free LDAP_P((ucstring_t *string));
00129 
00130 /*
00131  * This changes the cursor motion flag for the string.
00132  */
00133 LDAP_LUNICODE_F (int)
00134 ucstring_set_cursor_motion LDAP_P((ucstring_t *string,
00135                                int cursor_motion));
00136 
00137 /*
00138  * This function will move the cursor to the right depending on the
00139  * type of cursor motion that was specified for the string.
00140  *
00141  * A 0 is returned if no cursor motion is performed, otherwise a
00142  * 1 is returned.
00143  */
00144 LDAP_LUNICODE_F (int)
00145 ucstring_cursor_right LDAP_P((ucstring_t *string, int count));
00146 
00147 /*
00148  * This function will move the cursor to the left depending on the
00149  * type of cursor motion that was specified for the string.
00150  *
00151  * A 0 is returned if no cursor motion is performed, otherwise a
00152  * 1 is returned.
00153  */
00154 LDAP_LUNICODE_F (int)
00155 ucstring_cursor_left LDAP_P((ucstring_t *string, int count));
00156 
00157 /*
00158  * This routine retrieves the direction of the run containing the cursor
00159  * and the actual position in the original text string.
00160  */
00161 LDAP_LUNICODE_F (void)
00162 ucstring_cursor_info LDAP_P((ucstring_t *string, int *direction,
00163                           unsigned long *position));
00164 
00165 LDAP_END_DECL
00166 
00167 #endif /* _h_ucpgba */