chore: restructure and refine the ui (#199)
* update deps * clean up * add account crate * add person crate * add chat and chat ui crates * . * clean up the ui crate * . * .
This commit is contained in:
@@ -328,7 +328,7 @@ impl InputState {
|
||||
|
||||
Self {
|
||||
focus_handle: focus_handle.clone(),
|
||||
text: "".into(),
|
||||
text: Rope::default(),
|
||||
text_wrapper: TextWrapper::new(
|
||||
text_style.font(),
|
||||
text_style.font_size.to_pixels(window.rem_size()),
|
||||
@@ -718,7 +718,7 @@ impl InputState {
|
||||
/// Set the default value of the input field.
|
||||
pub fn default_value(mut self, value: impl Into<SharedString>) -> Self {
|
||||
let text: SharedString = value.into();
|
||||
self.text = Rope::from(text.as_str());
|
||||
self.text = Rope::from_str_small(text.as_str());
|
||||
self.text_wrapper.set_default_text(&self.text);
|
||||
self
|
||||
}
|
||||
@@ -2099,7 +2099,9 @@ impl EntityInputHandler for InputState {
|
||||
.unwrap_or(self.selected_range.into());
|
||||
|
||||
let old_text = self.text.clone();
|
||||
self.text.replace(range.clone(), new_text);
|
||||
let executor = cx.background_executor();
|
||||
|
||||
self.text.replace(range.clone(), new_text, executor);
|
||||
|
||||
let mut new_offset = (range.start + new_text.len()).min(self.text.len());
|
||||
|
||||
@@ -2113,7 +2115,7 @@ impl EntityInputHandler for InputState {
|
||||
|
||||
if !self.mask_pattern.is_none() {
|
||||
let mask_text = self.mask_pattern.mask(&pending_text);
|
||||
self.text = Rope::from(mask_text.as_str());
|
||||
self.text = Rope::from_str_small(mask_text.as_str());
|
||||
let new_text_len =
|
||||
(new_text.len() + mask_text.len()).saturating_sub(pending_text.len());
|
||||
new_offset = (range.start + new_text_len).min(mask_text.len());
|
||||
@@ -2121,8 +2123,13 @@ impl EntityInputHandler for InputState {
|
||||
}
|
||||
|
||||
self.push_history(&old_text, &range, new_text);
|
||||
self.text_wrapper
|
||||
.update(&self.text, &range, &Rope::from(new_text), false, cx);
|
||||
self.text_wrapper.update(
|
||||
&self.text,
|
||||
&range,
|
||||
&Rope::from_str_small(new_text),
|
||||
false,
|
||||
cx,
|
||||
);
|
||||
self.selected_range = (new_offset..new_offset).into();
|
||||
self.ime_marked_range.take();
|
||||
self.update_preferred_column();
|
||||
@@ -2154,7 +2161,9 @@ impl EntityInputHandler for InputState {
|
||||
.unwrap_or(self.selected_range.into());
|
||||
|
||||
let old_text = self.text.clone();
|
||||
self.text.replace(range.clone(), new_text);
|
||||
let executor = cx.background_executor();
|
||||
|
||||
self.text.replace(range.clone(), new_text, executor);
|
||||
|
||||
if self.mode.is_single_line() {
|
||||
let pending_text = self.text.to_string();
|
||||
@@ -2165,8 +2174,13 @@ impl EntityInputHandler for InputState {
|
||||
}
|
||||
|
||||
self.push_history(&old_text, &range, new_text);
|
||||
self.text_wrapper
|
||||
.update(&self.text, &range, &Rope::from(new_text), false, cx);
|
||||
self.text_wrapper.update(
|
||||
&self.text,
|
||||
&range,
|
||||
&Rope::from_str_small(new_text),
|
||||
false,
|
||||
cx,
|
||||
);
|
||||
if new_text.is_empty() {
|
||||
// Cancel selection, when cancel IME input.
|
||||
self.selected_range = (range.start..range.start).into();
|
||||
|
||||
Reference in New Issue
Block a user