fix(toolchain): Unbreak client startup

This reverts commit 9f900a7325.
This commit is contained in:
har7an 2025-03-03 09:26:58 +00:00 committed by GitHub
parent b7cc3f3a62
commit 736d43b138
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 207 additions and 138 deletions

View file

@ -37,7 +37,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* feat(plugins): add tab_history to the session metadata (https://github.com/zellij-org/zellij/pull/4014)
* chore(repo): update some dependencies (https://github.com/zellij-org/zellij/pull/4019)
* fix(grid): reap sixel images on clear (https://github.com/zellij-org/zellij/pull/3982)
* chore(repo): remove compile warnings (https://github.com/zellij-org/zellij/pull/4026)
* fix(panes): properly render stacked panes when pane frames are disabled (https://github.com/zellij-org/zellij/pull/4035)
## [0.41.2] - 2024-11-19

17
Cargo.lock generated
View file

@ -5102,39 +5102,40 @@ dependencies = [
[[package]]
name = "xflags"
version = "0.3.2"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d9e15fbb3de55454b0106e314b28e671279009b363e6f1d8e39fdc3bf048944"
checksum = "c4554b580522d0ca238369c16b8f6ce34524d61dafe7244993754bbd05f2c2ea"
dependencies = [
"xflags-macros",
]
[[package]]
name = "xflags-macros"
version = "0.3.2"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "672423d4fea7ffa2f6c25ba60031ea13dc6258070556f125cc4d790007d4a155"
checksum = "f58e7b3ca8977093aae6b87b6a7730216fc4c53a6530bab5c43a783cd810c1a8"
[[package]]
name = "xshell"
version = "0.2.7"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e7290c623014758632efe00737145b6867b66292c42167f2ec381eb566a373d"
checksum = "6d47097dc5c85234b1e41851b3422dd6d19b3befdd35b4ae5ce386724aeca981"
dependencies = [
"xshell-macros",
]
[[package]]
name = "xshell-macros"
version = "0.2.7"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32ac00cd3f8ec9c1d33fb3e7958a82df6989c42d747bd326c822b1d625283547"
checksum = "88301b56c26dd9bf5c43d858538f82d6f3f7764767defbc5d34e59459901c41a"
[[package]]
name = "xtask"
version = "0.1.0"
dependencies = [
"anyhow",
"lazy_static",
"prost-build",
"toml 0.5.10",
"which",

View file

@ -6,8 +6,9 @@ edition = "2021"
[dependencies]
anyhow = "1.0"
xshell = "= 0.2.7"
xflags = "0.3.2"
lazy_static = "1.4"
xshell = "= 0.2.2"
xflags = "0.3.1"
which = "4.2"
toml = "0.5"
prost-build = "0.11.9"

View file

@ -22,7 +22,7 @@ pub fn build(sh: &Shell, flags: flags::Build) -> anyhow::Result<()> {
std::process::exit(1);
}
for WorkspaceMember { crate_name, .. } in crate::workspace_members()
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS
.iter()
.filter(|member| member.build)
{
@ -32,9 +32,11 @@ pub fn build(sh: &Shell, flags: flags::Build) -> anyhow::Result<()> {
if flags.no_plugins {
continue;
}
} else if flags.plugins_only {
} else {
if flags.plugins_only {
continue;
}
}
// zellij-utils requires protobuf definition files to be present. Usually these are
// auto-generated with `build.rs`-files, but this is currently broken for us.
@ -151,7 +153,7 @@ pub fn manpage(sh: &Shell) -> anyhow::Result<()> {
let project_root = crate::project_root();
let asset_dir = &project_root.join("assets").join("man");
sh.create_dir(asset_dir).context(err_context)?;
sh.create_dir(&asset_dir).context(err_context)?;
let _pd = sh.push_dir(asset_dir);
cmd!(sh, "{mandown} {project_root}/docs/MANPAGE.md 1")

View file

@ -77,7 +77,7 @@ fn e2e_build(sh: &Shell) -> anyhow::Result<()> {
sh.remove_path(&data_dir)
.and_then(|_| sh.create_dir(&data_dir))
.and_then(|_| sh.create_dir(data_dir.join("plugins")))
.and_then(|_| sh.create_dir(&data_dir.join("plugins")))
.context(err_context)?;
for plugin in plugins {
@ -119,15 +119,15 @@ fn e2e_test(sh: &Shell, args: Vec<OsString>) -> anyhow::Result<()> {
// plugin system tests are run here because they're medium-slow
let _pd = sh.push_dir(Path::new("zellij-server"));
println!();
let msg = ">> Testing Plugin System".to_string();
println!("");
let msg = format!(">> Testing Plugin System");
crate::status(&msg);
println!("{}", msg);
cmd!(sh, "{cargo} test -- --ignored --nocapture --test-threads 1")
.args(args.clone())
.run()
.with_context(|| "Failed to run tests for the Plugin System".to_string())?;
.with_context(|| format!("Failed to run tests for the Plugin System"))?;
Ok(())
})
.context(err_context)

View file

@ -21,7 +21,7 @@ pub fn clippy(sh: &Shell, _flags: flags::Clippy) -> anyhow::Result<()> {
.and_then(|_| crate::cargo())
.context("failed to run task 'clippy'")?;
for WorkspaceMember { crate_name, .. } in crate::workspace_members().iter() {
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS.iter() {
let _pd = sh.push_dir(Path::new(crate_name));
// Tell the user where we are now
println!();

View file

@ -9,7 +9,7 @@ xflags::xflags! {
cmd xtask {
/// Deprecation warning. Compatibility to transition from `cargo make`.
cmd deprecated {
repeated _args: OsString
repeated args: OsString
}
/// Tasks for the CI
@ -128,7 +128,7 @@ pub enum XtaskCmd {
#[derive(Debug)]
pub struct Deprecated {
pub _args: Vec<OsString>,
pub args: Vec<OsString>,
}
#[derive(Debug)]

View file

@ -11,7 +11,7 @@ pub fn format(sh: &Shell, flags: flags::Format) -> anyhow::Result<()> {
.and_then(|_| crate::cargo())
.context("failed to run task 'format'")?;
for WorkspaceMember { crate_name, .. } in crate::workspace_members().iter() {
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS.iter() {
let _pd = sh.push_dir(Path::new(crate_name));
// Tell the user where we are now
println!();

View file

@ -19,7 +19,6 @@ use anyhow::Context;
use std::{
env,
path::{Path, PathBuf},
sync::OnceLock,
time::Instant,
};
use xshell::Shell;
@ -29,72 +28,24 @@ pub struct WorkspaceMember {
build: bool,
}
fn workspace_members() -> &'static Vec<WorkspaceMember> {
static WORKSPACE_MEMBERS: OnceLock<Vec<WorkspaceMember>> = OnceLock::new();
WORKSPACE_MEMBERS.get_or_init(|| {
vec![
WorkspaceMember {
crate_name: "default-plugins/compact-bar",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/status-bar",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/strider",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/tab-bar",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/fixture-plugin-for-tests",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/session-manager",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/configuration",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/plugin-manager",
build: true,
},
WorkspaceMember {
crate_name: "default-plugins/about",
build: true,
},
WorkspaceMember {
crate_name: "zellij-utils",
build: false,
},
WorkspaceMember {
crate_name: "zellij-tile-utils",
build: false,
},
WorkspaceMember {
crate_name: "zellij-tile",
build: false,
},
WorkspaceMember {
crate_name: "zellij-client",
build: false,
},
WorkspaceMember {
crate_name: "zellij-server",
build: false,
},
WorkspaceMember {
crate_name: ".",
build: true,
},
]
})
lazy_static::lazy_static! {
pub static ref WORKSPACE_MEMBERS: Vec<WorkspaceMember> = vec![
WorkspaceMember{crate_name: "default-plugins/compact-bar", build: true},
WorkspaceMember{crate_name: "default-plugins/status-bar", build: true},
WorkspaceMember{crate_name: "default-plugins/strider", build: true},
WorkspaceMember{crate_name: "default-plugins/tab-bar", build: true},
WorkspaceMember{crate_name: "default-plugins/fixture-plugin-for-tests", build: true},
WorkspaceMember{crate_name: "default-plugins/session-manager", build: true},
WorkspaceMember{crate_name: "default-plugins/configuration", build: true},
WorkspaceMember{crate_name: "default-plugins/plugin-manager", build: true},
WorkspaceMember{crate_name: "default-plugins/about", build: true},
WorkspaceMember{crate_name: "zellij-utils", build: false},
WorkspaceMember{crate_name: "zellij-tile-utils", build: false},
WorkspaceMember{crate_name: "zellij-tile", build: false},
WorkspaceMember{crate_name: "zellij-client", build: false},
WorkspaceMember{crate_name: "zellij-server", build: false},
WorkspaceMember{crate_name: ".", build: true},
];
}
fn main() -> anyhow::Result<()> {

View file

@ -317,7 +317,7 @@ pub fn publish(sh: &Shell, flags: flags::Publish) -> anyhow::Result<()> {
}
// Publish all the crates
for WorkspaceMember { crate_name, .. } in crate::workspace_members().iter() {
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS.iter() {
if crate_name.contains("plugin") || crate_name.contains("xtask") {
continue;
}

View file

@ -20,15 +20,15 @@ pub fn test(sh: &Shell, flags: flags::Test) -> anyhow::Result<()> {
)
.context(err_context)?;
for WorkspaceMember { crate_name, .. } in crate::workspace_members().iter() {
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS.iter() {
// the workspace root only contains e2e tests, skip it
if crate_name == &"." {
if *crate_name == "." {
continue;
}
let _pd = sh.push_dir(Path::new(crate_name));
// Tell the user where we are now
println!();
println!("");
let msg = format!(">> Testing '{}'", crate_name);
crate::status(&msg);
println!("{}", msg);
@ -60,9 +60,9 @@ pub fn host_target_triple(sh: &Shell) -> anyhow::Result<String> {
return None;
}
if let Some((_, triple)) = line.split_once(": ") {
Some(triple.to_string())
return Some(triple.to_string());
} else {
None
return None;
}
})
.collect::<Vec<String>>();

View file

@ -46,14 +46,15 @@ pub(crate) enum ClientInstruction {
UnblockInputThread,
Exit(ExitReason),
Connected,
ActiveClients(Vec<ClientId>),
StartedParsingStdinQuery,
DoneParsingStdinQuery,
Log(Vec<String>),
LogError(Vec<String>),
SwitchSession(ConnectToSession),
SetSynchronizedOutput(Option<SyncOutput>),
UnblockCliPipeInput(()), // String -> pipe name
CliPipeOutput((), ()), // String -> pipe name, String -> output
UnblockCliPipeInput(String), // String -> pipe name
CliPipeOutput(String, String), // String -> pipe name, String -> output
QueryTerminalSize,
WriteConfigToDisk { config: String },
}
@ -65,16 +66,17 @@ impl From<ServerToClientMsg> for ClientInstruction {
ServerToClientMsg::Render(buffer) => ClientInstruction::Render(buffer),
ServerToClientMsg::UnblockInputThread => ClientInstruction::UnblockInputThread,
ServerToClientMsg::Connected => ClientInstruction::Connected,
ServerToClientMsg::ActiveClients(clients) => ClientInstruction::ActiveClients(clients),
ServerToClientMsg::Log(log_lines) => ClientInstruction::Log(log_lines),
ServerToClientMsg::LogError(log_lines) => ClientInstruction::LogError(log_lines),
ServerToClientMsg::SwitchSession(connect_to_session) => {
ClientInstruction::SwitchSession(connect_to_session)
},
ServerToClientMsg::UnblockCliPipeInput(_pipe_name) => {
ClientInstruction::UnblockCliPipeInput(())
ServerToClientMsg::UnblockCliPipeInput(pipe_name) => {
ClientInstruction::UnblockCliPipeInput(pipe_name)
},
ServerToClientMsg::CliPipeOutput(_pipe_name, _output) => {
ClientInstruction::CliPipeOutput((), ())
ServerToClientMsg::CliPipeOutput(pipe_name, output) => {
ClientInstruction::CliPipeOutput(pipe_name, output)
},
ServerToClientMsg::QueryTerminalSize => ClientInstruction::QueryTerminalSize,
ServerToClientMsg::WriteConfigToDisk { config } => {
@ -92,6 +94,7 @@ impl From<&ClientInstruction> for ClientContext {
ClientInstruction::Render(_) => ClientContext::Render,
ClientInstruction::UnblockInputThread => ClientContext::UnblockInputThread,
ClientInstruction::Connected => ClientContext::Connected,
ClientInstruction::ActiveClients(_) => ClientContext::ActiveClients,
ClientInstruction::Log(_) => ClientContext::Log,
ClientInstruction::LogError(_) => ClientContext::LogError,
ClientInstruction::StartedParsingStdinQuery => ClientContext::StartedParsingStdinQuery,

View file

@ -92,6 +92,7 @@ pub enum ServerInstruction {
ClientId,
),
ConnStatus(ClientId),
ActiveClients(ClientId),
Log(Vec<String>, ClientId),
LogError(Vec<String>, ClientId),
SwitchSession(ConnectToSession, ClientId),
@ -132,6 +133,7 @@ impl From<&ServerInstruction> for ServerContext {
ServerInstruction::DetachSession(..) => ServerContext::DetachSession,
ServerInstruction::AttachClient(..) => ServerContext::AttachClient,
ServerInstruction::ConnStatus(..) => ServerContext::ConnStatus,
ServerInstruction::ActiveClients(_) => ServerContext::ActiveClients,
ServerInstruction::Log(..) => ServerContext::Log,
ServerInstruction::LogError(..) => ServerContext::LogError,
ServerInstruction::SwitchSession(..) => ServerContext::SwitchSession,
@ -1043,6 +1045,15 @@ pub fn start_server(mut os_input: Box<dyn ServerOsApi>, socket_path: PathBuf) {
let _ = os_input.send_to_client(client_id, ServerToClientMsg::Connected);
remove_client!(client_id, os_input, session_state);
},
ServerInstruction::ActiveClients(client_id) => {
let client_ids = session_state.read().unwrap().client_ids();
send_to_client!(
client_id,
os_input,
ServerToClientMsg::ActiveClients(client_ids),
session_state
);
},
ServerInstruction::Log(lines_to_log, client_id) => {
send_to_client!(
client_id,

View file

@ -2033,11 +2033,8 @@ impl<'a> TiledPaneGrid<'a> {
return None;
}
StackedPanes::new(self.panes.clone())
.combine_vertically_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_above)
.non_fatal();
StackedPanes::new(self.panes.clone())
.expand_pane(&pane_id)
.non_fatal();
.combine_vertically_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_above);
StackedPanes::new(self.panes.clone()).expand_pane(&pane_id);
Some(vec![*pane_id])
}
pub fn unstack_pane_up(&mut self, pane_id: &PaneId) -> Option<Vec<PaneId>> {
@ -2117,11 +2114,8 @@ impl<'a> TiledPaneGrid<'a> {
return None;
}
StackedPanes::new(self.panes.clone())
.combine_vertically_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_below)
.non_fatal();
StackedPanes::new(self.panes.clone())
.expand_pane(&pane_id)
.non_fatal();
.combine_vertically_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_below);
StackedPanes::new(self.panes.clone()).expand_pane(&pane_id);
Some(vec![*pane_id])
}
pub fn direct_neighboring_pane_ids_to_the_left(&self, root_pane_id: &PaneId) -> Vec<PaneId> {
@ -2190,12 +2184,11 @@ impl<'a> TiledPaneGrid<'a> {
{
return None;
}
StackedPanes::new(self.panes.clone())
.combine_horizontally_aligned_panes_to_stack(&pane_id, neighboring_pane_ids_to_the_left)
.non_fatal();
StackedPanes::new(self.panes.clone())
.expand_pane(&pane_id)
.non_fatal();
StackedPanes::new(self.panes.clone()).combine_horizontally_aligned_panes_to_stack(
&pane_id,
neighboring_pane_ids_to_the_left,
);
StackedPanes::new(self.panes.clone()).expand_pane(&pane_id);
Some(vec![*pane_id])
}
pub fn direct_neighboring_pane_ids_to_the_right(&self, root_pane_id: &PaneId) -> Vec<PaneId> {
@ -2267,15 +2260,11 @@ impl<'a> TiledPaneGrid<'a> {
if neighboring_pane_ids_to_the_right.is_empty() {
return None;
}
StackedPanes::new(self.panes.clone())
.combine_horizontally_aligned_panes_to_stack(
StackedPanes::new(self.panes.clone()).combine_horizontally_aligned_panes_to_stack(
&pane_id,
neighboring_pane_ids_to_the_right,
)
.non_fatal();
StackedPanes::new(self.panes.clone())
.expand_pane(&pane_id)
.non_fatal();
);
StackedPanes::new(self.panes.clone()).expand_pane(&pane_id);
Some(vec![*pane_id])
}
pub fn next_stack_id(&self) -> usize {
@ -2293,6 +2282,74 @@ impl<'a> TiledPaneGrid<'a> {
.set_geom(geom_of_active_pane);
Ok(())
}
fn get_vertically_aligned_pane_id_above(&self, pane_id: &PaneId) -> Option<PaneId> {
let Some(pane_geom) = self.get_pane_geom(pane_id) else {
return None;
};
let panes = self.panes.borrow();
let stacked_panes = StackedPanes::new(self.panes.clone());
let pane_geom = if pane_geom.is_stacked() {
stacked_panes
.position_and_size_of_stack(pane_id)
.unwrap_or(pane_geom)
} else {
pane_geom
};
panes.iter().find_map(|(candidate_pane_id, p)| {
if !p.selectable() {
return None;
}
let candidate_geom = p.current_geom();
let candidate_geom = if candidate_geom.is_stacked() {
stacked_panes
.position_and_size_of_stack(candidate_pane_id)
.unwrap_or(candidate_geom)
} else {
candidate_geom
};
if candidate_geom.y + candidate_geom.rows.as_usize() == pane_geom.y
&& candidate_geom.x == pane_geom.x
&& candidate_geom.cols.as_usize() == pane_geom.cols.as_usize()
{
return Some(p.pid());
}
return None;
})
}
fn get_vertically_aligned_pane_id_below(&self, pane_id: &PaneId) -> Option<PaneId> {
let Some(pane_geom) = self.get_pane_geom(pane_id) else {
return None;
};
let panes = self.panes.borrow();
let stacked_panes = StackedPanes::new(self.panes.clone());
let pane_geom = if pane_geom.is_stacked() {
stacked_panes
.position_and_size_of_stack(pane_id)
.unwrap_or(pane_geom)
} else {
pane_geom
};
panes.iter().find_map(|(candidate_pane_id, p)| {
if !p.selectable() {
return None;
}
let candidate_geom = p.current_geom();
let candidate_geom = if candidate_geom.is_stacked() {
stacked_panes
.position_and_size_of_stack(candidate_pane_id)
.unwrap_or(candidate_geom)
} else {
candidate_geom
};
if candidate_geom.y == pane_geom.y + pane_geom.rows.as_usize()
&& candidate_geom.x == pane_geom.x
&& candidate_geom.cols.as_usize() == pane_geom.cols.as_usize()
{
return Some(p.pid());
}
return None;
})
}
}
pub fn split(direction: SplitDirection, rect: &PaneGeom) -> Option<(PaneGeom, PaneGeom)> {

View file

@ -638,6 +638,7 @@ impl<'a> PluginLoader<'a> {
.filter_map(|export| export.clone().into_func().map(|_| export.name()))
{
if function_name.ends_with("_worker") {
let plugin_config = self.plugin.clone();
let (mut store, instance) =
self.create_plugin_instance_and_wasi_env_for_worker()?;
@ -648,7 +649,7 @@ impl<'a> PluginLoader<'a> {
.call(&mut store, ())
.with_context(err_context)?;
let worker = RunningWorker::new(store, instance, &function_name);
let worker = RunningWorker::new(store, instance, &function_name, plugin_config);
let worker_sender = plugin_worker(worker);
workers.insert(function_name.into(), worker_sender);
}

View file

@ -5,21 +5,29 @@ use wasmtime::{Instance, Store};
use zellij_utils::async_channel::{unbounded, Receiver, Sender};
use zellij_utils::async_std::task;
use zellij_utils::errors::prelude::*;
use zellij_utils::input::plugins::PluginConfig;
use zellij_utils::plugin_api::message::ProtobufMessage;
use zellij_utils::prost::Message;
pub struct RunningWorker {
pub instance: Instance,
pub name: String,
pub plugin_config: PluginConfig,
pub store: Store<PluginEnv>,
}
impl RunningWorker {
pub fn new(store: Store<PluginEnv>, instance: Instance, name: &str) -> Self {
pub fn new(
store: Store<PluginEnv>,
instance: Instance,
name: &str,
plugin_config: PluginConfig,
) -> Self {
RunningWorker {
store,
instance,
name: name.into(),
plugin_config,
}
}
pub fn send_message(&mut self, message: String, payload: String) -> Result<()> {

View file

@ -1188,6 +1188,9 @@ pub(crate) fn route_thread_main(
let _ = to_server.send(ServerInstruction::DetachSession(client_id));
should_break = true;
},
ClientToServerMsg::ListClients => {
let _ = to_server.send(ServerInstruction::ActiveClients(client_id));
},
ClientToServerMsg::ConfigWrittenToDisk(config) => {
let _ = to_server
.send(ServerInstruction::ConfigWrittenToDisk(client_id, config));

View file

@ -186,6 +186,7 @@ pub(crate) struct Tab {
viewport: Rc<RefCell<Viewport>>, // includes all non-UI panes
display_area: Rc<RefCell<Size>>, // includes all panes (including eg. the status bar and tab bar in the default layout)
character_cell_size: Rc<RefCell<Option<SizeInPixels>>>,
stacked_resize: Rc<RefCell<bool>>,
sixel_image_store: Rc<RefCell<SixelImageStore>>,
os_api: Box<dyn ServerOsApi>,
pub senders: ThreadSenders,
@ -205,6 +206,7 @@ pub(crate) struct Tab {
// it seems that optimization is possible using `active_panes`
focus_pane_id: Option<PaneId>,
copy_on_select: bool,
last_mouse_hold_position: Option<Position>,
terminal_emulator_colors: Rc<RefCell<Palette>>,
terminal_emulator_color_codes: Rc<RefCell<HashMap<usize, String>>>,
pids_waiting_resize: HashSet<u32>, // u32 is the terminal_id
@ -689,6 +691,7 @@ impl Tab {
viewport,
display_area,
character_cell_size,
stacked_resize,
sixel_image_store,
synchronize_is_active: false,
os_api,
@ -706,6 +709,7 @@ impl Tab {
clipboard_provider,
focus_pane_id: None,
copy_on_select: copy_options.copy_on_select,
last_mouse_hold_position: None,
terminal_emulator_colors,
terminal_emulator_color_codes,
pids_waiting_resize: HashSet::new(),
@ -3886,7 +3890,6 @@ impl Tab {
Ok(())
}
#[cfg(test)]
pub fn handle_right_mouse_release(
&mut self,
position: &Position,
@ -3896,6 +3899,7 @@ impl Tab {
format!("failed to handle right mouse release at position {position:?} for client {client_id}")
};
self.last_mouse_hold_position = None;
let active_pane = self.get_active_pane_or_floating_pane_mut(client_id);
if let Some(active_pane) = active_pane {
let mut relative_position = active_pane.relative_position(position);
@ -3919,7 +3923,6 @@ impl Tab {
Ok(())
}
#[cfg(test)]
fn handle_middle_mouse_release(
&mut self,
position: &Position,
@ -3929,6 +3932,7 @@ impl Tab {
format!("failed to handle middle mouse release at position {position:?} for client {client_id}")
};
self.last_mouse_hold_position = None;
let active_pane = self.get_active_pane_or_floating_pane_mut(client_id);
if let Some(active_pane) = active_pane {
let mut relative_position = active_pane.relative_position(position);

View file

@ -64,6 +64,9 @@ impl SwapLayouts {
pub fn reset_floating_damage(&mut self) {
self.is_floating_damaged = false;
}
pub fn reset_tiled_damage(&mut self) {
self.is_tiled_damaged = false;
}
pub fn is_floating_damaged(&self) -> bool {
self.is_floating_damaged
}
@ -277,4 +280,31 @@ impl SwapLayouts {
}
None
}
pub fn best_effort_tiled_layout(
&mut self,
tiled_panes: &TiledPanes,
) -> Option<TiledPaneLayout> {
for swap_layout in self.swap_tiled_layouts.iter() {
for (_constraint, layout) in swap_layout.0.iter() {
let focus_layout_if_not_focused = true;
let display_area = self.display_area.borrow();
// TODO: reuse the assets from position_panes_in_space here?
let pane_count = tiled_panes.visible_panes_count();
let display_area = PaneGeom::from(&*display_area);
if layout
.position_panes_in_space(
&display_area,
Some(pane_count),
false,
focus_layout_if_not_focused,
)
.is_ok()
{
return Some(layout.clone());
}
}
}
log::error!("Could not find layout that would fit on screen!");
None
}
}

View file

@ -82,13 +82,7 @@ impl TerminalBytes {
let mut buf = [0u8; 65536];
loop {
match self.deadline_read(&mut buf).await {
// EOF
ReadResult::Ok(0) => break,
// Some error occured
ReadResult::Err(err) => {
log::error!("{}", err);
break;
},
ReadResult::Ok(0) | ReadResult::Err(_) => break, // EOF or error
ReadResult::Timeout => {
let time_to_send_render = self
.async_send_to_screen(ScreenInstruction::Render)

View file

@ -450,6 +450,7 @@ pub enum ClientContext {
ServerError,
SwitchToMode,
Connected,
ActiveClients,
Log,
LogError,
OwnClientId,
@ -476,6 +477,7 @@ pub enum ServerContext {
DetachSession,
AttachClient,
ConnStatus,
ActiveClients,
Log,
LogError,
SwitchSession,

View file

@ -92,6 +92,7 @@ pub enum ClientToServerMsg {
ClientExited,
KillSession,
ConnStatus,
ListClients,
ConfigWrittenToDisk(Config),
FailedToWriteConfigToDisk(Option<PathBuf>),
}
@ -103,6 +104,7 @@ pub enum ServerToClientMsg {
UnblockInputThread,
Exit(ExitReason),
Connected,
ActiveClients(Vec<ClientId>),
Log(Vec<String>),
LogError(Vec<String>),
SwitchSession(ConnectToSession),