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
This commit is contained in:
Linas Vepstas 1998-08-24 06:16:56 +00:00
parent 9b24b1dd57
commit bdf4a8dc41
4 changed files with 34 additions and 7 deletions

View File

@ -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 ----------------- */

View File

@ -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.

View File

@ -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; i<curs->numRows; i++) {

View File

@ -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;
}
}
}