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
|
|
|
|
* Copyright 1995-2000 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
|
|
|
|
|
|
|
|
#include <cctype>
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsNewlineChar(char c) {
|
1999-11-15 10:54:16 +00:00
|
|
|
return (c == LyXParagraph::META_NEWLINE);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +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
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsHfillChar(char c) {
|
1999-11-15 10:54:16 +00:00
|
|
|
return (c == LyXParagraph::META_HFILL);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsInsetChar(char c) {
|
1999-11-15 10:54:16 +00:00
|
|
|
return (c == LyXParagraph::META_INSET);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsFloatChar(char c) {
|
1999-11-15 10:54:16 +00:00
|
|
|
return (c == LyXParagraph::META_FOOTNOTE
|
|
|
|
|| c == LyXParagraph::META_MARGIN
|
|
|
|
|| c == LyXParagraph::META_FIG
|
|
|
|
|| c == LyXParagraph::META_TAB
|
|
|
|
|| c == LyXParagraph::META_ALGORITHM
|
|
|
|
|| c == LyXParagraph::META_WIDE_FIG
|
|
|
|
|| c == LyXParagraph::META_WIDE_TAB);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +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
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +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 == '\\'
|
|
|
|
|| c == LyXParagraph::META_NEWLINE
|
1999-09-27 18:44:28 +00:00
|
|
|
);
|
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +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
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsPrintable(unsigned char c) {
|
1999-11-15 10:54:16 +00:00
|
|
|
return (c >= ' ');
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
1999-11-15 10:54:16 +00:00
|
|
|
|
|
|
|
|
1999-09-27 18:44:28 +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) {
|
|
|
|
return !( IsSeparatorChar( c )
|
|
|
|
|| IsKommaChar( c )
|
|
|
|
|| IsHfillChar( c )
|
|
|
|
|| IsFloatChar( c )
|
|
|
|
|| IsInsetChar( c ) ) ;
|
1999-11-15 10:54:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///
|
2000-02-29 02:19:17 +00:00
|
|
|
inline
|
|
|
|
bool IsLetterCharOrDigit(char ch)
|
1999-11-15 10:54:16 +00:00
|
|
|
{
|
|
|
|
return IsLetterChar(ch) || isdigit(ch);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
#endif
|