]> git.lyx.org Git - lyx.git/blob - src/support/textutils.h
small changes read changelog
[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 IsKommaChar(char c) {
53         return (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                 || c == '-'
70                 || c == '~'
71                 || c == '#'
72                 || c == '%'
73                 || c == '^'
74                 || c == '/' 
75                 || c == '\\'
76                 || c == Paragraph::META_NEWLINE
77                 );
78 }
79
80
81 ///
82 inline
83 bool IsLetterChar(unsigned char c) {
84         return ((c >= 'A' && c <= 'Z')
85                 || (c >= 'a' && c <= 'z')
86                 || (c >= 192)); // in iso-8859-x these are accented chars
87 }
88
89
90 ///
91 inline
92 bool IsPrintable(unsigned char c) {
93         return ((c & 127) >= ' ');
94 }
95
96
97 ///
98 inline
99 bool IsPrintableNonspace(unsigned char c) {
100         return IsPrintable(c) && (c != ' ');
101 }
102
103
104 /// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset. 
105 inline
106 bool IsWordChar(unsigned char c) {
107         return !( IsSeparatorChar( c )
108                   || IsKommaChar( c )
109                   || IsHfillChar( c )
110                   || IsInsetChar( c ));
111 }
112
113
114 ///
115 inline
116 bool IsDigit(unsigned char ch)
117 {
118         return ch >= '0' && ch <= '9';
119 }
120
121
122 ///
123 inline
124 bool IsLetterCharOrDigit(unsigned char ch)
125 {
126         return IsLetterChar(ch) || IsDigit(ch);
127 }
128 #endif