Commit 523b03fc authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg
Browse files

- Do NOT clear a cell and save its value when we start editing. I assume this

  was done so that contents of spanning cells would not be visible when editing
  began.  Rather than doing that I've adjusted the grid to pretend the cell
  being edited is empty.

- Some cleanup editing and assigning text into cells.  Still can not directly
  call redo from the cmd.  Something screws up the memory associated with the
  text entry widget ??

2000-01-29  Jody Goldberg <jgoldberg@home.com>

	* src/commands.c (cmd_set_text_undo) : Special case VALUE_EMPTY.
	  Move to the previous cell only after reverting its value so that the
	  edit area is updated.
	(cmd_set_text) : Retrieve the old text of the cell directly.

	* src/sheet.c (sheet_set_current_value) : Delete and merge into...
	(sheet_accept_pending_input) : Here.  Harmonize the logic with.
	(sheet_cancel_pending_input) : this function.
	(sheet_set_text) : Publicize.
	(sheet_stop_editing) : Removed storage of value of cell being edited.
	(sheet_start_editing_at_cursor) : Ditto.

	* src/workbook.c (accept_input) : Use sheet_accept_pending_input.
	(redo_cmd, undo_cmd) : cancel pending input.

2000-01-28  Jody Goldberg <jgoldberg@home.com>

	* src/item-grid.c (item_grid_draw) : Pretend that the cell being
	  edited (and anything it spans) are empty.

	* src/sheet.c (sheet_duplicate_colrow) : Delete unused.
