Skip to content

Commit

Permalink
Added a config display if set is entered w/o parameters
Browse files Browse the repository at this point in the history
This also necessitated updates to help and the User Guide.
  • Loading branch information
frossm committed Aug 5, 2022
1 parent 4d7320e commit db641b6
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mdbook/src/Chapters/CalculatorCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ These commands, like the others you'll read about later, are executed by typing
|f <br> flip | **FLIP SIGN**<br>Flip the sign on the top stack item (`line1`). This is effectively multiplying `line1` by -1|
|c <br> clear| **CLEAR**<br>Clear the current stack and the screen. Memory data is retained and you can undo the clear with the undo `u` command|
|cl <br> clean| **CLEAN SCREEN**<br>Clear the current screen, but keep the stack. After cleaning, the stack will be displayed at the top of the screen. Used to remove the clutter|
|d<br>d [#]<br>d [#-#]| **DELETE**<br>If `d` is given without any parameters, it will delete `line1`. If a line number is given after the `d`, that line number will be deleted. A range can be given as well, such as `d 1-3` and RPNCalc will delete those lines and everything inbetween|
|d<br>d [#]<br>d [#-#]| **DELETE**<br>If `d` is given without any parameters, it will delete `line1`. If a line number is given after the `d`, that line number will be deleted. A range can be given as well, such as `d 1-3` and RPNCalc will delete those lines and everything in between. `del` can also be used|
|s [#] \[#] <br> swap [#] \[#]| **SWAP LINES**<br>Without an argument, swap the top two stack items (`line1 & line2`). You can swap any two line numbers in your stack by providing the two line numbers|
|%| **PERCENT**<br>Assumes `line1` contains a percent. This converts that into a number by simply dividing that value by 100. For example, if you want to take 50.123% of a number, you could just enter in `50.123 [ENTER] % [ENTER] *`|
|sqrt| **SQUARE ROOT**<br>Perform a [square root](https://en.wikipedia.org/wiki/Square_root) of the top stack item (`line1`)|
Expand Down
1 change: 1 addition & 0 deletions mdbook/src/Chapters/OperationalCommands.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Operational commands are commands that do not directly impact your stack numbers
|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|
|set|Display the current values of the configurable persistent settings|
|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 minimum 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, numbed 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 across RPNCalc executions. `set alignment` may also be used|
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>org.fross</groupId>
<artifactId>rpncalc</artifactId>
<version>4.6.7</version>
<version>4.6.8</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.6.7'
version: '4.6.8'
summary: The command line Reverse Polish Notation (RPN) calculator
description: |
RPNCalc is an easy to use command line based Reverse Polish
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/fross/rpncalc/CommandParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public static void Parse(StackObj calcStack, StackObj calcStack2, String cmdInpu
// Delete
case "del":
case "d":
case "drop":
StackCommands.cmdDelete(calcStack, cmdInputParam);
break;

Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/fross/rpncalc/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ 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, " set Display current values of configurations you can set");
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");
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/fross/rpncalc/StackOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ public static void cmdSet(String arg) {
String command = "";
String value = "";

// If there is not a parameter provided, display the current values and return
if (arg.isBlank()) {
Output.printColorln(Ansi.Color.YELLOW, "\n-Configuration Values" + "-".repeat(Main.configProgramWidth - 21));
Output.printColorln(Ansi.Color.CYAN, "Width: " + Main.configProgramWidth + "\t| Sets the program width in characters");
Output.printColorln(Ansi.Color.CYAN, "Align: " + Main.configAlignment + "\t| Sets alignment of the stack display");
Output.printColorln(Ansi.Color.CYAN, "MemSlots: " + Main.configMemorySlots + "\t| Sets number of available memory slots");
Output.printColorln(Ansi.Color.YELLOW, "-".repeat(Main.configProgramWidth) + "\n");
return;
}

// Parse the provided argument into a command and value
try {
argParse = arg.split(" ");
Expand All @@ -159,7 +169,7 @@ public static void cmdSet(String arg) {
case "align":
case "alignment":
if (value.toLowerCase().compareTo("l") != 0 && value.toLowerCase().compareTo("d") != 0 && value.toLowerCase().compareTo("r") != 0) {
Output.printColorln(Ansi.Color.RED, "Alignment can only be 'l'eft, 'd'ecimal, or 'r'ight. See help for mem command usage");
Output.printColorln(Ansi.Color.RED, "Alignment can only be 'l'eft, 'd'ecimal, or 'r'ight. See help for set command usage");
return;
}
Main.configAlignment = value;
Expand Down Expand Up @@ -191,7 +201,7 @@ public static void cmdSet(String arg) {
}

} catch (Exception ex) {
Output.printColorln(Ansi.Color.RED, "Error parsing set command: 'set " + arg + "' See help for mem command usage");
Output.printColorln(Ansi.Color.RED, "Error parsing set command: 'set " + arg + "' See help for set command usage");
return;
}
}
Expand Down

0 comments on commit db641b6

Please sign in to comment.