2003-07-18 12:22:19 +00:00
|
|
|
/**
|
|
|
|
* \file input_validators.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Allan Rae
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-06-12 11:55:12 +00:00
|
|
|
*/
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
#include <config.h>
|
2002-03-11 17:00:41 +00:00
|
|
|
|
2000-06-12 11:55:12 +00:00
|
|
|
#include "input_validators.h"
|
|
|
|
|
2003-09-05 13:15:43 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
#include "lyx_forms.h"
|
|
|
|
|
|
|
|
namespace support = lyx::support;
|
2004-11-30 09:21:12 +00:00
|
|
|
using support::contains;
|
|
|
|
using support::isStrInt;
|
|
|
|
using support::isStrDbl;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
2000-06-12 11:55:12 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2001-07-28 12:24:16 +00:00
|
|
|
int fl_int_filter(FL_OBJECT * ob,
|
|
|
|
char const *, char const *, int c)
|
|
|
|
{
|
|
|
|
if (c == 0 /* final test before handing contents to app */
|
2004-11-30 09:21:12 +00:00
|
|
|
|| contains("0123456789+-", c)) {
|
|
|
|
if (isStrInt(fl_get_input(ob)))
|
2001-07-28 12:24:16 +00:00
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-08 09:37:13 +00:00
|
|
|
int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
|
2001-07-28 12:24:16 +00:00
|
|
|
char const *, char const *, int c)
|
2000-06-12 11:55:12 +00:00
|
|
|
{
|
2000-06-13 17:10:47 +00:00
|
|
|
if (c == 0 /* final test before handing contents to app */
|
2004-11-30 09:21:12 +00:00
|
|
|
|| contains("0123456789", c)) {
|
2000-06-13 17:10:47 +00:00
|
|
|
/* since we only accept numerals then it must be valid */
|
2000-11-03 09:47:02 +00:00
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-28 12:24:16 +00:00
|
|
|
int fl_float_filter(FL_OBJECT * ob,
|
|
|
|
char const *, char const *, int c)
|
|
|
|
{
|
|
|
|
if (c == 0 /* final test before handing contents to app */
|
2004-11-30 09:21:12 +00:00
|
|
|
|| contains("0123456789.+-", c)) {
|
|
|
|
if (isStrDbl(fl_get_input(ob)))
|
2001-07-28 12:24:16 +00:00
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-06 22:24:17 +00:00
|
|
|
int fl_unsigned_float_filter(FL_OBJECT * ob,
|
2001-01-08 09:37:13 +00:00
|
|
|
char const * /*not_used*/,
|
|
|
|
char const * /*unused*/,
|
2000-12-06 22:24:17 +00:00
|
|
|
int c)
|
|
|
|
{
|
|
|
|
if (c == 0 /* final test before handing contents to app */
|
2004-11-30 09:21:12 +00:00
|
|
|
|| contains("0123456789.", c)) {
|
|
|
|
if (isStrDbl(fl_get_input(ob)))
|
2000-12-06 22:24:17 +00:00
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-08 09:37:13 +00:00
|
|
|
int fl_lowercase_filter(FL_OBJECT * /*ob*/,
|
|
|
|
char const * /*not_used*/,
|
|
|
|
char const * /*unused*/,
|
2000-11-03 09:47:02 +00:00
|
|
|
int c)
|
|
|
|
{
|
|
|
|
if (c == 0 /* final test before handing contents to app */
|
2004-11-30 09:21:12 +00:00
|
|
|
|| contains("abcdefghijklmnopqrstuvwxyz0123456789", c)) {
|
2000-11-03 09:47:02 +00:00
|
|
|
/* since we only accept numerals then it must be valid */
|
2000-06-12 11:55:12 +00:00
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|