Skip to content

Commit

Permalink
Merge pull request #78 from marc2332/chore/bump-freya
Browse files Browse the repository at this point in the history
feat: Bump freya
  • Loading branch information
marc2332 authored Jun 2, 2024
2 parents a4204b8 + e46289c commit 55db73c
Show file tree
Hide file tree
Showing 13 changed files with 546 additions and 442 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2021"
dioxus-sdk = { git = "https://github.com/DioxusLabs/sdk", rev = "57ab3fa972c6d4a7acc25e82a0aafc3ff9e63403" }

[dependencies]
freya-node-state = { git = "https://github.com/marc2332/freya", rev = "0bc8d3e6b05cbdbe2dba306255d7bb82e3362075" }
freya = { git = "https://github.com/marc2332/freya", rev = "0bc8d3e6b05cbdbe2dba306255d7bb82e3362075" }
freya-hooks = { git = "https://github.com/marc2332/freya", rev = "0bc8d3e6b05cbdbe2dba306255d7bb82e3362075" }
freya-node-state = { git = "https://github.com/marc2332/freya", rev = "865782c3f027bcbd1cf6fe239057a70e866abab6" }
freya = { git = "https://github.com/marc2332/freya", rev = "865782c3f027bcbd1cf6fe239057a70e866abab6" }
freya-hooks = { git = "https://github.com/marc2332/freya", rev = "865782c3f027bcbd1cf6fe239057a70e866abab6" }

dioxus-radio = "0.2.4"
dioxus = "0.5"
Expand Down
3 changes: 1 addition & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ pub fn App() -> Element {
onkeydown: onkeydown,
if focused_view == EditorView::Commander {
Commander {
editor_commands,
radio_app_state
editor_commands
}
}
rect {
Expand Down
36 changes: 17 additions & 19 deletions src/components/commander.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
use crate::{
keyboard_navigation::use_keyboard_navigation,
state::{Channel, EditorCommands, EditorView, RadioAppState},
state::{Channel, EditorCommands, EditorView},
TextArea,
};
use dioxus_radio::prelude::use_radio;
use freya::prelude::*;

#[derive(Props, Clone, PartialEq)]
pub struct CommanderProps {
editor_commands: Signal<EditorCommands>,
radio_app_state: RadioAppState,
}

#[allow(non_snake_case)]
pub fn Commander(
CommanderProps {
editor_commands,
mut radio_app_state,
}: CommanderProps,
) -> Element {
pub fn Commander(CommanderProps { editor_commands }: CommanderProps) -> Element {
let mut radio_app_state = use_radio(Channel::Global);
let mut value = use_signal(String::new);
let mut selected = use_signal(|| 0);
let mut keyboard_navigation = use_keyboard_navigation();
Expand Down Expand Up @@ -49,20 +45,22 @@ pub fn Commander(
let command_id = filtered_commands.get(selected()).cloned();

let onsubmit = move |_: String| {
let editor_commands = editor_commands.read();
let command = command_id
.as_ref()
.and_then(|command_i| editor_commands.commands.get(command_i));
if let Some(command) = command {
// Run the command
command.run();
to_owned![command_id];

// Focus the previous view
keyboard_navigation.callback(true, move || {
let editor_commands = editor_commands.read();
let command = command_id
.as_ref()
.and_then(|command_i| editor_commands.commands.get(command_i));
if let Some(command) = command {
// Run the command
command.run();

// Focus the previous view
keyboard_navigation.callback(true, move || {
let mut app_state = radio_app_state.write();
app_state.set_focused_view_to_previous();
})
}
}
});
};

let onkeydown = move |e: KeyboardEvent| {
Expand Down
6 changes: 3 additions & 3 deletions src/components/editor_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn EditorPanel(EditorPanelProps { panel_index, width }: EditorPanelProps) ->
let panel = app_state.panel(panel_index);
let active_tab_index = panel.active_tab();

let close_panel = move |_: Option<MouseEvent>| {
let close_panel = move |_| {
radio_app_state
.write_channel(Channel::Global)
.close_panel(panel_index);
Expand Down Expand Up @@ -92,7 +92,7 @@ pub fn EditorPanel(EditorPanelProps { panel_index, width }: EditorPanelProps) ->
height: "100%".into(),
padding: "10 8".into(),
}),
onclick: close_panel,
onpress: close_panel,
label {
"Close"
}
Expand All @@ -103,7 +103,7 @@ pub fn EditorPanel(EditorPanelProps { panel_index, width }: EditorPanelProps) ->
height: "100%".into(),
padding: "10 8".into(),
}),
onclick: split_panel,
onpress: split_panel,
label {
"Split"
}
Expand Down
14 changes: 8 additions & 6 deletions src/components/status_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ pub fn StatusBar(props: StatusBarProps) -> Element {
let panel = app_state.panel(app_state.focused_panel);
let tab_data = {
if let Some(active_tab) = panel.active_tab() {
panel
.tab(active_tab)
.as_text_editor()
.map(|editor_tab| (editor_tab.editor.cursor(), editor_tab.editor.editor_type()))
panel.tab(active_tab).as_text_editor().map(|editor_tab| {
(
editor_tab.editor.cursor_row_and_col(),
editor_tab.editor.editor_type(),
)
})
} else {
None
}
Expand Down Expand Up @@ -81,10 +83,10 @@ pub fn StatusBar(props: StatusBarProps) -> Element {
width: "50%",
direction: "horizontal",
main_align: "end",
if let Some((cursor, editor_type)) = tab_data {
if let Some(((row, col), editor_type)) = tab_data {
StatusBarItem {
label {
"Ln {cursor.row() + 1}, Col {cursor.col() + 1}"
"Ln {row + 1}, Col {col + 1}"
}
}
StatusBarItem {
Expand Down
4 changes: 2 additions & 2 deletions src/components/text_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub fn TextArea(props: TextAreaProps) -> Element {
);
let mut focus = use_focus();

use_hook(|| {
focus.focus();
use_hook(move || {
focus.queue_focus();
});

if &props.value != editable.editor().read().rope() {
Expand Down
Loading

0 comments on commit 55db73c

Please sign in to comment.