home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / fribidi / fribidi.h < prev   
Encoding:
C/C++ Source or Header  |  2008-04-07  |  11.3 KB  |  283 lines

  1. /* FriBidi - Library of BiDi algorithm
  2.  * Copyright (C) 1999,2000 Dov Grobgeld, and
  3.  * Copyright (C) 2001,2002 Behdad Esfahbod. 
  4.  * 
  5.  * This library is free software; you can redistribute it and/or 
  6.  * modify it under the terms of the GNU Lesser General Public 
  7.  * License as published by the Free Software Foundation; either 
  8.  * version 2.1 of the License, or (at your option) any later version. 
  9.  * 
  10.  * This library is distributed in the hope that it will be useful, 
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
  13.  * Lesser General Public License for more details. 
  14.  * 
  15.  * You should have received a copy of the GNU Lesser General Public License 
  16.  * along with this library, in a file named COPYING; if not, write to the 
  17.  * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
  18.  * Boston, MA 02111-1307, USA  
  19.  * 
  20.  * For licensing issues, contact <dov@imagic.weizmann.ac.il> and 
  21.  * <fwpg@sharif.edu>. 
  22.  */
  23.  
  24. #ifndef FRIBIDI_H
  25. #define FRIBIDI_H
  26.  
  27. #ifndef NULL
  28. #define NULL 0
  29. #endif
  30.  
  31. #include "fribidi_config.h"
  32. #include "fribidi_unicode.h"
  33. #include "fribidi_types.h"
  34. #ifndef FRIBIDI_NO_CHARSETS
  35. #include "fribidi_char_sets.h"
  36. #endif
  37.  
  38. #ifdef __cplusplus
  39. extern "C"
  40. {
  41. #endif
  42.  
  43.   FRIBIDI_API fribidi_boolean fribidi_log2vis (    /* input */
  44.                         FriBidiChar *str,
  45.                         FriBidiStrIndex len,
  46.                         FriBidiCharType *pbase_dirs,
  47.                         /* output */
  48.                         FriBidiChar *visual_str,
  49.                         FriBidiStrIndex
  50.                         *position_L_to_V_list,
  51.                         FriBidiStrIndex
  52.                         *position_V_to_L_list,
  53.                         FriBidiLevel
  54.                         *embedding_level_list);
  55.  
  56.   FRIBIDI_API fribidi_boolean fribidi_log2vis_get_embedding_levels (    /* input */
  57.                                      FriBidiChar
  58.                                      *str,
  59.                                      FriBidiStrIndex
  60.                                      len,
  61.                                      FriBidiCharType
  62.                                      *pbase_dir,
  63.                                      /* output */
  64.                                      FriBidiLevel
  65.                                      *embedding_level_list);
  66.  
  67. /*======================================================================
  68.  *  fribidi_remove_bidi_marks() removes bidirectional marks, and returns
  69.  *  the new length, also updates each of other inputs if not NULL.
  70.  *----------------------------------------------------------------------*/
  71.   FRIBIDI_API FriBidiStrIndex fribidi_remove_bidi_marks (FriBidiChar *str,
  72.                              FriBidiStrIndex
  73.                              length,
  74.                              FriBidiStrIndex
  75.                              *position_to_this_list,
  76.                              FriBidiStrIndex
  77.                              *position_from_this_list,
  78.                              FriBidiLevel
  79.                              *embedding_level_list);
  80.  
  81. /*======================================================================
  82.  *  fribidi_get_type() returns bidi type of a character.
  83.  *----------------------------------------------------------------------*/
  84.   FRIBIDI_API FriBidiCharType fribidi_get_type (FriBidiChar uch);
  85.  
  86. /*======================================================================
  87.  *  fribidi_get_types() returns bidi type of a string.
  88.  *----------------------------------------------------------------------*/
  89.   FRIBIDI_API void fribidi_get_types (    /* input */
  90.                        FriBidiChar *str,
  91.                        FriBidiStrIndex len,
  92.                        /* output */
  93.                        FriBidiCharType *type);
  94.  
  95. /*======================================================================
  96.  *  fribidi_get_mirror_char() returns the mirrored character, if input
  97.  *  character has a mirror, or the input itself.
  98.  *  if mirrored_ch is NULL, just returns if character has a mirror or not.
  99.  *----------------------------------------------------------------------*/
  100.   FRIBIDI_API fribidi_boolean fribidi_get_mirror_char (    /* Input */
  101.                             FriBidiChar ch,
  102.                             /* Output */
  103.                             FriBidiChar
  104.                             *mirrored_ch);
  105.  
  106. /*======================================================================
  107.  *  fribidi_mirroring_status() returns whether mirroring is on or off,
  108.  *  default is on.
  109.  *----------------------------------------------------------------------*/
  110.   FRIBIDI_API fribidi_boolean fribidi_mirroring_status (void);
  111.  
  112. /*======================================================================
  113.  *  fribidi_set_mirroring() sets mirroring on or off.
  114.  *----------------------------------------------------------------------*/
  115.   FRIBIDI_API void fribidi_set_mirroring (fribidi_boolean mirror);
  116.  
  117. /*======================================================================
  118.  *  fribidi_reorder_nsm_status() returns whether reordering of NSM
  119.  *  sequences is on or off, default is off.
  120.  *----------------------------------------------------------------------*/
  121.   FRIBIDI_API fribidi_boolean fribidi_reorder_nsm_status (void);
  122.  
  123. /*======================================================================
  124.  *  fribidi_set_reorder_nsm() sets reordering of NSM characters on or off.
  125.  *----------------------------------------------------------------------*/
  126.   FRIBIDI_API void fribidi_set_reorder_nsm (fribidi_boolean);
  127.  
  128. /*======================================================================
  129.  *  fribidi_set_debug() turn on or off debugging, default is off, return
  130.  *  false is fribidi is not compiled with debug enabled.
  131.  *----------------------------------------------------------------------*/
  132.   FRIBIDI_API fribidi_boolean fribidi_set_debug (fribidi_boolean debug);
  133.  
  134. /* fribidi_utils.c */
  135.  
  136. /*======================================================================
  137.  *  fribidi_find_string_changes() finds the bounding box of the section
  138.  *  of characters that need redrawing. It returns the start and the
  139.  *  length of the section in the new string that needs redrawing.
  140.  *----------------------------------------------------------------------*/
  141.   FRIBIDI_API void fribidi_find_string_changes (    /* input */
  142.                          FriBidiChar *old_str,
  143.                          FriBidiStrIndex old_len,
  144.                          FriBidiChar *new_str,
  145.                          FriBidiStrIndex new_len,
  146.                          /* output */
  147.                          FriBidiStrIndex
  148.                          *change_start,
  149.                          FriBidiStrIndex *change_len);
  150.  
  151.  
  152. /*======================================================================
  153.  *  The find_visual_ranges() function is used to convert between a
  154.  *  continous span in either logical or visual space to a one, two or
  155.  *  three discontinous spans in the other space. The function outputs
  156.  *  the number of ranges needed to display the mapped range as
  157.  *  well as the resolved ranges.
  158.  *
  159.  *  The variable is_v2l_map indicates whether the position map is
  160.  *  is in the direction of visual-to-logical. This information is
  161.  *  needed in order to look up the correct character from the
  162.  *  embedding_level_list which is assumed to be in logical order.
  163.  *
  164.  *  This function is typically used to resolve a logical range to visual
  165.  *  ranges e.g. to display the selection.
  166.  *
  167.  *  Example:
  168.  *     The selection is between logical characters 10 to 45. Calculate
  169.  *     the corresponding visual selection(s):
  170.  *
  171.  *     FriBidiStrIndex sel_span[2] = {10,45};
  172.  *
  173.  *     fribidi_map_range(sel_span,
  174.  *                       TRUE,
  175.  *                       length,
  176.  *                       vis2log_map,
  177.  *                       embedding_levels,
  178.  *                       // output
  179.  *                       &num_vis_ranges, *vis_ranges);
  180.  **----------------------------------------------------------------------*/
  181.   FRIBIDI_API void fribidi_map_range (FriBidiStrIndex span[2],
  182.                       FriBidiStrIndex len,
  183.                       fribidi_boolean is_v2l_map,
  184.                       FriBidiStrIndex *position_map,
  185.                       FriBidiLevel *embedding_level_list,
  186.                       /* output */
  187.                       int *num_mapped_spans,
  188.                       FriBidiStrIndex spans[3][2]);
  189.  
  190. /*======================================================================
  191.  *  fribidi_is_char_rtl() answers the question whether a character
  192.  *  was resolved in the rtl direction. This simply involves asking
  193.  *  if the embedding level for the character is odd.
  194.  *----------------------------------------------------------------------*/
  195.   FRIBIDI_API fribidi_boolean fribidi_is_char_rtl (FriBidiLevel
  196.                            *embedding_level_list,
  197.                            FriBidiCharType base_dir,
  198.                            FriBidiStrIndex idx);
  199.  
  200. /*======================================================================
  201.  *  fribidi_xpos_resolve() does the complicated translation of
  202.  *  an x-coordinate, e.g. as received through a mouse press event,
  203.  *  to the logical and the visual position the xcoordinate is closest
  204.  *  to. It will also resolve the direction of the cursor according
  205.  *  to the embedding level of the closest character.
  206.  *
  207.  *  It does this through the following logics:
  208.  *  Here are the different possibilities:
  209.  *
  210.  *        Pointer              =>          Log Pos         Vis pos
  211.  *  
  212.  *     Before first vis char             log_pos(vis=0)L       0
  213.  *     After last vis char               log_pos(vis=n-1)R     n
  214.  *     Within 1/2 width of vis char i    log_pos(vis=i)L       i
  215.  *     Within last 1/2 width of vchar i  log_pos(vis=i)R       i+1
  216.  *     Border between vis chars i,i+1       resolve!           i+1
  217.  *
  218.  *  Input:
  219.  *     x_pos        The pixel position to be resolved measured in pixels.
  220.  *     x_offset     The x_offset is the pixel position of the left side
  221.  *                  of the leftmost visual character. 
  222.  *     len          The length of the embedding level, the vis2log and
  223.  *                  the char width arrays.
  224.  *     base_dir     The resolved base direction of the line.
  225.  *     vis2log      The vis2log mapping.
  226.  *                  x_position and the character widths. The position
  227.  *                  (x_pos-x_offset) is number of pixels from the left
  228.  *                  of logical character 0.
  229.  *     char_widths  Width in pixels of each character. Note that the
  230.  *                  widths should be provided in logical order.
  231.  *
  232.  *  Output:
  233.  *     res_log_pos  Resolved logical position.
  234.  *     res_vis_pos  Resolved visual position
  235.  *     res_cursor_x_pos   The resolved pixel position to the left or
  236.  *                  the right of the character position x_pos.
  237.  *     res_cursor_dir_is_rtl   Whether the resolved dir of the character
  238.  *                  at position x_pos is rtl.
  239.  *     res_attach_before  Whether the x_pos is cutting the bounding
  240.  *                  box in such a way that the visual cursor should be
  241.  *                  be positioned before the following logical character.
  242.  *                  Note that in the bidi context, the positions "after
  243.  *                  a logical character" and "before the following logical
  244.  *                  character" is not necessarily the same. If x_pos is
  245.  *                  beyond the end of the line, res_attach_before is true.
  246.  *
  247.  *----------------------------------------------------------------------*/
  248.   FRIBIDI_API void fribidi_xpos_resolve (int x_pos,
  249.                      int x_offset,
  250.                      FriBidiStrIndex len,
  251.                      FriBidiLevel *embedding_level_list,
  252.                      FriBidiCharType base_dir,
  253.                      FriBidiStrIndex *vis2log,
  254.                      int *char_widths,
  255.                      /* output */
  256.                      FriBidiStrIndex *res_log_pos,
  257.                      FriBidiStrIndex *res_vis_pos,
  258.                      int *res_cursor_x_pos,
  259.                      fribidi_boolean
  260.                      *res_cursor_dir_is_rtl,
  261.                      fribidi_boolean *res_attach_before);
  262.  
  263. /*======================================================================
  264.  *  fribidi_runs_log2vis takes a list of logical runs and returns a
  265.  *  a list of visual runs. A run is defined as a sequence that has
  266.  *  the same attributes.
  267.  *----------------------------------------------------------------------*/
  268.   FRIBIDI_API void fribidi_runs_log2vis (    /* input */
  269.                       FriBidiList *logical_runs,    /* List of FriBidiRunType */
  270.  
  271.                       FriBidiStrIndex len,
  272.                       FriBidiStrIndex *log2vis,
  273.                       FriBidiCharType base_dir,
  274.                       /* output */
  275.                       FriBidiList **visual_runs);
  276.  
  277.  
  278. #ifdef    __cplusplus
  279. }
  280. #endif
  281.  
  282. #endif                /* FRIBIDI_H */
  283.