Commit 7bb1eb3f authored by Miguel de Icaza's avatar Miguel de Icaza Committed by Miguel de Icaza

Allow for parsing to be non-strict.



2000-03-21  Miguel de Icaza  <miguel@helixcode.com>

	* src/utils.c (parse_cell_name_or_range): Allow for parsing to be
	non-strict.

	* src/ranges.c (range_parse): Allow for parsing to be non-strict.

	* src/utils.c (parse_cell_name): Allow for parsing to be non-strict.

	* Makefile.am (SUBDIRS): Fix list of directories.

	* src/item-cursor.c (item_cursor_set_arg): Added optional color
	handling to item-cursor.

2000-03-20  Miguel de Icaza  <miguel@helixcode.com>

	* src/main.c (gnumeric_main): Removed broken style test.

	* src/ranges.c (range_parse): Update the range_parse API

	* src/print-info.c (load_range): Update API.

	* src/utils.c (parse_cell_name): Handle references that contain an
	absolute reference.
parent cfa86f9f
2000-03-21 Miguel de Icaza <miguel@helixcode.com>
* src/utils.c (parse_cell_name_or_range): Allow for parsing to be
non-strict.
* src/ranges.c (range_parse): Allow for parsing to be non-strict.
* src/utils.c (parse_cell_name): Allow for parsing to be non-strict.
* Makefile.am (SUBDIRS): Fix list of directories.
* src/item-cursor.c (item_cursor_set_arg): Added optional color
handling to item-cursor.
2000-03-20 Miguel de Icaza <miguel@helixcode.com>
* src/main.c (gnumeric_main): Removed broken style test.
* src/ranges.c (range_parse): Update the range_parse API
* src/print-info.c (load_range): Update API.
* src/utils.c (parse_cell_name): Handle references that contain an
absolute reference.
2000-03-19 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Move the styles before the contents
......
2000-03-21 Miguel de Icaza <miguel@helixcode.com>
* src/utils.c (parse_cell_name_or_range): Allow for parsing to be
non-strict.
* src/ranges.c (range_parse): Allow for parsing to be non-strict.
* src/utils.c (parse_cell_name): Allow for parsing to be non-strict.
* Makefile.am (SUBDIRS): Fix list of directories.
* src/item-cursor.c (item_cursor_set_arg): Added optional color
handling to item-cursor.
2000-03-20 Miguel de Icaza <miguel@helixcode.com>
* src/main.c (gnumeric_main): Removed broken style test.
* src/ranges.c (range_parse): Update the range_parse API
* src/print-info.c (load_range): Update API.
* src/utils.c (parse_cell_name): Handle references that contain an
absolute reference.
2000-03-19 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Move the styles before the contents
......
if BONOBO
SUBDIRS = intl po macros idl plugins wizards src graph doc icons
else
SUBDIRS = intl po macros idl plugins src doc icons
SUBDIRS = intl po macros plugins src doc icons
endif
change_logs = \
......
2000-03-21 Miguel de Icaza <miguel@helixcode.com>
* src/utils.c (parse_cell_name_or_range): Allow for parsing to be
non-strict.
* src/ranges.c (range_parse): Allow for parsing to be non-strict.
* src/utils.c (parse_cell_name): Allow for parsing to be non-strict.
* Makefile.am (SUBDIRS): Fix list of directories.
* src/item-cursor.c (item_cursor_set_arg): Added optional color
handling to item-cursor.
2000-03-20 Miguel de Icaza <miguel@helixcode.com>
* src/main.c (gnumeric_main): Removed broken style test.
* src/ranges.c (range_parse): Update the range_parse API
* src/print-info.c (load_range): Update API.
* src/utils.c (parse_cell_name): Handle references that contain an
absolute reference.
2000-03-19 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Move the styles before the contents
......
2000-03-21 Miguel de Icaza <miguel@helixcode.com>
* src/utils.c (parse_cell_name_or_range): Allow for parsing to be
non-strict.
* src/ranges.c (range_parse): Allow for parsing to be non-strict.
* src/utils.c (parse_cell_name): Allow for parsing to be non-strict.
* Makefile.am (SUBDIRS): Fix list of directories.
* src/item-cursor.c (item_cursor_set_arg): Added optional color
handling to item-cursor.
2000-03-20 Miguel de Icaza <miguel@helixcode.com>
* src/main.c (gnumeric_main): Removed broken style test.
* src/ranges.c (range_parse): Update the range_parse API
* src/print-info.c (load_range): Update API.
* src/utils.c (parse_cell_name): Handle references that contain an
absolute reference.
2000-03-19 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Move the styles before the contents
......
2000-03-21 Miguel de Icaza <miguel@helixcode.com>
* src/utils.c (parse_cell_name_or_range): Allow for parsing to be
non-strict.
* src/ranges.c (range_parse): Allow for parsing to be non-strict.
* src/utils.c (parse_cell_name): Allow for parsing to be non-strict.
* Makefile.am (SUBDIRS): Fix list of directories.
* src/item-cursor.c (item_cursor_set_arg): Added optional color
handling to item-cursor.
2000-03-20 Miguel de Icaza <miguel@helixcode.com>
* src/main.c (gnumeric_main): Removed broken style test.
* src/ranges.c (range_parse): Update the range_parse API
* src/print-info.c (load_range): Update API.
* src/utils.c (parse_cell_name): Handle references that contain an
absolute reference.
2000-03-19 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Move the styles before the contents
......
2000-03-21 Miguel de Icaza <miguel@helixcode.com>
* src/utils.c (parse_cell_name_or_range): Allow for parsing to be
non-strict.
* src/ranges.c (range_parse): Allow for parsing to be non-strict.
* src/utils.c (parse_cell_name): Allow for parsing to be non-strict.
* Makefile.am (SUBDIRS): Fix list of directories.
* src/item-cursor.c (item_cursor_set_arg): Added optional color
handling to item-cursor.
2000-03-20 Miguel de Icaza <miguel@helixcode.com>
* src/main.c (gnumeric_main): Removed broken style test.
* src/ranges.c (range_parse): Update the range_parse API
* src/print-info.c (load_range): Update API.
* src/utils.c (parse_cell_name): Handle references that contain an
absolute reference.
2000-03-19 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Move the styles before the contents
......
2000-03-21 Miguel de Icaza <miguel@helixcode.com>
* src/utils.c (parse_cell_name_or_range): Allow for parsing to be
non-strict.
* src/ranges.c (range_parse): Allow for parsing to be non-strict.
* src/utils.c (parse_cell_name): Allow for parsing to be non-strict.
* Makefile.am (SUBDIRS): Fix list of directories.
* src/item-cursor.c (item_cursor_set_arg): Added optional color
handling to item-cursor.
2000-03-20 Miguel de Icaza <miguel@helixcode.com>
* src/main.c (gnumeric_main): Removed broken style test.
* src/ranges.c (range_parse): Update the range_parse API
* src/print-info.c (load_range): Update API.
* src/utils.c (parse_cell_name): Handle references that contain an
absolute reference.
2000-03-19 Jody Goldberg <jgoldberg@home.com>
* src/sheet.c (sheet_move_range) : Move the styles before the contents
......
......@@ -4,6 +4,10 @@
*
* Author:
* Miguel de Icaza (miguel@gnu.org)
*
* Notes:
*
* Strings representing ranges, when parsed ignore relative strings.
*/
#include <config.h>
#include <libgnorba/gnome-factory.h>
......@@ -35,10 +39,12 @@
verify (r1 <= r2);
#define verify_range(sheet,range,l) \
if (!corba_range_parse (sheet,range,l)) { out_of_range (ev); return; }
if (!corba_range_parse (sheet,range,l)) \
{ out_of_range (ev); return; }
#define verify_range_val(sheet,range,l,val) \
if (!corba_range_parse (sheet,range,l)) { out_of_range (ev); return (val); }
if (!corba_range_parse (sheet,range,l)) \
{ out_of_range (ev); return (val); }
static POA_GNOME_Gnumeric_Sheet__vepv gnome_gnumeric_sheet_vepv;
static POA_GNOME_Gnumeric_Sheet__epv gnome_gnumeric_sheet_epv;
......@@ -66,7 +72,7 @@ corba_range_parse (Sheet *sheet, const char *range_spec, GSList **return_list)
{
GSList *list;
list = range_list_parse (sheet, range_spec);
list = range_list_parse (sheet, range_spec, TRUE);
if (list) {
*return_list = list;
return TRUE;
......@@ -317,8 +323,8 @@ Sheet_cell_set_value (PortableServer_Servant servant,
case GNOME_Gnumeric_VALUE_CELLRANGE: {
CellRef a, b;
parse_cell_name (value->_u.cell_range.cell_a, &a.col, &a.row);
parse_cell_name (value->_u.cell_range.cell_b, &b.col, &b.row);
parse_cell_name (value->_u.cell_range.cell_a, &a.col, &a.row, TRUE);
parse_cell_name (value->_u.cell_range.cell_b, &b.col, &b.row, TRUE);
a.sheet = sheet;
b.sheet = sheet;
a.col_relative = 0;
......
......@@ -324,9 +324,9 @@ parse_multiple_ranges (char *text, Range **ranges, int *dim)
if (p == NULL)
goto failure;
*p = '\0';
if (!parse_cell_name (buf+last, &start_col, &start_row))
if (!parse_cell_name (buf+last, &start_col, &start_row, TRUE))
goto failure;
if (!parse_cell_name (p+1, &end_col, &end_row))
if (!parse_cell_name (p+1, &end_col, &end_row, TRUE))
goto failure;
newranges = g_new (Range, curdim + end_col - start_col + 1);
for (j = 0; j < curdim; j++)
......
......@@ -355,7 +355,7 @@ dialog_loop:
/* Check that a cell entered in 'set cell' entry */
text = gtk_entry_get_text (GTK_ENTRY (set_entry));
if (!parse_cell_name (text, &set_cell_col, &set_cell_row)){
if (!parse_cell_name (text, &set_cell_col, &set_cell_row, TRUE)){
gnumeric_notice (wb, GNOME_MESSAGE_BOX_ERROR,
_("You should introduce a valid cell name in 'Set cell'"));
focus_on_entry (set_entry);
......@@ -376,7 +376,7 @@ dialog_loop:
/* Check that a cell entered in 'by changing cell' entry */
text = gtk_entry_get_text (GTK_ENTRY (change_entry));
if (!parse_cell_name (text, &change_cell_col, &change_cell_row)){
if (!parse_cell_name (text, &change_cell_col, &change_cell_row, TRUE)){
gnumeric_notice (wb, GNOME_MESSAGE_BOX_ERROR,
_("You should introduce a valid cell "
"name in 'By changing cell'"));
......
......@@ -897,13 +897,16 @@ do_fetch_page_info (dialog_print_info_t *dpi)
entry_top = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-rows-entry"));
entry_left = GTK_ENTRY (glade_xml_get_widget (dpi->gui, "repeat-cols-entry"));
if (range_parse (NULL, gtk_entry_get_text (entry_top), &top_range)){
top_range = range_parse (NULL, gtk_entry_get_text (entry_top), TRUE);
if (top_range){
dpi->pi->repeat_top.range = *top_range;
dpi->pi->repeat_top.use = TRUE;
value_release (top_range);
}
if (range_parse (NULL, gtk_entry_get_text (entry_left), &left_range)){
left_range = range_parse (NULL, gtk_entry_get_text (entry_left), TRUE);
if (left_range){
dpi->pi->repeat_left.range = *left_range;
dpi->pi->repeat_left.use = TRUE;
value_release (left_range);
......
......@@ -222,7 +222,7 @@ add_dialog:
lhs_text = gtk_entry_get_text (GTK_ENTRY (lhs_entry));
if (!parse_cell_name_or_range (lhs_text, &lhs_col, &lhs_row,
&lhs_cols, &lhs_rows)) {
&lhs_cols, &lhs_rows, TRUE)) {
gtk_widget_grab_focus (lhs_entry);
gtk_entry_set_position(GTK_ENTRY (lhs_entry), 0);
gtk_entry_select_region(GTK_ENTRY (lhs_entry), 0,
......@@ -236,7 +236,7 @@ add_dialog:
if ((strcmp (type_str, "Int") != 0 &&
strcmp (type_str, "Bool") != 0) &&
!parse_cell_name_or_range (rhs_text, &rhs_col, &rhs_row,
&rhs_cols, &rhs_rows)) {
&rhs_cols, &rhs_rows, TRUE)) {
gtk_widget_grab_focus (rhs_entry);
gtk_entry_set_position(GTK_ENTRY (rhs_entry), 0);
gtk_entry_select_region(GTK_ENTRY (rhs_entry), 0,
......@@ -395,7 +395,7 @@ loop:
constraint->lhs_row);
if (strcmp (entry, txt) != 0) {
if (!parse_cell_name_or_range (entry, &col, &row,
&lhs_cols, &lhs_rows)) {
&lhs_cols, &lhs_rows, TRUE)) {
gtk_widget_grab_focus (lhs_entry);
gtk_entry_set_position(GTK_ENTRY (lhs_entry),
0);
......@@ -422,7 +422,7 @@ loop:
constraint->rhs_row);
if (strcmp (entry, txt) != 0) {
if (!parse_cell_name_or_range (entry, &col, &row,
&rhs_cols, &rhs_rows)) {
&rhs_cols, &rhs_rows, TRUE)) {
gtk_widget_grab_focus (rhs_entry);
gtk_entry_set_position(GTK_ENTRY (rhs_entry),
0);
......@@ -856,7 +856,7 @@ main_dialog:
/* Parse target cell entry */
text = gtk_entry_get_text (GTK_ENTRY (target_entry));
if (!parse_cell_name (text, &target_cell_col, &target_cell_row)) {
if (!parse_cell_name (text, &target_cell_col, &target_cell_row, TRUE)) {
gnumeric_notice (wb, GNOME_MESSAGE_BOX_ERROR,
_("You should introduce a valid cell name "
"for 'Target cell'"));
......@@ -878,7 +878,7 @@ main_dialog:
text = gtk_entry_get_text (GTK_ENTRY (input_entry));
input_cells = (CellList *)
parse_cell_name_list (sheet, text, &error_flag);
parse_cell_name_list (sheet, text, &error_flag, TRUE);
if (error_flag) {
gnumeric_notice (wb, GNOME_MESSAGE_BOX_ERROR,
_("You should introduce a valid cell names "
......
......@@ -141,16 +141,23 @@ col_from_name (const char *cell_str)
* @cell_name: a string representation of a cell name.
* @col: result col
* @row: result row
*
* @strict: if this is TRUE, then parsing stops at possible errors,
* otherwise an attempt is made to return cell names with trailing garbage.
*
* Return value: true if the cell_name could be successfully parsed
*/
gboolean
parse_cell_name (const char *cell_str, int *col, int *row)
parse_cell_name (const char *cell_str, int *col, int *row, gboolean strict)
{
char c;
unsigned char c;
gboolean found_digits = FALSE;
if (*cell_str == '$')
cell_str++;
/* Parse column name: one or two letters. */
c = toupper ((unsigned char)*cell_str++);
c = toupper ((unsigned char) *cell_str);
cell_str++;
if (c < 'A' || c > 'Z')
return FALSE;
......@@ -163,10 +170,18 @@ parse_cell_name (const char *cell_str, int *col, int *row)
if (*col >= SHEET_MAX_COLS)
return FALSE;
if (*cell_str == '$')
cell_str++;
/* Parse row number: a sequence of digits. */
for (*row = 0; *cell_str; cell_str++) {
if (*cell_str < '0' || *cell_str > '9')
return FALSE;
if (*cell_str < '0' || *cell_str > '9'){
if (found_digits && strict == FALSE){
break;
} else
return FALSE;
}
found_digits = TRUE;
*row = *row * 10 + (*cell_str - '0');
if (*row > SHEET_MAX_ROWS) /* Note: ">" is deliberate. */
return FALSE;
......@@ -180,13 +195,12 @@ parse_cell_name (const char *cell_str, int *col, int *row)
}
gboolean
parse_cell_name_or_range (const char *cell_str, int *col, int *row,
int *cols, int *rows)
parse_cell_name_or_range (const char *cell_str, int *col, int *row, int *cols, int *rows, gboolean strict)
{
int e_col, e_row;
*cols = *rows = 1;
if (!parse_cell_name (cell_str, col, row)) {
if (!parse_cell_name (cell_str, col, row, strict)) {
if (!parse_range ((char *) cell_str, col, row, &e_col, &e_row))
return FALSE;
else {
......@@ -232,7 +246,8 @@ gnumeric_strcase_hash (gconstpointer v)
GSList *
parse_cell_name_list (Sheet *sheet,
const char *cell_name_str,
int *error_flag)
int *error_flag,
gboolean strict)
{
char *buf, *tmp = NULL;
GSList *cells = NULL;
......@@ -253,7 +268,7 @@ parse_cell_name_list (Sheet *sheet,
(cell_name_str [i] == '\0')){
buf [n] = '\0';
if (!parse_cell_name (buf, &col, &row)){
if (!parse_cell_name (buf, &col, &row, strict)){
error:
*error_flag = 1;
free (buf);
......@@ -273,10 +288,10 @@ parse_cell_name_list (Sheet *sheet,
else if (range_flag) {
int x1, x2, y1, y2;
parse_cell_name (tmp, &x1, &y1);
parse_cell_name (buf, &x2, &y2);
for (j=x1; j<=x2; j++)
for (k=y1; k<=y2; k++) {
parse_cell_name (tmp, &x1, &y1, strict);
parse_cell_name (buf, &x2, &y2, strict);
for (j = x1; j <= x2; j++)
for (k = y1; k <= y2; k++) {
cell = sheet_cell_fetch
(sheet, j, k);
cells = g_slist_append
......
......@@ -10,12 +10,12 @@ void float_get_from_range (const char *start, const char *end, float_t
const char *cell_name (int col, int row);
/* Various parsing routines */
gboolean parse_cell_name (const char *cell_str, int *col, int *row);
gboolean parse_cell_name (const char *cell_str, int *col, int *row, gboolean strict);
gboolean parse_cell_name_or_range (const char *cell_str, int *col, int *row,
int *cols, int *rows);
int *cols, int *rows, gboolean strict);
gboolean parse_cell_range (Sheet *sheet, const char *range, Value **v);
GSList *parse_cell_name_list (Sheet *sheet, const char *cell_name_str,
int *error_flag);
int *error_flag, gboolean strict);
/*
* Names
......
......@@ -33,6 +33,7 @@ enum {
ARG_SHEET, /* The Sheet * argument */
ARG_ITEM_GRID, /* The ItemGrid * argument */
ARG_STYLE, /* The style type */
ARG_COLOR, /* The optional color */
};
static int
......@@ -244,6 +245,14 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
back = &gs_white;
break;
case ITEM_CURSOR_BLOCK:
draw_center = 1;
draw_thick = 1;
draw_internal = 0;
draw_external = 1;
draw_stippled = 0;
break;
case ITEM_CURSOR_SELECTION:
draw_internal = 1;
draw_external = 1;
......@@ -275,6 +284,11 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
}
};
if (item_cursor->use_color){
fore = &item_cursor->color;
back = &item_cursor->color;
}
item_cursor->auto_fill_handle_at_top = (draw_handle >= 2);
clip_rect.x = 0;
......@@ -296,11 +310,13 @@ item_cursor_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, in
GDK_LINE_SOLID, -1, -1);
gdk_gc_set_foreground (item_cursor->gc, &gs_black);
gdk_gc_set_background (item_cursor->gc, &gs_white);
if (draw_external){
switch (draw_handle) {
/* Auto handle at bottom */
case 1 : premove = AUTO_HANDLE_SPACE;
/* Fall through */
case 1 :
premove = AUTO_HANDLE_SPACE;
/* Fall through */
/* No auto handle */
case 0 :
......@@ -1032,7 +1048,7 @@ item_cursor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
GnomeCanvasItem *item;
ItemCursor *item_cursor;
item = GNOME_CANVAS_ITEM (o);
item_cursor = ITEM_CURSOR (o);
......@@ -1046,6 +1062,17 @@ item_cursor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_STYLE:
item_cursor->style = GTK_VALUE_INT (*arg);
break;
case ARG_COLOR: {
GdkColor color;
char *color_name;
color_name = GTK_VALUE_STRING (*arg);
if (gnome_canvas_get_color (item->canvas, color_name, &color)){
item_cursor->color = color;
item_cursor->use_color = 1;
}
}
}
}
......@@ -1069,6 +1096,8 @@ item_cursor_class_init (ItemCursorClass *item_cursor_class)
GTK_ARG_WRITABLE, ARG_ITEM_GRID);
gtk_object_add_arg_type ("ItemCursor::Style", GTK_TYPE_INT,
GTK_ARG_WRITABLE, ARG_STYLE);
gtk_object_add_arg_type ("ItemCursor::Color", GTK_TYPE_STRING,
GTK_ARG_WRITABLE, ARG_COLOR);
object_class->set_arg = item_cursor_set_arg;
object_class->destroy = item_cursor_destroy;
......
......@@ -14,6 +14,7 @@ typedef enum {
ITEM_CURSOR_ANTED,
ITEM_CURSOR_AUTOFILL,
ITEM_CURSOR_DRAG,
ITEM_CURSOR_BLOCK
} ItemCursorStyle;
typedef struct {
......@@ -54,9 +55,11 @@ typedef struct {
/* Cached values of the last bounding box information used */
int cached_x, cached_y, cached_w, cached_h;
int visible;
int visible:1;
int use_color:1;
GdkPixmap *stipple;
GdkColor color;
} ItemCursor;
GtkType item_cursor_get_type (void);
......@@ -65,9 +68,9 @@ typedef struct {
GnomeCanvasItemClass parent_class;
} ItemCursorClass;
void item_cursor_set_bounds (ItemCursor *item_cursor,
int start_col, int start_row,
int end_col, int end_row);
void item_cursor_set_bounds (ItemCursor *item_cursor,
int start_col, int start_row,
int end_col, int end_row);
void item_cursor_set_spin_base (ItemCursor *item_cursor,
int col, int row);
......
......@@ -9,10 +9,14 @@
#include <config.h>
#include <gnome.h>
#include <ctype.h>
#include "gnumeric.h"
#include "gnumeric-sheet.h"
#include "item-edit.h"
#include "application.h"
#include "value.h"
#include "ranges.h"
#include "gnumeric-util.h"
#define CURSOR_LEN 4
static GnomeCanvasItem *item_edit_parent_class;
......@@ -190,7 +194,10 @@ item_edit_init (ItemEdit *item_edit)
item_edit->col_span = 1;
item_edit->row_span = 1;
/* Set invalid values so that we know when we have been fully initialized */
/*
* Set invalid values so that we know when we have
* been fully initialized
*/
item_edit->sheet = 0;
item_edit->col = -1;
item_edit->row = -1;
......@@ -209,10 +216,129 @@ queue_sync (ItemEdit *item_edit)
gnome_canvas_request_redraw (canvas, x, y, x+w, y+h);
}
static void
scan_at (const char *text, int *scan)
{
int i;
while (*scan > 0){
const char *p = &text [(*scan)-1];
char c = *p;
if (!(c == ':' || c == '$' || isalnum (*p)))
break;
(*scan)--;
}
}
static gboolean
setup_range_from_value (Range *range, Value *v)
{
if (v->v.cell_range.cell_a.sheet != v->v.cell_range.cell_a.sheet){
value_release (v);
return FALSE;
}
range->start.col = v->v.cell_range.cell_a.col;
range->start.row = v->v.cell_range.cell_a.row;
range->end.col = v->v.cell_range.cell_b.col;
range->end.row = v->v.cell_range.cell_b.row;
value_release (v);
return TRUE;
}
/*
* This routine could definetly be better.
*
* Currently it will not handle ranges like R[-1]C1, nor named ranges,
* nor will it detect whether something is part of an expression or a
* string .
*
* It also flops completely to understand
*/
static gboolean
point_is_inside_range (ItemEdit *item_edit, GtkEntry *entry, Range *range)
{
int text_len, cursor_pos, scan;
Value *v;
char *text;
text = gtk_entry_get_text (GTK_ENTRY (item_edit->editor));
if (!gnumeric_char_start_expr_p (text [0]))
return FALSE;
text++;
text_len = strlen (text);
cursor_pos = GTK_EDITABLE (item_edit->editor)->current_pos;
if (cursor_pos == 0)
return FALSE;
cursor_pos--;
scan = cursor_pos;
scan_at (text, &scan);
if ((v = range_parse (item_edit->sheet, &text [scan], FALSE)) != NULL)
return setup_range_from_value (range, v);
if (scan == cursor_pos && scan > 0)
scan--;
scan_at (text, &scan);
if ((v = range_parse (item_edit->sheet, &text [scan], FALSE)) != NULL)
return setup_range_from_value (range, v);
return FALSE;
}
static void
entry_create_feedback_range (ItemEdit *item_edit, Range *range)
{
GnomeCanvasItem *item = GNOME_CANVAS_ITEM (item_edit);
if (!item_edit->feedback_cursor){
item_edit->feedback_cursor = gnome_canvas_item_new (
GNOME_CANVAS_GROUP (item->canvas->root),
item_cursor_get_type (),
"Sheet", item_edit->sheet,
"Grid", item_edit->item_grid,
"Style", ITEM_CURSOR_BLOCK,
"Color", "red",
NULL);
}
item_cursor_set_bounds (
ITEM_CURSOR (item_edit->feedback_cursor),
range->start.col, range->start.row,
range->end.col, range->end.row);
}
static void
entry_destroy_feedback_range (ItemEdit *item_edit)
{
if (item_edit->feedback_cursor){
gtk_object_destroy (GTK_OBJECT (item_edit->feedback_cursor));
item_edit->feedback_cursor = NULL;
}
}
static void
scan_for_range (ItemEdit *item_edit, GtkEntry *entry)
{
Range range;
if (point_is_inside_range (item_edit, entry, &range))
entry_create_feedback_range (item_edit, &range);
else
entry_destroy_feedback_range (item_edit);
}
static void
entry_changed (GtkEntry *entry, void *data)
{
queue_sync (