Hello community,

here is the log from the commit of package rofi-calc for openSUSE:Factory 
checked in at 2020-01-24 13:12:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rofi-calc (Old)
 and      /work/SRC/openSUSE:Factory/.rofi-calc.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rofi-calc"

Fri Jan 24 13:12:50 2020 rev:7 rq:766761 version:1.6

Changes:
--------
--- /work/SRC/openSUSE:Factory/rofi-calc/rofi-calc.changes      2019-04-30 
13:00:16.290174142 +0200
+++ /work/SRC/openSUSE:Factory/.rofi-calc.new.26092/rofi-calc.changes   
2020-01-24 13:13:46.929496177 +0100
@@ -1,0 +2,9 @@
+Fri Jan 24 08:21:10 UTC 2020 - Michael Vetter <mvet...@suse.com>
+
+- Update to 1.6:
+  * Add option -qalc-binary to specify the name or path to the qalc binary
+  * Document comma & space seperator options in README
+  * Delete items from history file (#34) 
+  * Added version check in configure.ac (#28)
+
+-------------------------------------------------------------------

Old:
----
  v1.5.tar.gz

New:
----
  v1.6.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rofi-calc.spec ++++++
--- /var/tmp/diff_new_pack.B52UaR/_old  2020-01-24 13:13:48.737496903 +0100
+++ /var/tmp/diff_new_pack.B52UaR/_new  2020-01-24 13:13:48.741496905 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package rofi-calc
 #
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -12,12 +12,12 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
 Name:           rofi-calc
-Version:        1.5
+Version:        1.6
 Release:        0
 Summary:        Calculator for rofi
 License:        MIT

++++++ v1.5.tar.gz -> v1.6.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rofi-calc-1.5/.travis.yml 
new/rofi-calc-1.6/.travis.yml
--- old/rofi-calc-1.5/.travis.yml       2019-04-23 18:57:25.000000000 +0200
+++ new/rofi-calc-1.6/.travis.yml       2020-01-23 07:54:20.000000000 +0100
@@ -1,5 +1,5 @@
 sudo: required
-dist: xenial
+dist: bionic
 language: c
 compiler:
   - clang
@@ -47,7 +47,7 @@
   - cd -
   - git clone --recursive https://github.com/davatorium/rofi
   - cd rofi
-  - git checkout 1.5.2
+  - git checkout 1.5.4
   - autoreconf -i
   - ./configure
   - make
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rofi-calc-1.5/README.md new/rofi-calc-1.6/README.md
--- old/rofi-calc-1.5/README.md 2019-04-23 18:57:25.000000000 +0200
+++ new/rofi-calc-1.6/README.md 2020-01-23 07:54:20.000000000 +0100
@@ -18,8 +18,46 @@
 
 The result of the current input can be selected with `Ctrl+Enter`, and history 
entries can be selected with `Enter`. By default this will just output the 
equation/result.
 
+## Installation
+
+### Via package manager
+
+* [Arch AUR](https://aur.archlinux.org/packages/rofi-calc/)
+* [FreeBSD](https://www.freshports.org/x11/rofi-calc/)
+* [Gentoo](https://packages.gentoo.org/packages/x11-misc/rofi-calc)
+* [openSUSE](https://software.opensuse.org/package/rofi-calc)
+
+### From source
+
+You need a C compilation toolchain (a `cc`, `autoconf`, `pkg-config`, ...), 
`rofi` (version >= 1.5) as well as `libqalculate` (version > 2.0).
+
+You will also need development headers for `rofi` and `libqalculate`. 
Depending on your distribution these may be included in different packages:
+
+* Arch, Gentoo: included with `rofi`, `libqalculate`
+* OpenSUSE: `zypper in rofi rofi-devel qalculate`
+* Debian: `dpkg --install rofi-dev qalc libqalculate-dev`
+* Ubuntu: `apt install rofi-dev qalc libqalculate-dev`
+* Solus: `eopkg it rofi-devel libqalculate-devel`
+* CentOS, Fedora: Install `qalculate` `libqalculate-devel` (find `rofi-devel` 
headers yourself)
+* Others: look it up :)
+
+Some distributions ship an [extremely 
outdated](https://github.com/svenstaro/rofi-calc/issues/7) version of 
`libqalculate` so you might have to compile your own. If that is the case, see 
[here](https://github.com/svenstaro/rofi-calc/wiki/Installing-libqalculate-from-source).
+
+**rofi-calc** uses autotools as build system. If installing from git, the 
following steps should install it:
+
+```bash
+$ autoreconf -i
+$ mkdir build
+$ cd build/
+$ ../configure
+$ make
+$ make install
+```
+
 ## Advanced Usage
 
+Use the `-qalc-binary` option to specify the name or location of qalculate's 
`qalc` binary. Defaults to `qalc`.
+
 Use the `-terse` option to reduce the output of `qalc` to just the result of 
the input expression.
 
 Use the `-calc-command` option to specify a shell command to execute which 
will be interpolated with the following keys:
@@ -43,40 +81,18 @@
 
     rofi -show calc -modi calc -no-show-match -no-sort -no-history
 
-## Compilation
-
-### Dependencies
-
-You need a C compilation toolchain (a `cc`, `autoconf`, `pkg-config`, ...), 
`rofi` (version >= 1.5) as well as `libqalculate` (version > 2.0).
-
-You will also need development headers for `rofi` and `libqalculate`. 
Depending on your distribution these may be included in different packages:
-
-* Arch, Gentoo: included with `rofi`, `libqalculate`
-* OpenSUSE: `zypper in rofi rofi-devel qalculate`
-* Debian: `dpkg --install rofi-dev qalc libqalculate-dev`
-* Ubuntu: `apt install rofi-dev qalc libqalculate-dev`
-* Solus: `eopkg it rofi-devel libqalculate-devel`
-* CentOS, Fedora: Install `qalculate` `libqalculate-devel` (find `rofi-devel` 
headers yourself)
-* Others: look it up :)
+To enable thousand separators in the output (e.g. `5 * 12 = 6,000`, rather 
than `6000`) add the following to `~/.config/qalculate/qalc.cfg`
 
-Some distributions ship an [extremely 
outdated](https://github.com/svenstaro/rofi-calc/issues/7) version of 
`libqalculate` so you might have to compile your own. If that is the case, see 
[here](https://github.com/svenstaro/rofi-calc/wiki/Installing-libqalculate-from-source).
+> For `,` separator:
 
-### Installation
+    digit_grouping=2
 
-#### Package Manager
+> For space separator:
 
-* [Arch AUR](https://aur.archlinux.org/packages/rofi-calc/)
-* [openSUSE](https://software.opensuse.org/package/rofi-calc)
+    digit_grouping=1
 
-#### From source
+## Development
 
-**rofi-calc** uses autotools as build system. If installing from git, the 
following steps should install it:
+If you're developing this, it might be helpful to start rofi directly with a 
locally compiled plugin like this:
 
-```bash
-$ autoreconf -i
-$ mkdir build
-$ cd build/
-$ ../configure
-$ make
-$ make install
-```
+    rofi -plugin-path build/.libs -show calc -modi calc -no-show-match -no-sort
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rofi-calc-1.5/configure.ac 
new/rofi-calc-1.6/configure.ac
--- old/rofi-calc-1.5/configure.ac      2019-04-23 18:57:25.000000000 +0200
+++ new/rofi-calc-1.6/configure.ac      2020-01-23 07:54:20.000000000 +0100
@@ -48,7 +48,7 @@
 dnl ---------------------------------------------------------------------
 PKG_CHECK_MODULES([glib],     [glib-2.0 >= 2.40 gio-unix-2.0 gmodule-2.0 ])
 PKG_CHECK_MODULES([cairo],    [cairo])
-PKG_CHECK_MODULES([rofi],     [rofi])
+PKG_CHECK_MODULES([rofi],     [rofi >= 1.5.4])
 
 [rofi_PLUGIN_INSTALL_DIR]="`$PKG_CONFIG --variable=pluginsdir rofi`"
 AC_SUBST([rofi_PLUGIN_INSTALL_DIR])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/rofi-calc-1.5/src/calc.c new/rofi-calc-1.6/src/calc.c
--- old/rofi-calc-1.5/src/calc.c        2019-04-23 18:57:25.000000000 +0200
+++ new/rofi-calc-1.6/src/calc.c        2020-01-23 07:54:20.000000000 +0100
@@ -53,6 +53,10 @@
 #define EQUALS_SIGN  '='
 
 
+// qalc binary name
+#define QALC_BINARY_OPTION "-qalc-binary"
+
+
 // Calc command option
 #define CALC_COMMAND_OPTION "-calc-command"
 
@@ -147,6 +151,75 @@
 }
 
 
+// Count number of new lines in a string.
+static uint32_t get_number_of_newlines(gchar* string, gsize length) {
+    uint32_t lines = 0;
+    for (uint32_t i = 0; i < length; i++) {
+        if (string[i] == '\n') {
+            lines++;
+        }
+    }
+
+    return lines;
+}
+
+
+// Delete a certain line number from history.
+static void delete_line_from_history(uint32_t line) {
+    GError *error = NULL;
+    gchar* history_dir = g_build_filename(g_get_user_data_dir(), "rofi", NULL);
+    gchar* history_file = g_build_filename(history_dir, "rofi_calc_history", 
NULL);
+    gchar* history_contents;
+    gsize history_length;
+    gboolean old_history_was_read = FALSE;
+
+    if (g_file_test(history_file, G_FILE_TEST_EXISTS | 
G_FILE_TEST_IS_REGULAR)) {
+        g_file_get_contents(history_file, &history_contents, &history_length, 
&error);
+        old_history_was_read = TRUE;
+
+        if (error != NULL) {
+            g_error("Error while reading the history file: %s", 
error->message);
+            g_error_free(error);
+        }
+    } else {
+        // Empty history, do nothing and exit early.
+        return;
+    }
+
+    uint32_t newlines = get_number_of_newlines(history_contents, 
history_length);
+    GString* new_history = g_string_new("");
+    uint32_t current_line = 0;
+    uint32_t line_to_delete = newlines - line;
+    for (gsize c = 0; c < history_length; c++) {
+        if (history_contents[c] == '\n') {
+            current_line++;
+        }
+
+        // Skip any copying of history if the line we're on is the line we're 
trying to get rid of.
+        if (current_line == line_to_delete) {
+            continue;
+        }
+
+        new_history = g_string_append_c(new_history, history_contents[c]);
+    }
+
+    gchar* new_history_str = g_string_free(new_history, FALSE);
+    g_file_set_contents(history_file, new_history_str, -1, &error);
+
+    if (error != NULL) {
+        g_error("Error while writing the history file: %s", error->message);
+        g_error_free(error);
+    }
+
+    g_free(new_history_str);
+    if (old_history_was_read) {
+        g_free(history_contents);
+    }
+    g_free(history_file);
+    g_free(history_dir);
+}
+
+
 // Get the entries to display.
 // This gets called on plugin initialization.
 static void get_calc(Mode* sw)
@@ -330,6 +403,9 @@
     } else if (menu_entry & MENU_ENTRY_DELETE) {
         if (selected_line > 0) {
             g_ptr_array_remove_index(pd->history, 
get_real_history_index(pd->history, selected_line));
+            if (find_arg(NO_HISTORY_OPTION) == -1) {
+                delete_line_from_history(selected_line - 1);
+            }
         }
         retv = RELOAD_DIALOG;
     }
@@ -417,9 +493,14 @@
     GError *error = NULL;
     CALCModePrivateData* pd = (CALCModePrivateData*)mode_get_private_data(sw);
 
+    char *qalc_binary = "qalc";
+    if (find_arg(QALC_BINARY_OPTION) >= 0) {
+        find_arg_str(QALC_BINARY_OPTION, &qalc_binary);
+    }
+
     // Build array of strings that is later fed into a subprocess to actually 
start qalc with proper parameters.
     GPtrArray *argv = g_ptr_array_new();
-    g_ptr_array_add(argv, "qalc");
+    g_ptr_array_add(argv, qalc_binary);
     g_ptr_array_add(argv, "+u8");
     g_ptr_array_add(argv, "-s");
     g_ptr_array_add(argv, "update_exchange_rates 1days");


Reply via email to