Add help for connect, make help more consistent
authorLukáš Jiřiště <gymnazium.jiriste@gmail.com>
Sun, 15 Dec 2024 15:46:39 +0000 (16:46 +0100)
committerLukáš Jiřiště <gymnazium.jiriste@gmail.com>
Sun, 15 Dec 2024 15:46:39 +0000 (16:46 +0100)
src/text.c

index 7ef753332feb2b2bea5b33fd02666ddc68fcf8b9..9edb023d54343b698c5a3c3ae93a8b87ba081bcf 100644 (file)
@@ -13,62 +13,92 @@ static const char   g_next_help_str[] = ""
 
 static const char      g_draw_help_str[] = ""
        "draw [IND]\n"
-       "Draws the current state of the simulation.\n"
+       "Draws the current state of the simulation.\n\n"
        "IND\n"
-       "\tDraws the transistors with the index number IND.\n"
-       "\tDefaults to drawing every transistor.\n\n";
+       "\tIndex of the transistor to be drawn.\n"
+       "\tWhen omitted, all transistors are drawn.\n\n";
 
 static const char      g_setnode_help_str[] = ""
        "setnode IND STATE\n"
-       "Sets the \"set_state\" of the node with index IND to state STATE.\n\n";
+       "Sets the \"set_state\" of the node.\n\n"
+       "IND\n"
+       "\tIndex of the node.\n\n"
+       "STATE\n"
+       "\tWhat state the node is set to.\n\n";
 
 static const char      g_addnode_help_str[] = ""
        "addnode [STATE] [NUM]\n"
-       "Adds new nodes.\n"
-       "NUM\n"
-       "\tAdds NUM new nodes.\n"
-       "\tDefaults to 1.\n\n"
+       "Adds new nodes.\n\n"
        "STATE\n"
-       "\tSets \"set_state\" of new nodes to STATE.\n"
-       "\tDefaults to unknown state.\n\n";
+       "\tThe state of created nodes.\n"
+       "\tWhen omitted, state is set to unknown.\n\n"
+       "NUM\n"
+       "\tNumber of new nodes.\n"
+       "\tWhen omitted, adds a single node.\n\n";
 
 static const char      g_addfet_help_str[] = ""
        "addfet TYPE [NUM]\n"
-       "Adds new transistors of type TYPE.\n"
+       "Adds new transistors.\n\n"
+       "TYPE\n"
+       "\tThe type of created transistors.\n\n"
        "NUM\n"
-       "\tAdds NUM new transistors.\n"
-       "\tDefaults to 1.\n\n";
+       "\tNumber of new transistors.\n"
+       "\tWhen omitted, adds a single transistor.\n\n";
 
 static const char      g_bind_help_str[] = ""
        "bind NODE FET TERMINAL\n"
-       "Binds node with index NODE to the TERMINAL of transitor indexed by FET.\n"
-       "Possible values for TERMINAL are gate, source and drain.\n\n";
+       "Binds a terminal of transistor to a node.\n\n"
+       "NODE\n"
+       "\tWhat node the terminal is bound to.\n\n"
+       "FET\n"
+       "\tThe transitor, whose terminal is bound.\n\n"
+       "TERMINAL\n"
+       "\tThe terminal to be bound.\n\n";
 
 static const char      g_help_help_str[] = ""
        "help [COMMAND]\n"
-       "Prints a simple explanation.\n"
+       "Prints a simple explanation.\n\n"
        "COMMAND\n"
-       "\tPrints explanation of COMMAND.\n"
-       "\tWhen no COMMAND is provided, the general help with list of commands is shown.\n\n";
+       "\tThe command for which to print the help.\n"
+       "\tWhen omitted, prints the general help.\n\n";
+
+static const char      g_connect_help_str[] = ""
+       "connect FET_1 TERMINAL_1 FET_2 TERMINAL_2\n"
+       "Connects two terminals.\n\n"
+       "FET\n"
+       "\tThe transistor, whose terminal is connected\n\n"
+       "TERMINAL\n"
+       "\tThe terminal to be connected.\n\n";
 
 static const char      g_help_exit_str[] = ""
        "exit [...]\n"
-       "Exits FET_sim. One may also use ctrl-D.\n"
+       "Exits FET_sim. One may also use ctrl-D.\n\n"
        "[...]\n"
        "\tAnything after the command is ignored.\n\n";
 
 static const char      g_general_help_str[] = ""
-       "This is a FET_sim - simulator of FET (Field Effect Transistor) logic.\n"
+       "This is a FET_sim \n"
+               "\t- simulator of FET (Field Effect Transistor) logic.\n"
        "Version number: %s\n"
        "You can use the following commands:\n\n"
-       "next [STEPS] \t\t- advances the simulation\n"
-       "draw [IND] \t\t- draws the state of the simulation\n"
-       "setnode IND STATE \t- sets the \"set_state\" of the node indexed by IND to STATE\n"
-       "addnode [STATE] [NUM] \t- adds new nodes\n"
-       "addfet TYPE [NUM] \t- adds new FETs\n"
-       "bind NODE FET TERMINAL \t- binds node indexed by NODE to TERMINAL of transistor indexed by FET\n"
-       "help [COMMAND] \t\t- shows this help or help for COMMAND\n"
-       "exit [...] \t\t- exits this program\n\n";
+       "next [NUM] \n"
+               "\t- advances the simulation by NUM (1) steps\n"
+       "draw [FET] \n"
+               "\t- draws FET (all transistors)\n"
+       "setnode NODE STATE \n"
+               "\t- sets STATE to node NODE\n"
+       "addnode [STATE] [NUM] \n"
+               "\t- adds NUM (1) new nodes with STATE (unknown)\n"
+       "addfet TYPE [NUM] \n"
+               "\t- adds NUM (1) new transistors of TYPE\n"
+       "bind NODE FET TERMINAL \n"
+               "\t- binds NODE to TERMINAL of FET\n"
+       "connect FET TERMINAL FET TERMINAL\n"
+               "\t- connects TERMINALs of FETs together\n"
+       "help [COMMAND] \n"
+               "\t- shows help for COMMAND (this help)\n"
+       "exit [...] \n"
+               "\t- exits this program\n\n";
 
 void   print_help(WINDOW *command_win, t_command c)
 {
@@ -84,6 +114,8 @@ void print_help(WINDOW *command_win, t_command c)
                wprintw(command_win, g_addfet_help_str);
        else if (c == bind)
                wprintw(command_win, g_bind_help_str);
+       else if (c == connect)
+               wprintw(command_win, g_connect_help_str);
        else if (c == help)
                wprintw(command_win, g_help_help_str);
        else if (c == exitsim)