mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Quickfilling patch.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2392 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
8e6220eae1
commit
87fd144fde
@ -1,3 +1,8 @@
|
|||||||
|
2000-05-30 Dave Peticolas <peticola@cs.ucdavis.edu>
|
||||||
|
|
||||||
|
* src/register/quickfillcell.c: if a quickfill attempt fails,
|
||||||
|
replace the string with the original case string.
|
||||||
|
|
||||||
2000-05-29 Robert Graham Merkel <rgmerk@mira.net>
|
2000-05-29 Robert Graham Merkel <rgmerk@mira.net>
|
||||||
|
|
||||||
* src/scm/report/transaction-report-2.scm (make-account-subheading):
|
* src/scm/report/transaction-report-2.scm (make-account-subheading):
|
||||||
|
@ -32,7 +32,7 @@ INCLPATH = -I@top_srcdir@/ \
|
|||||||
-I@top_srcdir@/src/register/gnome
|
-I@top_srcdir@/src/register/gnome
|
||||||
|
|
||||||
|
|
||||||
CFLAGS := @CFLAGS@ @X_CFLAGS@ -DCELL_WIDGETS=1 ${INCLPATH} ${CPPFLAGS}
|
CFLAGS := @CFLAGS@ @X_CFLAGS@ -DCELL_WIDGETS=1 ${INCLPATH} ${CPPFLAGS} ${GLIB_CFLAGS}
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
# See Makefile.common for information about these variables.
|
# See Makefile.common for information about these variables.
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#include "basiccell.h"
|
#include "basiccell.h"
|
||||||
#include "quickfillcell.h"
|
#include "quickfillcell.h"
|
||||||
@ -69,6 +70,8 @@ quick_enter (BasicCell *_cell, const char *val,
|
|||||||
*start_selection = 0;
|
*start_selection = 0;
|
||||||
*end_selection = -1;
|
*end_selection = -1;
|
||||||
|
|
||||||
|
xaccSetQuickFillOriginal(cell, NULL);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +95,17 @@ quick_modify (BasicCell *_cell,
|
|||||||
/* If deleting, just accept */
|
/* If deleting, just accept */
|
||||||
if (change == NULL)
|
if (change == NULL)
|
||||||
{
|
{
|
||||||
|
/* if the new value is a prefix of the original modulo case,
|
||||||
|
* just truncate the end of the original. Otherwise, set it
|
||||||
|
* to NULL */
|
||||||
|
if ((*cursor_position >= strlen(newval)) &&
|
||||||
|
(cell->original != NULL) &&
|
||||||
|
(strlen(cell->original) >= strlen(newval)) &&
|
||||||
|
(strncasecmp(cell->original, newval, strlen(newval)) == 0))
|
||||||
|
cell->original[strlen(newval)] = '\0';
|
||||||
|
else
|
||||||
|
xaccSetQuickFillOriginal(cell, NULL);
|
||||||
|
|
||||||
SET (&(cell->cell), newval);
|
SET (&(cell->cell), newval);
|
||||||
return newval;
|
return newval;
|
||||||
}
|
}
|
||||||
@ -100,15 +114,32 @@ quick_modify (BasicCell *_cell,
|
|||||||
if (*cursor_position < strlen(oldval))
|
if (*cursor_position < strlen(oldval))
|
||||||
{
|
{
|
||||||
SET (&(cell->cell), newval);
|
SET (&(cell->cell), newval);
|
||||||
|
xaccSetQuickFillOriginal(cell, NULL);
|
||||||
return newval;
|
return newval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cell->original == NULL)
|
||||||
|
cell->original = g_strdup(newval);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *original = g_strconcat(cell->original, change, NULL);
|
||||||
|
g_free(cell->original);
|
||||||
|
cell->original = original;
|
||||||
|
}
|
||||||
|
|
||||||
match = xaccGetQuickFillStr(cell->qfRoot, newval);
|
match = xaccGetQuickFillStr(cell->qfRoot, newval);
|
||||||
|
|
||||||
if ((match == NULL) || (match->text == NULL))
|
if ((match == NULL) || (match->text == NULL))
|
||||||
{
|
{
|
||||||
SET (&(cell->cell), newval);
|
if (cell->original != NULL)
|
||||||
return newval;
|
retval = strdup(cell->original);
|
||||||
|
else
|
||||||
|
retval = newval;
|
||||||
|
|
||||||
|
*cursor_position += strlen(change);
|
||||||
|
|
||||||
|
SET (&(cell->cell), retval);
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = strdup(match->text);
|
retval = strdup(match->text);
|
||||||
@ -122,7 +153,7 @@ quick_modify (BasicCell *_cell,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================ */
|
/* ================================================ */
|
||||||
/* when leaving cell, make sure that text was put into the qf */
|
/* when leaving cell, make sure that text was put into the qf */
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
quick_leave (BasicCell *_cell, const char *val)
|
quick_leave (BasicCell *_cell, const char *val)
|
||||||
@ -156,6 +187,7 @@ xaccInitQuickFillCell (QuickFillCell *cell)
|
|||||||
cell->qfRoot = xaccMallocQuickFill();
|
cell->qfRoot = xaccMallocQuickFill();
|
||||||
cell->qf = cell->qfRoot;
|
cell->qf = cell->qfRoot;
|
||||||
cell->sort = QUICKFILL_LIFO;
|
cell->sort = QUICKFILL_LIFO;
|
||||||
|
cell->original = NULL;
|
||||||
|
|
||||||
cell->cell.enter_cell = quick_enter;
|
cell->cell.enter_cell = quick_enter;
|
||||||
cell->cell.modify_verify = quick_modify;
|
cell->cell.modify_verify = quick_modify;
|
||||||
@ -174,6 +206,9 @@ xaccDestroyQuickFillCell (QuickFillCell *cell)
|
|||||||
cell->qfRoot = NULL;
|
cell->qfRoot = NULL;
|
||||||
cell->qf = NULL;
|
cell->qf = NULL;
|
||||||
|
|
||||||
|
g_free(cell->original);
|
||||||
|
cell->original = NULL;
|
||||||
|
|
||||||
cell->cell.enter_cell = NULL;
|
cell->cell.enter_cell = NULL;
|
||||||
cell->cell.modify_verify = NULL;
|
cell->cell.modify_verify = NULL;
|
||||||
cell->cell.leave_cell = NULL;
|
cell->cell.leave_cell = NULL;
|
||||||
@ -202,4 +237,20 @@ xaccSetQuickFillSort (QuickFillCell *cell, QuickFillSort sort)
|
|||||||
cell->sort = sort;
|
cell->sort = sort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ================================================ */
|
||||||
|
|
||||||
|
void
|
||||||
|
xaccSetQuickFillOriginal (QuickFillCell *cell, const char *original)
|
||||||
|
{
|
||||||
|
if (cell == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_free(cell->original);
|
||||||
|
|
||||||
|
if ((original != NULL) && (*original != '\0'))
|
||||||
|
cell->original = g_strdup(original);
|
||||||
|
else
|
||||||
|
cell->original = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* =============== END OF FILE ==================== */
|
/* =============== END OF FILE ==================== */
|
||||||
|
@ -49,22 +49,24 @@
|
|||||||
|
|
||||||
typedef struct _QuickFillCell
|
typedef struct _QuickFillCell
|
||||||
{
|
{
|
||||||
BasicCell cell;
|
BasicCell cell;
|
||||||
QuickFill *qfRoot; /* root of quickfill-tree
|
QuickFill *qfRoot; /* root of quickfill-tree
|
||||||
* handled by this cell */
|
* handled by this cell */
|
||||||
QuickFill *qf; /* current position in tree */
|
QuickFill *qf; /* current position in tree */
|
||||||
|
|
||||||
QuickFillSort sort; /* determines order of strings matched.
|
QuickFillSort sort; /* determines order of strings matched.
|
||||||
* default is QUICKFILL_LIFO. */
|
* default is QUICKFILL_LIFO. */
|
||||||
|
|
||||||
|
char *original; /* original string entered in original case */
|
||||||
} QuickFillCell;
|
} QuickFillCell;
|
||||||
|
|
||||||
/* installs a callback to handle price recording */
|
|
||||||
QuickFillCell * xaccMallocQuickFillCell (void);
|
QuickFillCell * xaccMallocQuickFillCell (void);
|
||||||
void xaccInitQuickFillCell (QuickFillCell *);
|
void xaccInitQuickFillCell (QuickFillCell *);
|
||||||
void xaccDestroyQuickFillCell (QuickFillCell *);
|
void xaccDestroyQuickFillCell (QuickFillCell *);
|
||||||
|
|
||||||
void xaccSetQuickFillCellValue (QuickFillCell *, const char *);
|
void xaccSetQuickFillCellValue (QuickFillCell *, const char *);
|
||||||
void xaccSetQuickFillSort (QuickFillCell *, QuickFillSort);
|
void xaccSetQuickFillSort (QuickFillCell *, QuickFillSort);
|
||||||
|
void xaccSetQuickFillOriginal (QuickFillCell *, const char *);
|
||||||
|
|
||||||
/* GUI-dependent */
|
/* GUI-dependent */
|
||||||
void xaccQuickFillGUIInit (QuickFillCell *);
|
void xaccQuickFillGUIInit (QuickFillCell *);
|
||||||
|
Loading…
Reference in New Issue
Block a user