diff --git a/README.md b/README.md index f097e6e..5ff3568 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ An implementation of [openkal](https://github.com/mcpplibs/openkal) for Windows. ```toml [dependencies] -openkal = "0.13.0" +openkal = "0.14.0" [target.'cfg(windows)'.dependencies] -openkal-windows = "0.8.0" +openkal-windows = "0.9.0" ``` Its purpose is as much to test the specification as to be used. openkal was diff --git a/mcpp.toml b/mcpp.toml index 46b6c24..3e31ad1 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,7 +1,7 @@ [package] namespace = "mcpplibs" name = "openkal-windows" -version = "0.8.0" +version = "0.9.0" description = "An implementation of openkal for Windows, written on the Win32 interfaces and the object manager beneath them, using no C runtime symbol." license = "Apache-2.0" @@ -18,7 +18,7 @@ authors = ["mcpplibs"] repo = "https://github.com/mcpplibs/openkal-windows" [dependencies] -openkal = "0.13.0" +openkal = "0.14.0" # The package contributes definitions and no modules. The interface it # implements is declared by the specification package, which this package diff --git a/src/terminal.cpp b/src/terminal.cpp index 2fb9e5c..b68fb17 100644 --- a/src/terminal.cpp +++ b/src/terminal.cpp @@ -18,8 +18,17 @@ void* handle_of(kal_stream s) { return reinterpret_cast(s.h); } bool valid(void* h) { return h != nullptr && h != INVALID_HANDLE_VALUE; } // This environment's console input flags. -constexpr DWORD enable_line_input = 0x0002; -constexpr DWORD enable_echo_input = 0x0004; +constexpr DWORD enable_processed_input = 0x0001; +constexpr DWORD enable_line_input = 0x0002; +constexpr DWORD enable_echo_input = 0x0004; + +// KAL_TERM_PASS_CONTROL IS ENABLE_PROCESSED_INPUT, INVERTED. This environment +// keeps the keystrokes it reserves --- the interrupt, and the pair that stops +// and starts output --- behind one flag, so the position is set exactly when +// that flag is clear. The two environments this specification is otherwise +// implemented on spread the same reservation over three flags of their own; +// what the position states is that none of them reserves anything, which is one +// question on either side. } // namespace @@ -38,8 +47,9 @@ int kal_terminal_get_mode(kal_stream s, kal_uintptr* mode) { if (!GetConsoleMode(h, &m)) return kal_err_not_supported; kal_uintptr out = 0; - if ((m & enable_line_input) != 0) out |= KAL_TERM_LINE_EDIT; - if ((m & enable_echo_input) != 0) out |= KAL_TERM_ECHO; + if ((m & enable_line_input) != 0) out |= KAL_TERM_LINE_EDIT; + if ((m & enable_echo_input) != 0) out |= KAL_TERM_ECHO; + if ((m & enable_processed_input) == 0) out |= KAL_TERM_PASS_CONTROL; *mode = out; return kal_ok; } @@ -60,6 +70,15 @@ int kal_terminal_set_mode(kal_stream s, kal_uintptr mode) { else m &= ~enable_line_input; if ((mode & KAL_TERM_ECHO) != 0) m |= enable_echo_input; else m &= ~enable_echo_input; + if ((mode & KAL_TERM_PASS_CONTROL) != 0) m &= ~enable_processed_input; + else m |= enable_processed_input; + + // THE POSITION IS ONE FLAG HERE, SO WRITING IT AGAIN SETTLES NOTHING THE + // CALLER DID NOT ASK ABOUT. The rule the specification states beside + // set_mode --- that a position whose requested value is the one in effect + // is not written --- binds an implementation whose position stands for + // several mechanisms; this one stands for exactly one, and assigning it + // from the mode word is the same act as leaving it alone. // A position this implementation does not distinguish is ignored rather than // refused, which clause 6.2 requires of a word.