Commit 77d84d6c authored by Jody Goldberg's avatar Jody Goldberg Committed by Jody Goldberg

New files.


2000-05-21  Jody Goldberg <jgoldberg@home.com>

	* src/cmd-edit.[ch] : New files.

	* src/workbook.c (cb_edit_select_*) : Use the cmd-edit utilities.
	Make a 'select' sub menu of edit.

	* src/sheet.c : Use the newly added CellPos in each Cell rather than
	  mallocing a seperate struct.

	* src/selection.c (sheet_select_all) : Move.

	* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Make the
	  selection commands accelerators.
parent c56a9a92
2000-05-21 Jody Goldberg <jgoldberg@home.com>
* src/cmd-edit.[ch] : New files.
* src/workbook.c (cb_edit_select_*) : Use the cmd-edit utilities.
Make a 'select' sub menu of edit.
* src/sheet.c : Use the newly added CellPos in each Cell rather than
mallocing a seperate struct.
* src/selection.c (sheet_select_all) : Move.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Make the
selection commands accelerators.
2000-05-21 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.[ch] (gnumeric_toolbar_insert_with_eventbox):
......
2000-05-21 Jody Goldberg <jgoldberg@home.com>
* src/cmd-edit.[ch] : New files.
* src/workbook.c (cb_edit_select_*) : Use the cmd-edit utilities.
Make a 'select' sub menu of edit.
* src/sheet.c : Use the newly added CellPos in each Cell rather than
mallocing a seperate struct.
* src/selection.c (sheet_select_all) : Move.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Make the
selection commands accelerators.
2000-05-21 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.[ch] (gnumeric_toolbar_insert_with_eventbox):
......
Gnumeric 0.55
Jody:
* Speedup workbook exit, copy/paste.
Translations:
* Updated: de (Karl), ja (Oka), no (Kjartan), and more.
......@@ -12,7 +15,6 @@ Jacob:
Jody:
* Bug fixes.
* Initial applix import.
* Speedup workbook exit, copy/paste.
* Improve row/col insert/del.
JonKare:
......
2000-05-21 Jody Goldberg <jgoldberg@home.com>
* src/cmd-edit.[ch] : New files.
* src/workbook.c (cb_edit_select_*) : Use the cmd-edit utilities.
Make a 'select' sub menu of edit.
* src/sheet.c : Use the newly added CellPos in each Cell rather than
mallocing a seperate struct.
* src/selection.c (sheet_select_all) : Move.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Make the
selection commands accelerators.
2000-05-21 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.[ch] (gnumeric_toolbar_insert_with_eventbox):
......
2000-05-21 Jody Goldberg <jgoldberg@home.com>
* src/cmd-edit.[ch] : New files.
* src/workbook.c (cb_edit_select_*) : Use the cmd-edit utilities.
Make a 'select' sub menu of edit.
* src/sheet.c : Use the newly added CellPos in each Cell rather than
mallocing a seperate struct.
* src/selection.c (sheet_select_all) : Move.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Make the
selection commands accelerators.
2000-05-21 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.[ch] (gnumeric_toolbar_insert_with_eventbox):
......
2000-05-21 Jody Goldberg <jgoldberg@home.com>
* src/cmd-edit.[ch] : New files.
* src/workbook.c (cb_edit_select_*) : Use the cmd-edit utilities.
Make a 'select' sub menu of edit.
* src/sheet.c : Use the newly added CellPos in each Cell rather than
mallocing a seperate struct.
* src/selection.c (sheet_select_all) : Move.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Make the
selection commands accelerators.
2000-05-21 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.[ch] (gnumeric_toolbar_insert_with_eventbox):
......
2000-05-21 Jody Goldberg <jgoldberg@home.com>
* src/cmd-edit.[ch] : New files.
* src/workbook.c (cb_edit_select_*) : Use the cmd-edit utilities.
Make a 'select' sub menu of edit.
* src/sheet.c : Use the newly added CellPos in each Cell rather than
mallocing a seperate struct.
* src/selection.c (sheet_select_all) : Move.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Make the
selection commands accelerators.
2000-05-21 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.[ch] (gnumeric_toolbar_insert_with_eventbox):
......
2000-05-21 Jody Goldberg <jgoldberg@home.com>
* src/cmd-edit.[ch] : New files.
* src/workbook.c (cb_edit_select_*) : Use the cmd-edit utilities.
Make a 'select' sub menu of edit.
* src/sheet.c : Use the newly added CellPos in each Cell rather than
mallocing a seperate struct.
* src/selection.c (sheet_select_all) : Move.
* src/gnumeric-sheet.c (gnumeric_sheet_key_mode_sheet) : Make the
selection commands accelerators.
2000-05-21 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.[ch] (gnumeric_toolbar_insert_with_eventbox):
......
......@@ -58,6 +58,8 @@ GNUMERIC_BASE_SOURCES = \
cellspan.h \
clipboard.c \
clipboard.h \
cmd-edit.h \
cmd-edit.c \
collect.h \
collect.c \
color.c \
......
......@@ -9,10 +9,18 @@
typedef enum {
/* Cell has an expression rather than entered_text */
CELL_HAS_EXPRESSION = 1,
CELL_HAS_EXPRESSION = 0x1,
/* Cell has been queued for recalc */
CELL_QUEUED_FOR_RECALC = 2
CELL_QUEUED_FOR_RECALC = 0x2,
#if TODO
/* Cell has be linked into the workbook wide expression list */
CELL_IN_EXPR_LIST = 0x4,
/* Cell is linked into the sheet */
CELL_IN_SHEET_LIST = 0x8
#endif
} CellFlags;
typedef struct _CellComment CellComment;
......@@ -20,6 +28,7 @@ typedef struct _CellComment CellComment;
/* Definition of a Gnumeric Cell */
struct _Cell {
/* Mandatory state information */
CellPos pos;
CellFlags cell_flags;
Sheet *sheet;
ColRowInfo *col_info;
......
/* vim: set sw=8:
* $Id$
*/
/*
* cmd-edit.c: Various commands to be used by the edit menu.
*
* Copyright (C) 2000 Jody Goldberg (jgoldberg@home.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#include "config.h"
#include "cmd-edit.h"
#include "selection.h"
#include "sheet.h"
#include "cell.h"
#include "expr.h"
#include "eval.h"
#include "parse-util.h"
#include "stdio.h"
/**
* cmd_select_all:
* @sheet: The sheet
*
* Selects all of the cells in the sheet
*/
void
cmd_select_all (Sheet *sheet)
{
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet, 0, 0, 0, 0,
SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1);
sheet_update (sheet);
}
/**
* cmd_select_cur_row:
* @sheet: The sheet
*
* Selects an entire row
*/
void
cmd_select_cur_row (Sheet *sheet)
{
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet,
sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row,
0, sheet->cursor.edit_pos.row,
SHEET_MAX_COLS-1, sheet->cursor.edit_pos.row);
sheet_update (sheet);
}
/**
* cmd_select_cur_col:
* @sheet: The sheet
*
* Selects an entire column
*/
void
cmd_select_cur_col (Sheet *sheet)
{
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet,
sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row,
sheet->cursor.edit_pos.col, 0,
sheet->cursor.edit_pos.col, SHEET_MAX_ROWS-1);
sheet_update (sheet);
}
/**
* cmd_select_cur_array :
* @sheet: The sheet
*
* if the current cell is part of an array select
* the entire array.
*/
void
cmd_select_cur_array (Sheet *sheet)
{
ExprArray const *array;
int col, row;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
col = sheet->cursor.edit_pos.col;
row = sheet->cursor.edit_pos.row;
array = cell_is_array (sheet_cell_get (sheet, col, row));
if (array == NULL)
return;
sheet_selection_reset_only (sheet);
/*
* leave the edit cell where it is,
* select the entire array.
*/
sheet_selection_add_range (sheet, col, row,
col - array->x, row - array->y,
col - array->x + array->cols,
row - array->y + array->rows);
sheet_update (sheet);
}
static gint
cb_compare_deps (gconstpointer a, gconstpointer b)
{
Cell const *cell_a = a;
Cell const *cell_b = b;
int tmp;
tmp = cell_a->row_info->pos - cell_b->row_info->pos;
if (tmp != 0)
return tmp;
return cell_a->col_info->pos - cell_b->col_info->pos;
}
/**
* cmd_select_cur_depends :
* @sheet: The sheet
*
* Select all cells that depend on the expression in the current cell.
*/
void
cmd_select_cur_depends (Sheet *sheet)
{
Cell *cur_cell;
GList *deps, *ptr = NULL;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
cur_cell = sheet_cell_get (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
if (cur_cell == NULL)
return;
deps = cell_get_dependencies (cur_cell);
if (deps == NULL)
return;
sheet_selection_reset_only (sheet);
/* Short circuit */
if (g_list_length (deps) == 1) {
Cell *cell = deps->data;
sheet_selection_add (sheet, cell->col_info->pos, cell->row_info->pos);
} else {
Range *cur = NULL;
ptr = NULL;
/* Merge the sorted list of cells into rows */
for (deps = g_list_sort (deps, &cb_compare_deps) ; deps ; ) {
Cell *cell = deps->data;
if (cur == NULL ||
cur->end.row != cell->row_info->pos ||
cur->end.col+1 != cell->col_info->pos) {
if (cur)
ptr = g_list_prepend (ptr, cur);
cur = g_new (Range, 1);
cur->start.row = cur->end.row = cell->row_info->pos;
cur->start.col = cur->end.col = cell->col_info->pos;
} else
cur->end.col = cell->col_info->pos;
deps = g_list_remove (deps, cell);
}
if (cur)
ptr = g_list_prepend (ptr, cur);
/* Merge the coalesced rows into ranges */
deps = ptr;
for (ptr = NULL ; deps ; ) {
Range *r1 = deps->data;
GList *fwd;
for (fwd = deps->next ; fwd ; ) {
Range *r2 = fwd->data;
if (r1->start.col == r2->start.col &&
r1->end.col == r2->end.col &&
r1->start.row-1 == r2->end.row) {
r1->start.row = r2->start.row;
g_free (fwd->data);
fwd = g_list_remove (fwd, r2);
} else
fwd = fwd->next;
}
ptr = g_list_prepend (ptr, r1);
deps = g_list_remove (deps, r1);
}
/* now select the ranges */
while (ptr) {
Range *r = ptr->data;
sheet_selection_add_range (sheet,
r->start.col, r->start.row,
r->start.col, r->start.row,
r->end.col, r->end.row);
g_free (ptr->data);
ptr = g_list_remove (ptr, r);
}
}
sheet_update (sheet);
}
/**
* cmd_select_cur_inputs :
* @sheet: The sheet
*
* Select all cells that are direct potential inputs to the
* current cell.
*/
void
cmd_select_cur_inputs (Sheet *sheet)
{
Cell *cell;
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
cell = sheet_cell_get (sheet,
sheet->cursor.edit_pos.col,
sheet->cursor.edit_pos.row);
if (cell == NULL || !cell_has_expr (cell))
return;
/* TODO : finish this */
sheet_update (sheet);
}
#ifndef GNUMERIC_CMD_EDIT_H
#define GNUMERIC_CMD_EDIT_H
#include "gnumeric.h"
void cmd_select_all (Sheet *sheet);
void cmd_select_cur_row (Sheet *sheet);
void cmd_select_cur_col (Sheet *sheet);
void cmd_select_cur_array (Sheet *sheet);
void cmd_select_cur_depends (Sheet *sheet);
void cmd_select_cur_inputs (Sheet *sheet);
#endif /* GNUMERIC_CMD_EDIT_H */
......@@ -28,6 +28,7 @@
#include "sheet-private.h"
#include "cell-comment.h"
#include "rendered-value.h"
#include "cmd-edit.h"
#define verify(cond) if (!(cond)){ out_of_range (ev); return; }
#define verify_val(cond,val) if (!(cond)){ out_of_range (ev); return (val); }
......@@ -138,8 +139,7 @@ static void
Sheet_select_all (PortableServer_Servant servant, CORBA_Environment *ev)
{
Sheet *sheet = sheet_from_servant (servant);
sheet_select_all (sheet);
cmd_select_all (sheet);
}
static CORBA_boolean
......
......@@ -90,7 +90,7 @@ struct _ExprArray {
int ref_count;
int x, y;
int rows, cols;
int cols, rows;
union {
/* Upper left corner */
struct {
......
......@@ -630,31 +630,12 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
}
}
/* If not editing {Ctrl,Shift}space select a full col/row */
if (!wb->editing && event->keyval == GDK_space) {
/* select full column */
if ((event->state & GDK_CONTROL_MASK) != 0) {
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet,
sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row,
sheet->cursor.edit_pos.col, 0,
sheet->cursor.edit_pos.col, SHEET_MAX_ROWS-1);
sheet_redraw_all (sheet);
return 1;
}
/* select full row */
if ((event->state & GDK_SHIFT_MASK) != 0){
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet,
sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row,
0, sheet->cursor.edit_pos.row,
SHEET_MAX_COLS-1, sheet->cursor.edit_pos.row);
sheet_redraw_all (sheet);
return 1;
}
}
/*
* Magic : Some of these are accelerators,
* we need to catch them before entering because they appear to be printable
*/
if (event->keyval == GDK_space && (event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK)) )
return FALSE;
switch (event->keyval){
case GDK_KP_Left:
......
......@@ -630,31 +630,12 @@ gnumeric_sheet_key_mode_sheet (GnumericSheet *gsheet, GdkEventKey *event)
}
}
/* If not editing {Ctrl,Shift}space select a full col/row */
if (!wb->editing && event->keyval == GDK_space) {
/* select full column */
if ((event->state & GDK_CONTROL_MASK) != 0) {
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet,
sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row,
sheet->cursor.edit_pos.col, 0,
sheet->cursor.edit_pos.col, SHEET_MAX_ROWS-1);
sheet_redraw_all (sheet);
return 1;
}
/* select full row */
if ((event->state & GDK_SHIFT_MASK) != 0){
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet,
sheet->cursor.edit_pos.col, sheet->cursor.edit_pos.row,
0, sheet->cursor.edit_pos.row,
SHEET_MAX_COLS-1, sheet->cursor.edit_pos.row);
sheet_redraw_all (sheet);
return 1;
}
}
/*
* Magic : Some of these are accelerators,
* we need to catch them before entering because they appear to be printable
*/
if (event->keyval == GDK_space && (event->state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK)) )
return FALSE;
switch (event->keyval){
case GDK_KP_Left:
......
......@@ -229,26 +229,6 @@ sheet_selection_extend (Sheet *sheet, int n, gboolean jump_to_boundaries,
sheet_make_cell_visible (sheet, tmp.col, tmp.row);
}
/**
* sheet_select_all:
* Sheet: The sheet
*
* Selects all of the cells in the sheet
*/
void
sheet_select_all (Sheet *sheet)
{
g_return_if_fail (sheet != NULL);
g_return_if_fail (IS_SHEET (sheet));
sheet_selection_reset_only (sheet);
sheet_selection_add_range (sheet, 0, 0, 0, 0,
SHEET_MAX_COLS-1, SHEET_MAX_ROWS-1);
/* Queue redraws for columns and rows */
sheet_redraw_headers (sheet, TRUE, TRUE, NULL);
}
gboolean
sheet_is_all_selected (Sheet const * const sheet)
{
......
......@@ -7,7 +7,6 @@
gboolean sheet_is_all_selected (Sheet const * const sheet);
gboolean sheet_is_cell_selected (Sheet const * const sheet, int col, int row);
gboolean sheet_is_range_selected (Sheet const * const sheet, Range const *r);
void sheet_select_all (Sheet *sheet);
void sheet_selection_extend_to (Sheet *sheet, int col, int row);
void sheet_selection_extend (Sheet *sheet, int count, gboolean jump_to_boundaries,
gboolean const horizontal);
......
......@@ -23,6 +23,7 @@
#include "selection.h"
#include "application.h"
#include "cellspan.h"
#include "cmd-edit.h"
static GtkTableClass *sheet_view_parent_class;
......@@ -467,8 +468,7 @@ sheet_view_row_size_changed (ItemBar *item_bar, int row, int height, SheetView *
static void
button_select_all (GtkWidget *the_button, SheetView *sheet_view)
{
sheet_select_all (sheet_view->sheet);
sheet_redraw_all (sheet_view->sheet);
cmd_select_all (sheet_view->sheet);
}
static void
......
......@@ -23,6 +23,7 @@
#include "selection.h"
#include "application.h"
#include "cellspan.h"
#include "cmd-edit.h"
static GtkTableClass *sheet_view_parent_class;
......@@ -467,8 +468,7 @@ sheet_view_row_size_changed (ItemBar *item_bar, int row, int height, SheetView *
static void
button_select_all (GtkWidget *the_button, SheetView *sheet_view)
{
sheet_select_all (sheet_view->sheet);
sheet_redraw_all (sheet_view->sheet);
cmd_select_all (sheet_view->sheet);
}
static void
......
......@@ -93,15 +93,15 @@ sheet_redraw_headers (Sheet const *sheet,
static guint
cell_hash (gconstpointer key)
{
const CellPos *ca = (const CellPos *) key;
Cell const *cell = key;
return (ca->row << 8) | ca->col;
return (cell->pos.row << 8) | cell->pos.col;
}
static gint
cell_compare (CellPos const * a, CellPos const * b)
cell_compare (Cell const * a, Cell const * b)
{
return (a->row == b->row && a->col == b->col);
return (a->pos.row == b->pos.row && a->pos.col == b->pos.col);
}
void
......@@ -784,13 +784,13 @@ inline Cell *
sheet_cell_get (Sheet const *sheet, int col, int row)
{
Cell *cell;
CellPos cellpos;
Cell cellpos;
g_return_val_if_fail (sheet != NULL, NULL);
g_return_val_if_fail (IS_SHEET (sheet), NULL);
cellpos.col = col;
cellpos.row = row;
cellpos.pos.col = col;
cellpos.pos.row = row;
cell = g_hash_table_lookup (sheet->cell_hash, &cellpos);
return cell;
......@@ -873,7 +873,7 @@ sheet_get_extent (Sheet const *sheet)
g_return_val_if_fail (sheet != NULL, r);
g_return_val_if_fail (IS_SHEET (sheet), r);
g_hash_table_foreach(sheet->cell_hash, sheet_get_extent_cb, &r);
g_hash_table_foreach(sheet->cell_hash, &sheet_get_extent_cb, &r);
if (r.start.col >= SHEET_MAX_COLS - 2)
r.start.col = 0;
......@@ -1865,18 +1865,15 @@ sheet_is_region_empty_or_selected (Sheet *sheet, int start_col, int start_row, i
static void
sheet_cell_add_to_hash (Sheet *sheet, Cell *cell)
{
CellPos *cellpos;
g_return_if_fail (cell->col_info != NULL);
g_return_if_fail (cell->col_info->pos < SHEET_MAX_COLS);
g_return_if_fail (cell->row_info != NULL);
g_return_if_fail (cell->row_info->pos < SHEET_MAX_ROWS);
cellpos = g_new (CellPos, 1);
cellpos->col = cell->col_info->pos;
cellpos->row = cell->row_info->pos;
cell->pos.col = cell->col_info->pos;
cell->pos.row = cell->row_info->pos;
g_hash_table_insert (sheet->cell_hash, cellpos, cell);
g_hash_table_insert (sheet->cell_hash, cell, cell);
}
void
......@@ -1916,19 +1913,17 @@ sheet_cell_new (Sheet *sheet, int col, int row)
static void
sheet_cell_remove_from_hash (Sheet *sheet, Cell *cell)
{
CellPos cellpos;
gpointer original_key;
Cell cellpos;
cellpos.col = cell->col_info->pos;
cellpos.row = cell->row_info->pos;
cellpos.pos.col = cell->col_info->pos;
cellpos.pos.row = cell->row_info->pos;
cell_unregister_span (cell);
cell_drop_dependencies (cell);
if (g_hash_table_lookup_extended (sheet->cell_hash, &cellpos, &original_key, NULL)) {
if (g_hash_table_lookup (sheet->cell_hash, &cellpos))
g_hash_table_remove (sheet->cell_hash, &cellpos);
g_free (original_key);
} else
else
g_warning ("Cell not in hash table |\n");
}
......
......@@ -40,6 +40,7 @@
#include "wizard.h"
#include "gutils.h"
#include "rendered-value.h"
#include "cmd-edit.h"
#ifdef ENABLE_BONOBO
#include <bonobo/bonobo-persist-file.h>
......@@ -709,13 +710,31 @@ delete_sheet_cmd (GtkWidget *widget, Workbook *wb)
sheet_action_delete_sheet (widget, wb->current_sheet);
}
/* Callbacjs for the selection commands */
static void
select_all_cmd (GtkWidget *widget, Workbook *wb)
cb_edit_select_all (GtkWidget *widget, Workbook *wb)
{
Sheet *sheet = wb->current_sheet;