48 static void gnc_num_cell_init (
NumCell *cell);
49 static gboolean gnc_num_cell_enter (BasicCell *cell,
int *cursor_position,
50 int *start_selection,
int *end_selection);
55 gnc_parse_num (
const char *
string,
long int *num)
65 number = strtol (
string, NULL, 10);
67 if ((number == LONG_MIN) || (number == LONG_MAX))
77 gnc_num_cell_modify_verify (BasicCell *_cell,
87 gboolean accel = FALSE;
96 gnc_basic_cell_set_value_internal (&cell->cell, newval);
98 *end_selection = *start_selection = *cursor_position;
102 change_chars = g_utf8_strlen (change, -1);
104 if ((change_chars == 0) ||
108 gnc_basic_cell_set_value_internal (&cell->cell, newval);
114 is_num = gnc_parse_num (_cell->value, &number);
116 if (is_num && (number < 0))
119 uc = g_utf8_get_char (change);
151 if (accel && !is_num && (g_strcmp0(_cell->value,
"") != 0))
159 number = cell->next_num;
162 snprintf (buff,
sizeof(buff),
"%ld", number);
164 if (g_strcmp0 (buff,
"") == 0)
167 gnc_basic_cell_set_value_internal (&cell->cell, buff);
169 *cursor_position = -1;
174 gnc_basic_cell_set_value_internal (&cell->cell, newval);
178 gnc_num_cell_new (
void)
184 gnc_num_cell_init (cell);
190 gnc_num_cell_set_value_internal (BasicCell *_cell,
const char *str)
194 if (!cell->next_num_set)
198 if (gnc_parse_num (str, &number))
199 cell->next_num = number + 1;
202 gnc_basic_cell_set_value_internal (_cell, str);
206 gnc_num_cell_set_value (
NumCell *cell,
const char *str)
211 gnc_num_cell_set_value_internal (&cell->cell, str);
215 gnc_num_cell_set_last_num (
NumCell *cell,
const char *str)
222 if (gnc_parse_num (str, &number))
224 cell->next_num = number + 1;
225 cell->next_num_set = TRUE;
233 gnc_num_cell_init (
NumCell *cell)
235 gnc_basic_cell_init (&(cell->cell));
238 cell->next_num_set = FALSE;
240 cell->cell.modify_verify = gnc_num_cell_modify_verify;
241 cell->cell.set_value = gnc_num_cell_set_value_internal;
242 cell->cell.enter_cell = gnc_num_cell_enter;
246 gnc_num_cell_enter (BasicCell *cell,
int *cursor_position,
247 int *start_selection,
int *end_selection)
249 DEBUG(
"%d, %d, %d", *cursor_position, *start_selection, *end_selection);
250 *cursor_position = -1;
251 *start_selection = 0;
#define G_LOG_DOMAIN
Functions providing the SX List as a plugin page.
#define DEBUG(format, args...)
Print a debugging message.
gboolean gnc_strisnum(const gchar *s)
Returns true if string s is a number, possibly surrounded by whitespace.
All type declarations for the whole Gnucash engine.
The NumCell object implements a number handling cell.