Skip to content

Commit 83553c1

Browse files
committed
chore: Update freya to rc4 and bump to v0.20.0
1 parent 7af9940 commit 83553c1

File tree

10 files changed

+46
-40
lines changed

10 files changed

+46
-40
lines changed

Cargo.lock

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "valin"
3-
version = "0.0.19"
3+
version = "0.0.20"
44
edition = "2021"
55

66
[patch.crates-io]
@@ -14,8 +14,8 @@ edition = "2021"
1414
# generational-box = { git = "https://github.com/marc2332/dioxus", rev = "17b8b22d9b6c31a9ad5a8e291627776fa3c1ec49" }
1515

1616
[dependencies]
17-
freya = { version = "0.3.0-rc.1" }
18-
freya-hooks = { version = "0.3.0-rc.1" }
17+
freya = { version = "0.3.0-rc.4" }
18+
freya-hooks = { version = "0.3.0-rc.4" }
1919

2020
dioxus-radio = { version = "0.5.1", features = ["tracing"] }
2121
dioxus = { version = "0.6", default-features = false }

src/components/text_area.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ pub fn TextArea(props: TextAreaProps) -> Element {
8080
border: "1 solid {border_fill}",
8181
padding: "8 6",
8282
margin: "0 0 2 0",
83-
cursor_reference,
8483
a11y_id: focus.attribute(),
8584
a11y_role: "text-input",
8685
a11y_auto_focus: "true",
@@ -91,6 +90,7 @@ pub fn TextArea(props: TextAreaProps) -> Element {
9190
onmouseleave,
9291
onmousemove,
9392
width: "100%",
93+
cursor_reference,
9494
cursor_id: "0",
9595
cursor_index: "{cursor_char}",
9696
cursor_mode: "editable",

src/hooks/use_edit.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ impl UseEdit {
108108
}
109109
}
110110

111-
let event = editor_tab.editor.process_key(&e.key, &e.code, &e.modifiers);
111+
let event =
112+
editor_tab
113+
.editor
114+
.process_key(&e.key, &e.code, &e.modifiers, true, true, true);
112115
if event.contains(TextEvent::TEXT_CHANGED) {
113116
editor_tab.editor.run_parser();
114117
*self.dragging.write() = TextDragging::None;
@@ -134,7 +137,9 @@ impl UseEdit {
134137
};
135138

136139
if let Some((cursor_id, cursor_position, cursor_selection)) = res {
140+
println!("{res:?}");
137141
if self.dragging.peek().has_cursor_coords() {
142+
println!("..-");
138143
self.platform
139144
.send(EventLoopMessage::RemeasureTextGroup(TextGroupMeasurement {
140145
text_id: self.cursor_reference.peek().text_id,

src/state/app.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ use std::{collections::HashMap, vec};
22

33
use dioxus_clipboard::prelude::UseClipboard;
44
use dioxus_radio::prelude::{Radio, RadioChannel};
5-
use freya::core::accessibility::AccessibilityFocusStrategy;
6-
use freya_hooks::UsePlatform;
5+
use freya::{core::accessibility::AccessibilityFocusStrategy, hooks::UsePlatform};
76
use skia_safe::{textlayout::FontCollection, FontMgr};
87
use tracing::info;
98

@@ -314,7 +313,7 @@ impl AppState {
314313
pub fn focus_tab(&mut self, panel_i: usize, tab: Option<usize>) {
315314
self.panels[panel_i].active_tab = tab;
316315
if let Some(tab) = tab {
317-
let platform = UsePlatform::new();
316+
let platform = UsePlatform::current();
318317
let tab = self.panels[panel_i].tab(tab);
319318
platform.focus(AccessibilityFocusStrategy::Node(tab.get_data().focus_id));
320319
}

src/views/file_explorer/file_explorer_state.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
use freya::{core::accessibility::AccessibilityFocusStrategy, prelude::AccessibilityId};
2-
use freya_hooks::{UseFocus, UsePlatform};
1+
use freya::{
2+
core::accessibility::AccessibilityFocusStrategy,
3+
hooks::{UseFocus, UsePlatform},
4+
prelude::AccessibilityId,
5+
};
36

47
use super::file_explorer_ui::ExplorerItem;
58

@@ -17,7 +20,7 @@ impl FileExplorerState {
1720
}
1821

1922
pub fn focus(&self) {
20-
let platform = UsePlatform::new();
23+
let platform = UsePlatform::current();
2124
platform.focus(AccessibilityFocusStrategy::Node(self.focus_id));
2225
}
2326

src/views/file_explorer/file_explorer_ui.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ enum TreeTask {
138138
pub fn FileExplorer() -> Element {
139139
let mut radio_app_state = use_radio::<AppState, Channel>(Channel::FileExplorer);
140140
let app_state = radio_app_state.read();
141-
let mut focus = use_focus_from_id(app_state.file_explorer.focus_id);
141+
let mut focus = use_focus_for_id(app_state.file_explorer.focus_id);
142142
let mut focused_item_index = use_signal(|| 0);
143143

144144
let items = app_state
@@ -289,7 +289,7 @@ pub fn FileExplorer() -> Element {
289289

290290
let onclick = move |e: MouseEvent| {
291291
e.stop_propagation();
292-
focus.focus();
292+
focus.request_focus();
293293
};
294294

295295
if items.is_empty() {

src/views/panels/tabs/editor/editor_data.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use std::rc::Rc;
44
use std::{cmp::Ordering, fmt::Display, ops::Range, path::PathBuf};
55

66
use dioxus_clipboard::prelude::UseClipboard;
7-
use freya::hooks::{EditorHistory, HistoryChange, Line, TextCursor, TextEditor};
7+
use freya::hooks::{EditorHistory, HistoryChange, Line, LinesIterator, TextCursor, TextEditor};
88
use freya::prelude::Rope;
9-
use freya_hooks::LinesIterator;
109
use lsp_types::Url;
1110
use skia_safe::textlayout::FontCollection;
1211

src/views/panels/tabs/editor/editor_line.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub fn EditorLine(
125125
let line = editor.metrics.syntax_blocks.get_line(line_index);
126126
let highlights = editable.highlights_attr(line_index, editor_tab);
127127
let gutter_width = font_size * 5.0;
128+
let cursor_reference = editable.cursor_attr();
128129

129130
let is_line_selected = editor.cursor_row() == line_index;
130131

@@ -198,6 +199,7 @@ pub fn EditorLine(
198199
cursor_index,
199200
cursor_color: "white",
200201
max_lines: "1",
202+
cursor_reference,
201203
cursor_mode: "editable",
202204
cursor_id: "{line_index}",
203205
highlights,

src/views/panels/tabs/editor/editor_ui.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn EditorUi(
3535
let editor = &editor_tab.editor;
3636
let paths = editor.editor_type().paths();
3737

38-
let mut focus = use_focus_from_id(editor_tab.focus_id);
38+
let mut focus = use_focus_for_id(editor_tab.focus_id);
3939

4040
// What position in the text the user is hovering
4141
let hover_location = use_signal(|| None);
@@ -90,7 +90,7 @@ pub fn EditorUi(
9090

9191
let onclick = move |e: MouseEvent| {
9292
e.stop_propagation();
93-
focus.focus();
93+
focus.request_focus();
9494
radio_app_state.write_with_channel_selection(|app_state| {
9595
let mut channel = ChannelSelection::Silence;
9696

@@ -117,7 +117,6 @@ pub fn EditorUi(
117117
});
118118
};
119119

120-
let cursor_reference = editable.cursor_attr();
121120
let line_height = app_state.line_height();
122121
let font_size = app_state.font_size();
123122

@@ -242,7 +241,6 @@ pub fn EditorUi(
242241
onkeydown,
243242
onkeyup,
244243
onclick,
245-
cursor_reference,
246244
EditorScrollView {
247245
offset_x: scroll_offsets.read().0,
248246
offset_y: scroll_offsets.read().1,

0 commit comments

Comments
 (0)