Skip to content

Commit

Permalink
Updated help page, UDF exluded cmds, and User Guide
Browse files Browse the repository at this point in the history
  • Loading branch information
frossm committed Aug 5, 2022
1 parent 2665ec6 commit 4d7320e
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 64 deletions.
3 changes: 2 additions & 1 deletion mdbook/src/Chapters/UserDefinedFunctions.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ The following commands can be entered during a recording, but are not recorded.
- help, h, ?
- rec, record
- func, function
- cx, x, or exit
- set, reset
- cx, x, quit, exit

|Command|Description|
|-------|-----------|
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.6</version>
<version>4.6.7</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.6'
version: '4.6.7'
summary: The command line Reverse Polish Notation (RPN) calculator
description: |
RPNCalc is an easy to use command line based Reverse Polish
Expand Down
102 changes: 51 additions & 51 deletions src/main/java/org/fross/rpncalc/Help.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,75 +66,75 @@ public static void Display() {
Output.printColorln(Ansi.Color.WHITE, " ^ Power: Calculate line2 to the power of line1");

Output.printColorln(Ansi.Color.YELLOW, "\nCalculator Commands:");
Output.printColorln(Ansi.Color.WHITE, " u [STACK #] Undo last action or back to the undo stack defined in 'list undo'");
Output.printColorln(Ansi.Color.WHITE, " f Flip the sign of the element at line1");
Output.printColorln(Ansi.Color.WHITE, " c Clear the screen and empty current stack");
Output.printColorln(Ansi.Color.WHITE, " cl[ean] Clear screen but keep the stack values");
Output.printColorln(Ansi.Color.WHITE, " d [#] [#-#] Delete line1, the line number provided, or a range of lines");
Output.printColorln(Ansi.Color.WHITE, " s [#] [#] Swap the last two elments in the stack or the lines provided");
Output.printColorln(Ansi.Color.WHITE, " % Convert line1 into a percentage by multipling it by 0.01");
Output.printColorln(Ansi.Color.WHITE, " sqrt Perform a square root of the line1 value");
Output.printColorln(Ansi.Color.WHITE, " round [n] Round to n decimal places. Default is 0 decimals");
Output.printColorln(Ansi.Color.WHITE, " aa [keep] Add all stack items. Adding 'keep' will keep existing elements");
Output.printColorln(Ansi.Color.WHITE, " mod Modulus. Perform a division and return the remainder");
Output.printColorln(Ansi.Color.WHITE, " avg [keep] Replace stack with average of values. 'keep' will retain stack");
Output.printColorln(Ansi.Color.WHITE, " sd [keep] Standard deviation of stack items. 'keep' will retain stack");
Output.printColorln(Ansi.Color.WHITE, " copy [#] Copy line1 or the optional line number and add it to the stack");
Output.printColorln(Ansi.Color.WHITE, " log | log10 Calculate the natural (base e) or base10 logarithm");
Output.printColorln(Ansi.Color.WHITE, " int Convert line1 to an integer. No rounding is performed");
Output.printColorln(Ansi.Color.WHITE, " abs Take the absolute value of line1");
Output.printColorln(Ansi.Color.WHITE, " min | max Adds the minimum or maximum value of stack items to the stack");
Output.printColorln(Ansi.Color.WHITE, " rand [L] [H] Random integer between L and H inclusive. Default is 1-100");
Output.printColorln(Ansi.Color.WHITE, " dice XdY Roll a Y sided die X times. Default is 1d6");
Output.printColorln(Ansi.Color.WHITE, " u [STACK #] Undo last action or back to the undo stack defined in 'list undo'");
Output.printColorln(Ansi.Color.WHITE, " f Flip the sign of the element at line1");
Output.printColorln(Ansi.Color.WHITE, " c Clear the screen and empty current stack");
Output.printColorln(Ansi.Color.WHITE, " cl[ean] Clear screen but keep the stack values");
Output.printColorln(Ansi.Color.WHITE, " d [#] [#-#] Delete line1, the line number provided, or a range of lines");
Output.printColorln(Ansi.Color.WHITE, " s [#] [#] Swap the last two elments in the stack or the lines provided");
Output.printColorln(Ansi.Color.WHITE, " % Convert line1 into a percentage by multipling it by 0.01");
Output.printColorln(Ansi.Color.WHITE, " sqrt Perform a square root of the line1 value");
Output.printColorln(Ansi.Color.WHITE, " round [n] Round to n decimal places. Default is 0 decimals");
Output.printColorln(Ansi.Color.WHITE, " aa [keep] Add all stack items. Adding 'keep' will keep existing elements");
Output.printColorln(Ansi.Color.WHITE, " mod Modulus. Perform a division and return the remainder");
Output.printColorln(Ansi.Color.WHITE, " avg [keep] Replace stack with average of values. 'keep' will retain stack");
Output.printColorln(Ansi.Color.WHITE, " sd [keep] Standard deviation of stack items. 'keep' will retain stack");
Output.printColorln(Ansi.Color.WHITE, " copy [#] Copy line1 or the optional line number and add it to the stack");
Output.printColorln(Ansi.Color.WHITE, " log | log10 Calculate the natural (base e) or base10 logarithm");
Output.printColorln(Ansi.Color.WHITE, " int Convert line1 to an integer. No rounding is performed");
Output.printColorln(Ansi.Color.WHITE, " abs Take the absolute value of line1");
Output.printColorln(Ansi.Color.WHITE, " min | max Adds the minimum or maximum value of stack items to the stack");
Output.printColorln(Ansi.Color.WHITE, " rand [L] [H] Random integer between L and H inclusive. Default is 1-100");
Output.printColorln(Ansi.Color.WHITE, " dice XdY Roll a Y sided die X times. Default is 1d6");

Output.printColorln(Ansi.Color.YELLOW, "\nConversions:");
Output.printColorln(Ansi.Color.WHITE, " frac [base] Display as a fraction with min provided base. Default base is 64th");
Output.printColorln(Ansi.Color.WHITE, " in2mm Convert line1 from inches into millimeters");
Output.printColorln(Ansi.Color.WHITE, " mm2in Convert line1 from millimeters to inches");
Output.printColorln(Ansi.Color.WHITE, " rad2deg Convert line1 from raidans to degrees");
Output.printColorln(Ansi.Color.WHITE, " deg2rad Convert line1 from degrees to radians");
Output.printColorln(Ansi.Color.WHITE, " frac [base] Display as a fraction with min provided base. Default base is 64th");
Output.printColorln(Ansi.Color.WHITE, " in2mm Convert line1 from inches into millimeters");
Output.printColorln(Ansi.Color.WHITE, " mm2in Convert line1 from millimeters to inches");
Output.printColorln(Ansi.Color.WHITE, " rad2deg Convert line1 from raidans to degrees");
Output.printColorln(Ansi.Color.WHITE, " deg2rad Convert line1 from degrees to radians");

Output.printColorln(Ansi.Color.YELLOW, "\nTrigonometry Functions:");
Output.printColorln(Ansi.Color.WHITE, " sin|cos|tan [rad] Trig Functions: Angle in degrees unless rad is provided");
Output.printColorln(Ansi.Color.WHITE, " asin|acos|atan [rad] Trig Functions: Result in degrees unless rad is provided");
Output.printColorln(Ansi.Color.WHITE, " hypot Returns the hypotenuse using line1 and line2 as the legs");

Output.printColorln(Ansi.Color.YELLOW, "\nMemory Commands:");
Output.printColorln(Ansi.Color.WHITE, " mem [X] add Add line1 to memory slot X. Default slot is 0");
Output.printColorln(Ansi.Color.WHITE, " mem [X] copy Copy number from memory slot X. Default slot is 0");
Output.printColorln(Ansi.Color.WHITE, " mem [X] clr Clear memory from slot X. Default slot0");
Output.printColorln(Ansi.Color.WHITE, " mem clearall Clear all memory slots");
Output.printColorln(Ansi.Color.WHITE, " mem copyall Copy all memory items onto the stack");
Output.printColorln(Ansi.Color.WHITE, " mem addall Add all stack items to memory slots");
Output.printColorln(Ansi.Color.WHITE, " mem [X] add Add line1 to memory slot X. Default slot is 0");
Output.printColorln(Ansi.Color.WHITE, " mem [X] copy Copy number from memory slot X. Default slot is 0");
Output.printColorln(Ansi.Color.WHITE, " mem [X] clr Clear memory from slot X. Default slot0");
Output.printColorln(Ansi.Color.WHITE, " mem clearall Clear all memory slots");
Output.printColorln(Ansi.Color.WHITE, " mem copyall Copy all memory items onto the stack");
Output.printColorln(Ansi.Color.WHITE, " mem addall Add all stack items to memory slots");

Output.printColorln(Ansi.Color.YELLOW, "\nConstants:");
Output.printColorln(Ansi.Color.WHITE, " pi Add Archimede's constant (PI)");
Output.printColorln(Ansi.Color.WHITE, " phi Add the Golden Ratio (phi)");
Output.printColorln(Ansi.Color.WHITE, " euler Add Euler's exponential growth constant (e)");
Output.printColorln(Ansi.Color.WHITE, " sol Add the Speed of Light (c)");
Output.printColorln(Ansi.Color.WHITE, " pi Add Archimede's constant (PI)");
Output.printColorln(Ansi.Color.WHITE, " phi Add the Golden Ratio (phi)");
Output.printColorln(Ansi.Color.WHITE, " euler Add Euler's exponential growth constant (e)");
Output.printColorln(Ansi.Color.WHITE, " sol Add the Speed of Light (c)");

Output.printColorln(Ansi.Color.YELLOW, "\nUser Defined Functions:");
Output.printColorln(Ansi.Color.WHITE, " record on Turn on command recording");
Output.printColorln(Ansi.Color.WHITE, " record off Disable recording");
Output.printColorln(Ansi.Color.WHITE, " func del NAME Delete named user defined function");
Output.printColorln(Ansi.Color.WHITE, " func delall Delete all user defined functions");
Output.printColorln(Ansi.Color.WHITE, " record on Turn on command recording");
Output.printColorln(Ansi.Color.WHITE, " record off Disable recording");
Output.printColorln(Ansi.Color.WHITE, " func del NAME Delete named user defined function");
Output.printColorln(Ansi.Color.WHITE, " func delall Delete all user defined functions");

Output.printColorln(Ansi.Color.YELLOW, "\nOperational Commands:");
Output.printColorln(Ansi.Color.WHITE, " list stacks Show the list of saved stacks");
Output.printColorln(Ansi.Color.WHITE, " list mem Display contents of the memory slots");
Output.printColorln(Ansi.Color.WHITE, " list undo Show the current undo stack");
Output.printColorln(Ansi.Color.WHITE, " list func Display the detailed user defined functions");
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, " list stacks Show the list of saved stacks");
Output.printColorln(Ansi.Color.WHITE, " list mem Display contents of the memory slots");
Output.printColorln(Ansi.Color.WHITE, " list undo Show the current undo stack");
Output.printColorln(Ansi.Color.WHITE, " list func Display the detailed user defined functions");
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 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.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");

}
}
18 changes: 9 additions & 9 deletions src/main/java/org/fross/rpncalc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public class Main {
static StackObj calcStack2 = new StackObj();

// Configuration Values
static int configProgramWidth = 80;
static int configMemorySlots = 10;
static String configAlignment = "l";
static int configProgramWidth = CONFIG_DEFAULT_PROGRAM_WIDTH;
static int configMemorySlots = CONFIG_DEFAULT_MEMORY_SLOTS;
static String configAlignment = CONFIG_DEFAULT_ALIGNMENT;

/**
* Display Version(): Show the program version, copyright, and latest GitHub release
Expand Down Expand Up @@ -163,11 +163,11 @@ public static void main(String[] args) {
// Display some useful information about the environment if in Debug Mode
Debug.displaySysInfo();
Output.debugPrint("Command Line Options");
Output.debugPrint(" -D: " + Debug.query());
Output.debugPrint(" -l: " + calcStack.queryStackName());
Output.debugPrint(" -w: " + configProgramWidth);
Output.debugPrint(" -m: " + configMemorySlots);
Output.debugPrint(" Color Enabled: " + Output.queryColorEnabled());
Output.debugPrint(" - DebugModeOn: " + Debug.query());
Output.debugPrint(" - StackName: " + calcStack.queryStackName());
Output.debugPrint(" - Program Width: " + configProgramWidth);
Output.debugPrint(" - Memory Slots: " + configMemorySlots);
Output.debugPrint(" - Color Enabled: " + Output.queryColorEnabled());

// Restore the items in the memory slots during startup
StackMemory.RestoreMemSlots();
Expand Down Expand Up @@ -255,7 +255,7 @@ public static void main(String[] args) {
continue;
}
}
Output.debugPrint("Complete Input: '" + cmdInput + "' | InputCommand '" + cmdInputCmd + "' | InputParameter: '" + cmdInputParam + "'");
Output.debugPrint("Complete Input: '" + cmdInput + "' | InputCommand: '" + cmdInputCmd + "' | InputParameter: '" + cmdInputParam + "'");

// If recording is enabled, send the user input to be recorded
if (UserFunctions.recordingIsEnabled() == true) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/fross/rpncalc/UserFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ public static boolean recordingIsEnabled() {
*/
public static void RecordCommand(String arg) {
// Ignore the following commands from recording
String[] ignore = { "frac", "list", "debug", "ver", "version", "h", "help", "?", "record", "rec", "function", "func", "cx", "x", "exit" };
String[] ignore = { "frac", "list", "debug", "ver", "version", "h", "help", "?", "record", "rec", "function", "func", "set", "reset", "cx", "x", "exit",
"quit" };

// If the command starts with an ignored item, just return before adding it to the recording
for (int i = 0; i < ignore.length; i++) {
Expand Down

0 comments on commit 4d7320e

Please sign in to comment.