-  ____  _   _ ____   ___ 
g |  _ \| | | |    \ /___)
- | | | | |_| | | | |___ |
  |_| |_|____/|_|_|_(___/ 
	

gnums : a stack based calculator

gnums is a graphical calculator that uses postfix notation.

screenshot of the nums calculator interface

Building gnums


git clone https://tildegit.org/sloum/gnums && cd gnums

A Go compiler with a version >= 1.16 is required to build gnums.

Dependencies

gnums uses the giu toolkit for golang gui development. The following are all requirements of said toolkit. You can reference their repo for further information.

On OSX you will need to run the following:


xcode-select --install

On Windows you will need to install mingw.

On Debian (and derivatives) Linux you will need the following:


sudo apt install libx11-dev libxcursor-dev libxrandr-dev libxinerama-dev libxi-dev libglx-dev libgl1-mesa-dev libxxf86vm-dev

Other linux systems as well as BSD are not officially supported, but may still work with equivalent packages installed.

Optional dependencies

I recommend using the program `upx` to compress the executable. This will result in a significantly reduced filesize with no reduced functionality. This is an optional dependency and does not need to be installed to complete the build.

Most package managers should have some version or other of upx available. Homebrew and apt both have it and it is widely supported for many platforms.

Installing

Now that you have your dependencies sorted you can go a few different directions. The first would be do use the makefile:


sudo make install && gnums

On linux this will also install a desktop entry and icon. On OSX it will install to /usr/local/bin.

For windows the following is recommended:


go build -ldflags "-s -w -H=windowsgui -extldflags=-static" -o gnums.exe

If you are using OSX or Linux and prefer to not use the Makefile (or it gave you trouble), you can try (eliminating the upx portion if you are not using upx):


go build -ldflags "-s -w" -o gnums && upx gnums

Both the windows build step and the non-make build step for OSX/Linux builds the executable in the local folder. You will likely want to copy it somewhere on your $PATH.

Using gnums

If you have used a stack based reverse polish notation calculator before it should mostly make sense. Enter a number and press enter to add it to the top of the stack. Press opperators to have them operate on the stack. If a stack overflow or underflow is encountered the stack will be reset and all calculations reset to 0.

gnums is based on the calculator core of my other program `nums`. The operators function in the same way.

Keyboard Shortcuts

gnums has a number of keyboard shortcuts available. At present, they are not configurable beyond editing the source code itself.

Key(s) Effect
Number Key (0-9) Enter the given number to the input value
. Enter a decimal point to the current input value
Backspace Delete a character from the current input value
Enter Place the current input value on the top of the stack
Tab Toggle the stack view open/closed
Control+q Exit gnums
+ Add the top two stack values
- Subtract the top stack value from the value underneath it
* Divide the top two stack values (divides the second stack value by the value on top of the stack)
! Invert the sign of the top stack value (+/-)
^ Raise the second value to the power of the top stack value
f Floor the top stack value
c Ceiling the top stack value
r Round the second stack value a number of decimal places represented by the top value ont he stack
q Calculate the square root of the top stack value
o Copy the second stack value to the top of the stack, pushing all other values down the stack (same as the "over" button)
s Swap the stack positions of the top two stack values
d Drop the top stack value (throw it away)
u Add a copy of the top stack value to the top of the stack