diff --git a/Cargo.toml b/Cargo.toml index 9222201..1637e50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,4 +5,4 @@ edition = "2024" [dependencies] nix = { version = "0.30.1", features = ["term", "process", "fs"], default-features = false } -iced = { version = "0.13.1", features = ["smol"] } +iced = { version = "0.13.1", features = ["advanced", "smol"] } diff --git a/src/lib.rs b/src/lib.rs index 904b260..99a4e0b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ -use iced::Element; -use iced::Font; +use iced::widget::text_input::Id; use iced::widget::{column, row, scrollable, text, text_input}; +use iced::{Element, Font, Task}; use nix::pty::{ForkptyResult, forkpty}; use nix::unistd::write; @@ -78,7 +78,7 @@ impl Model { } } - pub fn update(&mut self, msg: Msg) { + pub fn update(&mut self, msg: Msg) -> Task { match msg { Msg::HasInput => { let mut write_buffer = self.input.as_bytes().to_vec(); @@ -91,7 +91,8 @@ impl Model { Some(red) => self.update_screen_buffer(&red), None => (), }, - } + }; + iced::widget::text_input::focus::(Id::new("text_input")) } pub fn view(&self) -> Element<'_, Msg> { @@ -110,13 +111,14 @@ impl Model { ), }; scrollable(column![ - text(left).font(Font::MONOSPACE), + text(left), row![ - text(right).font(Font::MONOSPACE), + text(right), text_input("", &self.input) .on_input(Msg::InputChanged) .on_submit(Msg::HasInput) - .font(Font::MONOSPACE) + .padding(0) + .id(Id::new("text_input")) ] ]) .into() diff --git a/src/main.rs b/src/main.rs index 783808e..abd02b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ use rust_term::*; fn main() -> iced::Result { iced::application("test", Model::update, Model::view) .theme(Model::theme) + .default_font(iced::Font::MONOSPACE) + .decorations(false) .subscription(Model::subscription) .run() /*