1/* linebreak.h - line breaking of Unicode strings 2 Copyright (C) 2001-2003, 2006-2007 Free Software Foundation, Inc. 3 Written by Bruno Haible <haible@clisp.cons.org>, 2001. 4 5This program is free software: you can redistribute it and/or modify 6it under the terms of the GNU General Public License as published by 7the Free Software Foundation; either version 3 of the License, or 8(at your option) any later version. 9 10This program is distributed in the hope that it will be useful, 11but WITHOUT ANY WARRANTY; without even the implied warranty of 12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13GNU General Public License for more details. 14 15You should have received a copy of the GNU General Public License 16along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 18#ifndef _LINEBREAK_H 19#define _LINEBREAK_H 20 21/* Get size_t. */ 22#include <stddef.h> 23 24 25#ifdef __cplusplus 26extern "C" { 27#endif 28 29 30/* Line breaking. */ 31 32enum { 33 UC_BREAK_UNDEFINED, 34 UC_BREAK_PROHIBITED, 35 UC_BREAK_POSSIBLE, 36 UC_BREAK_MANDATORY, 37 UC_BREAK_HYPHENATION 38}; 39 40/* Determine the line break points in S, and store the result at p[0..n-1]. 41 p[i] = UC_BREAK_MANDATORY means that s[i] is a line break character. 42 p[i] = UC_BREAK_POSSIBLE means that a line break may be inserted between 43 s[i-1] and s[i]. 44 p[i] = UC_BREAK_HYPHENATION means that a hyphen and a line break may be 45 inserted between s[i-1] and s[i]. But beware of language dependent 46 hyphenation rules. 47 p[i] = UC_BREAK_PROHIBITED means that s[i-1] and s[i] must not be separated. 48 */ 49extern void u8_possible_linebreaks (const unsigned char *s, size_t n, 50 const char *encoding, 51 char *p); 52extern void u16_possible_linebreaks (const unsigned short *s, size_t n, 53 const char *encoding, 54 char *p); 55extern void u32_possible_linebreaks (const unsigned int *s, size_t n, 56 const char *encoding, 57 char *p); 58extern void mbs_possible_linebreaks (const char *s, size_t n, 59 const char *encoding, 60 char *p); 61 62/* Choose the best line breaks, assuming the uc_width function. 63 Return the column after the end of the string. 64 o is an optional override; if o[i] != UC_BREAK_UNDEFINED, o[i] takes 65 precedence over p[i] as returned by the *_possible_linebreaks function. 66 */ 67extern int 68 u8_width_linebreaks (const unsigned char *s, size_t n, 69 int width, int start_column, int at_end_columns, 70 const char *o, const char *encoding, 71 char *p); 72extern int 73 u16_width_linebreaks (const unsigned short *s, size_t n, 74 int width, int start_column, int at_end_columns, 75 const char *o, const char *encoding, 76 char *p); 77extern int 78 u32_width_linebreaks (const unsigned int *s, size_t n, 79 int width, int start_column, int at_end_columns, 80 const char *o, const char *encoding, 81 char *p); 82extern int 83 mbs_width_linebreaks (const char *s, size_t n, 84 int width, int start_column, int at_end_columns, 85 const char *o, const char *encoding, 86 char *p); 87 88 89#ifdef __cplusplus 90} 91#endif 92 93 94#endif /* _LINEBREAK_H */ 95