[gcalctool] Make "Insert character" work, use unsigned numbers, and work with UTF-8
- From: Robin Sonefors <rsonefors src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gcalctool] Make "Insert character" work, use unsigned numbers, and work with UTF-8
- Date: Sat, 3 Oct 2009 23:28:55 +0000 (UTC)
commit 024c2854f94485eddacc6090f5ae7d91968288e3
Author: Robin Sonefors <ozamosi flukkost nu>
Date: Sun Oct 4 01:28:32 2009 +0200
Make "Insert character" work, use unsigned numbers, and work with UTF-8
ChangeLog | 4 ++++
data/gcalctool.ui | 1 +
src/display.c | 29 ++++++++++++++++++++++-------
3 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1b57150..13da6de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@
gcalctool change history.
=========================
+2009-10-04 Robin Sonefors <ozamosi flukkost nu>
+
+ * Make "Insert character" work, use unsigned numbers, and work with UTF-8
+
2009-10-03 Robin Sonefors <ozamosi flukkost nu>
* Fix so the code builds without warnings on 64 bit platforms
diff --git a/data/gcalctool.ui b/data/gcalctool.ui
index 7a0472f..a8271c6 100644
--- a/data/gcalctool.ui
+++ b/data/gcalctool.ui
@@ -3509,6 +3509,7 @@
<property name="AtkObject::accessible-name" translatable="yes" comments="Accessible name for the insert character button">Insert Character</property>
</object>
</child>
+ <signal name="clicked" handler="insert_ascii_cb"/>
</object>
<packing>
<property name="left_attach">9</property>
diff --git a/src/display.c b/src/display.c
index 9e37181..3c9af48 100644
--- a/src/display.c
+++ b/src/display.c
@@ -209,9 +209,14 @@ display_get_cursor(GCDisplay *display)
void
display_set_number(GCDisplay *display, const MPNumber *x)
{
- char text[MAX_DISPLAY];
- display_make_number(display, text, MAX_DISPLAY, x);
- display_set_string(display, text, -1);
+ char text[MAX_DISPLAY];
+ int enabled;
+ guint64 bit_value;
+ display_make_number(display, text, MAX_DISPLAY, x);
+ display_set_string(display, text, -1);
+
+ enabled = display_get_unsigned_integer(display, &bit_value);
+ ui_set_bitfield(enabled, bit_value);
}
@@ -825,10 +830,20 @@ do_paste(GCDisplay *display, int cursor_start, int cursor_end, const char *text)
static void
-do_insert_character(GCDisplay *display, const char *text)
+do_insert_character(GCDisplay *display, const unsigned char *text)
{
MPNumber value;
- mp_set_from_integer(text[0], &value);
+ int i = 0;
+ mp_set_from_integer(0, &value);
+ while (TRUE) {
+ mp_add_integer(&value, text[i], &value);
+ if (text[i+1]) {
+ mp_shift(&value, 8, &value);
+ i++;
+ } else {
+ break;
+ }
+ }
display_set_number(display, &value);
}
@@ -937,7 +952,7 @@ display_do_function(GCDisplay *display, int function, gpointer arg, int cursor_s
return;
case FN_INSERT_CHARACTER:
- do_insert_character(display, (const char *)arg);
+ do_insert_character(display, (const unsigned char *)arg);
return;
case FN_STORE:
@@ -1029,7 +1044,7 @@ display_do_function(GCDisplay *display, int function, gpointer arg, int cursor_s
break;
case FN_TEXT:
- display_insert(display, cursor_start, cursor_end, (const char *)arg); // FIXME: Probably not 64 bit safe
+ display_insert(display, cursor_start, cursor_end, (const char *)arg);
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]