boot: more editor key binds
This commit is contained in:
parent
14345b73db
commit
aca614207e
@ -6,6 +6,7 @@
|
||||
#include "menu.h"
|
||||
#include "text.h"
|
||||
#include "multiboot.h"
|
||||
#include "editor.h"
|
||||
|
||||
/* Basic text strings */
|
||||
#define BASE_VERSION "ToaruOS Bootloader v4.0"
|
||||
@ -80,60 +81,64 @@ int kmain() {
|
||||
"Migrates the ramdisk from tarball to an in-memory",
|
||||
"temporary filesystem at boot. Needed for packages.");
|
||||
|
||||
/* Loop over rendering the menu */
|
||||
show_menu();
|
||||
while (1) {
|
||||
/* Loop over rendering the menu */
|
||||
show_menu();
|
||||
|
||||
/* Build our command line. */
|
||||
strcat(cmdline, DEFAULT_ROOT_CMDLINE);
|
||||
/* Build our command line. */
|
||||
strcat(cmdline, DEFAULT_ROOT_CMDLINE);
|
||||
|
||||
if (_migrate) {
|
||||
strcat(cmdline, MIGRATE_CMDLINE);
|
||||
}
|
||||
if (_migrate) {
|
||||
strcat(cmdline, MIGRATE_CMDLINE);
|
||||
}
|
||||
|
||||
char * _video_command_line = DEFAULT_VID_CMDLINE;
|
||||
char * _video_command_line = DEFAULT_VID_CMDLINE;
|
||||
|
||||
if (boot_mode == 1) {
|
||||
strcat(cmdline, DEFAULT_GRAPHICAL_CMDLINE);
|
||||
strcat(cmdline, _video_command_line);
|
||||
} else if (boot_mode == 2) {
|
||||
strcat(cmdline, DEFAULT_TEXT_CMDLINE);
|
||||
} else if (boot_mode == 3) {
|
||||
strcat(cmdline, DEFAULT_SINGLE_CMDLINE);
|
||||
strcat(cmdline, _video_command_line);
|
||||
} else if (boot_mode == 4) {
|
||||
strcat(cmdline, DEFAULT_HEADLESS_CMDLINE);
|
||||
}
|
||||
if (boot_mode == 1) {
|
||||
strcat(cmdline, DEFAULT_GRAPHICAL_CMDLINE);
|
||||
strcat(cmdline, _video_command_line);
|
||||
} else if (boot_mode == 2) {
|
||||
strcat(cmdline, DEFAULT_TEXT_CMDLINE);
|
||||
} else if (boot_mode == 3) {
|
||||
strcat(cmdline, DEFAULT_SINGLE_CMDLINE);
|
||||
strcat(cmdline, _video_command_line);
|
||||
} else if (boot_mode == 4) {
|
||||
strcat(cmdline, DEFAULT_HEADLESS_CMDLINE);
|
||||
}
|
||||
|
||||
if (_debug) {
|
||||
txt_debug = 1;
|
||||
}
|
||||
if (_debug) {
|
||||
txt_debug = 1;
|
||||
}
|
||||
|
||||
if (!_vbox) {
|
||||
strcat(cmdline, "novbox ");
|
||||
}
|
||||
if (!_vbox) {
|
||||
strcat(cmdline, "novbox ");
|
||||
}
|
||||
|
||||
if (_vbox && !_vboxrects) {
|
||||
strcat(cmdline, "novboxseamless ");
|
||||
}
|
||||
if (_vbox && !_vboxrects) {
|
||||
strcat(cmdline, "novboxseamless ");
|
||||
}
|
||||
|
||||
if (_vbox && !_vboxpointer) {
|
||||
strcat(cmdline, "novboxpointer ");
|
||||
}
|
||||
if (_vbox && !_vboxpointer) {
|
||||
strcat(cmdline, "novboxpointer ");
|
||||
}
|
||||
|
||||
if (_vmware && !_vmwareres) {
|
||||
strcat(cmdline, "novmwareresset ");
|
||||
}
|
||||
if (_vmware && !_vmwareres) {
|
||||
strcat(cmdline, "novmwareresset ");
|
||||
}
|
||||
|
||||
if (!_smp) {
|
||||
strcat(cmdline, "nosmp ");
|
||||
}
|
||||
if (!_smp) {
|
||||
strcat(cmdline, "nosmp ");
|
||||
}
|
||||
|
||||
if (_qemubug) {
|
||||
strcat(cmdline, "sharedps2 ");
|
||||
}
|
||||
if (_qemubug) {
|
||||
strcat(cmdline, "sharedps2 ");
|
||||
}
|
||||
|
||||
if (boot_edit) {
|
||||
boot_editor();
|
||||
if (!boot_edit) break;
|
||||
if (boot_editor()) break;
|
||||
|
||||
boot_edit = 0;
|
||||
memset(cmdline, 0, 1024);
|
||||
}
|
||||
|
||||
boot();
|
||||
|
@ -2,11 +2,11 @@
|
||||
#include "options.h"
|
||||
#include "text.h"
|
||||
#include "util.h"
|
||||
#include "kbd.h"
|
||||
|
||||
extern int read_key(char * c);
|
||||
|
||||
void boot_editor(void) {
|
||||
int boot_edit = 0;
|
||||
|
||||
int boot_editor(void) {
|
||||
int len = strlen(cmdline);
|
||||
int cursor = len;
|
||||
|
||||
@ -30,7 +30,9 @@ void boot_editor(void) {
|
||||
if (status == 0) {
|
||||
/* Handle a few special characters */
|
||||
if (data == '\n') {
|
||||
return;
|
||||
return 1;
|
||||
} else if (data == 27) {
|
||||
return 0;
|
||||
} else if (data == '\b') {
|
||||
if (!cursor) continue;
|
||||
if (cursor == len) {
|
||||
@ -61,7 +63,16 @@ void boot_editor(void) {
|
||||
/* Left */
|
||||
if (cursor) cursor--;
|
||||
} else if (status == 3) {
|
||||
/* Right */
|
||||
if (cursor < len) cursor++;
|
||||
} else if (status == 4) {
|
||||
/* Shift-left: Word left */
|
||||
while (cursor && cmdline[cursor] == ' ') cursor--;
|
||||
while (cursor && cmdline[cursor] != ' ') cursor--;
|
||||
} else if (status == 5) {
|
||||
/* Shift-right: Word right */
|
||||
while (cursor < len && cmdline[cursor] == ' ') cursor++;
|
||||
while (cursor < len && cmdline[cursor] != ' ') cursor++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4
boot/editor.h
Normal file
4
boot/editor.h
Normal file
@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
extern int boot_edit;
|
||||
int boot_editor(void);
|
@ -20,7 +20,7 @@ static char kbd_us_l2[128] = {
|
||||
'_','+','\b', '\t', 'Q','W','E','R','T','Y','U','I','O','P','{','}','\n',
|
||||
0, 'A','S','D','F','G','H','J','K','L',':','"', '~',
|
||||
0, '|','Z','X','C','V','B','N','M','<','>','?',
|
||||
0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, '*', 0, '\037', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
'-', 0, 0, 0, '+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
@ -42,8 +42,8 @@ int read_key(char * c) {
|
||||
return 1;
|
||||
|
||||
/* Keft left and right */
|
||||
case 0x4B: return 2;
|
||||
case 0x4D: return 3;
|
||||
case 0x4B: return shift_state ? 4 : 2;
|
||||
case 0x4D: return shift_state ? 5 : 3;
|
||||
}
|
||||
|
||||
if (!(sc & 0x80)) {
|
||||
|
@ -9,4 +9,5 @@
|
||||
#define KBD_SCAN_9 10
|
||||
|
||||
int read_scancode(int);
|
||||
int read_key(char * c);
|
||||
|
||||
|
@ -3,13 +3,13 @@
|
||||
#include "util.h"
|
||||
#include "kbd.h"
|
||||
#include "qemu.h"
|
||||
#include "editor.h"
|
||||
|
||||
struct option boot_options[20] = {{0}};
|
||||
|
||||
int sel_max = 0;
|
||||
int sel = 0;
|
||||
int boot_mode = 0;
|
||||
int boot_edit = 0;
|
||||
|
||||
void toggle(int ndx, int value, char *str) {
|
||||
set_attr(sel == ndx ? 0x70 : 0x07);
|
||||
|
@ -1,6 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
extern int boot_mode;
|
||||
extern int boot_edit;
|
||||
void show_menu(void);
|
||||
void boot_editor(void);
|
||||
|
Loading…
Reference in New Issue
Block a user