Commit Graph

395 Commits

Author SHA1 Message Date
Ryan Prichard
09735e220a Add a --mouse argument to unix-adapter that enables terminal mouse input.
Fixes https://github.com/rprichard/winpty/issues/57
2015-12-16 06:22:25 -06:00
Ryan Prichard
48ddc93ed9 Recognize terminal mouse input and generate MOUSE_EVENT records.
Tracked by https://github.com/rprichard/winpty/issues/57
2015-12-16 06:22:25 -06:00
Ryan Prichard
d4b4cb6bcc Expand the agent's input dumping; change --showkey to --show-input
Details:

 * Rename --showkey to --show-input and dump everything *except* mouse
   input.

 * Add a mode, --show-input --with-mouse, that also dumps the mouse
   input.
2015-12-16 06:22:25 -06:00
Ryan Prichard
c857ae1dea Add mouse input mode tracking in the agent. 2015-12-16 06:22:25 -06:00
Ryan Prichard
05a01ab4b5 Add mouse input notes 2015-12-16 06:22:25 -06:00
Ryan Prichard
08e86e2f3e Work around a bug in MSYS's select call.
Now that the InputHandler thread blocks with select, in addition to the
main thread that also blocks with select, winpty has hit a bug in the
original MSYS where select returns EAGAIN.  select is not supposed to fail
with that error (EAGAIN doesn't make much sense as a select error).  Add
a workaround just for the original MSYS.
2015-12-16 06:22:25 -06:00
Ryan Prichard
e4d9295cba Use the appropriate MSYS1-vs-MSYS2-specific g++ compiler 2015-12-16 06:22:25 -06:00
Ryan Prichard
230ae4fdf9 unix-adapter: Accommodate partial write calls, if it happens somehow.
Maybe this can happen?  I don't know.
2015-12-16 06:22:25 -06:00
Ryan Prichard
80f0e87dc1 unix-adapter: Shut down gracefully; refactor a lot of code.
Explicitly shut down the I/O handling threads before restoring the terminal
state.  Start calling winpty_close.

This change doesn't fix any bug, AFAIK.  It's nice to test/demonstrate the
use of winpty_close.

The InputHandler now uses select to wait on both the blocking stdin tty and
a wakeup fd.  This is the same behavior I saw in OpenSSH.  OpenSSH sets
its select FDs to O_NONBLOCK *except* FDs for which isatty returns true.
It puts tty FDs into raw mode, but it does not set VMIN/VTIME to 0/0, so
the terminal driver blocks.  (In any case, I tested the 0/0 values, and
IIRC they prevented blocking only with a Cygwin emulated pty -- console FDs
in Cygwin blocked; as did both consoles and emulated ptys in the original,
old MSYS.  O_NONBLOCK prevented blocking in all cases, though.)
2015-12-16 06:22:25 -06:00
Ryan Prichard
966328214d Reject unrecognized options in the unix-adapter 2015-12-16 06:22:25 -06:00
Ryan Prichard
2ca31b4de0 Refactor: rename lastWriteTick field to m_lastWriteTick 2015-12-16 06:22:25 -06:00
Ryan Prichard
3ad4dc4530 Clarification about the wow64dup bug 2015-12-15 21:01:49 -06:00
Ryan Prichard
c2ffc0c4a6 Fix a typo: There is no Windows 7 SP2; I actually tested Windows 7 SP1. 2015-12-15 19:55:25 -06:00
Ryan Prichard
48b0ec1425 Fix a typo: There is no Windows 7 SP2; I actually tested Windows 7 SP1. 2015-12-15 19:46:29 -06:00
Ryan Prichard
7814da4dd3 Miscellaneous edits to console-handles.md. 2015-12-15 19:14:10 -06:00
Ryan Prichard
6f2a481b6b Add a table of contents to console-handles.md. 2015-12-15 18:54:01 -06:00
Ryan Prichard
876836b824 Add a missing stdio.h include.
The code happened to compile without this include on Cygwin and MSYS2,
the original MSYS/MinGW toolchain rejects it.
2015-12-14 19:05:13 -06:00
Ryan Prichard
fa84d20933 Update the release notes 2015-12-03 23:41:11 -06:00
Ryan Prichard
439759af40 Mask bytes to 0-255 for unix-adapter --showkey 2015-12-03 23:28:45 -06:00
Ryan Prichard
d4bd76ff47 Replace VK_NUMPAD5 with VK_CLEAR.
Windows uses VK_NUMPAD5 when typing '5', which only happens with NumLock
on.  With NumLock off, the button sends VK_CLEAR.
2015-12-03 23:28:23 -06:00
Ryan Prichard
da6bf1f159 Add "application numpad" escape sequences.
Terminals output these codes under various circumstances:
 * rxvt-unicode: numpad, hold down SHIFT
 * rxvt: numpad, by default
 * xterm: numpad, after enabling app-mode using DECPAM (`ESC =`).  xterm
   generates `ESC O <mod> <letter>` for modified numpad presses,
   necessitating kBareMod.
 * mintty: by combining Ctrl with various keys such as '1' or ','.
   Handling those keys is difficult, because mintty is generating the
   same sequence for Ctrl-1 and Ctrl-NumPadEnd -- should the virtualKey
   be '1' or VK_HOME?
2015-12-03 22:51:17 -06:00
Ryan Prichard
f1e3b092ba Add a --showkey option to winpty-agent.
The intent is to make it easier to determine how Windows creates KEY_EVENT
records.  The code lives in winpty-agent because (1) it's very small, and
(2) I can't test all the interesting keyboards/locales/etc, so if
someone hits a bug, placing it in winpty-agent.exe ensures that they'll
have access to the tools needed to debug it.
2015-12-03 22:48:43 -06:00
Ryan Prichard
850eb9ff3f Micro-optimize the InputMap class a little.
* Cuts the DefaultInputMap setup time.  It was about a millisecond; now
   it's about a quarter of a millisecond.
2015-12-02 23:08:00 -06:00
Ryan Prichard
6795a6ee49 Add WINPTY_DEBUG=dump_input_map for dumping the InputMap. 2015-12-02 01:42:53 -06:00
Ryan Prichard
cf4a99e63b Stop relying on NUL string termination in the InputMap.
* I don't anticipate caring about this, but in principle, there's nothing
   wrong with a NUL character in the input map, so fix this while the code
   is fresh in my mind.
2015-12-02 01:07:28 -06:00
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