Commit Graph

562 Commits

Author SHA1 Message Date
Ryan Prichard
4978cf94b6 Go back to using GenerateConsoleCtrlEvent for processed-mode Ctrl-C
This change reverts the first part of the GH-116 fix.

See https://github.com/rprichard/winpty/issues/116
2017-05-19 03:14:13 -05:00
Ryan Prichard
0c86e4f78e Add an entry for Ctrl-C in DefaultInputMap's SimpleEncoding table
Fixes https://github.com/rprichard/winpty/issues/116
2017-05-18 05:04:59 -05:00
Ryan Prichard
c9ce3ad1e3 Use Window messages rather than GenerateConsoleCtrlEvent for Ctrl-C
Fixes https://github.com/rprichard/winpty/issues/116
2017-05-17 06:03:17 -05:00
Ryan Prichard
096f978c7a Flush INPUT_RECORD objects prior to SendMessage/GenerateConsoleCtrlEvent
Fixes https://github.com/rprichard/winpty/issues/117
2017-05-17 05:29:07 -05:00
Ryan Prichard
faf75f74b7 Bump version to 0.4.4-dev 2017-05-17 02:01:42 -05:00
Ryan Prichard
3e1ab962d5 Version 0.4.3 2017-05-17 01:47:20 -05:00
Ryan Prichard
e75bd9cbdd Explicitly use the Unicode function WriteConsoleInputW 2017-05-17 01:47:19 -05:00
Ryan Prichard
6765a41c5b Change the modified-Home/End escape sequence from H/F to 1/4
For unmodified Home/End, winpty instead sends WM_KEYDOWN / WM_KEYUP
messages to the console window so that the console can decide what escape
to use based on the VT terminal "alternate mode".

Fixes https://github.com/rprichard/winpty/issues/114
2017-04-27 21:17:03 -07:00
Ryan Prichard
5814705546 Update release notes 2017-04-24 00:47:14 -07:00
Ryan Prichard
b4db322010 Stop using fonts smaller than 5px in height
The console must decide whether characters are half-vs-full width, and it
seems to make poorer decisions with fonts that are atypically small.  The
console properties dialog doesn't allow fonts smaller than 5px.

For example, (U+2026 HORIZONTAL ELLIPSIS) is half-width in Lucida Console
and Consolas, but with Lucida Console, 2px or 4px height, the console
thinks it's full-width.

Disallowing smaller fonts will force winpty to use larger windows, which
makes it more likely to hit the maximum window size constraint.

See https://github.com/Microsoft/vscode/issues/19665.
2017-04-24 00:38:05 -07:00
Ryan Prichard
af4bc8b78a Update release notes 2017-04-22 23:51:06 -07:00
Ryan Prichard
5b99238fca Don't show the cursor if it is outside the console window
Fixes https://github.com/rprichard/winpty/issues/113
2017-04-22 23:41:22 -07:00
Ryan Prichard
bae43674b1 Update release notes 2017-04-22 22:09:36 -07:00
Ryan Prichard
ac33b66172 Direct mode: invalidate m_bufferData on resize
Also, for efficieny in direct mode, only output the lines that have
changed, rather than reprinting all of the lines after the first changed
line.

Fixes https://github.com/rprichard/winpty/issues/112
2017-04-22 22:05:16 -07:00
Ryan Prichard
d636a1de86 Synthesize a WINDOW_BUFFER_SIZE_EVENT event after winpty is resized
Fixes https://github.com/rprichard/winpty/issues/110.
2017-04-22 14:57:35 -07:00
Ryan Prichard
838d959579 Update the release notes 2017-04-22 03:11:58 -05:00
Ryan Prichard
201d8aeb3a Fix handling of AltGr keys
* Respect the result of VkKeyScan when it returns multiple modifiers.  I
   *think* the old if-else behavior was a typo?

 * Refactor the code to restrict the scope of the Alt-implies-NUL behavior.
   On my US keyboard, if I press either Alt-P or Alt-Ctrl-P, the console
   reports a VirtualKey of 'P', and a NUL codepoint for KeyUp.  For KeyDown,
   though, Alt-P reports a 'P' codepoint, but Alt-Ctrl-P reports a NUL
   codepoint.  winpty previously implemented this logic in appendKeyPress, but
   now it's factored out.

   If the terminal sends us U+20AC (EURO SIGN), VkKeyScan decides that it must
   have been typed using both Ctrl and Alt.  (Pressing Ctrl-LeftAlt-E on my US
   keyboard produces a Euro, as does RightAlt-E; AltGr/RightAlt seems to imply
   Ctrl.)  If the Alt keypress only comes from VkKeyScan, then continue using
   the proper codepoint.

 * Avoid changing the VT/reencoding behavior.  In appendUtf8Char, pass the
   unadjusted codepoint and Alt-escape to appendKeyPress, which will pass it
   to reencodeEscapedKeyPress if the console is using VT input.

