summaryrefslogtreecommitdiff
path: root/com32/hdt/hdt-cli.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/hdt/hdt-cli.c')
-rw-r--r--com32/hdt/hdt-cli.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 871fd76c..0d38fb2b 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -43,7 +43,9 @@ struct cli_mode_descr *list_modes[] = {
&cpu_mode,
&pci_mode,
&vesa_mode,
+ &disk_mode,
&vpd_mode,
+ &memory_mode,
NULL,
};
@@ -179,6 +181,12 @@ void set_mode(cli_mode_t mode, struct s_hardware* hardware)
snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
CLI_DMI);
break;
+ case DISK_MODE:
+ detect_disks(hardware);
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
+ CLI_DISK);
+ break;
case VPD_MODE:
detect_vpd(hardware);
if (!hardware->is_vpd_valid) {
@@ -189,7 +197,11 @@ void set_mode(cli_mode_t mode, struct s_hardware* hardware)
snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
CLI_VPD);
break;
-
+ case MEMORY_MODE:
+ hdt_cli.mode = mode;
+ snprintf(hdt_cli.prompt, sizeof(hdt_cli.prompt), "%s> ",
+ CLI_MEMORY);
+ break;
default:
/* Invalid mode */
printf("Unknown mode, please choose among:\n");
@@ -424,16 +436,14 @@ void find_cli_callback_descr(const char* module_name,
struct cli_callback_descr** module_found)
{
int modules_iter = 0;
- int module_len = strlen(module_name);
if (modules_list == NULL)
goto not_found;
/* Find the callback to execute */
while (modules_list->modules[modules_iter].name &&
- strncmp(module_name,
- modules_list->modules[modules_iter].name,
- module_len) != 0)
+ strcmp(module_name,
+ modules_list->modules[modules_iter].name) != 0)
modules_iter++;
if (modules_list->modules[modules_iter].name) {
@@ -765,16 +775,23 @@ void start_cli_mode(struct s_hardware *hardware)
printf("Entering CLI mode\n");
- /* Display the cursor */
- display_cursor(true);
-
reset_prompt();
while (hdt_cli.mode != EXIT_MODE) {
- //fgets(cli_line, sizeof cli_line, stdin);
+ /* Display the cursor */
+ display_cursor(true);
+
+ /* Let's put the cursor blinking until we get an input */
+ set_cursor_blink(true);
+
+ /* We wait endlessly for a keyboard input*/
current_key = get_key(stdin, 0);
+ /* We have to cancel the blinking mode to prevent
+ * input text to blink */
+ set_cursor_blink(false);
+
/* Reset autocomplete buffer unless TAB is pressed */
if (current_key != KEY_TAB)
autocomplete_destroy_list();
@@ -967,14 +984,10 @@ void start_cli_mode(struct s_hardware *hardware)
/* Print the resulting buffer */
printf("%s", hdt_cli.input + hdt_cli.cursor_pos - 1);
- /* Realing to the place we were */
- move_cursor_left(strlen(hdt_cli.input + hdt_cli.cursor_pos - 1));
- move_cursor_right(1);
+ /* Realing to a char before the place we were */
+ hdt_cli.cursor_pos--;
+ move_cursor_to_column(strlen(hdt_cli.prompt)+hdt_cli.cursor_pos+1);
- /* Don't decrement the position unless
- * if we are at then end of the line*/
- if (hdt_cli.cursor_pos > (int)strlen(hdt_cli.input))
- hdt_cli.cursor_pos--;
break;
case KEY_F1: