]> git.lyx.org Git - lyx.git/blob - src/support/textutils.h
Look for mathed xpms. Doesn't do anything yet due to lack of workable XPMs
[lyx.git] / src / support / textutils.h
1 // -*- C++ -*-
2 /**
3  * \file textutils.h
4  * Copyright 1995-2002 the LyX Team
5  * Read the file COPYING
6  *
7  * \author unknown
8  */
9
10 // FIXME: I can think of a better name for this file ...
11
12 #ifndef TEXTUTILS_H
13 #define TEXTUTILS_H
14
15 /// return true if the char is a meta-character newline
16 inline
17 bool IsNewlineChar(char c)
18 {
19         return (c == Paragraph::META_NEWLINE);
20 }
21
22
23 /// return true if the char is a word separator
24 inline
25 bool IsSeparatorChar(char c)
26 {
27         return (c == ' ');
28 }
29
30
31 /// return true if the char is a line separator
32 inline
33 bool IsLineSeparatorChar(char c)
34 {
35         return (c == ' ');
36 }
37
38
39 /// return true if the char is a meta-character for hfill
40 inline
41 bool IsHfillChar(char c)
42 {
43         return (c == Paragraph::META_HFILL);
44 }
45
46
47 /// return true if the char is a meta-character for an inset
48 inline
49 bool IsInsetChar(char c)
50 {
51         return (c == Paragraph::META_INSET);
52 }
53
54
55 /// return true if the char is "punctuation"
56 inline
57 bool IsKommaChar(char c)
58 {
59         return (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 == '%'
79                 || c == '^'
80                 || c == '/'
81                 || c == '\\'
82                 || c == Paragraph::META_NEWLINE
83                 );
84 }
85
86
87 /// return true if a char is alphabetical (including accented chars)
88 inline
89 bool IsLetterChar(unsigned char c)
90 {
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 /// return true if the char is printable (masked to 7-bit ASCII)
98 inline
99 bool IsPrintable(unsigned char c)
100 {
101         return ((c & 127) >= ' ');
102 }
103
104
105 /// return true if the char is printable and not a space (masked to 7-bit ASCII)
106 inline
107 bool IsPrintableNonspace(unsigned char c)
108 {
109         return IsPrintable(c) && (c != ' ');
110 }
111
112
113 /// return true if the char forms part of a word
114 inline
115 bool IsWordChar(unsigned char c)
116 {
117         return !(IsSeparatorChar(c)
118                   || IsKommaChar(c)
119                   || IsHfillChar(c)
120                   || IsInsetChar(c));
121 }
122
123
124 /// completely pointless FIXME
125 inline
126 bool IsDigit(unsigned char ch)
127 {
128         return ch >= '0' && ch <= '9';
129 }
130
131
132 /// return true if the char is alphanumeric
133 inline
134 bool IsLetterCharOrDigit(unsigned char ch)
135 {
136         return IsLetterChar(ch) || IsDigit(ch);
137 }
138
139 #endif // TEXTUTILS_H