mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Take the selection into account when handling the keypad decimal point
key. Fixes 314775. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13312 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
4e402ce74e
commit
27d5ac3cf2
@ -1,5 +1,9 @@
|
|||||||
2006-02-19 David Hampton <hampton@employees.org>
|
2006-02-19 David Hampton <hampton@employees.org>
|
||||||
|
|
||||||
|
* src/register/register-gnome/pricecell-gnome.c: Take the
|
||||||
|
selection into account when handling the keypad decimal point key.
|
||||||
|
Fixes 314775.
|
||||||
|
|
||||||
* src/register/register-gnome/combocell-gnome.c: When looking for
|
* src/register/register-gnome/combocell-gnome.c: When looking for
|
||||||
an matching account name, start at the beginning of the selected
|
an matching account name, start at the beginning of the selected
|
||||||
region, not the end. Problem created when the code stopped adding
|
region, not the end. Problem created when the code stopped adding
|
||||||
|
@ -50,9 +50,8 @@ gnc_price_cell_direct_update (BasicCell *bcell,
|
|||||||
struct lconv *lc;
|
struct lconv *lc;
|
||||||
GString *newval_gs;
|
GString *newval_gs;
|
||||||
gboolean is_return;
|
gboolean is_return;
|
||||||
int i;
|
gint start, end;
|
||||||
const char *c;
|
gchar *buf;
|
||||||
gunichar uc;
|
|
||||||
|
|
||||||
if (event->type != GDK_KEY_PRESS)
|
if (event->type != GDK_KEY_PRESS)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -67,6 +66,7 @@ gnc_price_cell_direct_update (BasicCell *bcell,
|
|||||||
if (!(event->state &
|
if (!(event->state &
|
||||||
(GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)))
|
(GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)))
|
||||||
is_return = TRUE;
|
is_return = TRUE;
|
||||||
|
/* fall through */
|
||||||
|
|
||||||
case GDK_KP_Enter:
|
case GDK_KP_Enter:
|
||||||
{
|
{
|
||||||
@ -113,6 +113,7 @@ gnc_price_cell_direct_update (BasicCell *bcell,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This point is only reached when the KP_Decimal key is pressed. */
|
||||||
if (cell->print_info.monetary)
|
if (cell->print_info.monetary)
|
||||||
decimal_point = lc->mon_decimal_point[0];
|
decimal_point = lc->mon_decimal_point[0];
|
||||||
else
|
else
|
||||||
@ -121,32 +122,23 @@ gnc_price_cell_direct_update (BasicCell *bcell,
|
|||||||
/* allocate space for newval_ptr : oldval + one letter ( the
|
/* allocate space for newval_ptr : oldval + one letter ( the
|
||||||
decimal_point ) */
|
decimal_point ) */
|
||||||
newval_gs = g_string_new("");
|
newval_gs = g_string_new("");
|
||||||
/* copy oldval up to the cursor position */
|
|
||||||
i = 0;
|
|
||||||
c = bcell->value;
|
|
||||||
while (*c && (i < *cursor_position))
|
|
||||||
{
|
|
||||||
uc = g_utf8_get_char (c);
|
|
||||||
g_string_append_unichar (newval_gs, uc);
|
|
||||||
c = g_utf8_next_char (c);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* insert the decimal_point at cursor position */
|
start = MIN(*start_selection, *end_selection);
|
||||||
g_string_append_c (newval_gs, decimal_point);
|
end = MAX(*start_selection, *end_selection);
|
||||||
i++;
|
|
||||||
c = g_utf8_next_char (c);
|
/* length in bytes, not chars. do not use g_utf8_strlen. */
|
||||||
|
buf = malloc(strlen(bcell->value));
|
||||||
/* copy oldval after cursor position */
|
g_utf8_strncpy(buf, bcell->value, start);
|
||||||
while (*c)
|
g_string_append(newval_gs, buf);
|
||||||
{
|
g_free(buf);
|
||||||
uc = g_utf8_get_char (c);
|
|
||||||
g_string_append_unichar (newval_gs, uc);
|
g_string_append_unichar(newval_gs, decimal_point);
|
||||||
c = g_utf8_next_char (c);
|
|
||||||
}
|
buf = g_utf8_offset_to_pointer(bcell->value, end);
|
||||||
|
g_string_append(newval_gs, buf);
|
||||||
|
|
||||||
/* update the cursor position */
|
/* update the cursor position */
|
||||||
(*cursor_position)++;
|
*cursor_position = start + 1;
|
||||||
|
|
||||||
gnc_basic_cell_set_value_internal (bcell, newval_gs->str);
|
gnc_basic_cell_set_value_internal (bcell, newval_gs->str);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user