Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Float Pane #5576

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
5ee02e4
Attempt at float pane
e82eric Jun 17, 2024
518e0c8
Try to prevent changes when a float is being shown
e82eric Jun 18, 2024
be7d669
Trying to get cli float-pane to work
e82eric Jun 19, 2024
6da5f03
Reverted changes to allow float pane size configuration
e82eric Jun 19, 2024
83b7974
Experiment with float borders
e82eric Jun 20, 2024
44c8a21
float padding config
e82eric Jun 21, 2024
3bcf229
Remove float pane from tab.panes
e82eric Jun 23, 2024
f9de55f
Removed pane_id where not needed
e82eric Jun 23, 2024
543af2b
More accurate float borders
e82eric Jul 2, 2024
275567a
Handle Resize
e82eric Jul 3, 2024
203e362
Better mouse handling
e82eric Jul 3, 2024
a3e7444
Clean up
e82eric Jul 3, 2024
e8ee2a8
Update float-pane to use cwd instead of home directory
e82eric Jul 13, 2024
128a1ca
prevent running pane manipulation actions when float pane is active
e82eric Jul 14, 2024
adba9f2
Updated float pane icons
e82eric Aug 9, 2024
cd0ee5f
Floating pane: address initial feedback
e82eric Sep 21, 2024
e567786
Fix for not creating float pane in multiplexer
e82eric Sep 22, 2024
55b9d8a
Support for floating panes in cli list-panes
e82eric Sep 23, 2024
7b20a18
Re-attach the floating pane
e82eric Sep 23, 2024
29d3988
Fix for floating pane not being removed from all connected wezterms for
e82eric Sep 24, 2024
5ad7fe6
Refactored remove_float_pane
e82eric Sep 24, 2024
b2e2b79
Fix for floating pane not working with rotate_clockwise and
e82eric Sep 25, 2024
7fa4cca
Refactor compute_background_rect
e82eric Sep 26, 2024
d771fb7
bump codec version
e82eric Sep 26, 2024
20fbe7a
Fix for resize not being applied to floating pane when updating window
e82eric Sep 26, 2024
e240f67
Attempt at being able to hide the floating pane
e82eric Sep 29, 2024
0d05175
Add is_floating to cli list
e82eric Oct 5, 2024
9534be7
Update to only hide the floating pane if clicked outside of floating
e82eric Oct 5, 2024
2fb7f8b
Update so that cli active-pane --pane-id works floating pane.
e82eric Oct 5, 2024
d5a0072
Bump codec version
e82eric Oct 6, 2024
2e83b11
Update so that cli activate-pane will show/hide the floating pane when
e82eric Oct 6, 2024
9cb6443
Fix for cli list floating_pane.is_active always being true
e82eric Oct 6, 2024
ab7acd6
Revert "Update so that cli activate-pane will show/hide the floating …
e82eric Oct 6, 2024
c534829
Fix for activate-pane --pane-id (selecting non floating pane when
e82eric Oct 6, 2024
7852213
Update so that cli activate-pane will show/hide the floating pane when
e82eric Oct 6, 2024
cfe8edf
Kill the floating pane if it is the last remaining pane in the tab (I
e82eric Oct 7, 2024
bb4b59d
Update toggle floating pane to create floating pane if it doesn't exist
e82eric Oct 8, 2024
2bf08bb
Attempt at being able to move a float pane to a split pane
e82eric Jul 14, 2024
09d1b6e
Ability to move existing pane to a floating pane
e82eric Oct 10, 2024
1da1d9f
Some clean up for move floating pane to split
e82eric Oct 10, 2024
b0c3dd1
Update move pane to floating pane to use selection UI
e82eric Oct 10, 2024
3a24295
More clean up of moving floating panes to horizontal and vertical splits
e82eric Oct 11, 2024
2c231f5
Use floating_pane instead of float_pane
e82eric Oct 11, 2024
f477cac
Basic support for multiple floating panes
e82eric Oct 11, 2024
691e8f6
Support for move pervious, move next in floating panes
e82eric Oct 12, 2024
a68e7d3
Fix list and activate floating panes from cli
e82eric Oct 12, 2024
84b4390
Fixes for move floting pane to split and Move pane to floating pane
e82eric Oct 12, 2024
2ff6f96
Use floating pane instead float pane
e82eric Oct 12, 2024
2da46fe
Fixes for move floating pane to split where there are multiple floating
e82eric Oct 12, 2024
c116dea
Update so zoom works with floating pane
e82eric Oct 13, 2024
b332626
Update so that moving a floating pane to a split hides other floating
e82eric Oct 13, 2024
50634cf
Clean up floating pane code
e82eric Oct 13, 2024
2e9d54f
Merge remote-tracking branch 'origin/main' into multiple-floating-panes
e82eric Oct 13, 2024
3034fc6
Update that cli uses spwan instead of float-pane to create floating pane
e82eric Oct 13, 2024
e489871
Refactored floating pane code in mux/src/(lib|tab).rs
e82eric Oct 14, 2024
426f0e2
Try to improve floating pane defaults
e82eric Oct 16, 2024
0f4010d
Fix for overlays (quick-select, find, copy mode) not working with
e82eric Oct 18, 2024
ad6439d
Fix for tab level overlays being hidden by floating pane.
e82eric Oct 18, 2024
435d838
Update so that cli move-pane-to-new-tab works with floating panes
e82eric Oct 18, 2024
107b353
Update so that floating panes are included in tab pane counts
e82eric Oct 19, 2024
d14d094
Update move_floating_pane_to_split to match move_pane_to_new_tab
e82eric Oct 19, 2024
32b6ca3
Simplified move_floating_pane_to_split
e82eric Oct 19, 2024
aa19544
Clean up floating pane code
e82eric Oct 19, 2024
9691610
Removed ctrl|shift|e default key binding for toggle floating pane. (Not
e82eric Oct 19, 2024
181884c
Update so that floating panes are hidden when a normal pane is activated
e82eric Oct 19, 2024
31afd6c
Clarified floating pane mouse handling in comments
e82eric Oct 20, 2024
068a321
Add scrollbar support for floating panes
e82eric Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions codec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ pdu! {
GetPaneDirection: 60,
GetPaneDirectionResponse: 61,
AdjustPaneSize: 62,
FloatPane: 63,
}

impl Pdu {
Expand Down Expand Up @@ -649,6 +650,14 @@ pub struct ListPanesResponse {
pub window_titles: HashMap<WindowId, String>,
}

#[derive(Deserialize, Serialize, PartialEq, Debug)]
pub struct FloatPane {
pub pane_id: PaneId,
pub command: Option<CommandBuilder>,
pub command_dir: Option<String>,
pub domain: config::keyassignment::SpawnTabDomain,
}

#[derive(Deserialize, Serialize, PartialEq, Debug)]
pub struct SplitPane {
pub pane_id: PaneId,
Expand Down
32 changes: 32 additions & 0 deletions config/src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,23 @@ pub struct WindowFrameConfig {
pub border_bottom_color: Option<RgbaColor>,
}

#[derive(Debug, Clone, FromDynamic, ToDynamic)]
pub struct FloatBorderConfig {
#[dynamic(try_from = "crate::units::PixelUnit", default = "default_zero_pixel")]
pub left_width: Dimension,
#[dynamic(try_from = "crate::units::PixelUnit", default = "default_zero_pixel")]
pub right_width: Dimension,
#[dynamic(try_from = "crate::units::PixelUnit", default = "default_zero_pixel")]
pub top_height: Dimension,
#[dynamic(try_from = "crate::units::PixelUnit", default = "default_zero_pixel")]
pub bottom_height: Dimension,

pub left_color: Option<RgbaColor>,
pub right_color: Option<RgbaColor>,
pub top_color: Option<RgbaColor>,
pub bottom_color: Option<RgbaColor>,
}

const fn default_zero_pixel() -> Dimension {
Dimension::Pixels(0.)
}
Expand Down Expand Up @@ -629,6 +646,21 @@ impl Default for WindowFrameConfig {
}
}

impl Default for FloatBorderConfig {
fn default() -> Self {
Self {
left_width: default_zero_pixel(),
right_width: default_zero_pixel(),
top_height: default_zero_pixel(),
bottom_height: default_zero_pixel(),
left_color: None,
right_color: None,
top_color: None,
bottom_color: None,
}
}
}

fn default_inactive_titlebar_bg() -> RgbaColor {
RgbColor::new_8bpc(0x33, 0x33, 0x33).into()
}
Expand Down
17 changes: 16 additions & 1 deletion config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
default_true, default_win32_acrylic_accent_color, GpuInfo, IntegratedTitleButtonColor,
KeyMapPreference, LoadedConfig, MouseEventTriggerMods, RgbaColor, SerialDomain, SystemBackdrop,
WebGpuPowerPreference, CONFIG_DIRS, CONFIG_FILE_OVERRIDE, CONFIG_OVERRIDES, CONFIG_SKIP,
HOME_DIR,
HOME_DIR,FloatBorderConfig
};
use anyhow::Context;
use luahelper::impl_lua_conversion_dynamic;
Expand Down Expand Up @@ -142,6 +142,9 @@ pub struct Config {
#[dynamic(default)]
pub window_frame: WindowFrameConfig,

#[dynamic(default)]
pub float_pane_border: FloatBorderConfig,

#[dynamic(default = "default_char_select_font_size")]
pub char_select_font_size: f64,

Expand Down Expand Up @@ -515,6 +518,9 @@ pub struct Config {
#[dynamic(default)]
pub window_padding: WindowPadding,

#[dynamic(default = "default_float_pane_padding")]
pub float_pane_padding: WindowPadding,

/// Specifies the path to a background image attachment file.
/// The file can be any image format that the rust `image`
/// crate is able to identify and load.
Expand Down Expand Up @@ -1573,6 +1579,15 @@ fn default_integrated_title_buttons() -> Vec<IntegratedTitleButton> {
vec![Hide, Maximize, Close]
}

fn default_float_pane_padding() -> WindowPadding {
WindowPadding{
left: Dimension::Percent(0.20),
top: Dimension::Percent(0.20),
right: Dimension::Percent(0.20),
bottom: Dimension::Percent(0.20),
}
}

fn default_char_select_font_size() -> f64 {
18.0
}
Expand Down
1 change: 1 addition & 0 deletions config/src/keyassignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ pub enum KeyAssignment {
SpawnCommandInNewWindow(SpawnCommand),
SplitHorizontal(SpawnCommand),
SplitVertical(SpawnCommand),
FloatPane(SpawnCommand),
ShowLauncher,
ShowLauncherArgs(LauncherActionArgs),
ClearScrollback(ScrollbackEraseMode),
Expand Down
19 changes: 19 additions & 0 deletions mux/src/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,25 @@ pub trait Domain: Downcast + Send + Sync {
Ok(tab)
}

async fn add_float_pane(
&self,
tab: TabId,
_pane_id: PaneId,
command_builder: Option<CommandBuilder>,
command_dir: Option<String>
) -> anyhow::Result<Arc<dyn Pane>> {
let mux = Mux::get();
let tab = match mux.get_tab(tab) {
Some(t) => t,
None => anyhow::bail!("Invalid tab id {}", tab),
};

let float_size = tab.get_float_size();
let pane = self.spawn_pane(float_size, command_builder, command_dir) .await?;
tab.insert_float(float_size, Arc::clone(&pane))?;
Ok(pane)
}

async fn split_pane(
&self,
source: SplitSource,
Expand Down
71 changes: 71 additions & 0 deletions mux/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,15 @@ impl Mux {
}
}

fn remove_float_pane_internal(&self, pane_id: PaneId) {
log::debug!("removing float pane {}", pane_id);
if let Some(pane) = self.panes.write().remove(&pane_id).clone() {
log::debug!("killing float pane {}", pane_id);
pane.kill();
self.notify(MuxNotification::PaneRemoved(pane_id));
}
}

fn remove_tab_internal(&self, tab_id: TabId) -> Option<Arc<Tab>> {
log::debug!("remove_tab_internal tab {}", tab_id);

Expand Down Expand Up @@ -876,6 +885,11 @@ impl Mux {
self.prune_dead_windows();
}

pub fn remove_float_pane(&self, pane_id: PaneId) {
self.remove_float_pane_internal(pane_id);
self.prune_dead_windows();
}

pub fn remove_tab(&self, tab_id: TabId) -> Option<Arc<Tab>> {
let tab = self.remove_tab_internal(tab_id);
self.prune_dead_windows();
Expand Down Expand Up @@ -1169,6 +1183,63 @@ impl Mux {
})
}

pub async fn float_pane(
&self,
// TODO: disambiguate with TabId
pane_id: PaneId,
command_builder: Option<CommandBuilder>,
command_dir: Option<String>,
domain: config::keyassignment::SpawnTabDomain,
) -> anyhow::Result<(Arc<dyn Pane>, TerminalSize)> {
let (_pane_domain_id, window_id, tab_id) = self
.resolve_pane_id(pane_id)
.ok_or_else(|| anyhow!("pane_id {} invalid", pane_id))?;

let domain = self
.resolve_spawn_tab_domain(Some(pane_id), &domain)
.context("resolve_spawn_tab_domain")?;

if domain.state() == DomainState::Detached {
domain.attach(Some(window_id)).await?;
}

let current_pane = self
.get_pane(pane_id)
.ok_or_else(|| anyhow!("pane_id {} is invalid", pane_id))?;
let term_config = current_pane.get_config();

let command_dir = if !command_dir.is_some() {
self.resolve_cwd(
command_dir,
Some(Arc::clone(&current_pane)),
domain.domain_id(),
CachePolicy::FetchImmediate,
)
} else {
command_dir
};

let pane = domain.add_float_pane(tab_id, pane_id, command_builder, command_dir).await?;

if let Some(config) = term_config {
pane.set_config(config);
}

// FIXME: clipboard

let dims = pane.get_dimensions();

let size = TerminalSize {
cols: dims.cols,
rows: dims.viewport_rows,
pixel_height: 0, // FIXME: split pane pixel dimensions
pixel_width: 0,
dpi: dims.dpi,
};

Ok((pane, size))
}

pub async fn split_pane(
&self,
// TODO: disambiguate with TabId
Expand Down
Loading