Skip to content

Commit

Permalink
Lots of changes. See release notes for v4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
frossm committed Jul 23, 2022
1 parent 0db9a29 commit 7aaa208
Show file tree
Hide file tree
Showing 18 changed files with 171 additions and 124 deletions.
Binary file modified graphics/Banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified graphics/Banner.xcf
Binary file not shown.
Binary file modified graphics/ScreenShot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions mdbook/src/Chapters/CommandLineOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ You can set the number of memory slots, decimal alignment, debug mode, and other
|Option|Name|Description|
|------|----|-----------|
|-D | `DEBUG MODE`| Runs the program in debug mode. This will display quite a bit of information in RED as you use the program. This is mostly used by the developer and clutters everythign up, but you may find it useful if you are trying to debug something. I could certainly add a lot more if needed, but it's useful today. You can also toggle debug mode on/off by entering in the command `debug` while within the program - you don't have to restart RPNCalc|
|-l name |`LOAD STACK`| Load a saved stack. This essentially will "name" your session and store the stack upon exit in the Java preferences system. You can load the stack with the `-l name` command line option, or from within the program by using the `load name` command. Please note the name field is whatever you want to call the instance but avoid spaces in the name. I'm not aware of a limit to the number of saved stacks You can have. If the name to load does not exist, the stack will be created and saved when you exit.|
|-a l <br> -a d <br> -a r | `ALIGNMENT`| This option sets the display alignment of the numbers on the stack. Alignment can either be an `-a l` for LEFT alignment, an `-a r` for RIGHT alignment, or a `-a d` to align to the decimal point. This impacts the display only and doesn't impact the calculations. For example, when I load my saved stack `-l checkbook`, I align by decimal which makes it a bit easier to read a stack with only two decimal place numbers. Alignments can also be changed within the program itself using the `a` command|
|-m [slots]| `MEMORY SLOTS`| Override the default of ten available memory slots. If you need 25 memory slots, just use `-m 25` when starting the program. Please note that if you have 25 slots, the slot numbers within the program will be 0 - 24. Slots are saved and restored between sessions, but if you run the program again and do not specify `-m 25`, it will default to 10 and you'll lose the memory slots greater than that. If this is important, define an alias|
|-w width| `WIDTH`| Set the width of the program header and status line. Default is 80 characters. Useful if you are using a very small terminal. The minimum width of the console is currently 46 characters and RPNCalc will adjust to that if a lesser number is provided|
|-l `name` |`LOAD STACK`| Load a saved stack. This essentially will "name" your session and store the stack upon exit in the Java preferences system. You can load the stack with the `-l name` command line option, or from within the program by using the `load name` command. Please note the name field is whatever you want to call the instance but avoid spaces in the name. I'm not aware of a limit to the number of saved stacks You can have. If the name to load does not exist, the stack will be created and saved when you exit.|
|-z| `DISABLE COLOR`| Disable colorized output. Useful if your current terminal doesn't support ANSI color sequences|
|-v| `VERSION`| This will display the current program version, but will also check GitHub for the leatest release. It is possible, especially if you are using RPNCalc as a Snap, to have a later version than the latest GitHub release.|
|-h or -?| `HELP`| Display the program help page and exit. This is the same as the `h` or `help` command within RPNCalc|
6 changes: 5 additions & 1 deletion mdbook/src/Chapters/MemoryCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

# Memory Commands

The memory capabilities are fairly flexible. By default, there are 10 memory slots you can use (numbers 0 - 9). This amount can be increased with the `-m NumSlots` command. But be aware, that if you use the `-m` command, it only applies for that instance.
The memory capabilities are fairly flexible. By default, there are 10 memory slots you can use (numbers 0 - 9). This amount can be increased with the `set memslots` command. If you increase or decrease the number of memory slots, it is persistent across RPNCalc executions. You can change it as will, but if you decrease the number of slots, anything held in the "no longer there" slots will be discarded.

For example, say you `set memslots 20` and store values in all of them. If you later `set memslots 10`, the values in the upper 10 slots will be gone.

The operational command `reset` will set the number of memory slots back to the default of 10.

The basic need to is to save a value from the current `line1` into a memory slot and copy it back later. The memory slots are saved between program executions so if you need it in a later session, it will be there. It's saved in the Java preferences system as discussed earlier.

Expand Down
9 changes: 6 additions & 3 deletions mdbook/src/Chapters/OperationalCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ Operational commands are commands that do not directly impact your stack numbers
|list mem|Display the contents of the memory slots|
|list undo|Displays all of the saved stacks and their contents used for undo operations. Basically what your stack will look like when you perform an undo. These are not saved between RPNCalc executions|
|list func|Show a list of the defined User Defined Functions (UDF) and the steps within each one|
|load NAME|Load the named stack. You can `load` a stack name even if it doesn't exist, and it will be created. This is how a new stack is created and is similar to using the `-l name` command line switch. Exiting the program or loading another stack will save the current stack before switching|
|import FILENAME|With `import` RPNCalc will replace the current stack with one loaded from a file. The file format is simple, just one number per line. Do not include any comments or alphanumeric/special characters. Just one number per line with the last number being `line1` - just like the display in RPNCalc|
|load `NAME`|Load the named stack. You can `load` a stack name even if it doesn't exist, and it will be created. This is how a new stack is created and is similar to using the `-l name` command line switch. Exiting the program or loading another stack will save the current stack before switching|
|import `FILENAME`|With `import` RPNCalc will replace the current stack with one loaded from a file. The file format is simple, just one number per line. Do not include any comments or alphanumeric/special characters. Just one number per line with the last number being `line1` - just like the display in RPNCalc|
|ss|Swap the current stack with the secondary. The primary and secondary stacks are described in the Stacks section. Executing `ss` again will swap them back. The secondary stack it just a place to do a bit of other work then you can swap back. They are in no way connected. The secondary stack is also saved upon exit|
|debug|Toggle debug mode which will display additional information on what's happening internally in the program. Same as the `-D` command line switch. Probably not the useful for a normal user|
|a l <br> a d <br> a r| Align the display output to be `l(eft)`, `d(ecimal)`, or `r(ight)`. This is the same as the `-a <l, d, r>` command line switch. `align` or `alignment` may also be used|
|set width `NUM`| Sets the width of the program. The default is 80 characters. If you are using a small display, and the calculator wraps, this can be used to make the width smaller (or larger). Please note that there is a minimium width that must be used. At the time of this writing, it's 46 characters. This setting is persistent across RPNCalc executions|
|set memslots `NUM`| Set the number of memory slots available to RPNCalc to `NUM`. The default is 10 slots, numberd 0 through 9. If you need more, or less, it can be changed with this command. The setting is persistent across RPNCalc executions. `set mem` or `set memoryslots` may also be used. See the memory commands chapter for more information|
|set align `l\|d\|r`| Set the alignment of the stack when it's displayed. The default is `l` or left alignment. The numbers are aligned to the left. `r` or right alignment has the numbers aligned to the right. `d` or decimal aligns all of the decimal points together in a column. This setting is persistent acrsoss PRNCalc executions. `set alignment` may also be used|
|reset| This command resets the configuration setting that are set with the `set` command back to their default values|
|ver| Display the current version number and copyright as well as the latest GitHub release. This is equivalent to the `-v` command line option. Users of Snap installations will automatically be up to date.|
|h <br> ?|`h` or `?` will display the in-program help page|
|cx|`cx` will clear the stack and then exit the program|
Expand Down
8 changes: 1 addition & 7 deletions mdbook/src/Chapters/Stacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ Saving and loading stacks is fundamental to RPNCalc. You can have as many named

It is safe to delete these if you wish to stay tidy, but of course you'll lose any saved stacks, memory slots, and user defined functions which are stored there. They will be recreated again when RPNCalc is started.

