diff --git a/hel/src/utils.rs b/hel/src/utils.rs index 39a4367..15936fb 100644 --- a/hel/src/utils.rs +++ b/hel/src/utils.rs @@ -52,7 +52,7 @@ pub mod rnd { #[wasm_bindgen] extern "C" { - #[wasm_bindgen(js_name = rnd_range)] + #[wasm_bindgen(js_name = hel_rnd_range)] fn extern_rnd_range(start: u32, end: u32) -> u32; } @@ -154,11 +154,11 @@ pub mod editor { #[wasm_bindgen] extern "C" { - #[wasm_bindgen(js_name = read_line)] - fn extern_readline(prompt: &str) -> String; + #[wasm_bindgen(js_name = hel_read_password)] + fn extern_read_password(prompt: &str); - #[wasm_bindgen(js_name = read_password)] - fn extern_password(prompt: &str) -> String; + #[wasm_bindgen(js_name = hel_current_password)] + fn extern_current_password() -> Option; } #[derive(Debug)] @@ -187,13 +187,19 @@ pub mod editor { Ok(()) } - pub fn readline<'a>(&mut self, prompt: &str) -> Result> { - Ok(extern_readline(&prompt)) + pub fn readline<'a>(&mut self, _prompt: &str) -> Result> { + Ok("".to_string()) } } pub fn password(prompt: String) -> std::io::Result { - Ok(extern_password(&prompt)) + extern_read_password(&prompt); + loop { + match extern_current_password() { + Some(p) => return Ok(p), + None => std::thread::sleep(std::time::Duration::from_millis(100)), + } + } } } diff --git a/helwasm/index.html b/helwasm/index.html index 0cc36e1..57e0885 100644 --- a/helwasm/index.html +++ b/helwasm/index.html @@ -72,25 +72,24 @@ font-size: 16px; white-space: pre-wrap; } + + #passwordPrompt { + position: fixed; + top: 50%; + left: 50%; + tranform: translate(-50%, -50%); + backrground-color: white; + border: 1px solid black; + padding: 20px; + }