From bdf4a8dc4108b46b14d4b8eb4ff1fe3c5e398b8f Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Mon, 24 Aug 1998 06:16:56 +0000 Subject: [PATCH] fixes to get traversal into table first time to work correctly git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1042 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/register/cellblock.c | 14 ++++++++++++-- src/register/cellblock.h | 8 ++++++++ src/register/table-allgui.c | 11 +++++++---- src/register/table-motif.c | 8 +++++++- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/register/cellblock.c b/src/register/cellblock.c index d96b08c8d3..2051a6a74e 100644 --- a/src/register/cellblock.c +++ b/src/register/cellblock.c @@ -131,6 +131,10 @@ xaccInitCellBlock (CellBlock *arr, int numrows, int numcols) (arr->right_traverse_r)[numrows-1][numcols-1] = 0; (arr->right_traverse_c)[numrows-1][numcols-1] = 0; + /* last is last ... */ + arr->last_reenter_traverse_row = numrows-1; + arr->last_reenter_traverse_col = numcols-1; + arr->widths = (short *) malloc (numcols * sizeof(short)); arr->alignments = (unsigned char *) malloc (numcols * sizeof(unsigned char)); @@ -182,14 +186,20 @@ xaccNextRight (CellBlock *arr, int row, int col, if ((0 > row) || (0 > col)) return; if ((row >= arr->numRows) || (col >= arr->numCols)) return; - /* -1 is a valid value for next ... it signifies - * that traversal should go to next tab group */ + /* -1 is a valid value for next ... it signifies that traversal + * should go to next tab group, so do not check for neg values */ /* if ((0 > next_row) || (0 > next_col)) return; */ if ((next_row >= arr->numRows) || (next_col >= arr->numCols)) return; (arr->right_traverse_r)[row][col] = next_row; (arr->right_traverse_c)[row][col] = next_col; + /* if traversing out (neg values) record this as the last ... */ + if ((0 > next_row) || (0 > next_col)) { + arr->last_reenter_traverse_row = row; + arr->last_reenter_traverse_col = col; + } + } /* --------------- end of file ----------------- */ diff --git a/src/register/cellblock.h b/src/register/cellblock.h index 34592a3cfe..3adff89a44 100644 --- a/src/register/cellblock.h +++ b/src/register/cellblock.h @@ -91,6 +91,14 @@ struct _CellBlock { * shift-tab is hit), but we haven't (yet) done so. */ + /* the last-reneter row and column should contain the very last + * cell when the cursor was traversed out of. They determine + * the first cell that will be entered (since the first follows + * the last). + */ + short last_reenter_traverse_row; + short last_reenter_traverse_col; + void * user_data; /* above is a pointer to anything the programmer-user of this struct * wants it to be. Handy for stuff. diff --git a/src/register/table-allgui.c b/src/register/table-allgui.c index ed73f99c61..24115580bc 100644 --- a/src/register/table-allgui.c +++ b/src/register/table-allgui.c @@ -383,8 +383,8 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col, int do_move_gui) table->current_cursor_phys_col = -1; table->current_cursor_virt_row = -1; table->current_cursor_virt_col = -1; - table->prev_phys_traverse_row = 0; - table->prev_phys_traverse_col = 0; + table->prev_phys_traverse_row = -1; + table->prev_phys_traverse_col = -1; curs = table->current_cursor; if (curs) curs->user_data = NULL; table->current_cursor = NULL; @@ -433,8 +433,11 @@ doMoveCursor (Table *table, int new_phys_row, int new_phys_col, int do_move_gui) table->current_cursor_phys_row = phys_row_origin; table->current_cursor_phys_col = phys_col_origin; - table->prev_phys_traverse_row = phys_row_origin; - table->prev_phys_traverse_col = phys_col_origin; + + /* setting the previous traversal value to the last of a traversal chain will + * gaurentee that first entry into a register will occur at the first cell */ + table->prev_phys_traverse_row = phys_row_origin + curs->last_reenter_traverse_row; + table->prev_phys_traverse_col = phys_col_origin + curs->last_reenter_traverse_col; /* update the cell values to reflect the new position */ for (i=0; inumRows; i++) { diff --git a/src/register/table-motif.c b/src/register/table-motif.c index 12d95e78c9..11c9d0f8bc 100644 --- a/src/register/table-motif.c +++ b/src/register/table-motif.c @@ -433,16 +433,22 @@ traverseCB (Widget mw, XtPointer cd, XtPointer cb) * row and column to that of the ComboCell, which we had * previously recorded, and continue on as if nothing * happened. + * * BTW -- note that we are emulating a normal, right-moving tab. * Backwards tabs are broken. + * + * Note that the quark may also be zero if we are entering + * the register for the first time after a table resize. */ - if (NULLQUARK == cbs->qparam) { + if (NULLQUARK == cbs->qparam) { if ((0==row) && (0==col)) { if ((0 <= table->prev_phys_traverse_row) && (0 <= table->prev_phys_traverse_col)) { cbs->qparam = QRight; row = table->prev_phys_traverse_row; col = table->prev_phys_traverse_col; + if (0 > row) row = 0; + if (0 > col) col = 0; } } }