console-rs / console

A rust console and terminal abstraction
MIT License
953 stars 113 forks source link

Disabling "Quick Edit Mode" in Windows #209

Open moranbw opened 8 months ago

moranbw commented 8 months ago

I have written a CLI application for Windows using the console family of libraries, also using dialoguer and indicatif. I kept running into an issue with some of my users, where the application would seemingly "freeze", but would "wake up" upon keypress (specifically ENTER). I originally though this was just the computer falling asleep, but on further review there is actually a well-known issue with "Quick Edit Mode" in Windows terminals:

In my application I have disabled it:

    unsafe {
        let input_handle = GetStdHandle(STD_INPUT_HANDLE);
        let mut mode: CONSOLE_MODE = 0;
        if GetConsoleMode(input_handle, &mut mode) != 0 {
            mode &= !ENABLE_QUICK_EDIT_MODE;
            mode |= ENABLE_EXTENDED_FLAGS;
            SetConsoleMode(input_handle, mode);
        }
    }

We seem to be doing some ConsoleMode manipulation already in windows_term/mod.rs...but it probably does not make sense to disable this behavior by default (some users may want the click and drag functionality that Quick Edit Mode provides).

But maybe it could somehow be an option when creating your Term? Or perhaps a note in the docs....or maybe the existence of this opened issue will be enough if anyone else runs into this behavior.