Each stack you load (default or a named stack) actually has 2 internal stacks defined; a primary and secondary. You can quickly swap stacks using the swap stack `ss` command. For example, you are working on something and need to do a few calculations that you wish to keep separate from your main work. You can swap stacks, do the work, then swap back. They do not communicate in any way and are distinctly separate. The primary and secondadry stack data is saved and restored upon loading the stack.
Each stack you load (default or a named stack) actually has 2 internal stacks defined; a primary and secondary. You can quickly swap stacks using the swap stack `ss` command. For example, you are working on something and need to do a few calculations that you wish to keep separate from your main work. You can swap stacks, do the work, then swap back. They do not communicate in any way and are distinctly separate. The primary and secondadry stack data is saved and restored upon loading the stack. The primary and secondary stacks have their own unique undo stacks as of version 4.5. This was long standing issue that's now been resolved.

When you start up RPNCalc, you can load a named stack with the `-l name` command. If the stack `name` exists, it will be loaded. If it does not exist, the stack will be created and when you leave the program it will be saved. You can always view what stack you are using in the lower right of the dashed bar. The `:1` or `:2` after the stack name will tell you if you are on the primary or secondary stack.

As a side note, both stacks and memory slots are saved during shutdown. While the data in a stack is specific to that stack, memory slots are global. The default stack items are restored at startup (or whatever stack you choose to load with `-l name`.) Memory slots are also restored at startup. `list mem` will show the values in current memory, and `list stacks` will show the saved stacks available to load.

<hr>

***`Please note that the undo functionality is shared (and shouldn't be) so you could undo on one stack and restore the other. I'm looking into correcting this or perhaps removing the secondary stack as I'm not sure how much it's being used`***

<hr>
2 changes: 0 additions & 2 deletions mdbook/src/Chapters/TrigFunctions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

RPNCalc does not consider itself a scientific calculator (at least not currently). However, it's certainly beyond a very basic calculator. The trigonometry commands listed here are very basic, but do fill a need if you need to do a few basic calculations.



Lastly, I'm happy to add more capabilities if there is a desire (and an offer to help test).

|Command|Description|
Expand Down
4 changes: 2 additions & 2 deletions mdbook/src/Chapters/UserDefinedFunctions.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ User defined functions can be deleted with the `func del NAME` command or you ca

Functions are global and can work across any stack. They are saved in the preferences system and will be reloaded when RPNCalc starts. They are saved immediatly after you give a new recording a name and press enter.

When you execute a function, the steps of that function are executed one after the other. Therefore when you execute `undo` you will undo back through your function step by step. You do not `undo` the entire function in one command. Of course you can always run `undo NUM` where num is the steps to undo.
When you execute a function, the steps of that function are executed one after the other. Therefore when you execute `undo` you will undo back through your function step by step. You do not `undo` the entire function in one command. Of course you can always run `undo NUM` where `NUM` is the steps to undo.

The following commands can be entered during a recording, but are not recorded.
- frac
Expand All @@ -30,7 +30,7 @@ The following commands can be entered during a recording, but are not recorded.
|-------|-----------|
|record on<br>rec on|Turn on recording. Most commands and numbers entered after record is enabled will be saved. There are some that are excluded from being recorded as detailed above|
|record off<br>rec off| Turn off recording. The user will be prompted to enter in a name for this function and that name will be used to run it in the future. If you do not enter in a name the recording is canceled and nothing will be saved|
|func del NAME|Delete a saved function. The name must match the one given when saved. A list of functions can be viewed with `list func`. Undo will not recover a deleted function|
|func del `NAME`|Delete a saved function. The name must match the one given when saved. A list of functions can be viewed with `list func`. Undo will not recover a deleted function|
|func delall|Delete all saved user defined functions. Please note that undo will not recover deleted functions|

### Example
Expand Down
2 changes: 1 addition & 1 deletion mdbook/src/Chapters/Wrapup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Well, if you've read this far you probably know more about RPNCalc than I do. I

I'll continue to add new features as I think about them. If you have suggestions, issues, or ideas, the links to reach out to me are on the Introduction page.

Best wishes and happy calculating...
Best wishes and happy reverse Polish notation calculating...
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.fross</groupId>
<artifactId>rpncalc</artifactId>
<version>4.4.2</version>
<version>4.5.0</version>
<packaging>jar</packaging>

