[gnome-calculator] Support latex-style multipy (fixes #164)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] Support latex-style multipy (fixes #164)
- Date: Thu, 4 Jun 2020 14:29:07 +0000 (UTC)
commit c0ec19b8d80b5498c1d873f46fe694aedbae8e4a
Author: Robert Roth <robert roth off gmail com>
Date: Thu Jun 4 17:26:01 2020 +0300
Support latex-style multipy (fixes #164)
lib/equation-lexer.vala | 4 +++-
lib/math-equation.vala | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/lib/equation-lexer.vala b/lib/equation-lexer.vala
index 6a5b8d92..6c2a5f02 100644
--- a/lib/equation-lexer.vala
+++ b/lib/equation-lexer.vala
@@ -151,7 +151,7 @@ public class PreLexer : Object
if (c == '"')
return LexerTokenType.PL_SECOND;
- if (c.isalpha () || c == '_')
+ if (c.isalpha () || c == '_' || c == '\\')
return LexerTokenType.PL_LETTER;
if (c == '∧')
@@ -709,6 +709,8 @@ public class Lexer : Object
return insert_token (LexerTokenType.MOD);
if (name == "and")
return insert_token (LexerTokenType.AND);
+ if (name == "\\cdot")
+ return insert_token (LexerTokenType.MULTIPLY);
if (name == "or")
return insert_token (LexerTokenType.OR);
if (name == "xor")
diff --git a/lib/math-equation.vala b/lib/math-equation.vala
index 46c91c08..ae71e706 100644
--- a/lib/math-equation.vala
+++ b/lib/math-equation.vala
@@ -798,7 +798,7 @@ public class MathEquation : Gtk.SourceBuffer
/* Show the number in the user chosen format */
var text = serializer.to_string (x);
- this.history_signal (get_current_state ().expression, x, number_base, representation_base); /*emits
signal to enter a new entry into history-view */
+ this.history_signal (get_current_state ().expression.replace ("\\cdot", "×"), x, number_base,
representation_base); /*emits signal to enter a new entry into history-view */
set_text (text, -1);
state.ans = x;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]