Commit Graph

520 Commits

Author SHA1 Message Date
Ryan Prichard
3fc4b88b39 Refactor: create a InputMap::Key::toString method. 2015-12-02 01:07:27 -06:00
Ryan Prichard
9922a0ab19 Recognize Alt-{F1-F4} for TERM=cygwin. 2015-12-02 01:07:26 -06:00
Ryan Prichard
4b254ff015 Refactoring: handle ESC / Alt-Shift-O / Alt-[ implicitly
* Remove these characters from the input map and handle them via the
   ordinary <Char> and Alt-<Char> code paths.

 * Refactor lookupKey to remove the isEof parameter.
2015-12-02 01:07:25 -06:00
Ryan Prichard
8d8506d489 Handle many more keypress escape sequences, particularly for putty/rxvt
* Factor out the tables from ConsoleInput.cc to DefaultInputMap.cc.

Fixes https://github.com/rprichard/winpty/issues/40
2015-12-02 01:07:24 -06:00
Ryan Prichard
b416a4a7c1 Tolerate embedded NULs when scanning for a keypress
* Ctrl-2 (^@) is encoded as a NUL byte.

 * Instead of looking for a NUL byte, we need to check the input size.
   Places affected: scanKeyPress, matchDsr, lookupKey

 * N.B.: putty and rxvt encode Ctrl-Alt-2 as `ESC NUL`.

Previously, after inputting a NUL using Ctrl-2, one could type an arbitrary
amount of input into the input buffer, and winpty wouldn't do anything
until 1-second inactivity timeout had expired.  (i.e. It thought it was
seeing an incomplete DSR, so it kept waiting for the DSR to complete.)
2015-12-01 23:03:43 -06:00
Ryan Prichard
08a14e7ddd Fix Shift-Alt-O and Alt-[.
* ^[O is Shift-Alt-O, not Alt-O.  Alt-O is ^[o

 * '[' is not a valid virtualkey.  It's typically VK_OEM_4 on a US
   keyboard, but it needs to be looked up dynamically.

 * The unicodeChar fields should be 'O' and '[', not NUL.
2015-12-01 05:03:58 -06:00
Ryan Prichard
c60f748fb3 Factor out an InputMap class for doing keypress decoding. 2015-12-01 04:57:56 -06:00
Ryan Prichard
42838973de Add --showkey and WINPTY_DEBUG=input
* Add a --showkey argument to the unix adapter.

   My Ubuntu machine has a nice showkey -a utility that dumps keys, but I
   can't find something similar for Cygwin/MSYS.  It's a very useful tool
   for debugging UNIX terminal interoperability, so add it to the unix
   adapter.

 * Add WINPTY_DEBUG=input to log input bytes and console key events.
2015-12-01 04:00:35 -06:00
Ryan Prichard
6ed4572eec Make WINPTY_DEBUG a comma-separated list of flags. Improve thread-safety. 2015-12-01 03:39:41 -06:00
Ryan Prichard
95aff6bc69 Move source files into a src subdirectory.
Fixes https://github.com/rprichard/winpty/issues/51
2015-11-29 03:50:06 -06:00
Ryan Prichard
df6b9b1f60 Move Notes.txt into the misc subdirectory 2015-11-29 03:33:38 -06:00
Ryan Prichard
3f0c12fcbf Cleanup in configure script
* Remove GIT_REVPARSE_WORKS, which is never used

 * Rename the shell variables {UNIX,MINGW}_GPP to {UNIX,MINGW}_CXX to
   match the config.mk variable names.
2015-11-29 03:33:23 -06:00
Ryan Prichard
b5045f4ed3 Add a RELEASES.md file and bump version to 0.2.0. 2015-11-13 18:22:05 -08:00
Ryan Prichard
d21d0d0598 Add an "implicit copyright grant" notice; update copyright notices 2015-11-08 00:37:25 -06:00
Ryan Prichard
6741c6a980 README: Add a section heading for MSYS2 packages 2015-11-08 00:18:08 -06:00
Ryan Prichard
c82849f5b6 Upgrade line counters to 64 bits.
Fixes https://github.com/rprichard/winpty/issues/48
2015-11-07 23:44:22 -06:00
Ryan Prichard
bf7b3c328a Add a script for creating binary winpty releases. 2015-11-07 21:19:09 -06:00
Ryan Prichard
7b7192e441 Add version tracking. Add a --version arg to console and winpty-agent.
There is a "version suffix" that defaults to "-dev".  A maintainer could
change the suffix (or remove it) by invoking make:

    make BUILD_SUFFIX=-foo
    make BUILD_SUFFIX=

It can also be changed in gyp builds:

    gyp winpty.gyp --depth=1 -D BUILD_SUFFIX=-foo
    gyp winpty.gyp --depth=1 -D BUILD_SUFFIX=

If git cannot be executed, the string "none" is used for the commit hash.
2015-11-07 21:19:03 -06:00
Ryan Prichard
52b11bfba9 Convert the makefiles from recursive to non-recursive
* This change reduces the total build time from about 14 seconds to about
   9 seconds on my computer.

Also:

 * Consolidate all the intermediate files into the build directory to
   reduces clutter.

 * Allow specifying UNIX_ADAPTER_EXE to make.  Perhaps this will be helpful
   to the MSYS2 fork, which renames console.exe to winpty.exe.  (I like
   the renaming, but I don't know about the other winpty users.  Maybe
   I'll make the change after I've put out another stable release...)

 * Rename the WINPTY define to COMPILING_WINPTY_DLL define.  The longer
   name is clearer.  I define the macro inside libwinpty/winpty.cc, so the
   build system no longer needs to.  (I removed the define from
   winpty.gyp.)

 * Consolidate config-unix.mk and config-mingw.mk into config.mk.  The
   separation was previously necessary because each file had a conflicting
   definition of CXX.

 * Rename the UNIX_LDFLAGS_STATIC_LIBSTDCXX macro to UNIX_LDFLAGS_STATIC,
   because libstdc++ isn't the only thing I'm linking statically.
2015-11-06 22:08:24 -06:00
Ryan Prichard
70eafd08d3 Avoid a potentially invalid LargeConsoleRead line.
I think it might be possible for m_dirtyLineCount to be greater than the
windowRect.top() + windowRect.height().  If it is, then scanForDirtyLines
will perform an invalid read while trying to initialize prevLineAttr.
2015-11-06 02:25:08 -06:00
Ryan Prichard
24dd41bb79 Improve error reporting for an invalid LargeConsoleRead line. 2015-11-06 02:21:36 -06:00
Ryan Prichard
ce2d9f1b04 Use Mark instead of SelectAll in the Windows 10 non-legacy console mode
Fixes https://github.com/rprichard/winpty/issues/53
2015-11-06 01:41:43 -06:00
Ryan Prichard
5fb236d70e Improve the SelectAllTest a little 2015-11-06 01:00:26 -06:00
Ryan Prichard
2e24ecdcd2 Remove TestHandleInheritance, which is obsoleted by HandleTests. 2015-11-06 00:44:21 -06:00
Ryan Prichard
0d4c175037 Expand the modern console I/O tests 2015-11-06 00:30:35 -06:00
Ryan Prichard
d3198232ce Also verify that Detached->Detached CreateProcess sets NULL stdhandles. 2015-11-05 02:15:11 -06:00
Ryan Prichard
303ddb9b4a Update the gyp file to account for recent file renamings and refactoring.
Also add agent/EventLoop.h.  I don't know why it wasn't listed.

With these changes, gyp no longer complains about missing files.
Unfortunately I can't do more testing at the moment.

This commit might fix issue https://github.com/rprichard/winpty/issues/55.
2015-11-02 16:44:24 -08:00
Ryan Prichard
fb0940b6da Add intro material to document 2015-10-27 13:34:42 -05:00
Ryan Prichard
18941a60c2 Update duplication tests for WOW64, XP inheritability bug 2015-10-27 13:34:42 -05:00
Ryan Prichard
c9a5f624be misc/buffer-tests: Add test failure reporting 2015-10-27 13:23:18 -05:00
Ryan Prichard
7c12d90086 Get the tests running inside the WOW64 environment on pre-Win7 OSs
Prior to Windows 7, the undocumented NtQuerySystemInformation API did
not return valid handle information when called by a WOW64 process.  To
work around this problem, the 32-bit test program connects to a 64-bit
worker and uses the existing RPC mechanism, issuing LookupKernelObject
commands, which call NtQuerySystemInformation in a native 64-bit
environment.

Even on Windows 7, the NtQuerySystemInformation API returns truncated
kernel object pointers, so, AFAIK, we still need to do this work. Maybe
not, though, if the lower 32 bits are guaranteed to be unique.

On Windows 10, there is a CompareObjectHandles API that works in WOW64
mode.
2015-10-27 13:19:42 -05:00
Ryan Prichard
72c5ea52fd Fixes and comments to Test_CreateProcess_Duplicate_PseudoHandleBug
It seems that this bug was fixed in WOW64 prior to its fixing in the
normal environment.

It makes no sense to run Test_CreateProcess_Duplicate_PseudoHandleBug_IL
on OS's that don't have inherit lists.
2015-10-26 18:42:06 -05:00
Ryan Prichard
b95da0a6d8 Document my theory for the CONOUT$ Win7 bug and add a safe-ish? testcase. 2015-10-26 17:39:04 -05:00
Ryan Prichard
116f3402ba Make the Windows 7 note a bit clearer. 2015-10-26 13:09:08 -05:00
Ryan Prichard
a7feca65a7 Consolidate InheritList tests, expand them, document the semantics.
Provide a way to test for UpdateProcThreadAttribute failures, because
trying to create an empty inherit list seems interesting to me.
2015-10-26 11:53:39 -05:00
Ryan Prichard
29b9ebbc2e Add Test_AttachConsole_AllocConsole_StdHandles trad + modern tests. 2015-10-26 01:14:23 -05:00
Ryan Prichard
4a67a2073e Suppress tests; XP doesn't have inherit lists 2015-10-25 23:38:51 -05:00
Ryan Prichard
37b467c2c5 Test with both CREATE_NEW_CONSOLE and CREATE_NO_WINDOW as the default.
Also fix a problem with a 0xdeadbeef handle.
2015-10-25 23:28:34 -05:00
Ryan Prichard
6f77ca472d CreateProcess can duplicate standard handles in another instance 2015-10-25 23:18:03 -05:00
Ryan Prichard
649bdad6e2 Documentation updates 2015-10-25 20:54:50 -05:00
Ryan Prichard
ff5be78af6 Rename the "default inheritance" concept to "duplicate". 2015-10-25 20:36:01 -05:00
Ryan Prichard
0b2e0c20ee Document DETACHED_PROCESS behavior and add a test for it. 2015-10-25 20:30:21 -05:00
Ryan Prichard
45a38be9e4 Add a simple test for the CreateProcess NewConsole standard handle case.
Simplify checkModernConsoleHandleInit usage; it isn't necessary to build
a list of potential console handles.  We can just scan for them.
2015-10-25 19:50:57 -05:00
Ryan Prichard
7ad3f28f48 Rewording in console-handles.md. 2015-10-25 19:35:30 -05:00
Ryan Prichard
ae8a725170 Refactor Test_CreateProcess_UseStdHandles to better follow spec. 2015-10-25 19:15:46 -05:00
Ryan Prichard
4b76f1e3a7 Rework standard handle setting in CreateProcess documentation.
I don't *think* this changes the semantics at all.

Also, move the INVALID_HANDLE_VALUE thing into a note at the bottom.

Improve intra-document bug linking.
2015-10-25 18:56:22 -05:00
Ryan Prichard
955b5c61c3 Fix CreateProcess_UseStdHandles on Win8 and fix the spec.
* The NULL-to-new-handle conversion only happens when creating a new
   console, not when attaching to the parent's console.

 * Also, Windows reports that the handle value 0x7 is value, presumably
   because it ignores the lowest 2 bits.  It's better to just remove those
   values from this test.
2015-10-25 17:37:06 -05:00
Ryan Prichard
9260d0b54e If Test_CreateProcess_DefaultInherit fails, don't ASSERT-fail. 2015-10-25 16:56:45 -05:00
Ryan Prichard
f4a3bd1743 Fill out CreateProcess UseStdHandles testing.
There's just one test, and it iterates over these combinations:
 - CreationConsoleMode=NewConsole and CreationConsoleMode=Inherit
 - bInheritHandles=FALSE and bInheritHandles=TRUE

It takes several seconds to run, but that's OK.
2015-10-25 16:56:38 -05:00
Ryan Prichard
8ed8bac96b Add tests for CreateProcess UseStdHandles !InheritHandles 2015-10-25 14:14:28 -05:00