Start-local-collaboration script: put peers' windows at different positions
This commit is contained in:
parent
6120d6488b
commit
a48cd9125b
2 changed files with 33 additions and 4 deletions
|
@ -17,7 +17,10 @@ use lazy_static::lazy_static;
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
actions,
|
||||||
geometry::vector::vec2f,
|
geometry::{
|
||||||
|
rect::RectF,
|
||||||
|
vector::{vec2f, Vector2F},
|
||||||
|
},
|
||||||
impl_actions,
|
impl_actions,
|
||||||
platform::{WindowBounds, WindowOptions},
|
platform::{WindowBounds, WindowOptions},
|
||||||
AssetSource, AsyncAppContext, TitlebarOptions, ViewContext, WindowKind,
|
AssetSource, AsyncAppContext, TitlebarOptions, ViewContext, WindowKind,
|
||||||
|
@ -71,6 +74,14 @@ actions!(
|
||||||
const MIN_FONT_SIZE: f32 = 6.0;
|
const MIN_FONT_SIZE: f32 = 6.0;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
static ref ZED_WINDOW_SIZE: Option<Vector2F> = env::var("ZED_WINDOW_SIZE")
|
||||||
|
.ok()
|
||||||
|
.as_deref()
|
||||||
|
.and_then(parse_pixel_position_env_var);
|
||||||
|
static ref ZED_WINDOW_POSITION: Option<Vector2F> = env::var("ZED_WINDOW_POSITION")
|
||||||
|
.ok()
|
||||||
|
.as_deref()
|
||||||
|
.and_then(parse_pixel_position_env_var);
|
||||||
pub static ref RELEASE_CHANNEL_NAME: String =
|
pub static ref RELEASE_CHANNEL_NAME: String =
|
||||||
env::var("ZED_RELEASE_CHANNEL").unwrap_or(include_str!("../RELEASE_CHANNEL").to_string());
|
env::var("ZED_RELEASE_CHANNEL").unwrap_or(include_str!("../RELEASE_CHANNEL").to_string());
|
||||||
pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME.as_str() {
|
pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME.as_str() {
|
||||||
|
@ -346,8 +357,13 @@ pub fn initialize_workspace(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_window_options() -> WindowOptions<'static> {
|
pub fn build_window_options() -> WindowOptions<'static> {
|
||||||
|
let bounds = if let Some((position, size)) = ZED_WINDOW_POSITION.zip(*ZED_WINDOW_SIZE) {
|
||||||
|
WindowBounds::Fixed(RectF::new(position, size))
|
||||||
|
} else {
|
||||||
|
WindowBounds::Maximized
|
||||||
|
};
|
||||||
WindowOptions {
|
WindowOptions {
|
||||||
bounds: WindowBounds::Maximized,
|
bounds,
|
||||||
titlebar: Some(TitlebarOptions {
|
titlebar: Some(TitlebarOptions {
|
||||||
title: None,
|
title: None,
|
||||||
appears_transparent: true,
|
appears_transparent: true,
|
||||||
|
@ -612,6 +628,13 @@ fn schema_file_match(path: &Path) -> &Path {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_pixel_position_env_var(value: &str) -> Option<Vector2F> {
|
||||||
|
let mut parts = value.split(',');
|
||||||
|
let width: usize = parts.next()?.parse().ok()?;
|
||||||
|
let height: usize = parts.next()?.parse().ok()?;
|
||||||
|
Some(vec2f(width as f32, height as f32))
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -26,8 +26,14 @@ fi
|
||||||
|
|
||||||
export ZED_ADMIN_API_TOKEN=secret
|
export ZED_ADMIN_API_TOKEN=secret
|
||||||
export ZED_SERVER_URL=http://localhost:8080
|
export ZED_SERVER_URL=http://localhost:8080
|
||||||
|
export ZED_WINDOW_SIZE=800,600
|
||||||
|
|
||||||
|
cargo build
|
||||||
|
sleep 0.1
|
||||||
|
|
||||||
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
|
||||||
ZED_IMPERSONATE=${github_login} cargo run --quiet $@ &
|
ZED_WINDOW_POSITION=0,0 ZED_IMPERSONATE=${github_login} target/debug/Zed $@ &
|
||||||
ZED_IMPERSONATE=${other_github_login} cargo run --quiet &
|
sleep 0.1
|
||||||
|
ZED_WINDOW_POSITION=800,0 ZED_IMPERSONATE=${other_github_login} target/debug/Zed &
|
||||||
|
sleep 0.1
|
||||||
wait
|
wait
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue