Commit Graph

520 Commits

Author SHA1 Message Date
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
Ryan Prichard
d7290359d5 Minor tweaks in ship/make_msvc_package.py
- Fix a typo in the 7-Zip default paths.

 - Change env["Path"] to env["PATH"].  Python is case-sensitive, and "Path"
   isn't working.  Windows itself seems to prefer "Path".  I'm guessing
   Python is converting "Path" to "PATH" for platform interoperability.
2016-06-14 05:38:09 -05:00
Ryan Prichard
c6603f72f5 Replace an ASSERT(false) with an exception
This code path only occurs if the start-process reply packet has an
unexpected value in it, so it should never occur.  If it somehow did,
though, it would be inconsistent (and poor behavior) to crash the process
using libwinpty.
2016-06-14 02:59:52 -05:00
Ryan Prichard
ac99610234 Put AgentDesktop into an anonymous namespace 2016-06-14 02:59:52 -05:00
Ryan Prichard
86d47df74b On RPC I/O failure, close the control pipe (which kills the agent)
- Also: ensure that the duplication of the process/thread handles can't
   leak a handle.
2016-06-14 02:59:33 -05:00
Ryan Prichard
fab4f7bb62 Code cleanup: remove a bunch of obsolete TODO comments 2016-06-14 01:07:32 -05:00
Ryan Prichard
b542453ce6 Code cleanup: propagate the LastError info more explicitly 2016-06-14 00:42:23 -05:00
Ryan Prichard
37624c05f4 Add a tea-ci badge to the README 2016-06-14 00:03:47 -05:00
Ryan Prichard
f872ded72c DebugClient improvements: preserve LastError and add TRACE() macro
TRACE() is like trace() but only evaluates its arguments when tracing is
enabled.

In various places on the default code path, where arguments are expensive
to evaluate, switch trace() to TRACE().
2016-06-13 23:50:38 -05:00
Ryan Prichard
913e8cbc71 Merge pull request #83 from fracting/tea-ci
Continuous Integration: Add build configure for Tea CI.
2016-06-13 23:04:26 -05:00
Qian Hong
22b42e29ee Continuous Integration: Add build configure for Tea CI. 2016-06-14 11:50:59 +08:00
Ryan Prichard
ac5d8e95e7 GetConsolePos: also print the cursor position 2016-06-10 01:15:22 -05:00
Ryan Prichard
e7c63efbbd Always use the default attribute (ltgray-on-black) to clear lines
I'm not sure this actually *fixes* anything, but it arguably makes more
sense than using the current color, which is not guaranteed to match the
prevailing background color.

Aside: for scrolling output, console apps generally don't try to change
the background color, and it doesn't work well, even in Unix.

Fixes https://github.com/rprichard/winpty/issues/52
2016-06-09 03:53:16 -05:00
Ryan Prichard
3388c5449f Make width/height limits consistent and cap out-of-bounds values
When resizing, ensure that the replacement sync marker does not become
visible if the buffer height is increased by more than the marker's margin
(currently 200 rows).
2016-06-09 03:22:36 -05:00
Ryan Prichard
fa6ba9c725 Windows 10 new console: try to avoid freezing the console while scraping
Fixes https://github.com/rprichard/winpty/issues/53
2016-06-09 02:34:17 -05:00
Ryan Prichard
b8c2c41eb7 Pass keyboard escapes to the WSL bash.exe wrapper
The wrapper enables the undocumented mode flag 0x200 on the CONIN handle,
which directs the Windows console to replace most KeyDown input records
with sequences of plain bytes, which are escape sequences for control and
navigation keys.

This particular solution reencodes escape sequences and looks roughly
similar to what the Windows console generates, with a few differences:
 * For Alt-Backspace, winpty generates ^[ ^?, whereras Windows generates
   ^[ ^H.
 * For Shift/Alt/Ctrl-modified sequences, winpty encodes the mask of
   modifiers into the escape sequences.
 * winpty generates ^[ Z for Shift-Tab, rather than ^I.
 * winpty generates ^[ E for the NumPad "clear/5" key, rather than nothing.

I'm still not sure winpty *ought* to do this reencoding.  I don't think
generating KeyUp events is necessary.  In principle, it might be
needed/useful for dealing with various terminals.  WSL bash.exe always
sets TERM to xterm, and even if changing it is correct w.r.t. input, it's
not necessarily correct for output -- the Windows console system is
expecting to see TERM=xterm output, which it uses to updates it screen
buffer.  (I'm not sure that matters, much, though.  I suppose
TERM=xterm-256color could be a problem?)

Fixes https://github.com/rprichard/winpty/issues/82
2016-06-08 03:36:02 -05:00
Ryan Prichard
6837b929e1 Refactor UTF-8 input handling: use code points rather than UTF-16 units
Discard bytes that don't decode as UTF-8.

Stop calling VkKeyScan on the two halves of a surrogate pair.  It's
impossible for VkKeyScan to return a useful result.
2016-06-07 23:31:02 -05:00
Ryan Prichard
448186dcb1 Stop encoding the surrogate pair region into UTF-8 and UTF-16 2016-06-07 18:42:47 -07:00
Ryan Prichard
6ebbe4e3cf build-pty4j-libpty.bat: abort if VsDevCmd.bat fails (or doesn't exist) 2016-06-07 18:10:48 -07:00
Ryan Prichard
2d54d78e19 Explicitly specify the Unicode version of two APIs 2016-06-07 18:04:40 -07:00
Ryan Prichard
78911a1546 Update the release notes. 2016-06-07 03:39:06 -07:00
Ryan Prichard
e11e229edf detectNewWindows10Console: rewrite the 1x1 special case
Also: if we're on Win7 or earlier, skip this check.  We'd like to skip
on Win8 and 8.1, too, but doing a version check for those versions is
complicated (e.g. requires a correct manifest or hacks).
2016-06-07 02:02:29 -07:00
Ryan Prichard
572759519b Accommodate very narrow consoles better
If SetConsoleScreenBufferSize fails with a width under 20, keep trying
with wider widths until the API succeeds.
2016-06-07 00:40:25 -07:00
Ryan Prichard
85d737795b Initialize FontFamily (always to 0x36) for SetCurrentConsoleFontEx
On Windows 10 build 14342, with the new console, the Japanese system
locale, and the 437 code page, calling SetCurrentConsoleFontEx to set
the Consolas font breaks if FontFamily is 0, but it works if FontFamily
is 0x36.

See misc/Font-Report-June2016/Windows10SetFontBugginess.txt.
2016-06-07 00:08:26 -07:00
Ryan Prichard
cda0b02660 Adjust the font size according to the number of columns
Additionally, if it is impossible to fit the entire screen buffer on the
current monitor, detect this condition uising the
GetLargestConsoleWindowSize API and make the console window as large as
possible.  This is suboptimal for full-screen console programs (e.g. Far
Manager), but because the scrolling-mode scraper scrapes the screen buffer
rather than the visble window, the smaller-than-desired window frequently
has no noticeable effect.

Revert the use of MARK to freeze the new Windows 10 console.  Use
SELECT_ALL again.

Fixes https://github.com/rprichard/winpty/issues/61
Fixes https://github.com/rprichard/winpty/issues/79
Breaks https://github.com/rprichard/winpty/issues/53 again
2016-06-07 00:08:24 -07:00
Ryan Prichard
b67841911f Improve debugging output in Win32ConsoleBuffer::read
The reads were failing when running wmic.exe under winpty on Windows
10 build 14342.  In that build, after running wmic.exe, the console
buffer was resized to (1500,300), but the window was not moved upward,
so it was hundreds to thousands of lines below the actual buffer.

This is obviously a Windows 10 bug, because even running wmic.exe in a
normal console demonstrates the issue.  Simply fill the console with more
than 300 lines of junk, then try to run wmic.exe, and none of the
wmic.exe output is visible, even after hitting Return repeatedly.
2016-06-07 00:08:18 -07:00
Ryan Prichard
ec4558e0ec Add a test result from Win10/10586 regarding the JP locale + 437 codepage 2016-06-07 00:08:15 -07:00
Ryan Prichard
54d599d4ab Update notes -- correct a typo and comment on the 14342 bug with wmic.exe. 2016-06-06 22:27:35 -07:00
Ryan Prichard
f334c73b34 Make m_syncCounter unsigned to avoid UB on overflow 2016-06-05 23:32:44 -07:00
Ryan Prichard
33fae530ec Add notes about SetCurrentConsoleFontEx. 2016-06-05 23:04:33 -07:00
Ryan Prichard
661094b401 Add font information from various OS versions 2016-06-05 22:01:37 -07:00
Ryan Prichard
8bb13c6849 FontSurvey: automatically classify HHFFFF=GOOD and HHHFFF=OK 2016-06-05 19:23:26 -07:00
Ryan Prichard
111d0c67b1 Add a FontSurvey program for automatically testing 100 font sizes 2016-06-05 19:07:03 -07:00
Ryan Prichard
f7545a8499 Enhancements to misc/SetFont test program 2016-06-05 17:36:23 -07:00
Ryan Prichard
bdf3e0ec4c misc/Utf16Echo: Suppress some warnings 2016-06-05 17:05:41 -07:00
Ryan Prichard
f57ed5bede winpty-agent --show-input: add --escape-input flag
Improve debugging for the case where SetConsoleMode fails.  Apparently
on Windows 7, the call fails, but the 0x200 flag is still enabled.  A
later GetConsoleMode call succeeds, but of course, further calls to
SetConsoleMode will still fail unless they unset 0x200.

Given that the 0x200 flag is undocumented and only respected in preview
releases, I'm hesistant to clear the flag when --escape-input isn't set.

Related to https://github.com/rprichard/winpty/issues/82
2016-06-05 02:32:12 -05:00
Ryan Prichard
33c5687d4a More updates to test programs for font/resizing work 2016-06-05 01:47:05 -05:00
Ryan Prichard
ebefb91e80 Update test programs for font/resizing work
* Rename QueryFont.exe to GetFont.exe -- it's shorted.  Make font table
   output shorter.  Make the program work on XP.

 * Add IsNewConsole.exe

 * Add GetBufferInfo.exe

 * Clear the executable bit on some .cc files
2016-06-04 21:10:19 -05:00
Ryan Prichard
d0ae4cbb28 Add a missing header include to OsModule.h 2016-06-04 21:07:12 -05:00
Ryan Prichard
52abfbb908 Add misc/MoveConsoleWindow test program 2016-06-04 02:48:11 -05:00
Ryan Prichard
3854d04282 Add misc/SetBufferSize.exe and misc/SetWindowRect.exe test programs 2016-06-04 02:35:03 -05:00
Ryan Prichard
0f6de50111 Get a bunch of misc test programs compiling again 2016-06-03 22:17:37 -05:00
Ryan Prichard
71405ba1d4 Revert the requirement that pipes have been opened by winpty_spawn time.
The immediate problem is that the implementation has a race condition.  We
service the control pipe before the other pipes, so we can see the
winpty_spawn RPC request before noticing that the I/O pipes are connected.
(This situation actually happened and caused a pty4j test to fail.)

There are a few ways to fix this problem, such as by adding special calls
to service the I/O pipes in handleStartProcessPacket.

It occurred to me, though, that ensuring that pipes are connected before
calling winpty_spawn might be difficult in some environments that provide
high-level I/O systems.  I'm specifically thinking of nodejs/libuv, where,
IIRC, it was difficult to guarantee that the CreateFile API would be called
synchronously.

It turns out to be easy to relax the restriction, anyway, so just do that.

I also think that CONIN and CONOUT/CONERR are sufficiently different that
perhaps CONIN should have been exempted.
2016-06-02 01:52:46 -05:00