From 13654f360749a4367fab98402df090e02413da9a Mon Sep 17 00:00:00 2001 From: Linas Vepstas Date: Wed, 28 Jan 1998 06:36:19 +0000 Subject: [PATCH] first cut for quickfill in cells git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@455 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/QuickFill.c | 27 +++++++++++------------- src/register/Makefile | 2 +- src/register/quickfillcell.c | 41 ++++++++++++++++++++++++++++++++++++ src/register/quickfillcell.h | 31 +++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 16 deletions(-) create mode 100644 src/register/quickfillcell.c create mode 100644 src/register/quickfillcell.h diff --git a/src/QuickFill.c b/src/QuickFill.c index 632ddc6703..2b6aaf214c 100644 --- a/src/QuickFill.c +++ b/src/QuickFill.c @@ -1,6 +1,7 @@ /********************************************************************\ * QuickFill.h -- the quickfill tree data structure * * Copyright (C) 1997 Robin D. Clark * + * Copyright (C) 1998 Linas Vepstas * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License as * @@ -27,15 +28,11 @@ #include "config.h" -#include "Account.h" -#include "date.h" #include "QuickFill.h" #include "util.h" /** PROTOTYPES ******************************************************/ -void qfInsertTransactionRec( QuickFill *qf, Transaction *trans, int depth ); - -/** GLOBALS *********************************************************/ +static void qfInsertTextRec( QuickFill *qf, const char * text, int depth ); /********************************************************************\ @@ -66,7 +63,7 @@ mallocQuickFill( void ) for( i=0; iqf[i] = NULL; - qf->trans = NULL; + qf->text = NULL; return qf; } @@ -104,30 +101,30 @@ getQuickFill( QuickFill *qf, char c ) /********************************************************************\ \********************************************************************/ void -qfInsertTransaction( QuickFill *qf, Transaction *trans ) +qfInsertText( QuickFill *qf, const char * text ) { - qfInsertTransactionRec( qf, trans, 0 ); + qfInsertTransactionRec( qf, text, 0 ); } /********************************************************************\ \********************************************************************/ -void -qfInsertTransactionRec( QuickFill *qf, Transaction *trans, int depth ) +static void +qfInsertTextRec( QuickFill *qf, const char *text, int depth ) { if( qf != NULL ) { - if( trans->description ) + if( text ) { - if( trans->description[depth] != '\0' ) + if( text[depth] != '\0' ) { - int index = CHAR_TO_INDEX( trans->description[depth] ); + int index = CHAR_TO_INDEX( text[depth] ); if( qf->qf[index] == NULL ) qf->qf[index] = mallocQuickFill(); - qf->qf[index]->trans = trans; + qf->qf[index]->text = text; - qfInsertTransactionRec( qf->qf[index], trans, ++depth ); + qfInsertTransactionRec( qf->qf[index], text, ++depth ); } } } diff --git a/src/register/Makefile b/src/register/Makefile index 5ef33ce817..418a07f7ff 100644 --- a/src/register/Makefile +++ b/src/register/Makefile @@ -27,7 +27,7 @@ LIBCOMBO = ../lib/ComboBox-1.33/libComboBox.a LIBTRANS = ../Account.o ../Data.o ../FileIO.o ../Transaction.o ../date.o ###################################################################### SRCS = actioncell.c basiccell.c cellblock.c combocell.c \ - datecell.c pricecell.c \ + datecell.c pricecell.c QuickFill.c quickfillcell.c \ recncell.c register.c table.c textcell.c OBJS = ${SRCS:.c=.o} ###################################################################### diff --git a/src/register/quickfillcell.c b/src/register/quickfillcell.c new file mode 100644 index 0000000000..a39f24fe35 --- /dev/null +++ b/src/register/quickfillcell.c @@ -0,0 +1,41 @@ + +#include + +#include "basiccell.h" +#include "quickfillcell.h" + +/* ================================================ */ +/* by definition, all text is valid text. So accept + * all modifications */ + +static const char * +quickMV (struct _BasicCell *_cell, + const char *oldval, + const char *change, + const char *newval) +{ + return newval; +} + +/* ================================================ */ + +QuickFillCell * +xaccMallocQuickFillCell (void) +{ + QuickFillCell *cell; + cell = xaccMallocQuickFillCell(); + xaccInitBasicCell (&(cell->cell)); + + cell->qf = xaccMallocQuickFill(); + return cell; +} + +/* ================================================ */ + +void +xaccInitQuickFillCell (QuickFillCell *cell) +{ + cell->cell.modify_verify = quickMV; +} + +/* =============== END OF FILE ==================== */ diff --git a/src/register/quickfillcell.h b/src/register/quickfillcell.h new file mode 100644 index 0000000000..de492d0fac --- /dev/null +++ b/src/register/quickfillcell.h @@ -0,0 +1,31 @@ + +/* + * FILE: + * quickfillcell.h + * + * FUNCTION: + * implements a text cell with quick-fill capabilities + * + * HISTORY: + * Copyright (c) 1997, 1998 Linas Vepstas + */ + +#ifndef __XACC_FILL_CELL_C__ +#define __XACC_FILL_CELL_C__ + +#include "basiccell.h" +#include "QuickFill.h" + +typedef struct _QuickFillCell { + BasicCell cell; + QuickFill *qf; +} QuickFillCell; + +/* installs a callback to handle price recording */ +QuickFillCell * xaccMallocQuickFillCell (void); +void xaccInitQuickFillCell (QuickFillCell *); + + +#endif /* __XACC_FILL_CELL_C__ */ + +/* --------------- end of file ---------------------- */