Commit Graph

544 Commits

Author SHA1 Message Date
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
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