diff --git a/lapce-data/src/command.rs b/lapce-data/src/command.rs index aa80b225..e96ba0bc 100644 --- a/lapce-data/src/command.rs +++ b/lapce-data/src/command.rs @@ -116,8 +116,9 @@ pub fn is_palette_command(&self) -> bool { | LapceWorkbenchCommand::ChangeColorTheme | LapceWorkbenchCommand::ChangeIconTheme | LapceWorkbenchCommand::ConnectSshHost - | LapceWorkbenchCommand::ConnectWsl | LapceWorkbenchCommand::PaletteWorkspace => return true, + #[cfg(windows)] + LapceWorkbenchCommand::ConnectWsl => return true, _ => {} } } @@ -322,6 +323,7 @@ pub enum LapceWorkbenchCommand { #[strum(message = "Connect to SSH Host")] ConnectSshHost, + #[cfg(windows)] #[strum(serialize = "connect_wsl")] #[strum(message = "Connect to WSL")] ConnectWsl, diff --git a/lapce-data/src/config.rs b/lapce-data/src/config.rs index 43ba5713..822412c1 100644 --- a/lapce-data/src/config.rs +++ b/lapce-data/src/config.rs @@ -1163,6 +1163,7 @@ fn merge_config( } } LapceWorkspaceType::RemoteSSH(_) => {} + #[cfg(windows)] LapceWorkspaceType::RemoteWSL => {} } diff --git a/lapce-data/src/data.rs b/lapce-data/src/data.rs index fd9c9c3e..47d59c1a 100644 --- a/lapce-data/src/data.rs +++ b/lapce-data/src/data.rs @@ -141,7 +141,7 @@ pub fn load( .map(|i| (i.size, i.pos)) .unwrap_or_else(|_| (Size::new(800.0, 600.0), Point::new(0.0, 0.0))); for dir in dirs { - #[cfg(target_os = "windows")] + #[cfg(windows)] let workspace_type = if !env::var("WSL_DISTRO_NAME").unwrap_or_default().is_empty() || !env::var("WSL_INTEROP").unwrap_or_default().is_empty() @@ -151,7 +151,7 @@ pub fn load( LapceWorkspaceType::Local }; - #[cfg(not(target_os = "windows"))] + #[cfg(not(windows))] let workspace_type = LapceWorkspaceType::Local; let info = WindowInfo { @@ -1827,6 +1827,7 @@ pub fn run_workbench_command( Target::Widget(self.palette.widget_id), )); } + #[cfg(windows)] LapceWorkbenchCommand::ConnectWsl => ctx.submit_command(Command::new( LAPCE_UI_COMMAND, LapceUICommand::SetWorkspace(LapceWorkspace { @@ -4585,16 +4586,23 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { pub enum LapceWorkspaceType { Local, RemoteSSH(SshHost), + #[cfg(windows)] RemoteWSL, } impl LapceWorkspaceType { + #[cfg(windows)] pub fn is_remote(&self) -> bool { matches!( self, LapceWorkspaceType::RemoteSSH(_) | LapceWorkspaceType::RemoteWSL ) } + + #[cfg(not(windows))] + pub fn is_remote(&self) -> bool { + matches!(self, LapceWorkspaceType::RemoteSSH(_)) + } } impl std::fmt::Display for LapceWorkspaceType { @@ -4604,6 +4612,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { LapceWorkspaceType::RemoteSSH(ssh) => { write!(f, "ssh://{ssh}") } + #[cfg(windows)] LapceWorkspaceType::RemoteWSL => f.write_str("WSL"), } } diff --git a/lapce-data/src/palette.rs b/lapce-data/src/palette.rs index 63fd78f6..018bfa6e 100644 --- a/lapce-data/src/palette.rs +++ b/lapce-data/src/palette.rs @@ -939,6 +939,7 @@ fn get_workspaces(&mut self, _ctx: &mut EventCtx) { LapceWorkspaceType::RemoteSSH(ssh) => { format!("[{ssh}] {text}") } + #[cfg(windows)] LapceWorkspaceType::RemoteWSL => { format!("[wsl] {text}") } diff --git a/lapce-data/src/proxy.rs b/lapce-data/src/proxy.rs index 5102667e..a7fc001a 100644 --- a/lapce-data/src/proxy.rs +++ b/lapce-data/src/proxy.rs @@ -379,6 +379,7 @@ fn start( LapceWorkspaceType::RemoteSSH(ssh) => { self.start_remote(SshRemote { ssh })?; } + #[cfg(windows)] LapceWorkspaceType::RemoteWSL => { let distro = WslDistro::all()? .into_iter() @@ -866,12 +867,14 @@ fn command_builder(&self) -> Command { } } +#[cfg(windows)] #[derive(Debug)] struct WslDistro { pub name: String, pub default: bool, } +#[cfg(windows)] impl WslDistro { fn all() -> Result> { let cmd = new_command("wsl") @@ -906,10 +909,12 @@ fn all() -> Result> { } } +#[cfg(windows)] struct WslRemote { distro: String, } +#[cfg(windows)] impl Remote for WslRemote { fn upload_file(&self, local: impl AsRef, remote: &str) -> Result<()> { let mut wsl_path = Path::new(r"\\wsl.localhost\").join(&self.distro); diff --git a/lapce-ui/src/palette.rs b/lapce-ui/src/palette.rs index fbb36540..a981d573 100644 --- a/lapce-ui/src/palette.rs +++ b/lapce-ui/src/palette.rs @@ -602,6 +602,7 @@ fn paint( LapceWorkspaceType::RemoteSSH(ssh) => { format!("[{ssh}] {text}") } + #[cfg(windows)] LapceWorkspaceType::RemoteWSL => { format!("[wsl] {text}") } diff --git a/lapce-ui/src/tab.rs b/lapce-ui/src/tab.rs index 37e45096..fc55fd64 100644 --- a/lapce-ui/src/tab.rs +++ b/lapce-ui/src/tab.rs @@ -106,6 +106,7 @@ fn workspace_title(workspace: &LapceWorkspace) -> Option { Some(match &workspace.kind { LapceWorkspaceType::Local => format!("{dir}"), LapceWorkspaceType::RemoteSSH(ssh) => format!("{dir} [{ssh}]"), + #[cfg(windows)] LapceWorkspaceType::RemoteWSL => format!("{dir} [wsl]"), }) } diff --git a/lapce-ui/src/title.rs b/lapce-ui/src/title.rs index f11483d3..1b3b5b31 100644 --- a/lapce-ui/src/title.rs +++ b/lapce-ui/src/title.rs @@ -167,19 +167,18 @@ fn update_remote( LapceWorkspaceType::Local => data .config .get_color_unchecked(LapceTheme::LAPCE_REMOTE_LOCAL), - LapceWorkspaceType::RemoteSSH(_) | LapceWorkspaceType::RemoteWSL => { - match *data.proxy_status { - ProxyStatus::Connecting => data - .config - .get_color_unchecked(LapceTheme::LAPCE_REMOTE_CONNECTING), - ProxyStatus::Connected => data - .config - .get_color_unchecked(LapceTheme::LAPCE_REMOTE_CONNECTED), - ProxyStatus::Disconnected => data - .config - .get_color_unchecked(LapceTheme::LAPCE_REMOTE_DISCONNECTED), - } - } + // LapceWorkspaceType::Remote* + _ => match *data.proxy_status { + ProxyStatus::Connecting => data + .config + .get_color_unchecked(LapceTheme::LAPCE_REMOTE_CONNECTING), + ProxyStatus::Connected => data + .config + .get_color_unchecked(LapceTheme::LAPCE_REMOTE_CONNECTED), + ProxyStatus::Disconnected => data + .config + .get_color_unchecked(LapceTheme::LAPCE_REMOTE_DISCONNECTED), + }, }; self.rects.push((remote_rect, color.clone())); let remote_svg = data.config.ui_svg(LapceIcons::REMOTE); @@ -529,6 +528,7 @@ fn update_folder( LapceWorkspaceType::RemoteSSH(ssh) => { format!(" [SSH: {}]", ssh.host) } + #[cfg(windows)] LapceWorkspaceType::RemoteWSL => " [WSL]".to_string(), }; let text = format!("{path}{remote}");