[gnome-calculator] Use _ instead of ans for last result (bgo#785107)
- From: Robert Roth <robertroth src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] Use _ instead of ans for last result (bgo#785107)
- Date: Thu, 2 Nov 2017 06:22:18 +0000 (UTC)
commit ad694dba6d13633bb5a2ec6f41b3a3fe9758007d
Author: Robert Roth <robert roth off gmail com>
Date: Sun Sep 17 00:35:46 2017 +0300
Use _ instead of ans for last result (bgo#785107)
help/C/variables.page | 2 +-
lib/math-equation.vala | 18 +++++++++---------
src/math-variable-popover.vala | 6 +++---
3 files changed, 13 insertions(+), 13 deletions(-)
---
diff --git a/help/C/variables.page b/help/C/variables.page
index 47c9f43..9fdf71a 100644
--- a/help/C/variables.page
+++ b/help/C/variables.page
@@ -37,7 +37,7 @@
</p>
<table>
<tr>
- <td><p>ans</p></td>
+ <td><p>_</p></td>
<td><p>Result of previous calculation</p></td>
</tr>
<tr>
diff --git a/lib/math-equation.vala b/lib/math-equation.vala
index cfd7b8e..bb9c771 100644
--- a/lib/math-equation.vala
+++ b/lib/math-equation.vala
@@ -661,11 +661,11 @@ public class MathEquation : Gtk.SourceBuffer
get
{
/* Check if the previous answer is before start of error token.
- * If so, subtract 3 (the length of string "ans") and add actual answer length (ans_end -
ans_start) into it. */
+ * If so, subtract 1 (the length of string "_") and add actual answer length (ans_end -
ans_start) into it. */
int ans_start, ans_end;
get_ans_offsets (out ans_start, out ans_end);
if (ans_start != -1 && ans_start < state.error_token_start)
- return state.error_token_start + ans_end - ans_start - 3;
+ return state.error_token_start + ans_end - ans_start - 1;
return state.error_token_start;
}
@@ -676,11 +676,11 @@ public class MathEquation : Gtk.SourceBuffer
get
{
/* Check if the previous answer is before end of error token.
- * If so, subtract 3 (the length of string "ans") and add actual answer length (ans_end -
ans_start) into it. */
+ * If so, subtract 1 (the length of string "_") and add actual answer length (ans_end -
ans_start) into it. */
int ans_start, ans_end;
get_ans_offsets (out ans_start, out ans_end);
if (ans_start != -1 && ans_start < state.error_token_end)
- return state.error_token_end + ans_end - ans_start - 3;
+ return state.error_token_end + ans_end - ans_start - 1;
return state.error_token_end;
}
@@ -693,7 +693,7 @@ public class MathEquation : Gtk.SourceBuffer
public bool is_result
{
- get { return equation == "ans"; }
+ get { return equation == "_"; }
}
public string equation
@@ -707,7 +707,7 @@ public class MathEquation : Gtk.SourceBuffer
if (ans_start_mark != null)
get_ans_offsets (out ans_start, out ans_end);
if (ans_start >= 0)
- text = text.splice (text.index_of_nth_char (ans_start), text.index_of_nth_char (ans_end),
"ans");
+ text = text.splice (text.index_of_nth_char (ans_start), text.index_of_nth_char (ans_end),
"_");
var last_is_digit = false;
var index = 0;
@@ -1063,7 +1063,7 @@ public class MathEquation : Gtk.SourceBuffer
return;
/* If showing a result return to the equation that caused it */
- // FIXME: Result may not be here due to solve (i.e. the user may have entered "ans")
+ // FIXME: Result may not be here due to solve (i.e. the user may have entered "_")
if (is_result)
{
undo ();
@@ -1388,7 +1388,7 @@ private class MEquation : Equation
{
var lower_name = name.down ();
- if (lower_name == "rand" || lower_name == "ans")
+ if (lower_name == "rand" || lower_name == "_")
return true;
return m_equation.variables.get (name) != null;
@@ -1400,7 +1400,7 @@ private class MEquation : Equation
if (lower_name == "rand")
return new Number.random ();
- else if (lower_name == "ans")
+ else if (lower_name == "_")
return m_equation.answer;
else
return m_equation.variables.get (name);
diff --git a/src/math-variable-popover.vala b/src/math-variable-popover.vala
index c9837e0..17c2f87 100644
--- a/src/math-variable-popover.vala
+++ b/src/math-variable-popover.vala
@@ -11,7 +11,7 @@
[GtkTemplate (ui = "/org/gnome/calculator/math-variable-popover.ui")]
public class MathVariablePopover : Gtk.Popover
{
- private static string[] RESERVED_VARIABLE_NAMES = {"ans", "rand"};
+ private static string[] RESERVED_VARIABLE_NAMES = {"_", "rand"};
private MathEquation equation;
@@ -55,8 +55,8 @@ public class MathVariablePopover : Gtk.Popover
private void handler (string answer, Number number, int number_base, uint representation_base)
{
- variable_list.remove (find_row_for_variable ("ans"));
- variable_list.add (make_variable_row ("ans", number));
+ variable_list.remove (find_row_for_variable ("_"));
+ variable_list.add (make_variable_row ("_", number));
}
private Gtk.ListBoxRow? find_row_for_variable (string name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]