]> git.lyx.org Git - lyx.git/blob - src/support/textutils.h
fix bug 175 (minipage in minipage); fix some warnings; apply external.diff from Herbert
[lyx.git] / src / support / textutils.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  * 
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef TEXTUTILS_H
13 #define TEXTUTILS_H
14
15 ///
16 inline
17 bool IsNewlineChar(char c) {
18         return (c == Paragraph::META_NEWLINE);
19 }
20
21
22 ///
23 inline
24 bool IsSeparatorChar(char c) {
25         return (c == ' ');
26 }
27
28
29 ///
30 inline
31 bool IsHfillChar(char c) {
32         return (c == Paragraph::META_HFILL);
33 }
34
35
36 ///
37 inline
38 bool IsInsetChar(char c) {
39         return (c == Paragraph::META_INSET);
40 }
41
42
43 ///
44 inline
45 bool IsLineSeparatorChar(char c) {
46         return (c == ' ');
47 }
48
49
50 ///
51 inline
52 bool IsLineSeparatorChar(char c, Inset * in) {
53         return ((c == ' ') || (in && in->isSpace()));
54 }
55
56
57 ///
58 inline
59 bool IsKommaChar(char c) {
60         return (c == ',' 
61                 || c == '('
62                 || c == ')'
63                 || c == '['
64                 || c == ']'
65                 || c == '{'
66                 || c == '}'
67                 || c == ';'
68                 || c == '.'
69                 || c == ':'
70                 || c == '-'
71                 || c == '?'
72                 || c == '!'
73                 || c == '&'
74                 || c == '@'
75                 || c == '+'
76                 || c == '-'
77                 || c == '~'
78                 || c == '#'
79                 || c == '%'
80                 || c == '^'
81                 || c == '/' 
82                 || c == '\\'
83                 || c == Paragraph::META_NEWLINE
84                 );
85 }
86
87
88 ///
89 inline
90 bool IsLetterChar(unsigned char c) {
91         return ((c >= 'A' && c <= 'Z')
92                 || (c >= 'a' && c <= 'z')
93                 || (c >= 192)); // in iso-8859-x these are accented chars
94 }
95
96
97 ///
98 inline
99 bool IsPrintable(unsigned char c) {
100         return ((c & 127) >= ' ');
101 }
102
103
104 ///
105 inline
106 bool IsPrintableNonspace(unsigned char c) {
107         return IsPrintable(c) && (c != ' ');
108 }
109
110
111 /// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset. 
112 inline
113 bool IsWordChar(unsigned char c) {
114         return !( IsSeparatorChar( c )
115                   || IsKommaChar( c )
116                   || IsHfillChar( c )
117                   || IsInsetChar( c ));
118 }
119
120
121 ///
122 inline
123 bool IsDigit(unsigned char ch)
124 {
125         return ch >= '0' && ch <= '9';
126 }
127
128
129 ///
130 inline
131 bool IsLetterCharOrDigit(unsigned char ch)
132 {
133         return IsLetterChar(ch) || IsDigit(ch);
134 }
135 #endif