1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright 1995 Matthias Ettrich
|
2001-05-30 13:53:44 +00:00
|
|
|
* Copyright 1995-2001 The LyX Team.
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
1999-11-15 10:54:16 +00:00
|
|
|
* ====================================================== */
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-15 10:54:16 +00:00
|
|
|
#ifndef TEXTUTILS_H
|
|
|
|
#define TEXTUTILS_H
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsNewlineChar(char c) {
|
2001-06-25 00:06:33 +00:00
|
|
|
return (c == Paragraph::META_NEWLINE);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsSeparatorChar(char c) {
|
|
|
|
return (c == ' ');
|
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsHfillChar(char c) {
|
2001-06-25 00:06:33 +00:00
|
|
|
return (c == Paragraph::META_HFILL);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsInsetChar(char c) {
|
2001-06-25 00:06:33 +00:00
|
|
|
return (c == Paragraph::META_INSET);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsLineSeparatorChar(char c) {
|
1999-09-27 18:44:28 +00:00
|
|
|
return (c == ' ');
|
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsKommaChar(char c) {
|
1999-09-27 18:44:28 +00:00
|
|
|
return (c == ','
|
1999-11-15 10:54:16 +00:00
|
|
|
|| c == '('
|
|
|
|
|| c == ')'
|
|
|
|
|| c == '['
|
|
|
|
|| c == ']'
|
|
|
|
|| c == '{'
|
|
|
|
|| c == '}'
|
|
|
|
|| c == ';'
|
|
|
|
|| c == '.'
|
|
|
|
|| c == ':'
|
|
|
|
|| c == '-'
|
|
|
|
|| c == '?'
|
|
|
|
|| c == '!'
|
|
|
|
|| c == '&'
|
|
|
|
|| c == '@'
|
|
|
|
|| c == '+'
|
|
|
|
|| c == '-'
|
|
|
|
|| c == '~'
|
|
|
|
|| c == '#'
|
|
|
|
|| c == '%'
|
|
|
|
|| c == '^'
|
|
|
|
|| c == '/'
|
|
|
|
|| c == '\\'
|
2001-06-25 00:06:33 +00:00
|
|
|
|| c == Paragraph::META_NEWLINE
|
1999-09-27 18:44:28 +00:00
|
|
|
);
|
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsLetterChar(unsigned char c) {
|
1999-11-15 10:54:16 +00:00
|
|
|
return ((c >= 'A' && c <= 'Z')
|
|
|
|
|| (c >= 'a' && c <= 'z')
|
|
|
|
|| (c >= 192)); // in iso-8859-x these are accented chars
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsPrintable(unsigned char c) {
|
2001-06-25 00:06:33 +00:00
|
|
|
return ((c & 127) >= ' ');
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-07-04 20:32:37 +00:00
|
|
|
inline
|
|
|
|
bool IsPrintableNonspace(unsigned char c) {
|
2001-06-25 00:06:33 +00:00
|
|
|
return IsPrintable(c) && (c != ' ');
|
2000-07-04 20:32:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
/// Word is not IsSeparator or IsKomma or IsHfill or IsFloat or IsInset.
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsWordChar(unsigned char c) {
|
2000-07-19 17:16:27 +00:00
|
|
|
return !( IsSeparatorChar( c )
|
|
|
|
|| IsKommaChar( c )
|
|
|
|
|| IsHfillChar( c )
|
|
|
|
|| IsInsetChar( c ));
|
1999-11-15 10:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-14 17:53:12 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
2001-06-25 00:06:33 +00:00
|
|
|
bool IsDigit(unsigned char ch)
|
|
|
|
{
|
|
|
|
return ch >= '0' && ch <= '9';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
inline
|
|
|
|
bool IsLetterCharOrDigit(unsigned char ch)
|
1999-11-15 10:54:16 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
return IsLetterChar(ch) || IsDigit(ch);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
#endif
|