parent 333a8167
2000-01-29 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_set_text_undo) : Special case VALUE_EMPTY.
Move to the previous cell only after reverting its value so that the
edit area is updated.
(cmd_set_text) : Retrieve the old text of the cell directly.
* src/sheet.c (sheet_set_current_value) : Delete and merge into...
(sheet_accept_pending_input) : Here. Harmonize the logic with.
(sheet_cancel_pending_input) : this function.
(sheet_set_text) : Publicize.
(sheet_stop_editing) : Removed storage of value of cell being edited.
(sheet_start_editing_at_cursor) : Ditto.
* src/workbook.c (accept_input) : Use sheet_accept_pending_input.
(redo_cmd, undo_cmd) : cancel pending input.
2000-01-28 Jody Goldberg <jgoldberg@home.com>
* src/item-grid.c (item_grid_draw) : Pretend that the cell being
edited (and anything it spans) are empty.
* src/sheet.c (sheet_duplicate_colrow) : Delete unused.
2000-01-29 Jon K Hellan <hellan@acm.org>
Megacommit.
......@@ -76,11 +100,12 @@
2000-01-28 Mike Kestner <mkestner@ameritech.net>
* src/sheet-style.c (sheet_style_insert_colrow): Now does option checking
and calls either the new style preserving insert function or the existing
functionality in its new function. (stylish_insert_colrow): New.
Preserves style information by extending ranges that contain the
insertion point. (styleless_insert_colrow): Renamed. Existing algorithm
that fragments style ranges to insert an unformatted col/row.
and calls either the new style preserving insert function or the existing
functionality in its new function.
(stylish_insert_colrow): New. Preserves style information by
extending ranges that contain the insertion point.
(styleless_insert_colrow): Renamed. Existing algorithm that fragments
style ranges to insert an unformatted col/row.
2000-01-28 Michael Meeks <mmeeks@gnu.org>
......
......@@ -17,6 +17,7 @@ Jukka:
Jody:
* Row/Col header redraw improvements.
* Zoom enhancement/fixing.
* More work on undo.
Jon:
* Cursor fixes and speedups.
......
2000-01-29 Jody Goldberg <jgoldberg@home.com>
* src/commands.c (cmd_set_text_undo) : Special case VALUE_EMPTY.
Move to the previous cell only after reverting its value so that the
edit area is updated.
(cmd_set_text) : Retrieve the old text of the cell directly.
* src/sheet.c (sheet_set_current_value) : Delete and merge into...
(sheet_accept_pending_input) : Here. Harmonize the logic with.
(sheet_cancel_pending_input) : this function.
(sheet_set_text) : Publicize.
(sheet_stop_editing) : Removed storage of value of cell being edited.
(sheet_start_editing_at_cursor) : Ditto.
* src/workbook.c (accept_input) : Use sheet_accept_pending_input.
(redo_cmd, undo_cmd) : cancel pending input.
2000-01-28 Jody Goldberg <jgoldberg@home.com>
* src/item-grid.c (item_grid_draw) : Pretend that the cell being
edited (and anything it spans) are empty.
* src/sheet.c (sheet_duplicate_colrow) : Delete unused.
2000-01-29 Jon K Hellan <hellan@acm.org>
Megacommit.
......@@ -76,11 +100,12 @@
2000-01-28 Mike Kestner <mkestner@ameritech.net>
* src/sheet-style.c (sheet_style_insert_colrow): Now does option checking
and calls either the new style preserving insert function or the existing
functionality in its new function. (stylish_insert_colrow): New.
Preserves style information by extending ranges that contain the
insertion point. (styleless_insert_colrow): Renamed. Existing algorithm
that fragments style ranges to insert an unformatted col/row.
and calls either the new style preserving insert function or the existing
functionality in its new function.
(stylish_insert_colrow): New. Preserves style information by
extending ranges that contain the insertion point.
(styleless_insert_colrow): Renamed. Existing algorithm that fragments
style ranges to insert an unformatted col/row.
2000-01-28 Michael Meeks <mmeeks@gnu.org>
......
......@@ -317,29 +317,32 @@ cmd_set_text_undo (GnumericCommand *cmd, CommandContext *context)
g_return_val_if_fail (me != NULL, TRUE);
/* Move back to the cell that was edited */
sheet_cursor_move (me->pos.sheet,
me->pos.eval.col,
me->pos.eval.row,
TRUE, TRUE);
/* Save the new value so we can redo */
cell = sheet_cell_get (me->pos.sheet,
me->pos.eval.col,
me->pos.eval.row);
g_return_val_if_fail (cell != NULL, TRUE);
new_text = cell_get_text (cell);
new_text = (cell == NULL || cell->value == NULL || cell->value->type == VALUE_EMPTY)
? NULL : cell_get_text (cell);
/* Restore the old value (possibly empty) */
if (me->text != NULL) {
cell_set_text (cell, me->text);
Range r;
r.start = me->pos.eval;
r.end = me->pos.eval;
sheet_set_text (me->pos.sheet, me->text, &r);
g_free (me->text);
} else
} else if (cell != NULL)
cell_set_value (cell, value_new_empty ());
me->text = new_text;
/* Move back to the cell that was edited, and update the edit area */
sheet_cursor_move (me->pos.sheet,
me->pos.eval.col,
me->pos.eval.row,
TRUE, TRUE);
return FALSE;
}
......@@ -364,8 +367,7 @@ cmd_set_text_destroy (GtkObject *cmd)
gboolean
cmd_set_text (CommandContext *context,
Sheet *sheet, CellPos const * const pos,
char * new_text,
String const * const old_text)
char * new_text)
{
static int const max_descriptor_width = 15;
......@@ -373,6 +375,7 @@ cmd_set_text (CommandContext *context,
CmdSetText *me;
gchar *pad = "";
gchar *text;
Cell *cell;
g_return_val_if_fail (sheet != NULL, TRUE);
g_return_val_if_fail (new_text != NULL, TRUE);
......@@ -385,10 +388,14 @@ cmd_set_text (CommandContext *context,
/* Store the specs for the object */
me->pos.sheet = sheet;
me->pos.eval = *pos;
if (old_text != NULL)
me->text = g_strdup (old_text->str);
else
me->text = NULL;
/* Save the new value so we can redo */
cell = sheet_cell_get (me->pos.sheet,
me->pos.eval.col,
me->pos.eval.row);
me->text = (cell == NULL || cell->value == NULL || cell->value->type == VALUE_EMPTY)
? NULL : cell_get_text (cell);
/* Limit the size of the descriptor to something reasonable */
if (strlen(new_text) > max_descriptor_width) {
......
......@@ -13,8 +13,7 @@ void command_list_release (GSList *cmds);
gboolean cmd_set_text (CommandContext *context,
Sheet *sheet, CellPos const * const pos,
char * new_text,
String const * const old_text);
char * new_text);
gboolean cmd_set_date_time (CommandContext *context, gboolean is_date,
Sheet *sheet, int col, int row);
......
......@@ -445,7 +445,7 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int
continue;
/* If the cell does not exist paint it as an empty cell */
if (cell == NULL) {
if (cell == NULL || sheet->editing_cell == cell) {
item_grid_paint_empty_cell (
drawable, item_grid, ci, ri,
col, row, x_paint, y_paint,
......@@ -470,7 +470,7 @@ item_grid_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int
* cell, adjust x to point to the beginning
* of that cell.
*/
if (cell) {
if (cell != NULL && sheet->editing_cell != cell) {
int i, count, end_col;
/*
......
......@@ -340,19 +340,6 @@ sheet_set_zoom_factor (Sheet *sheet, double factor)
sheet_cells_update (sheet, sheet_get_full_range (), FALSE);
}
/*
* Duplicates a column or row
*/
ColRowInfo *
sheet_duplicate_colrow (ColRowInfo *original)
{
ColRowInfo *info = g_new (ColRowInfo, 1);
*info = *original;
return info;
}
ColRowInfo *
sheet_row_new (Sheet *sheet)
{
......@@ -1297,7 +1284,7 @@ cb_set_cell_value (Sheet *sheet, int col, int row, Cell *cell,
return NULL;
}
static void
void
sheet_set_text (Sheet *sheet, char const *text, Range const * r)
{
g_return_if_fail (sheet != NULL);
......@@ -1329,8 +1316,15 @@ sheet_set_text (Sheet *sheet, char const *text, Range const * r)
&cb_set_cell_text, (void *)text);
}
static void
sheet_stop_editing (Sheet *sheet)
{
sheet->editing = FALSE;
sheet->editing_cell = NULL;
}
void
sheet_set_current_value (Sheet *sheet)
sheet_accept_pending_input (Sheet *sheet)
{
GList *l;
char *str;
......@@ -1339,6 +1333,10 @@ sheet_set_current_value (Sheet *sheet)
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
if (!sheet->editing)
return;
sheet_stop_editing (sheet);
str = gtk_entry_get_text (GTK_ENTRY (sheet->workbook->ea_input));
g_return_if_fail (str != NULL);
......@@ -1356,43 +1354,9 @@ sheet_set_current_value (Sheet *sheet)
/* TODO : Get a context */
/* Store the old value for undo */
if (!cmd_set_text (NULL, sheet, &r.start, str, sheet->editing_saved_text))
if (!cmd_set_text (NULL, sheet, &r.start, str))
sheet_set_text (sheet, str, &r);
for (l = sheet->sheet_views; l; l = l->next){
GnumericSheet *gsheet = GNUMERIC_SHEET_VIEW (l->data);
gnumeric_sheet_destroy_editing_cursor (gsheet);
}
workbook_recalc (sheet->workbook);
}
static void
sheet_stop_editing (Sheet *sheet)
{
sheet->editing = FALSE;
if (sheet->editing_saved_text) {
string_unref (sheet->editing_saved_text);
sheet->editing_saved_text = NULL;
sheet->editing_cell = NULL;
}
}
void
sheet_accept_pending_input (Sheet *sheet)
{
GList *l;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
if (!sheet->editing)
return;
sheet_set_current_value (sheet);
/*
* If user was editing on the input line, get the focus back
*/
......@@ -1403,7 +1367,8 @@ sheet_accept_pending_input (Sheet *sheet)
gnumeric_sheet_stop_editing (gsheet);
}
sheet_stop_editing (sheet);
workbook_recalc (sheet->workbook);
}
void
......@@ -1416,21 +1381,18 @@ sheet_cancel_pending_input (Sheet *sheet)
if (!sheet->editing)
return;
if (sheet->editing_cell) {
const char *oldtext = sheet->editing_saved_text->str;
gtk_entry_set_text (GTK_ENTRY (sheet->workbook->ea_input), oldtext);
cell_set_text (sheet->editing_cell, oldtext);
}
sheet_stop_editing (sheet);
/*
* If user was editing on the input line, get the focus back
*/
workbook_focus_current_sheet (sheet->workbook);
for (l = sheet->sheet_views; l; l = l->next){
GnumericSheet *gsheet = GNUMERIC_SHEET_VIEW (l->data);
gnumeric_sheet_destroy_editing_cursor (gsheet);
}
workbook_recalc (sheet->workbook);
}
/**
......@@ -1477,7 +1439,6 @@ void
sheet_start_editing_at_cursor (Sheet *sheet, gboolean blankp, gboolean cursorp)
{
GList *l;
Cell *cell;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
......@@ -1494,18 +1455,8 @@ sheet_start_editing_at_cursor (Sheet *sheet, gboolean blankp, gboolean cursorp)
}
sheet->editing = TRUE;
cell = sheet_cell_get (sheet, sheet->cursor_col, sheet->cursor_row);
if (cell) {
char *text;
text = cell_get_text (cell);
sheet->editing_saved_text = string_get (text);
g_free (text);
sheet->editing_cell = cell;
if (blankp)
cell_set_text (cell, "");
}
sheet->editing_cell =
sheet_cell_get (sheet, sheet->cursor_col, sheet->cursor_row);
}
/**
......
......@@ -119,13 +119,9 @@ struct _Sheet {
double last_zoom_factor_used;
/*
* When editing a cell: the cell (may be NULL) and
* the original text of the cell
*/
String *editing_saved_text;
/* When editing a cell: the cell (may be NULL) */
Cell *editing_cell;
int editing;
int editing;
/* Objects */
SheetModeType mode; /* Sheet mode */
......@@ -220,9 +216,6 @@ double * sheet_save_row_col_sizes (Sheet *sheet, gboolean const is_cols,
void sheet_restore_row_col_sizes (Sheet *sheet, gboolean const is_cols,
int index, int count, double *);
/* Duplicates the information of a col/row */
ColRowInfo *sheet_duplicate_colrow (ColRowInfo *original);
/* Retrieve information from a col/row */
ColRowInfo *sheet_col_get_info (Sheet const *sheet, int const col);
ColRowInfo *sheet_row_get_info (Sheet const *sheet, int const row);
......@@ -350,10 +343,10 @@ void sheet_update_controls (Sheet *sheet);
* Sheet visual editing
*/
void sheet_start_editing_at_cursor (Sheet *sheet, gboolean blankp, gboolean cursorp);
void sheet_set_current_value (Sheet *sheet);
void sheet_accept_pending_input (Sheet *sheet);
void sheet_cancel_pending_input (Sheet *sheet);
void sheet_load_cell_val (Sheet *sheet);
void sheet_set_text (Sheet *sheet, char const *text, Range const * r);
int sheet_col_selection_type (Sheet const *sheet, int col);
int sheet_row_selection_type (Sheet const *sheet, int row);
......
......@@ -611,15 +611,33 @@ quit_cmd (void)
g_list_free (n);
}
static void
accept_input (GtkWidget *IGNORED, Workbook *wb)
{
Sheet *sheet = wb->current_sheet;
sheet_accept_pending_input (sheet);
workbook_focus_current_sheet (wb);
}
static void
cancel_input (GtkWidget *IGNORED, Workbook *wb)
{
Sheet *sheet = wb->current_sheet;
sheet_cancel_pending_input (sheet);
workbook_focus_current_sheet (wb);
}
static void
undo_cmd (GtkWidget *widget, Workbook *wb)
{
cancel_input (NULL, wb);
command_undo (workbook_command_context_gui (wb), wb);
}
static void
redo_cmd (GtkWidget *widget, Workbook *wb)
{
cancel_input (NULL, wb);
command_redo (workbook_command_context_gui (wb), wb);
}
......@@ -1590,22 +1608,6 @@ workbook_set_region_status (Workbook *wb, const char *str)
gtk_entry_set_text (GTK_ENTRY (wb->ea_status), str);
}
static void
accept_input (GtkWidget *widget, Workbook *wb)
{
Sheet *sheet = wb->current_sheet;
sheet_set_current_value (sheet);
workbook_focus_current_sheet (wb);
}
static void
cancel_input (GtkWidget *widget, Workbook *wb)
{
Sheet *sheet = wb->current_sheet;
sheet_cancel_pending_input (sheet);
workbook_focus_current_sheet (wb);
}
static void
wizard_input (GtkWidget *widget, Workbook *wb)
{
......@@ -1986,7 +1988,6 @@ workbook_persist_file_load (BonoboPersistFile *ps, const CORBA_char *filename, v
{
Workbook *wb = closure;
CommandContext *context = workbook_command_context_gui (wb);
return workbook_load_from (context, wb, filename);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment