mirror of
https://github.com/veeso/termscp.git
synced 2026-04-01 07:42:17 -07:00
49 lines
1.6 KiB
Rust
49 lines
1.6 KiB
Rust
use tuirealm::event::NoUserEvent;
|
|
use tuirealm::{Component, MockComponent};
|
|
|
|
use super::*;
|
|
|
|
#[derive(MockComponent)]
|
|
pub struct InputWebDAVUri {
|
|
component: Input,
|
|
form_tab: FormTab,
|
|
}
|
|
|
|
impl InputWebDAVUri {
|
|
pub fn new(host: &str, form_tab: FormTab, color: Color) -> Self {
|
|
Self {
|
|
component: Input::default()
|
|
.borders(
|
|
Borders::default()
|
|
.color(color)
|
|
.modifiers(BorderType::Rounded),
|
|
)
|
|
.foreground(color)
|
|
.placeholder(
|
|
"http://localhost:8080",
|
|
Style::default().fg(Color::Rgb(128, 128, 128)),
|
|
)
|
|
.title("HTTP url", Alignment::Left)
|
|
.input_type(InputType::Text)
|
|
.value(host),
|
|
form_tab,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl Component<Msg, NoUserEvent> for InputWebDAVUri {
|
|
fn on(&mut self, ev: Event<NoUserEvent>) -> Option<Msg> {
|
|
let on_key_down = match self.form_tab {
|
|
FormTab::Remote => Msg::Ui(UiMsg::Remote(UiAuthFormMsg::WebDAVUriBlurDown)),
|
|
FormTab::HostBridge => Msg::Ui(UiMsg::HostBridge(UiAuthFormMsg::WebDAVUriBlurDown)),
|
|
};
|
|
let on_key_up = match self.form_tab {
|
|
FormTab::Remote => Msg::Ui(UiMsg::Remote(UiAuthFormMsg::WebDAVUriBlurUp)),
|
|
FormTab::HostBridge => Msg::Ui(UiMsg::HostBridge(UiAuthFormMsg::WebDAVUriBlurUp)),
|
|
};
|
|
|
|
let form_tab = self.form_tab;
|
|
handle_input_ev(self, ev, on_key_down, on_key_up, form_tab)
|
|
}
|
|
}
|