Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
gnumeric
Commits
a52c1166
Commit
a52c1166
authored
Aug 13, 1998
by
Arturo Espinosa
Browse files
Walking trough selections/tab/enter walking
parent
f1c7b189
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/clipboard.c
View file @
a52c1166
...
...
@@ -10,6 +10,7 @@
#include
<gnome.h>
#include
"gnumeric.h"
#include
"clipboard.h"
#include
"eval.h"
typedef
struct
{
int
base_col
,
base_row
;
...
...
@@ -83,7 +84,11 @@ clipboard_paste_region (CellRegion *region, Sheet *dest_sheet, int dest_col, int
for
(
l
=
region
->
list
;
l
;
l
=
l
->
next
){
CellCopy
*
c_copy
=
l
->
data
;
Cell
*
new_cell
;
int
target_col
,
target_row
;
target_col
=
dest_col
+
c_copy
->
col_offset
;
target_row
=
dest_row
+
c_copy
->
row_offset
;
/* FIXME: create a cell_copy_flags that uses
* the bits more or less like paste_flags.
*
...
...
@@ -94,9 +99,7 @@ clipboard_paste_region (CellRegion *region, Sheet *dest_sheet, int dest_col, int
*/
new_cell
=
cell_copy
(
c_copy
->
cell
);
sheet_cell_add
(
dest_sheet
,
new_cell
,
dest_col
+
c_copy
->
col_offset
,
dest_row
+
c_copy
->
row_offset
);
sheet_cell_add
(
dest_sheet
,
new_cell
,
target_col
,
target_row
);
if
(
new_cell
->
parsed_node
)
cell_queue_recalc
(
new_cell
);
}
...
...
src/gnumeric-canvas.c
View file @
a52c1166
...
...
@@ -557,10 +557,25 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
(
*
movefn_vertical
)(
gsheet
,
1
);
break
;
case
GDK_Tab
:
case
GDK_Return
:
g_warning
(
"FIXME: Should move to next cell in selection
\n
"
);
move_cursor
(
gsheet
,
gsheet
->
cursor_col
,
gsheet
->
cursor_row
,
0
);
{
int
col
,
row
;
int
walking_selection
;
int
direction
,
horizontal
;
/* Figure out the direction */
direction
=
(
event
->
state
&
GDK_SHIFT_MASK
)
?
0
:
1
;
horizontal
=
(
event
->
keyval
==
GDK_Tab
)
?
1
:
0
;
selection_remove_selection_string
(
gsheet
);
walking_selection
=
sheet_selection_walk_step
(
gsheet
->
sheet
,
direction
,
horizontal
,
gsheet
->
cursor_col
,
gsheet
->
cursor_row
,
&
col
,
&
row
);
move_cursor
(
gsheet
,
col
,
row
,
walking_selection
==
0
);
break
;
}
case
GDK_Escape
:
cancel_pending_input
(
gsheet
);
...
...
src/gnumeric-sheet.c
View file @
a52c1166
...
...
@@ -557,10 +557,25 @@ gnumeric_sheet_key (GtkWidget *widget, GdkEventKey *event)
(
*
movefn_vertical
)(
gsheet
,
1
);
break
;
case
GDK_Tab
:
case
GDK_Return
:
g_warning
(
"FIXME: Should move to next cell in selection
\n
"
);
move_cursor
(
gsheet
,
gsheet
->
cursor_col
,
gsheet
->
cursor_row
,
0
);
{
int
col
,
row
;
int
walking_selection
;
int
direction
,
horizontal
;
/* Figure out the direction */
direction
=
(
event
->
state
&
GDK_SHIFT_MASK
)
?
0
:
1
;
horizontal
=
(
event
->
keyval
==
GDK_Tab
)
?
1
:
0
;
selection_remove_selection_string
(
gsheet
);
walking_selection
=
sheet_selection_walk_step
(
gsheet
->
sheet
,
direction
,
horizontal
,
gsheet
->
cursor_col
,
gsheet
->
cursor_row
,
&
col
,
&
row
);
move_cursor
(
gsheet
,
col
,
row
,
walking_selection
==
0
);
break
;
}
case
GDK_Escape
:
cancel_pending_input
(
gsheet
);
...
...
src/sheet.c
View file @
a52c1166
...
...
@@ -1059,7 +1059,8 @@ sheet_selection_clear_only (Sheet *sheet)
}
g_list_free
(
sheet
->
selections
);
sheet
->
selections
=
NULL
;
sheet
->
walk_info
.
current
=
NULL
;
/* Unselect the column bar */
if
(
clean_bar_selection
(
sheet
->
cols_info
)
>
0
)
gnome_canvas_request_redraw
(
GNOME_CANVAS
(
sheet
->
col_canvas
),
...
...
@@ -1108,6 +1109,93 @@ sheet_selection_is_cell_selected (Sheet *sheet, int col, int row)
return
0
;
}
/*
* walk_boundaries: implements the decitions for walking a region
* returns TRUE if the cursor left the boundary region
*/
static
int
walk_boundaries
(
int
lower_col
,
int
lower_row
,
int
upper_col
,
int
upper_row
,
int
inc_x
,
int
inc_y
,
int
current_col
,
int
current_row
,
int
*
new_col
,
int
*
new_row
,
int
wrap
)
{
if
(
current_row
+
inc_y
==
upper_row
||
current_col
+
inc_x
==
upper_col
){
*
new_row
=
current_row
;
*
new_col
=
current_col
;
return
TRUE
;
}
else
{
if
(
current_row
+
inc_y
<
lower_row
||
current_col
+
inc_x
<
lower_col
){
*
new_row
=
current_row
;
*
new_col
=
current_col
;
return
TRUE
;
}
else
{
*
new_row
=
current_row
+
inc_y
;
*
new_col
=
current_col
+
inc_x
;
}
}
return
FALSE
;
}
int
sheet_selection_walk_step
(
Sheet
*
sheet
,
int
forward
,
int
horizontal
,
int
current_col
,
int
current_row
,
int
*
new_col
,
int
*
new_row
)
{
int
inc_x
=
0
,
inc_y
=
0
,
diff
,
overflow
;
diff
=
forward
?
1
:
-
1
;
if
(
horizontal
)
inc_x
=
diff
;
else
inc_y
=
diff
;
if
(
g_list_length
(
sheet
->
selections
)
==
1
){
SheetSelection
*
ss
=
sheet
->
selections
->
data
;
/* If there is no selection besides the cursor, plain movement */
if
(
ss
->
start_col
==
ss
->
end_col
&&
ss
->
start_row
==
ss
->
end_row
){
walk_boundaries
(
0
,
0
,
SHEET_MAX_COLS
,
SHEET_MAX_ROWS
,
inc_x
,
inc_y
,
current_col
,
current_row
,
new_col
,
new_row
,
FALSE
);
return
FALSE
;
}
}
if
(
!
sheet
->
walk_info
.
current
)
sheet
->
walk_info
.
current
=
sheet
->
selections
->
data
;
do
{
SheetSelection
*
ss
=
sheet
->
walk_info
.
current
;
overflow
=
walk_boundaries
(
ss
->
start_col
,
ss
->
start_row
,
ss
->
end_col
,
ss
->
end_row
,
inc_x
,
inc_y
,
current_col
,
current_row
,
new_col
,
new_row
,
TRUE
);
if
(
overflow
){
GList
*
l
=
sheet
->
selections
;
for
(;
l
;
l
=
l
->
next
){
if
(
l
->
data
!=
sheet
->
walk_info
.
current
)
continue
;
l
=
l
->
next
;
sheet
->
walk_info
.
current
=
l
?
l
->
data
:
sheet
->
selections
->
data
;
*
new_col
=
ss
->
start_col
;
*
new_row
=
ss
->
start_row
;
return
TRUE
;
}
}
}
while
(
overflow
);
return
TRUE
;
}
/*
* Returns an allocated column: either an existing one, or a fresh copy
*/
...
...
src/sheet.h
View file @
a52c1166
...
...
@@ -77,6 +77,11 @@ typedef struct {
/* The list of formulas */
GList
*
formula_cell_list
;
/* For walking trough a selection */
struct
{
SheetSelection
*
current
;
}
walk_info
;
}
Sheet
;
#define SHEET_SIGNATURE 0x12349876
...
...
@@ -120,7 +125,10 @@ void sheet_selection_cut (Sheet *sheet);
void
sheet_selection_paste
(
Sheet
*
sheet
,
int
dest_col
,
int
dest_row
,
int
paste_flags
);
int
sheet_selection_walk_step
(
Sheet
*
sheet
,
int
forward
,
int
horizontal
,
int
current_col
,
int
current_row
,
int
*
new_col
,
int
*
new_row
);
void
sheet_selection_extend_horizontal
(
Sheet
*
sheet
,
int
count
);
void
sheet_selection_extend_vertical
(
Sheet
*
sheet
,
int
count
);
int
sheet_selection_is_cell_selected
(
Sheet
*
sheet
,
int
col
,
int
row
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment