]> git.lyx.org Git - lyx.git/blob - src/support/textutils.h
split LyXText::rowlist_ into individual Paragraph::rows_ chunks
[lyx.git] / src / support / textutils.h
1 // -*- C++ -*-
2 /**
3  * \file textutils.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Matthias Ettrich
8  * \author Lars Gullik Bjønnes
9  *
10  * Full author contact details are available in file CREDITS
11  */
12
13 // FIXME: I can think of a better name for this file ...
14
15 #ifndef TEXTUTILS_H
16 #define TEXTUTILS_H
17
18 /// return true if the char is a word separator
19 inline
20 bool IsSeparatorChar(char c)
21 {
22         return (c == ' ');
23 }
24
25
26 /// return true if the char is a line separator
27 inline
28 bool IsLineSeparatorChar(char c)
29 {
30         return (c == ' ');
31 }
32
33
34 /// return true if the char is a meta-character for an inset
35 inline
36 bool IsInsetChar(char c)
37 {
38         return (c == Paragraph::META_INSET);
39 }
40
41
42 /// return true if the char is "punctuation"
43 inline
44 bool IsKommaChar(char c)
45 {
46         return (c == ','
47                 || c == '('
48                 || c == ')'
49                 || c == '['
50                 || c == ']'
51                 || c == '{'
52                 || c == '}'
53                 || c == ';'
54                 || c == '.'
55                 || c == ':'
56                 || c == '-'
57                 || c == '?'
58                 || c == '!'
59                 || c == '&'
60                 || c == '@'
61                 || c == '+'
62                 || c == '-'
63                 || c == '~'
64                 || c == '#'
65                 || c == '%'
66                 || c == '^'
67                 || c == '/'
68                 || c == '\\'
69                 );
70 }
71
72
73 /// return true if a char is alphabetical (including accented chars)
74 inline
75 bool IsLetterChar(unsigned char c)
76 {
77         return ((c >= 'A' && c <= 'Z')
78                 || (c >= 'a' && c <= 'z')
79                 || (c >= 192)); // in iso-8859-x these are accented chars
80 }
81
82
83 /// return true if the char is printable (masked to 7-bit ASCII)
84 inline
85 bool IsPrintable(unsigned char c)
86 {
87         return ((c & 127) >= ' ');
88 }
89
90
91 /// return true if the char is printable and not a space (masked to 7-bit ASCII)
92 inline
93 bool IsPrintableNonspace(unsigned char c)
94 {
95         return IsPrintable(c) && (c != ' ');
96 }
97
98
99 /// return true if the char forms part of a word
100 inline
101 bool IsWordChar(unsigned char c)
102 {
103         return !(IsSeparatorChar(c)
104                   || IsKommaChar(c)
105                   || IsInsetChar(c));
106 }
107
108
109 /// completely pointless FIXME
110 inline
111 bool IsDigit(unsigned char ch)
112 {
113         return ch >= '0' && ch <= '9';
114 }
115
116
117 /// return true if the char is alphanumeric
118 inline
119 bool IsLetterCharOrDigit(unsigned char ch)
120 {
121         return IsLetterChar(ch) || IsDigit(ch);
122 }
123
124 #endif // TEXTUTILS_H