diff --git a/CHANGELOG.md b/CHANGELOG.md index 42987030..4e1f72b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Unreleased +Added: + +- Customize default pane splitting direction (vertical or horizontal) + # 2025.2 (2025-02-20) Added: diff --git a/book/src/SUMMARY.md b/book/src/SUMMARY.md index 9033ec20..9c70689f 100644 --- a/book/src/SUMMARY.md +++ b/book/src/SUMMARY.md @@ -25,6 +25,7 @@ - [Font](configuration/font.md) - [Keyboard](configuration/keyboard.md) - [Notifications](configuration/notifications.md) + - [Pane](configuration/pane.md) - [Proxy](configuration/proxy.md) - [Preview](configuration/preview.md) - [Scale factor](configuration/scale-factor.md) diff --git a/book/src/configuration/pane.md b/book/src/configuration/pane.md new file mode 100644 index 00000000..e06cca73 --- /dev/null +++ b/book/src/configuration/pane.md @@ -0,0 +1,16 @@ +# `[pane]` + +Pane settings for Halloy. A pane contains a [buffer](../configuration//buffer.md). + +## `split_axis` + +Default axis used when splitting a pane (i.e. default orientation of the divider between panes). + +```toml +# Type: string +# Values: "horizontal", "vertical" +# Default: "horizontal" + +[pane] +split_axis = "vertical" +``` diff --git a/data/src/config.rs b/data/src/config.rs index 2ec872f5..52ab5615 100644 --- a/data/src/config.rs +++ b/data/src/config.rs @@ -15,6 +15,7 @@ pub use self::channel::Channel; pub use self::file_transfer::FileTransfer; pub use self::keys::Keyboard; pub use self::notification::Notifications; +pub use self::pane::Pane; pub use self::preview::Preview; pub use self::proxy::Proxy; pub use self::server::Server; @@ -32,6 +33,7 @@ pub mod channel; pub mod file_transfer; pub mod keys; pub mod notification; +pub mod pane; pub mod preview; pub mod proxy; pub mod server; @@ -48,6 +50,7 @@ pub struct Config { pub font: Font, pub scale_factor: ScaleFactor, pub buffer: Buffer, + pub pane: Pane, pub sidebar: Sidebar, pub keyboard: Keyboard, pub notifications: Notifications, @@ -159,6 +162,8 @@ impl Config { #[serde(default)] pub buffer: Buffer, #[serde(default)] + pub pane: Pane, + #[serde(default)] pub sidebar: Sidebar, #[serde(default)] pub keyboard: Keyboard, @@ -195,6 +200,7 @@ impl Config { file_transfer, tooltips, preview, + pane, } = toml::from_str(content.as_ref()).map_err(|e| Error::Parse(e.to_string()))?; servers.read_passwords().await?; @@ -218,6 +224,7 @@ impl Config { file_transfer, tooltips, preview, + pane, }) } diff --git a/data/src/config/pane.rs b/data/src/config/pane.rs new file mode 100644 index 00000000..5f477783 --- /dev/null +++ b/data/src/config/pane.rs @@ -0,0 +1,16 @@ +use serde::Deserialize; + +#[derive(Debug, Clone, Deserialize, Default)] +pub struct Pane { + /// Default axis used when splitting a pane. + #[serde(default)] + pub split_axis: SplitAxis, +} + +#[derive(Debug, Copy, Clone, Deserialize, Default)] +#[serde(rename_all = "kebab-case")] +pub enum SplitAxis { + #[default] + Horizontal, + Vertical, +} diff --git a/src/screen/dashboard.rs b/src/screen/dashboard.rs index e4c41062..fd707e54 100644 --- a/src/screen/dashboard.rs +++ b/src/screen/dashboard.rs @@ -274,6 +274,7 @@ impl Dashboard { main_window, data::Buffer::Upstream(buffer), config.buffer.clone().into(), + config, ), ]), None, @@ -376,6 +377,7 @@ impl Dashboard { main_window, buffer.clone(), config.buffer.clone().into(), + config, )); } @@ -487,6 +489,7 @@ impl Dashboard { main_window, data::Buffer::Upstream(buffer), config.buffer.clone().into(), + config, ), None, ), @@ -737,11 +740,11 @@ impl Dashboard { command_bar::Configuration::OpenCacheDirectory => { let _ = open::that_detached(environment::cache_dir()); (Task::none(), None) - }, + } command_bar::Configuration::OpenDataDirectory => { let _ = open::that_detached(environment::data_dir()); (Task::none(), None) - }, + } command_bar::Configuration::OpenWebsite => { let _ = open::that_detached(environment::WIKI_WEBSITE); (Task::none(), None) @@ -774,7 +777,9 @@ impl Dashboard { } }, command_bar::Command::Window(command) => match command { - command_bar::Window::ToggleFullscreen => (window::toggle_fullscreen(), None), + command_bar::Window::ToggleFullscreen => { + (window::toggle_fullscreen(), None) + } }, }; @@ -951,9 +956,7 @@ impl Dashboard { None, ); } - ToggleFullscreen => { - return (window::toggle_fullscreen(), None) - }, + ToggleFullscreen => return (window::toggle_fullscreen(), None), } } Message::FileTransfer(update) => { @@ -1360,6 +1363,7 @@ impl Dashboard { main_window, data::Buffer::Internal(buffer), config.buffer.clone().into(), + config, ), BufferAction::NewWindow => self.open_popout_window( main_window, @@ -1374,6 +1378,7 @@ impl Dashboard { main_window: &Window, buffer: data::Buffer, settings: buffer::Settings, + config: &Config, ) -> Task { let panes = self.panes.clone(); @@ -1402,8 +1407,6 @@ impl Dashboard { } } - // Default split could be a config option. - let axis = pane_grid::Axis::Horizontal; let pane_to_split = { if let Some((_, pane)) = self.focus.filter(|(window, _)| *window == main_window.id) { pane @@ -1416,7 +1419,10 @@ impl Dashboard { }; let result = self.panes.main.split( - axis, + match config.pane.split_axis { + config::pane::SplitAxis::Horizontal => pane_grid::Axis::Horizontal, + config::pane::SplitAxis::Vertical => pane_grid::Axis::Vertical, + }, pane_to_split, Pane::with_settings(Buffer::from(buffer), settings), ); @@ -1836,7 +1842,7 @@ impl Dashboard { .and_then(|panes| panes.get(pane).cloned()) { let task = match pane.buffer.data() { - Some(buffer) => self.open_buffer(main_window, buffer, pane.settings), + Some(buffer) => self.open_buffer(main_window, buffer, pane.settings, config), None => self.new_pane(pane_grid::Axis::Horizontal, config, main_window), }; @@ -2202,6 +2208,7 @@ impl Dashboard { main_window, data::Buffer::Upstream(buffer), config.buffer.clone().into(), + config, ) } }