Fixes https://github.com/rprichard/winpty/issues/109
2017-04-22 03:11:58 -05:00
Ryan Prichard
6360ec6a5b Add test case demonstrating a Win10 15048 ReadConsoleOutput bug 2017-03-16 20:57:35 -05:00
Ryan Prichard
47e7e005e8 Change program execution: resolve symlinks and do PATH search explicitly
Fixes https://github.com/rprichard/winpty/issues/81
Fixes https://github.com/rprichard/winpty/issues/98
2017-02-01 20:48:43 -06:00
Ryan Prichard
75301a2703 Stop building the MSYS package
See https://github.com/rprichard/winpty/issues/97
2017-02-01 17:53:21 -06:00
Ryan Prichard
9f900cc152 Debug output: when virtualkey is 0, print 0 rather than 0x0 2017-01-31 22:06:06 -06:00
Ryan Prichard
ed9d5ad158 Use hex for scan code --show-input debug output 2017-01-31 22:05:24 -06:00
Ryan Prichard
bf98ff3c20 Add a test program that dumps console input via _getch. 2017-01-31 22:03:52 -06:00
Ryan Prichard
84016539f3 Set the ENHANCED_KEY key state for these keys:
* Arrow keys (up, down, left, right)
 * The block of 6 keys (insert, delete, home, end, pgup, pgdn)

This change fixes arrow keys in the Ruby REPL (irb)

Fixes https://github.com/rprichard/winpty/issues/99
2017-01-31 21:53:26 -06:00
Ryan Prichard
db874f4a70 Bump version 2017-01-18 05:35:39 -06:00
Ryan Prichard
410d634987 Set version to 0.4.2 2017-01-18 05:02:24 -06:00
Ryan Prichard
a703349883 Put the commit hash into the msvc binary package 2017-01-18 04:57:11 -06:00
Ryan Prichard
9fcad3a144 ship: make it easier to spot-check packages by leaving package dirs around 2017-01-18 04:55:55 -06:00
Ryan Prichard
1ad7e4eed8 Release notes for 0.4.2 2017-01-18 02:42:52 -06:00
Ryan Prichard
a674301a4b Fix a build problem with MSYS2 by adding a missing header 2017-01-18 01:29:39 -06:00
Ryan Prichard
eed0b3bd71 Get the code compiling with the latest MinGW.org toolchain.
(MinGW-w64 works already -- only the old MinGW toolchain had trouble.)

 * We need to build the test case with -std=g++11 to provide vsnprintf,
   even though vsnprintf is in C99 and is provided by both MSVC and
   MinGW-w64.

 * The old MinGW provides a non-conforming swprintf.
2017-01-18 01:25:10 -06:00
Ryan Prichard
67a34b6c03 Build system: redo how version number tracking works
* Remove the "version suffix" and BUILD_INFO.txt mechanisms, which I
   believe no one uses except winpty itself.  Instead, a suffix can be
   added in the VERSION.txt file.

 * Instead of passing the version and commit info as a preprocessor macro
   when building every C++ file, write the info into a GenVersion.h
   header that is only included by WinptyVersion.cc.

 * Instead of writing a BUILD_INFO.txt in ship.py, pass COMMIT_HASH=<hash>
   to make.

These changes accomplish two things:

 * People who build a tag from source won't see a "<ver>-dev" suffix
   anymore.

 * Changing the version or the commit will correctly rebuild the version
   object files (and only those object files).  It will also relink every
   binary.

Fixes https://github.com/rprichard/winpty/issues/72
2017-01-17 23:39:14 -06:00
Ryan Prichard
643e14894a Remove an obsolete comment. 2017-01-17 21:50:34 -06:00
Ryan Prichard
36d6a4d82e Support the COMMON_LVB_REVERSE_VIDEO and COMMON_LVB_UNDERSCORE flags
These flags are used with WSL (Bash on Windows) and are commonly used.
(e.g. a pager status bar, man pages, etc.)

The most difficult part of this commit is figuring out when Windows
respects the flags versus ignores them.  Apparently it deliberately
ignores them for backwards-compatibility with some programs.
2017-01-15 06:36:18 -06:00
Ryan Prichard
40d5b72c43 Pass certain keys to the console using windows messages.
If the terminal is placed in an alternate mode using DECCKM, then we
need to generate different input escape sequences for WSL (and other
programs using ENABLE_VIRTUAL_TERMINAL_INPUT).  AFAIK, there is no way
for winpty to detect whether an alternate mode is enabled, but it only
seems to affect a small number of keys, so send those keys as window
messages.

We don't send *all* keys as window messages, because the console may try
to interpret some of them.  It doesn't interpret the arrow keys and
Home/End, AFAICT, and those seem to be the only keys affected by DECCKM.
(The console's line-input mode *does* care about these navigation keys,
but in that case, WriteConsoleInput and window messages work equally well.)

DECCKM only seems to affect the keys when there is no modifier key.

I believe that by using SendMessage, winpty-agent will block until the
keys are appended to the console input buffer.  I'm not sure how to verify
it.  If this *weren't* the case, there could be a danger of key input
being transposed.  It seems unlikely to be an issue.

Fixes https://github.com/rprichard/winpty/issues/90
2017-01-15 04:20:05 -06:00
Ryan Prichard
27dfaaefb6 Bump version to 0.4.2 2017-01-03 23:08:15 -06:00
Ryan Prichard
ff8e67d313 Update release notes for 0.4.1. 2017-01-03 22:16:54 -06:00
Ryan Prichard
a850639a87 Fix various MSVC 2015 /W3 warnings
* The compiler doesn't like implicit conversions to bool.
   (it emits a "performance warning")

 * It also doesn't like an unused argument in an exception catch block.
2017-01-03 20:51:29 -06:00
Ryan Prichard
9f0d7e6b4e Add an assertion check in readAll
If the assertion could fail somehow, we could have memory unsafety.
2017-01-03 20:18:29 -06:00
Ryan Prichard
91fce49ab1 Respect the pos parameter in WriteBuffer::replaceRawData
This omission didn't actually break anything, because `pos` is always
0.
2016-10-19 23:05:37 -05:00
Ryan Prichard
68c0c140b2 Fix a read-from-end-of-buffer issue
Fixes https://github.com/rprichard/winpty/issues/94
2016-10-19 23:04:45 -05:00
Ryan Prichard
d02e42d815 Largely cosmetic: avoid a 0-size WriteConsoleInput call 2016-08-14 00:48:55 -05:00
Ryan Prichard
d9935eb21f Improve Ctrl-D detection for winpty-agent --show-input test mode. 2016-08-13 22:59:34 -05:00
Ryan Prichard
4a2ff5da03 Add new test programs: ConinMode, ConoutMode, WriteConsole 2016-08-13 22:12:18 -05:00
Ryan Prichard
6c994460a3 Stylistic change: Add C++11 override keywords everywhere possible.
GCC 5.1 added a -Wsuggest-override option that reports missing `override`
keywords, which I used to prepare this commit.  I'm not turning the option
on yet, though, because my Cygwin environment is still using GCC 4.9.
2016-07-24 00:21:10 -05:00
Ryan Prichard
30d59523ed Stylistic change: put a space between a macro and an opening double-quotes
Initially, some of this code omitted a space between a closing
double-quotes and a macro, which broke with C++11:

    m_output.write(CSI"0m"CSI"1;1H"CSI"2J");

To make it work with C++11, it changed to:

    m_output.write(CSI"0m" CSI"1;1H" CSI"2J");

Now I'm fully separating them:

    m_output.write(CSI "0m" CSI "1;1H" CSI "2J");

I don't expect C++ to change again, breaking my code, but it seems prudent
to avoid that possibility.

I searched the codebase for matches using this Sublime/Perl regex:

    ^([^"'\n]*("([^\\"\n]|\\.)*"|'([^\\'\n]|\\.)*'))*[^"'\n]*(?<!^)(?<!\bL)(?<=[A-Za-z0-9_])("([^\\"\n]|\\.)*"|'([^\\'\n]|\\.)*')
2016-07-23 23:49:45 -05:00
Ryan Prichard
18d71a73f2 Bump the version to 0.4.1 2016-06-28 23:54:45 -05:00
Ryan Prichard
c66253e782 Update release notes for 0.4.0. 2016-06-28 22:37:09 -05:00
Ryan Prichard
a0e3f337c0 Add a misc/IdentifyConsoleWindow.ps1 test script
It determines:
 - whether the program has a console
 - whether that console has a window
 - whether that window is on the current window station

It's motivated by the IntelliJ clipboard/winpty bug.
2016-06-20 00:15:53 -05:00
Ryan Prichard
fb8fb49c46 Update API documentation 2016-06-15 14:03:34 -05:00