<name>rpncalc</name>
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: rpncalc
version: '4.4.2'
version: '4.5.0'
summary: The command line Reverse Polish Notation (RPN) calculator
description: |
RPNCalc is an easy to use command line based Reverse Polish
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/org/fross/rpncalc/CommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public static void Parse(StackObj calcStack, StackObj calcStack2, String cmdInpu
/*******************************************************************************
* Stack Operational Commands
******************************************************************************/
// List - Supported commands are "stacks" | "mem" | "undo"
// List
case "list":
StackOperations.cmdList(calcStack, cmdInputParam);
break;
Expand All @@ -296,15 +296,14 @@ public static void Parse(StackObj calcStack, StackObj calcStack2, String cmdInpu
StackOperations.cmdDebug();
break;

// Display Alignment
case "a":
case "align":
case "alignment":
try {
StackOperations.cmdAlign(cmdInputParam.charAt(0));
} catch (StringIndexOutOfBoundsException ex) {
Output.printColorln(Ansi.Color.RED, "ERROR: Must provide an alignment value of 'l'eft, 'd'ecimal, or 'r'ight");
}
// Set configuration options
case "set":
StackOperations.cmdSet(cmdInputParam);
break;

// Reset configuration to defaults
case "reset":
StackOperations.cmdReset();
break;

// Version
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/fross/rpncalc/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ public static void Display() {
Output.printColorln(Ansi.Color.YELLOW, "\nCommand Line Options:");
Output.printColorln(Ansi.Color.WHITE, " -l Load a saved named stack. Create the stack if it does not exist");
Output.printColorln(Ansi.Color.WHITE, " -D Start in debug mode. Same as using the 'debug' command");
Output.printColorln(Ansi.Color.WHITE, " -a [lrd] Alignment of numbers. (l)eft, (r)ight, or (d)ecmimal. Default: left");
Output.printColorln(Ansi.Color.WHITE, " -m num Set the number of memory slots. Default value is 10");
Output.printColorln(Ansi.Color.WHITE, " -w num Set Width of header / status line. Default is 70 characters");
Output.printColorln(Ansi.Color.WHITE, " -v Display version information as well as latest GitHub release");
Output.printColorln(Ansi.Color.WHITE, " -z Disable colorized output");
Output.printColorln(Ansi.Color.WHITE, " -h | ? Show this help information. Either key will work.");
Expand Down Expand Up @@ -130,15 +127,14 @@ public static void Display() {
Output.printColorln(Ansi.Color.WHITE, " ss Swap primary and secondary stack");
Output.printColorln(Ansi.Color.WHITE, " load NAME Load (or create if needed) a named stack");
Output.printColorln(Ansi.Color.WHITE, " import FILE Replace current stack with file contents (one number per line)");
Output.printColorln(Ansi.Color.WHITE, " a [lrd] Set display alignment to be (l)eft, (r)ight, or (d)ecmial");
Output.printColorln(Ansi.Color.WHITE, " set align l|d|r Set alignment of the stack display to 'l'eft, 'd'ecimal, or 'r'ight");
Output.printColorln(Ansi.Color.WHITE, " set width num Set the width of the display to num");
Output.printColorln(Ansi.Color.WHITE, " set memslots num Set the number of memory slots");
Output.printColorln(Ansi.Color.WHITE, " reset Resets configurations set with 'set' back to defaults");
Output.printColorln(Ansi.Color.WHITE, " debug Toggle DEBUG mode on/off");
Output.printColorln(Ansi.Color.WHITE, " ver Display the current version");
Output.printColorln(Ansi.Color.WHITE, " h|? Show this help information. Either key will work.");
Output.printColorln(Ansi.Color.WHITE, " cx|x|exit Exit Calculator. 'cx' will clear before exiting");

Output.printColorln(Ansi.Color.YELLOW, "\nNotes:");
Output.printColorln(Ansi.Color.WHITE, " - You can place an operand at the end of a number & execute in one step.");
Output.printColorln(Ansi.Color.WHITE, " Example adding two numbers: 2 <enter> 3+ <enter> will produce 5.");
Output.printColorln(Ansi.Color.CYAN, " - See GitHub homepage (listed above) for more detailed usage instructions\n");
}
}
Loading

0 comments on commit 7aaa208

Please sign in to comment.