File: FBidi.h

package info (click to toggle)
fvwm 1:2.6.8-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 15,804 kB
  • sloc: ansic: 145,770; xml: 17,093; perl: 7,302; sh: 4,921; makefile: 1,094; yacc: 688; lex: 187; sed: 11
file content (94 lines) | stat: -rw-r--r-- 2,790 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* -*-c-*- */
/* Copyright (C) 2002 Mikhael Goikhman */
/*
 * FBidi.h - interface to Bidi (bidirectionality for some asian languages).
 */
/***
 * The main function is
 *   char *FBidiConvert(
 *     const char *logical_str, const char *charset, int str_len, Bool *is_rtl,
 *     int *out_len);
 *
 * input:
 *   logical string - the original string
 *   string charset - examples: "iso8859-15", "iso8859-8", "iso8859-6", "utf-8"
 *
 * output:
 *   visual string is returned (should be free'd), or NULL if not applicable
 *   the last argument is set to True if the string has the base RTL direction
 *
 * The is_rtl aggument may be used for 2 purposes. The first is to change the
 * string alignment if there is a free space (but it probably worth not to
 * override the user specified string aligment). The second is to determine
 * where to put ellipses if the string is longer than the available space.
 *
 * There are several possible ways to solve the ellipses problem.
 * This is not automated, the caller should choose one or another way.
 *
 * 1) For a logical string evaluate a visual string (and a base direction)
 *    only once. If needed, cut the visual string and add ellipses at the
 *    correct string side.
 *
 * 2) Cut logical string to the size that will be drawn, add allipses to the
 *    end and call FBidiConvert on the resulting string.
 *
 * 3) Cut logical string to the size that will be drawn, call FBidiConvert
 *    and add ellipses at the correct string side.
 *
 * Probably 2) is the best, but there is one nuance, the ellipses may be at
 * the middle of the string. With 1) and 3) the ellipses are always on the
 * edge of the string. The 1) is good when speed is more important than memory
 * and the string is usually either pure LTR or RTL.
 *
 * Example 1:
 *
 * input:  she said "SHALOM" and then "BOKER TOV".
 * output: she said "MOLAHS" and then "VOT REKOB".
 * is_rtl: False
 *
 * 1) she said "MO...
 * 2) she said ...HS"
 * 3) she said HS"...
 *
 * Example 2:
 *
 * input:  SHALOM, world!
 * output: !world ,MOLAHS
 * is_rtl: True
 *
 * 1) ...ld ,MOLAHS
 * 2) wo... ,MOLAHS
 * 3) ...wo ,MOLAHS
 *
 **/

#ifndef FBIDI_H
#define FBIDI_H

#include "config.h"
#include <X11/Xlib.h>
#include "CombineChars.h"

#if HAVE_BIDI
/*
 * Checks whether the string in the given charset should be BidiConvert'd.
 */
Bool FBidiIsApplicable(const char *charset);

/*
 * Converts the given logical string to visual string for the given charset.
 */
char *FBidiConvert(
	const char *logical_str, const char *charset, int str_len,
	Bool *is_rtl, int *out_len, superimpose_char_t *comb_chars,
	int *pos_l_to_v);

#else /* !HAVE_BIDI */

#define FBidiIsApplicable(c) False

#define FBidiConvert(s, c, l, r, o, cc, lv) NULL

#endif /* HAVE_BIDI */

#endif /* FBIDI_H */