textarea shows but doesnt update
This commit is contained in:
parent
72bd4ce74c
commit
d1ea7eb2c0
1 changed files with 27 additions and 7 deletions
34
src/ui.rs
34
src/ui.rs
|
@ -77,12 +77,11 @@ impl Widget for Popup<'_> {
|
||||||
async fn handle_key_event(mut client: &mut Client<'_>, key_event: KeyEvent) {
|
async fn handle_key_event(mut client: &mut Client<'_>, key_event: KeyEvent) {
|
||||||
match &client.popup_user_input {
|
match &client.popup_user_input {
|
||||||
true => {
|
true => {
|
||||||
match key_event.code {
|
match key_event.into() {
|
||||||
KeyCode::Esc => client.popup_user_input = false,
|
Input {key: Key::Esc, ..} => client.popup_user_input = false,
|
||||||
KeyCode::Char(c) => {
|
input => {
|
||||||
todo!()
|
client.textarea.input(input);
|
||||||
},
|
},
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
false => {
|
false => {
|
||||||
|
@ -151,10 +150,10 @@ async fn handle_key_event(mut client: &mut Client<'_>, key_event: KeyEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_events(client: &mut Client<'_>) -> anyhow::Result<()> {
|
pub async fn handle_events(app: &mut Client<'_>) -> anyhow::Result<()> {
|
||||||
match event::read()? {
|
match event::read()? {
|
||||||
Event::Key(key) if key.kind == KeyEventKind::Press => {
|
Event::Key(key) if key.kind == KeyEventKind::Press => {
|
||||||
handle_key_event(client, key).await
|
handle_key_event(app, key).await
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
@ -243,6 +242,27 @@ pub fn ui(frame: &mut Frame, app: &mut Client) {
|
||||||
frame.render_widget(popup, popup_area);
|
frame.render_widget(popup, popup_area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let mut textarea = TextArea::default();
|
||||||
|
textarea.set_block(
|
||||||
|
Block::default()
|
||||||
|
.borders(Borders::ALL)
|
||||||
|
.border_style(Style::default().fg(Color::LightBlue))
|
||||||
|
.title("Crossterm Popup Example"),
|
||||||
|
);
|
||||||
|
|
||||||
|
let area = Rect {
|
||||||
|
width: 40,
|
||||||
|
height: 5,
|
||||||
|
x: 5,
|
||||||
|
y: 5,
|
||||||
|
};
|
||||||
|
|
||||||
|
textarea.set_style(Style::default().fg(Color::Yellow));
|
||||||
|
textarea.set_placeholder_style(Style::default());
|
||||||
|
app.textarea = textarea;
|
||||||
|
|
||||||
if app.popup_user_input == true {
|
if app.popup_user_input == true {
|
||||||
|
frame.render_widget(&app.textarea, area);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue