From c1479157b32b9cc9991f6a22253bd59c7941ff83 Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Sun, 15 Mar 1998 19:31:02 +0000 Subject: [PATCH] add new function git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@647 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/register/table-allgui.c | 39 +++++++++++++++++++++++++++++++++++++ src/register/table-allgui.h | 3 +++ 2 files changed, 42 insertions(+) diff --git a/src/register/table-allgui.c b/src/register/table-allgui.c index 3f62dab82c..a2cacb0015 100644 --- a/src/register/table-allgui.c +++ b/src/register/table-allgui.c @@ -235,4 +235,43 @@ xaccTableResizeUserData (Table * table, int new_virt_rows, int new_virt_cols) } } +/* ==================================================== */ + +void +xaccAddCursor (Table *table, CellBlock *curs) +{ + CellBlock **old_arr; + size_t ncurs = 0; + + /* count the old number of entries */ + if (table->cursors) { + CellBlock *tmp = table->cursors[0]; + while (tmp) { + ncurs ++; + tmp = table->cursors[ncurs]; + } + } + old_arr = table->cursors; + + /* malloc the list of new handlers */ + table->cursors = (CellBlock **) malloc ((ncurs+2) * sizeof (CellBlock *)); + + /* copy the old array to the new array */ + ncurs = 0; + if (old_arr) { + CellBlock *tmp = old_arr[0]; + while (tmp) { + table->cursors[ncurs] = tmp; + ncurs ++; + tmp = old_arr[ncurs]; + } + } + + /* append the new cursor to the list */ + table->cursors[ncurs] = curs; + table->cursors[ncurs+1] = NULL; + + free (old_arr); +} + /* ================== end of file ======================= */ diff --git a/src/register/table-allgui.h b/src/register/table-allgui.h index 7c345e12b5..8ad3a80ed8 100644 --- a/src/register/table-allgui.h +++ b/src/register/table-allgui.h @@ -47,6 +47,9 @@ xaccTableResizeStringArr (Table * table, int num_phys_rows, int num_phys_cols); extern void xaccTableResizeUserData (Table * table, int new_virt_rows, int new_virt_cols); +extern void +xaccAddCursor (Table *table, CellBlock *curs); + #endif /* __XACC_TABLE_ALLGUI_H__ */ /* ================== end of file ======================= */