rofi-calc-2.2.1-add-to-history-hint.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --- a/src/calc.c
  2. +++ b/src/calc.c
  3. @@ -44,6 +44,7 @@ typedef struct
  4. char* cmd;
  5. char *hint_result;
  6. char *hint_welcome;
  7. + char *hint_history;
  8. char *last_result;
  9. char *previous_input;
  10. GPtrArray* history;
  11. @@ -82,6 +82,10 @@ typedef struct
  12. #define HINT_WELCOME "-hint-welcome"
  13. #define HINT_WELCOME_STR "Calculator"
  14. +// Option to specify history hint
  15. +#define HINT_HISTORY "-hint-history"
  16. +#define HINT_HISTORY_STR "Add to history"
  17. +
  18. // The following keys can be specified in `CALC_COMMAND_FLAG` and
  19. // will be replaced with the left-hand side and right-hand side of
  20. // the equation.
  21. @@ -254,6 +258,10 @@ static void get_calc(Mode* sw)
  22. ? g_strdup(cmd)
  23. : HINT_WELCOME_STR;
  24. + pd->hint_history = find_arg_str(HINT_HISTORY, &cmd)
  25. + ? g_strdup(cmd)
  26. + : HINT_HISTORY_STR;
  27. +
  28. if (find_arg(NO_PERSIST_HISTORY_OPTION) == -1 && find_arg(NO_HISTORY_OPTION) == -1) {
  29. // Load old history if it exists.
  30. GError *error = NULL;
  31. @@ -501,7 +509,7 @@ static char* calc_get_display_value(cons
  32. if (selected_line == 0) {
  33. if (find_arg(NO_HISTORY_OPTION) == -1)
  34. - return g_strdup("Add to history");
  35. + return g_strdup(pd->hint_history);
  36. else
  37. return g_strdup("");
  38. }