]> git.lyx.org Git - lyx.git/blob - src/support/textutils.h
remove !NEW_INSETS cruft
[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-2000 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef TEXTUTILS_H
13 #define TEXTUTILS_H
14
15 #include <cctype>
16
17 ///
18 inline
19 bool IsNewlineChar(char c) {
20         return (c == LyXParagraph::META_NEWLINE);
21 }
22
23
24 ///
25 inline
26 bool IsSeparatorChar(char c) {
27         return (c == ' ');
28 }
29
30
31 ///
32 inline
33 bool IsHfillChar(char c) {
34         return (c == LyXParagraph::META_HFILL);
35 }
36
37
38 ///
39 inline
40 bool IsInsetChar(char c) {
41         return (c == LyXParagraph::META_INSET);
42 }
43
44
45 ///
46 inline
47 bool IsLineSeparatorChar(char c) {
48         return (c == ' ');
49 }
50
51
52 ///
53 inline
54 bool IsKommaChar(char c) {
55         return (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 == '/' 
77                 || c == '\\'
78                 || c == LyXParagraph::META_NEWLINE
79                 );
80 }
81
82
83 ///
84 inline
85 bool IsLetterChar(unsigned char c) {
86         return ((c >= 'A' && c <= 'Z')
87                 || (c >= 'a' && c <= 'z')
88                 || (c >= 192)); // in iso-8859-x these are accented chars
89 }
90
91
92 ///
93 inline
94 bool IsPrintable(unsigned char c) {
95         return (c >= ' ');
96 }
97
98
99 ///
100 inline
101 bool IsPrintableNonspace(unsigned char c) {
102         return (c > ' ');
103 }
104
105
106 /// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset. 
107 inline
108 bool IsWordChar(unsigned char c) {
109         return !( IsSeparatorChar( c )
110                   || IsKommaChar( c )
111                   || IsHfillChar( c )
112                   || IsInsetChar( c ));
113 }
114
115
116 ///
117 inline
118 bool IsLetterCharOrDigit(char ch)
119 {
120         return IsLetterChar(ch) || isdigit(ch);
121 }
122 #endif