Skip to content
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

Variables are not saved #49

Open
symphorien opened this issue Jun 18, 2020 · 8 comments
Open

Variables are not saved #49

symphorien opened this issue Jun 18, 2020 · 8 comments

Comments

@symphorien
Copy link

Steps to reproduce:

  1. open rofi calc
  2. type: foo := 1 then enter then empty the prompt and type foo + 1

Expected result

2

Actual result

error foo is not a valid variable/unit/... (translated from my locale)

Notes

Works in qalculate-gtk

I understand that persistence across rofi-calc runs may be hard, but I would expect variable to stay as long as I don't close rofi-calc.

@symphorien
Copy link
Author

forgot to mention: rofi-calc 1.7 and rofi 1.5.4

@svenstaro
Copy link
Owner

The thing is that every single line is its own qalc call and it doesn't have any context. In fact it might lead to some unexpected behavior if we kept variables around. One might then expect all calls in the history to be available in the context but again I think that might lead to odd results.

Honestly not sure what the best course of action is here. This wasn't really intended for multi line math stuff. I suppose you could use ; to put multiple assignments or statements on the same line beside one another to get access to multiple variables but it's probably not as tidy.

@symphorien
Copy link
Author

In fact it might lead to some unexpected behavior if we kept variables around.

I'm curious what you have in mind

The thing is that every single line is its own qalc call and it doesn't have any context.

Does rofi-calc call the executable qalc ? I thought it used libqalculate.so... In this case I understand it's hard to keep state.

@svenstaro
Copy link
Owner

In fact it might lead to some unexpected behavior if we kept variables around.

I'm curious what you have in mind

Well, let's say at some point in your history you defined x but forgot about it. You call rofi-calc again at some point but forget that you had set x previously and just use it in an equation and suddenly is has an unexpected value.

The thing is that every single line is its own qalc call and it doesn't have any context.

Does rofi-calc call the executable qalc ? I thought it used libqalculate.so... In this case I understand it's hard to keep state.

Yeah, it just calls out to qalc.

I'm not opposed to this idea of context but we have to be smarter about it. If you have any proposal I'm all ears.

@symphorien
Copy link
Author

What I had in mind is a middle ground: variables are kept until we quit rofi
Launch rofi; x:=1; x+1; quit rofi works
Launch rofi; x:=1; quit rofi; start rofi; x+1 does not work

But I'm not sure it's worth the hassle.

@svenstaro
Copy link
Owner

Might be cool and somewhat convenient I suppose. I'd make it an option in rofi-calc and have it on by default. Would you like to take a stab at implementing this?

@symphorien
Copy link
Author

Not really, sorry.

@SpicyCheesePizza
Copy link

Would this be easier to implement if variables were simply stored in the history and this persistent variable behavior was tied to having persistent history disabled (the setting that clears the history when rofi is closed)?

This would allow for users that required persistent variables to make use of it and would stop it from getting cluttered later down the line, but it does restrict the use case slightly by making all calculations conform to the same temporary history rules.

I'm not sure how much easier this would be to implement than simply creating the functionality separately but thought it could be worth mentioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants