mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 13:52:55 +03:00
Build a windows subsystem app on windows
This commit is contained in:
parent
45c1f5b4f3
commit
00442cd6c8
19
src/main.rs
19
src/main.rs
@ -1,3 +1,6 @@
|
||||
// Don't create a new standard console window when launched from the windows GUI.
|
||||
#![windows_subsystem = "windows"]
|
||||
|
||||
#[macro_use]
|
||||
extern crate failure;
|
||||
#[macro_use]
|
||||
@ -136,6 +139,22 @@ fn run_terminal_gui(config: Arc<config::Config>, opts: &StartCommand) -> Result<
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
// This is a bit gross.
|
||||
// In order to not to automatically open a standard windows console when
|
||||
// we run, we use the windows_subsystem attribute at the top of this
|
||||
// source file. That comes at the cost of causing the help output
|
||||
// to disappear if we are actually invoked from a console.
|
||||
// This AttachConsole call will attach us to the console of the parent
|
||||
// in that situation, but since we were launched as a windows subsystem
|
||||
// application we will be running asynchronously from the shell in
|
||||
// the command window, which means that it will appear to the user
|
||||
// that we hung at the end, when in reality the shell is waiting for
|
||||
// input but didn't know to re-draw the prompt.
|
||||
#[cfg(windows)]
|
||||
unsafe {
|
||||
winapi::um::wincon::AttachConsole(winapi::um::wincon::ATTACH_PARENT_PROCESS)
|
||||
};
|
||||
|
||||
let opts = Opt::from_args();
|
||||
let config = Arc::new(if opts.skip_config {
|
||||
config::Config::default_config()
|
||||
|
Loading…
Reference in New Issue
Block a user