[gnome-calculator] Created experimental insert character code
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] Created experimental insert character code
- Date: Thu, 22 Oct 2020 05:23:56 +0000 (UTC)
commit bfe08f8b7eeca7d3987ddd99ade0b51193c11837
Author: A.M. Rowsell <amrowsell frozenelectronics ca>
Date: Thu Oct 22 05:23:55 2020 +0000
Created experimental insert character code
This code breaks the unicode string down into UTF-8 bytes and
then inserts them into the equation display.
src/math-buttons.vala | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/math-buttons.vala b/src/math-buttons.vala
index cbda5672..aaa01a62 100644
--- a/src/math-buttons.vala
+++ b/src/math-buttons.vala
@@ -614,17 +614,20 @@ public class MathButtons : Gtk.Box
private void character_code_dialog_response_cb (Gtk.Widget dialog, int response_id)
{
- var text = character_code_entry.get_text ();
-
+ string text = character_code_entry.get_text ();
if (response_id == Gtk.ResponseType.OK)
{
var x = new Number.integer (0);
- for (var i = 0; text[i] != '\0'; i++)
+ var decoded = text.data;
+ var len = decoded.length;
+ for (var i = 0; i < len; i++)
{
- x = x.add (new Number.integer (text[i]));
- x = x.shift (8);
+ x = x.add (new Number.integer (decoded[i]));
+ if(i != (len - 1))
+ {
+ x = x.shift (8);
+ }
}
-
equation.insert_number (x);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]