Skip to content

Commit

Permalink
Merge pull request #793 from squidowl/pane-split-direction
Browse files Browse the repository at this point in the history
Control default pane split direction
  • Loading branch information
casperstorm authored Feb 25, 2025
2 parents b484dd7 + 2e680a5 commit f35f939
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

Added:

- Customize default pane splitting direction (vertical or horizontal)

# 2025.2 (2025-02-20)

Added:
Expand Down
1 change: 1 addition & 0 deletions book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions book/src/configuration/pane.md
Original file line number Diff line number Diff line change
@@ -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"
```
7 changes: 7 additions & 0 deletions data/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<Sound>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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?;
Expand All @@ -218,6 +224,7 @@ impl Config {
file_transfer,
tooltips,
preview,
pane,
})
}

Expand Down
16 changes: 16 additions & 0 deletions data/src/config/pane.rs
Original file line number Diff line number Diff line change
@@ -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,
}
27 changes: 17 additions & 10 deletions src/screen/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ impl Dashboard {
main_window,
data::Buffer::Upstream(buffer),
config.buffer.clone().into(),
config,
),
]),
None,
Expand Down Expand Up @@ -376,6 +377,7 @@ impl Dashboard {
main_window,
buffer.clone(),
config.buffer.clone().into(),
config,
));
}

Expand Down Expand Up @@ -487,6 +489,7 @@ impl Dashboard {
main_window,
data::Buffer::Upstream(buffer),
config.buffer.clone().into(),
config,
),
None,
),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}
},
};

Expand Down Expand Up @@ -951,9 +956,7 @@ impl Dashboard {
None,
);
}
ToggleFullscreen => {
return (window::toggle_fullscreen(), None)
},
ToggleFullscreen => return (window::toggle_fullscreen(), None),
}
}
Message::FileTransfer(update) => {
Expand Down Expand Up @@ -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,
Expand All @@ -1374,6 +1378,7 @@ impl Dashboard {
main_window: &Window,
buffer: data::Buffer,
settings: buffer::Settings,
config: &Config,
) -> Task<Message> {
let panes = self.panes.clone();

Expand Down Expand Up @@ -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
Expand All @@ -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),
);
Expand Down Expand Up @@ -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),
};

Expand Down Expand Up @@ -2202,6 +2208,7 @@ impl Dashboard {
main_window,
data::Buffer::Upstream(buffer),
config.buffer.clone().into(),
config,
)
}
}
Expand Down

0 comments on commit f35f939

Please sign in to comment.