@@ -92,7 +92,7 @@ fn setup_storage(storage: &mut endbasic_std::storage::Storage) {
9292/// Connects the EndBASIC interpreter to a web page.
9393#[ wasm_bindgen]
9494pub struct WebTerminal {
95- console : Rc < RefCell < CanvasConsole > > ,
95+ console : CanvasConsole ,
9696 on_screen_keyboard : OnScreenKeyboard ,
9797}
9898
@@ -103,7 +103,7 @@ impl WebTerminal {
103103 pub fn new ( terminal : HtmlCanvasElement ) -> Self {
104104 let input = WebInput :: default ( ) ;
105105 let on_screen_keyboard = input. on_screen_keyboard ( ) ;
106- let console = Rc :: from ( RefCell :: from ( CanvasConsole :: new ( terminal, input) . unwrap ( ) ) ) ;
106+ let console = CanvasConsole :: new ( terminal, input) . unwrap ( ) ;
107107 Self { console, on_screen_keyboard }
108108 }
109109
@@ -114,16 +114,16 @@ impl WebTerminal {
114114
115115 /// Returns a textual description of the size of the console.
116116 pub fn size_description ( & self ) -> String {
117- let console = self . console . borrow ( ) ;
118- let pixels = console. size_pixels ( ) ;
119- let chars = console. size ( ) . unwrap ( ) ;
117+ let pixels = self . console . size_pixels ( ) ;
118+ let chars = self . console . size ( ) . unwrap ( ) ;
120119 format ! ( "{}x{} pixels, {}x{} chars" , pixels. width, pixels. height, chars. x, chars. y)
121120 }
122121
123122 /// Starts the EndBASIC interpreter loop on the specified `terminal`.
124123 pub async fn run_repl_loop ( self ) {
124+ let console = Rc :: from ( RefCell :: from ( self . console ) ) ;
125125 let mut builder = endbasic_std:: MachineBuilder :: default ( )
126- . with_console ( self . console . clone ( ) )
126+ . with_console ( console. clone ( ) )
127127 . with_sleep_fn ( Box :: from ( js_sleep) )
128128 . make_interactive ( )
129129 . with_program ( Rc :: from ( RefCell :: from ( endbasic_repl:: editor:: Editor :: default ( ) ) ) ) ;
@@ -134,15 +134,12 @@ impl WebTerminal {
134134 setup_storage ( & mut storage. borrow_mut ( ) ) ;
135135
136136 let mut machine = builder. build ( ) . unwrap ( ) ;
137- endbasic_repl:: print_welcome ( self . console . clone ( ) ) . unwrap ( ) ;
138- endbasic_repl:: try_load_autoexec ( & mut machine, self . console . clone ( ) , storage)
139- . await
140- . unwrap ( ) ;
137+ endbasic_repl:: print_welcome ( console. clone ( ) ) . unwrap ( ) ;
138+ endbasic_repl:: try_load_autoexec ( & mut machine, console. clone ( ) , storage) . await . unwrap ( ) ;
141139 loop {
142140 let result =
143- endbasic_repl:: run_repl_loop ( & mut machine, self . console . clone ( ) , program. clone ( ) )
144- . await ;
145- let mut console = self . console . borrow_mut ( ) ;
141+ endbasic_repl:: run_repl_loop ( & mut machine, console. clone ( ) , program. clone ( ) ) . await ;
142+ let mut console = console. borrow_mut ( ) ;
146143 match result {
147144 Ok ( exit_code) => {
148145 console. print ( & format ! ( "Interpreter exited with code {}" , exit_code) )
0 commit comments