11//! Configuration related commands for Neotron OS
22
3- use crate :: { config, osprintln, Ctx } ;
3+ use crate :: { bios , config, osprintln, Ctx } ;
44
55pub static COMMAND_ITEM : menu:: Item < Ctx > = menu:: Item {
66 item_type : menu:: ItemType :: Callback {
@@ -42,16 +42,25 @@ fn command(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, args: &[&str], ctx:
4242 }
4343 } ,
4444 "vga" => match args. get ( 1 ) . cloned ( ) {
45- Some ( "on" ) => {
46- ctx. config . set_vga_console ( true ) ;
47- osprintln ! ( "VGA now on" ) ;
48- }
4945 Some ( "off" ) => {
50- ctx. config . set_vga_console ( false ) ;
46+ ctx. config . set_vga_console ( None ) ;
5147 osprintln ! ( "VGA now off" ) ;
5248 }
49+ Some ( mode_str) => {
50+ let Some ( mode) = mode_str
51+ . parse :: < u8 > ( )
52+ . ok ( )
53+ . and_then ( bios:: video:: Mode :: try_from_u8)
54+ . filter ( |m| m. is_text_mode ( ) )
55+ else {
56+ osprintln ! ( "Not a valid text mode" ) ;
57+ return ;
58+ } ;
59+ ctx. config . set_vga_console ( Some ( mode) ) ;
60+ osprintln ! ( "VGA set to mode {}" , mode. as_u8( ) ) ;
61+ }
5362 _ => {
54- osprintln ! ( "Give on or off as argument" ) ;
63+ osprintln ! ( "Give integer or off as argument" ) ;
5564 }
5665 } ,
5766 "serial" => match ( args. get ( 1 ) . cloned ( ) , args. get ( 1 ) . map ( |s| s. parse :: < u32 > ( ) ) ) {
@@ -68,7 +77,14 @@ fn command(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, args: &[&str], ctx:
6877 }
6978 } ,
7079 "print" => {
71- osprintln ! ( "VGA : {}" , ctx. config. get_vga_console( ) ) ;
80+ match ctx. config . get_vga_console ( ) {
81+ Some ( m) => {
82+ osprintln ! ( "VGA : Mode {}" , m. as_u8( ) ) ;
83+ }
84+ None => {
85+ osprintln ! ( "VGA : off" ) ;
86+ }
87+ } ;
7288 match ctx. config . get_serial_console ( ) {
7389 None => {
7490 osprintln ! ( "Serial: off" ) ;
@@ -83,7 +99,7 @@ fn command(_menu: &menu::Menu<Ctx>, _item: &menu::Item<Ctx>, args: &[&str], ctx:
8399 osprintln ! ( "config help - print this help text" ) ;
84100 osprintln ! ( "config reset - load config from BIOS store" ) ;
85101 osprintln ! ( "config save - save config to BIOS store" ) ;
86- osprintln ! ( "config vga on - turn VGA on " ) ;
102+ osprintln ! ( "config vga <n> - enable VGA in Mode <n> " ) ;
87103 osprintln ! ( "config vga off - turn VGA off" ) ;
88104 osprintln ! ( "config serial off - turn serial console off" ) ;
89105 osprintln ! ( "config serial <baud> - turn serial console on with given baud rate" ) ;
0 commit comments