From ee5deb87c1f04613b585043c77ccb2aacd1f16cefba53dab36b22429fc085133 Mon Sep 17 00:00:00 2001 From: Alex Wied <543423+centromere@users.noreply.github.com> Date: Mon, 29 Jun 2026 12:51:38 -0400 Subject: [PATCH] . --- publish/src/widget/iri_input.rs | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/publish/src/widget/iri_input.rs b/publish/src/widget/iri_input.rs index 28b613c..8157f2d 100644 --- a/publish/src/widget/iri_input.rs +++ b/publish/src/widget/iri_input.rs @@ -1,5 +1,5 @@ use std::collections::BTreeMap; -use iced::{keyboard, Element, Event, Length, Rectangle, Size}; +use iced::{keyboard, widget, Element, Event, Length, Rectangle, Size}; use iced::advanced::{mouse, text, Shell}; use iced::advanced::layout::{Limits, Node}; use iced::advanced::renderer::Style; @@ -7,11 +7,8 @@ use iced::advanced::{Layout, Widget}; use iced::advanced::widget::{tree, Tree}; use iced::mouse::{Cursor, Interaction}; use iced::widget::text_input::Catalog; -use iced::widget::TextInput; -use tracing::info; pub struct State { - value: String, control: bool, } @@ -21,21 +18,15 @@ where Renderer: text::Renderer, { prefixes: &'a BTreeMap, - placeholder: String, - iri: String, on_control_click: Option, on_input: Option Message + 'a>>, - text_input: TextInput<'a, Message, Theme, Renderer>, + text_input: widget::TextInput<'a, Message, Theme, Renderer>, } fn abbreviate(prefixes: &BTreeMap, iri: &str) -> Option { for (name, base) in prefixes { if let Some(local_name) = iri.strip_prefix(base) { - return if local_name.is_empty() { - Some(format!("{name}:")) - } else { - Some(format!("{name}:{local_name}")) - }; + return Some(format!("{name}:{local_name}")); } } None @@ -56,11 +47,9 @@ where { pub fn new(prefixes: &'a BTreeMap, placeholder: &str, iri: &str) -> Self { let display_value = abbreviate(prefixes, iri).unwrap_or_else(|| iri.to_string()); - let text_input = TextInput::new(placeholder, &display_value); + let text_input = widget::TextInput::new(placeholder, &display_value); Self { prefixes, - placeholder: placeholder.to_string(), - iri: iri.to_string(), on_control_click: None, on_input: None, text_input, @@ -72,10 +61,9 @@ where } pub fn on_input(mut self, on_input: impl Fn(String) -> Message + 'a) -> Self { - let iri = self.iri.clone(); let wrapped = move |value: String| { let expanded_value = expand(self.prefixes, &value); - on_input(expanded_value.unwrap_or_else(|| iri.clone())) + on_input(expanded_value.unwrap_or_else(|| value)) }; self.text_input = self.text_input.on_input(wrapped); @@ -128,7 +116,6 @@ where fn state(&self) -> tree::State { tree::State::new(State { - value: String::new(), control: false, }) } @@ -150,11 +137,6 @@ where shell.capture_event(); } } - Event::Keyboard(keyboard::Event::KeyPressed { text, .. }) => { - if let Some(text) = text { - state.value = text.to_string(); - } - } _ => {} }