-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Option to replace equation in input with result when added to history #97
Comments
Sounds cool. How do you suggest that usage be triggered? We could try to use another modifier with |
(rip... I totally wrote out a whole response and then got side-tracked and lost it 😂 ) I was imagining a cli arg like But if you'd rather go with a modifier, Shift+Enter or Ctrl+Shift+Enter might be options. I think Lines 442 to 456 in 3be0c3a
Or that maybe one of them trigger I'll see what I can do, but the last time I wrote |
EDIT: There's always a way. Getting a segfault right now at: textbox_text(state->text, result); But here's what I've got so far: diff --git a/src/calc.c b/src/calc.c
index fa29309..07d469d 100644
--- a/src/calc.c
+++ b/src/calc.c
@@ -94,6 +95,14 @@ typedef struct
#define AUTOMATIC_SAVE_TO_HISTORY "-automatic-save-to-history"
#define HISTORY_LENGTH 100
+// Stolen from rofi/include
+typedef struct textbox textbox;
+typedef struct {
+ /** #textbox with the user input in the input bar. */
+ textbox *text;
+} RofiViewState;
+RofiViewState *rofi_view_get_active(void);
+void textbox_text(textbox *tb, const char *text);
+
// Limit `str` to at most `limit` new lines.
// Returns a new string of either the limited length or the length length.
// However, in both cases, it's a new string.
@@ -427,6 +436,17 @@ static ModeMode calc_mode_result(Mode* sw, int menu_entry, G_GNUC_UNUSED char**
retv = PREVIOUS_DIALOG;
} else if (menu_entry & MENU_QUICK_SWITCH) {
retv = (menu_entry & MENU_LOWER_MASK);
+ } else if (menu_entry & MENU_CUSTOM_ACTION) {
+ g_debug("MENU_CUSTOM_ACTION: %x", menu_entry & MENU_CUSTOM_ACTION);
+ RofiViewState *state = rofi_view_get_active();
+ if (state != NULL) {
+ char* result = g_strdup_printf("%s", pd->last_result);
+ g_debug("pd->last_result: %s", result);
+ g_debug("RofiViewState NOT NULL");
+ textbox_text(state->text, result);
+ }
+ append_last_result_to_history(pd);
+ retv = RELOAD_DIALOG;
} else if ((menu_entry & MENU_OK) && (selected_line == 0 && find_arg(NO_HISTORY_OPTION) == -1)) {
append_last_result_to_history(pd);
retv = RELOAD_DIALOG; |
I tried changing my declarations to static, but still no dice. Any ideas? static RofiViewState *rofi_view_get_active(void);
static void textbox_text(textbox *tb, const char *text); |
Often times, I'd like to be able to do rapid-fire sequential equations in order get to the final result. It would be great if there was an option that could be passed that would replace the equation in the input with the result of the question that was just added to history. This would make it easy to do follow-up equations.
Example workflow:
This is especially useful when paired with
-no-persist-history
.The text was updated successfully, but these errors were encountered: