File tree 4 files changed +53
-5
lines changed
4 files changed +53
-5
lines changed Original file line number Diff line number Diff line change
1
+ use alloc:: string:: String ;
2
+ use liumlib:: gui:: * ;
3
+ use liumlib:: * ;
4
+
5
+ #[ derive( Debug , Clone ) ]
6
+ pub struct ApplicationWindow {
7
+ width : u64 ,
8
+ height : u64 ,
9
+ title : String ,
10
+ buffer : WindowBuffer ,
11
+ }
12
+
13
+ impl ApplicationWindow {
14
+ pub fn new ( w : u64 , h : u64 , title : String ) -> Self {
15
+ let window_buffer = match create_window ( w as usize , h as usize ) {
16
+ Err ( _) => panic ! ( "Failed to create window" ) ,
17
+ Ok ( w) => w,
18
+ } ;
19
+
20
+ Self {
21
+ width : w,
22
+ height : h,
23
+ title,
24
+ buffer : window_buffer,
25
+ }
26
+ }
27
+
28
+ pub fn initialize ( & mut self ) {
29
+ match draw_rect (
30
+ & self . buffer ,
31
+ 0xffffff ,
32
+ 0 ,
33
+ 0 ,
34
+ self . width as i64 ,
35
+ self . height as i64 ,
36
+ ) {
37
+ Ok ( ( ) ) => { }
38
+ Err ( e) => println ! ( "{}" , e) ,
39
+ } ;
40
+ self . buffer . flush ( ) ;
41
+ }
42
+ }
Original file line number Diff line number Diff line change 2
2
3
3
extern crate alloc;
4
4
5
+ pub mod gui;
5
6
pub mod http;
6
7
pub mod net;
7
8
pub mod renderer;
Original file line number Diff line number Diff line change 1
1
#![ no_std]
2
2
#![ no_main]
3
3
4
+ mod gui;
4
5
mod http;
5
6
mod net;
6
7
mod renderer;
@@ -9,32 +10,33 @@ mod url;
9
10
extern crate alloc;
10
11
11
12
use alloc:: string:: ToString ;
13
+ use liumlib:: gui:: * ;
12
14
use liumlib:: * ;
13
15
16
+ use crate :: gui:: ApplicationWindow ;
14
17
use crate :: net:: udp_response;
15
18
use crate :: renderer:: render;
16
19
use crate :: url:: ParsedUrl ;
17
20
18
21
fn help_message ( ) {
19
22
println ! ( "Usage: browser-rs.bin [ OPTIONS ]" ) ;
20
23
println ! ( " -u, --url URL. Default: http://127.0.0.1:8888/index.html" ) ;
24
+ println ! ( " -h, --help Show this help message." ) ;
21
25
exit ( 0 ) ;
22
26
}
23
27
24
28
entry_point ! ( main) ;
25
29
fn main ( ) {
26
30
let mut url = "http://127.0.0.1:8888/index.html" ;
27
31
28
- let help_flag = "--help" . to_string ( ) ;
29
- let url_flag = "--url" . to_string ( ) ;
30
-
31
32
let args = env:: args ( ) ;
32
33
for i in 1 ..args. len ( ) {
33
- if help_flag == args[ i] {
34
+ if "--help" . to_string ( ) == args [ i ] || "-h" == args[ i] {
34
35
help_message ( ) ;
36
+ return ;
35
37
}
36
38
37
- if url_flag == args[ i] {
39
+ if "--url" . to_string ( ) == args [ i ] || "-u" . to_string ( ) == args[ i] {
38
40
if i + 1 >= args. len ( ) {
39
41
help_message ( ) ;
40
42
}
@@ -44,6 +46,8 @@ fn main() {
44
46
45
47
let parsed_url = ParsedUrl :: new ( url. to_string ( ) ) ;
46
48
49
+ let _app = ApplicationWindow :: new ( 512 , 256 , "my browser" . to_string ( ) ) . initialize ( ) ;
50
+
47
51
let response = udp_response ( & parsed_url) ;
48
52
49
53
println ! ( "----- receiving a response -----" ) ;
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ pub struct BMPInfoV3Header {
34
34
pub b_mask : u32 ,
35
35
}
36
36
37
+ #[ derive( Debug , Clone ) ]
37
38
pub struct WindowBuffer {
38
39
file_buf : * mut u8 ,
39
40
file_size : usize ,
You can’t perform that action at this time.
0 commit comments