From 75f22316dd66959c9e24f254f937c98bd17f7988 Mon Sep 17 00:00:00 2001 From: jutn-dev Date: Wed, 14 Jan 2026 19:14:57 +0200 Subject: [PATCH 1/2] Updated to bevy-0.18 --- Cargo.toml | 12 ++++---- src/console.rs | 76 ++++++++++++++++++++++++++------------------------ 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f776141..9cd6e59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_console" -version = "0.16.0" -edition = "2021" +version = "0.17.0" +edition = "2024" authors = ["RichoDemus "] homepage = "https://github.com/RichoDemus/bevy-console" repository = "https://github.com/RichoDemus/bevy-console" @@ -10,13 +10,15 @@ license = "MIT" readme = "README.md" [dependencies] -bevy = { version = "0.17", default-features = false, features = [ +bevy = { version = "0.18", default-features = false, features = [ "std", "bevy_log", + "keyboard", + "mouse", ] } clap = { version = "4.5", features = ["derive"] } bevy_console_derive = { path = "./bevy_console_derive", version = "0.5.0" } -bevy_egui = { version = "0.37", default-features = false, features = [ +bevy_egui = { version = "0.39", default-features = false, features = [ "render", "default_fonts", ] } @@ -26,7 +28,7 @@ strip-ansi-escapes = "0.2" trie-rs = "0.4" [dev-dependencies] -bevy = { version = "0.17", features = ["std", "bevy_log"] } +bevy = { version = "0.18", features = ["std", "bevy_log", "keyboard", "mouse"] } color-print = { version = "0.3" } [workspace] diff --git a/src/console.rs b/src/console.rs index 94e46f7..0536961 100644 --- a/src/console.rs +++ b/src/console.rs @@ -1,7 +1,7 @@ use bevy::ecs::query::FilteredAccessSet; use bevy::ecs::resource::Resource; use bevy::ecs::{ - component::Tick, + change_detection::Tick, system::{ScheduleSystem, SystemMeta, SystemParam}, world::unsafe_world_cell::UnsafeWorldCell, }; @@ -156,46 +156,48 @@ unsafe impl SystemParam for ConsoleCommand<'_, T> { world: UnsafeWorldCell<'w>, change_tick: Tick, ) -> Self::Item<'w, 's> { - let mut message_reader = ConsoleCommandEnteredReaderSystemParam::get_param( - &mut state.message_reader, - system_meta, - world, - change_tick, - ); - let mut console_line = PrintConsoleLineWriterSystemParam::get_param( - &mut state.console_line, - system_meta, - world, - change_tick, - ); - - let command = message_reader.read().find_map(|command| { - if T::name() == command.command_name { - let clap_command = T::command().no_binary_name(true); - // .color(clap::ColorChoice::Always); - let arg_matches = clap_command.try_get_matches_from(command.args.iter()); - - debug!( - "Trying to parse as `{}`. Result: {arg_matches:?}", - command.command_name - ); + unsafe { + let mut message_reader = ConsoleCommandEnteredReaderSystemParam::get_param( + &mut state.message_reader, + system_meta, + world, + change_tick, + ); + let mut console_line = PrintConsoleLineWriterSystemParam::get_param( + &mut state.console_line, + system_meta, + world, + change_tick, + ); + + let command = message_reader.read().find_map(|command| { + if T::name() == command.command_name { + let clap_command = T::command().no_binary_name(true); + // .color(clap::ColorChoice::Always); + let arg_matches = clap_command.try_get_matches_from(command.args.iter()); - match arg_matches { - Ok(matches) => { - return Some(T::from_arg_matches(&matches)); - } - Err(err) => { - console_line.write(PrintConsoleLine::new(err.to_string())); - return Some(Err(err)); + debug!( + "Trying to parse as `{}`. Result: {arg_matches:?}", + command.command_name + ); + + match arg_matches { + Ok(matches) => { + return Some(T::from_arg_matches(&matches)); + } + Err(err) => { + console_line.write(PrintConsoleLine::new(err.to_string())); + return Some(Err(err)); + } } } - } - None - }); + None + }); - ConsoleCommand { - command, - console_line, + ConsoleCommand { + command, + console_line, + } } } } From 7556ec116326e11cae72b88b88e88a3f95932584 Mon Sep 17 00:00:00 2001 From: jutn-dev Date: Wed, 14 Jan 2026 22:54:48 +0200 Subject: [PATCH 2/2] cargo fmt --- examples/capture_bevy_logs.rs | 2 +- examples/completions.rs | 2 +- examples/log_command.rs | 2 +- src/color.rs | 9 +++++++-- src/commands/clear.rs | 2 +- src/commands/help.rs | 2 +- src/console.rs | 8 ++++---- src/lib.rs | 10 +++++----- 8 files changed, 21 insertions(+), 16 deletions(-) diff --git a/examples/capture_bevy_logs.rs b/examples/capture_bevy_logs.rs index 8b861fe..4a7c0fc 100644 --- a/examples/capture_bevy_logs.rs +++ b/examples/capture_bevy_logs.rs @@ -1,6 +1,6 @@ use bevy::log::LogPlugin; use bevy::{log, prelude::*}; -use bevy_console::{make_layer, ConsolePlugin}; +use bevy_console::{ConsolePlugin, make_layer}; fn main() { App::new() diff --git a/examples/completions.rs b/examples/completions.rs index 88662f2..41df4da 100644 --- a/examples/completions.rs +++ b/examples/completions.rs @@ -1,5 +1,5 @@ use bevy::prelude::*; -use bevy_console::{reply, AddConsoleCommand, ConsoleCommand, ConsoleConfiguration, ConsolePlugin}; +use bevy_console::{AddConsoleCommand, ConsoleCommand, ConsoleConfiguration, ConsolePlugin, reply}; use clap::{Parser, ValueEnum}; fn main() { diff --git a/examples/log_command.rs b/examples/log_command.rs index 9029f7a..6008f64 100644 --- a/examples/log_command.rs +++ b/examples/log_command.rs @@ -1,5 +1,5 @@ use bevy::prelude::*; -use bevy_console::{reply, AddConsoleCommand, ConsoleCommand, ConsolePlugin}; +use bevy_console::{AddConsoleCommand, ConsoleCommand, ConsolePlugin, reply}; use clap::Parser; fn main() { diff --git a/src/color.rs b/src/color.rs index 93be358..e5efbad 100644 --- a/src/color.rs +++ b/src/color.rs @@ -299,9 +299,14 @@ mod test { (" ", HashSet::from([])), ( "ERROR", - HashSet::from([TextFormattingOverride::Foreground(Color32::from_rgb(222, 56, 43))]) + HashSet::from([TextFormattingOverride::Foreground(Color32::from_rgb( + 222, 56, 43 + ))]) + ), + ( + " error: Could not find function: Displaying ScriptValue without world access: String(", + HashSet::from([]) ), - (" error: Could not find function: Displaying ScriptValue without world access: String(", HashSet::from([])), ] ); } diff --git a/src/commands/clear.rs b/src/commands/clear.rs index 1e7b247..97bd707 100644 --- a/src/commands/clear.rs +++ b/src/commands/clear.rs @@ -1,8 +1,8 @@ use bevy::prelude::*; use crate as bevy_console; -use crate::console::ConsoleState; use crate::ConsoleCommand; +use crate::console::ConsoleState; use clap::Parser; /// Clears the console diff --git a/src/commands/help.rs b/src/commands/help.rs index d2e0193..5880dde 100644 --- a/src/commands/help.rs +++ b/src/commands/help.rs @@ -2,7 +2,7 @@ use bevy::prelude::*; use clap::Parser; use crate as bevy_console; -use crate::{reply, ConsoleCommand, ConsoleConfiguration}; +use crate::{ConsoleCommand, ConsoleConfiguration, reply}; /// Prints available arguments and usage #[derive(Parser, ConsoleCommand)] diff --git a/src/console.rs b/src/console.rs index 0536961..2899352 100644 --- a/src/console.rs +++ b/src/console.rs @@ -8,11 +8,11 @@ use bevy::ecs::{ use bevy::platform::hash::FixedState; use bevy::{input::keyboard::KeyboardInput, prelude::*}; use bevy_egui::egui::{self, Align, ScrollArea, TextEdit}; -use bevy_egui::egui::{text::LayoutJob, text_selection::CCursorRange}; use bevy_egui::egui::{Context, Id}; +use bevy_egui::egui::{text::LayoutJob, text_selection::CCursorRange}; use bevy_egui::{ - egui::{epaint::text::cursor::CCursor, Color32, FontId, TextFormat}, EguiContexts, + egui::{Color32, FontId, TextFormat, epaint::text::cursor::CCursor}, }; use clap::{CommandFactory, FromArgMatches}; use core::str; @@ -24,8 +24,8 @@ use std::mem; use trie_rs::Trie; use crate::{ - color::{parse_ansi_styled_str, TextFormattingOverride}, ConsoleSet, + color::{TextFormattingOverride, parse_ansi_styled_str}, }; type ConsoleCommandEnteredReaderSystemParam = @@ -811,8 +811,8 @@ pub fn block_keyboard_input( #[cfg(test)] mod tests { - use bevy::input::keyboard::{Key, NativeKey, NativeKeyCode}; use bevy::input::ButtonState; + use bevy::input::keyboard::{Key, NativeKey, NativeKeyCode}; use super::*; diff --git a/src/lib.rs b/src/lib.rs index 7d06971..6400fb8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,19 +4,19 @@ use bevy::prelude::*; pub use bevy_console_derive::ConsoleCommand; use bevy_egui::{EguiPlugin, EguiPreUpdateSet, EguiPrimaryContextPass}; -use console::{block_keyboard_input, block_mouse_input, ConsoleCache}; +use console::{ConsoleCache, block_keyboard_input, block_mouse_input}; use trie_rs::TrieBuilder; -use crate::commands::clear::{clear_command, ClearCommand}; -use crate::commands::exit::{exit_command, ExitCommand}; -use crate::commands::help::{help_command, HelpCommand}; +use crate::commands::clear::{ClearCommand, clear_command}; +use crate::commands::exit::{ExitCommand, exit_command}; +use crate::commands::help::{HelpCommand, help_command}; pub use crate::console::{ AddConsoleCommand, Command, ConsoleCommand, ConsoleCommandEntered, ConsoleConfiguration, ConsoleOpen, NamedCommand, PrintConsoleLine, }; pub use crate::log::*; -use crate::console::{console_ui, receive_console_line, ConsoleState}; +use crate::console::{ConsoleState, console_ui, receive_console_line}; pub use clap; mod color;