* [pve-devel] [RFC PATCH installer 1/2] ui: stdio: replace newlines with whitespaces in prompt messages @ 2023-11-17 13:45 Christoph Heiss 2023-11-17 13:45 ` [pve-devel] [PATCH installer 2/2] tui: install progress: use ok/cancel as button text for installer prompt Christoph Heiss 2023-11-17 16:09 ` [pve-devel] applied: [RFC PATCH installer 1/2] ui: stdio: replace newlines with whitespaces in prompt messages Thomas Lamprecht 0 siblings, 2 replies; 3+ messages in thread From: Christoph Heiss @ 2023-11-17 13:45 UTC (permalink / raw) To: pve-devel The line-based protocol currently used cannot handle this properly, so introduce this as a stop-gap measure - otherwise messages might be cut off. This makes it work for now, and the text is wrapped correctely for the screen width in the TUI anyway - which is the only user of this so far. Will be reworked properly later on. Signed-off-by: Christoph Heiss <c.heiss@proxmox.com> --- Proxmox/UI/StdIO.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/Proxmox/UI/StdIO.pm b/Proxmox/UI/StdIO.pm index 0ee6311..f734c0b 100644 --- a/Proxmox/UI/StdIO.pm +++ b/Proxmox/UI/StdIO.pm @@ -36,6 +36,7 @@ sub finished { sub prompt { my ($self, $query) = @_; + $query =~ s/\n/ /g; print STDOUT "prompt: $query\n"; my $response = <STDIN> // ''; # FIXME: error handling? -- 2.42.0 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH installer 2/2] tui: install progress: use ok/cancel as button text for installer prompt 2023-11-17 13:45 [pve-devel] [RFC PATCH installer 1/2] ui: stdio: replace newlines with whitespaces in prompt messages Christoph Heiss @ 2023-11-17 13:45 ` Christoph Heiss 2023-11-17 16:09 ` [pve-devel] applied: [RFC PATCH installer 1/2] ui: stdio: replace newlines with whitespaces in prompt messages Thomas Lamprecht 1 sibling, 0 replies; 3+ messages in thread From: Christoph Heiss @ 2023-11-17 13:45 UTC (permalink / raw) To: pve-devel The GTK installer/UI module in the low-level installer does the same. Messages used with this are worded for this, using yes/no instead can be quite confusing (e.g. Proxmox::Install::ask_existing_vg_rename_or_abort()) Signed-off-by: Christoph Heiss <c.heiss@proxmox.com> --- proxmox-tui-installer/src/main.rs | 12 ++++++++---- proxmox-tui-installer/src/views/install_progress.rs | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/proxmox-tui-installer/src/main.rs b/proxmox-tui-installer/src/main.rs index e1411c6..4c14482 100644 --- a/proxmox-tui-installer/src/main.rs +++ b/proxmox-tui-installer/src/main.rs @@ -285,21 +285,23 @@ fn switch_to_prev_screen(siv: &mut Cursive) { siv.set_screen(id); } -fn yes_no_dialog( +fn prompt_dialog( siv: &mut Cursive, title: &str, text: &str, + yes_text: &str, callback_yes: Box<dyn Fn(&mut Cursive)>, + no_text: &str, callback_no: Box<dyn Fn(&mut Cursive)>, ) { siv.add_layer( Dialog::around(TextView::new(text)) .title(title) - .button("No", move |siv| { + .button(no_text, move |siv| { siv.pop_layer(); callback_no(siv); }) - .button("Yes", move |siv| { + .button(yes_text, move |siv| { siv.pop_layer(); callback_yes(siv); }), @@ -311,11 +313,13 @@ fn trigger_abort_install_dialog(siv: &mut Cursive) { siv.quit(); #[cfg(not(debug_assertions))] - yes_no_dialog( + prompt_dialog( siv, "Abort installation?", "Are you sure you want to abort the installation?", + "Yes", Box::new(Cursive::quit), + "No", Box::new(|_| {}), ) } diff --git a/proxmox-tui-installer/src/views/install_progress.rs b/proxmox-tui-installer/src/views/install_progress.rs index 76dd518..01c9941 100644 --- a/proxmox-tui-installer/src/views/install_progress.rs +++ b/proxmox-tui-installer/src/views/install_progress.rs @@ -13,7 +13,7 @@ use cursive::{ CbSink, Cursive, }; -use crate::{abort_install_button, setup::InstallConfig, yes_no_dialog, InstallerState}; +use crate::{abort_install_button, prompt_dialog, setup::InstallConfig, InstallerState}; use proxmox_installer_common::setup::spawn_low_level_installer; pub struct InstallProgressView { @@ -189,10 +189,11 @@ impl InstallProgressView { } fn show_prompt<W: Write + 'static>(siv: &mut Cursive, text: &str, writer: Arc<Mutex<W>>) { - yes_no_dialog( + prompt_dialog( siv, "Prompt", text, + "OK", Box::new({ let writer = writer.clone(); move |_| { @@ -201,6 +202,7 @@ impl InstallProgressView { } } }), + "Cancel", Box::new(move |_| { if let Ok(mut writer) = writer.lock() { let _ = writeln!(writer); -- 2.42.0 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] applied: [RFC PATCH installer 1/2] ui: stdio: replace newlines with whitespaces in prompt messages 2023-11-17 13:45 [pve-devel] [RFC PATCH installer 1/2] ui: stdio: replace newlines with whitespaces in prompt messages Christoph Heiss 2023-11-17 13:45 ` [pve-devel] [PATCH installer 2/2] tui: install progress: use ok/cancel as button text for installer prompt Christoph Heiss @ 2023-11-17 16:09 ` Thomas Lamprecht 1 sibling, 0 replies; 3+ messages in thread From: Thomas Lamprecht @ 2023-11-17 16:09 UTC (permalink / raw) To: Proxmox VE development discussion, Christoph Heiss Am 17/11/2023 um 14:45 schrieb Christoph Heiss: > The line-based protocol currently used cannot handle this properly, so > introduce this as a stop-gap measure - otherwise messages might be cut > off. > > This makes it work for now, and the text is wrapped correctely for the > screen width in the TUI anyway - which is the only user of this so far. > > Will be reworked properly later on. > > Signed-off-by: Christoph Heiss <c.heiss@proxmox.com> > --- > Proxmox/UI/StdIO.pm | 1 + > 1 file changed, 1 insertion(+) > > applied both patches, good enough as a stop-gap, thanks! ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-17 16:09 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-11-17 13:45 [pve-devel] [RFC PATCH installer 1/2] ui: stdio: replace newlines with whitespaces in prompt messages Christoph Heiss 2023-11-17 13:45 ` [pve-devel] [PATCH installer 2/2] tui: install progress: use ok/cancel as button text for installer prompt Christoph Heiss 2023-11-17 16:09 ` [pve-devel] applied: [RFC PATCH installer 1/2] ui: stdio: replace newlines with whitespaces in prompt messages Thomas Lamprecht
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox