Commit Graph

378 Commits

Author SHA1 Message Date
Ryan Prichard
483aeffee6 Makefile: stop reading environ variables and avoid spawning processes
The variables can be specified on the make command-line instead, and the
user could have unrelated variables that happen to have the name winpty
is using.

I verified that MSYS2 is passing UNIX_ADAPTER_EXE and PREFIX on the
command-line.  ship/ship.py already passes PREFIX on the command-line.

Previously, for each object file, the Makefile spawned a subprocess for
each of: echo, mkdir, dirname, and git.  Most of these can be eliminated:

 - echo: The gmake function $(info ...) is mostly good enough -- it
   affects the --dry-run/-n output, which might be undesired.

 - mkdir: We only need to invoke mkdir once per directory.  It's tricky
   to get the optimal behavior, but it's possible to do better than before.

 - dirname: The gmake function $(dir ...) is good enough.

 - git: only needed once per build, to get the commit hash.
2016-02-26 04:21:22 -06:00
Ryan Prichard
97e1bd2661 Enable C++11 mode and re-enable C++ exception handling. 2016-02-26 01:20:31 -06:00
Ryan Prichard
ec3eae8df5 Remove support for the MinGW compiler packaged with Cygwin.
MinGW-w64 is still supported, as is the MinGW compiler distributed by
mingw.org.

Cygwin's MinGW toolchain uses the 4.0-1 mingw-runtime package by
default, which appears to correspond to the "WSL-4" 4.x version of the
MinGW project's mingwrt packages.  (The version numbers in the
/usr/i686-pc-mingw32/sys-root/mingw/include/_mingw.h file are also
consistent with this theory.)

The WSL-4 branch was repudiated by the MinGW project as a mistake [1].
The MinGW project claims no responsibility for Cygwin's MinGW packages
[2].  There were several releases in short succession [3]:
  4.0.3 2013-09-22
  4.0.2 2013-09-15
  4.0.1 2013-09-14
  4.0.0 2013-08-23
There have been no 4.x releases since then, though there have been more
3.x releases (3.21 and 3.21.1).  The FILE_FLAG_FIRST_PIPE_INSTANCE bug
that this project has worked around was fixed in 4.0.3 [4], which was
never propagated to the Cygwin package.

The MinGW packages were apparently orphaned on 2014-09-18 [5] and are
still orphaned [6].

The g++ compiler in this package is still 4.7.3 (released on 2013-04-11),
which is almost three three years old.  While writing the "GenRandom"
module, I hit a bug where a non-static data member initializer of
pointer-to-function-type segfaulted the compiler.  (gcc seemed to have
confused the field with a pure virtual method.)

[1] http://sourceforge.net/p/mingw/bugs/1673/#5260/41ec
[2] http://sourceforge.net/p/mingw/bugs/1673/#2556/35d4
[3] http://sourceforge.net/projects/mingw/files/MinGW/Base/mingwrt/
[4] http://sourceforge.net/p/mingw/bugs/2050/
[5] https://cygwin.com/ml/cygwin/2014-09/msg00289.html
[6] https://cygwin.com/cygwin-pkg-maint
2016-02-26 00:12:24 -06:00
Ryan Prichard
11b3bbf66e Link statically to the MSVC runtime library in configurations.gypi. 2016-02-26 00:12:23 -06:00
Ryan Prichard
6d589b7e14 Bump the version 2016-02-26 00:12:22 -06:00
Ryan Prichard
58fa5f19ae Update the LICENSE copyright year 2016-02-25 21:27:47 -06:00
Ryan Prichard
73ec93d638 Update release notes for 0.2.2. 2016-02-25 21:21:22 -06:00
Ryan Prichard
a4ba2420e7 Split out misc/{buffer-tests,console-handles.md} to a new repo
See https://github.com/rprichard/win32-console-docs
2016-02-24 20:44:58 -06:00
Ryan Prichard
e235706503 Rename font-notes: this file isn't really Markdown. 2016-02-24 19:54:09 -06:00
Ryan Prichard
30c6e9f7e0 Generate an import lib to accompany winpty.dll.
winpty.lib isn't needed for console.exe, but it could be useful to other
software embedding winpty.  MSVC needs it to link against winpty.dll.
2016-02-21 01:35:30 -06:00
Ryan Prichard
d72f4a44f8 Get many misc test programs compiling again after the src reorg 2016-01-15 03:08:10 -06:00
Ryan Prichard
42cac8d24d Add a new debugflag, "input_separated_bytes", for testing incomplete input 2016-01-14 17:30:25 -06:00
Ryan Prichard
48e01facf4 Don't generate mouse input records on an incomplete mouse escape sequence 2016-01-14 17:02:59 -06:00
Ryan Prichard
79c9859805 Add missing copyright notices to WinptyVersion.{cc,h} 2016-01-05 06:43:29 -06:00
Ryan Prichard
f64a108868 Replace ASSERT with assert in TimeMeasurement.h
libwinpty does not include the agent's ASSERT mechanism currently, and
I'm only using this class during development.
2016-01-05 06:43:28 -06:00
Ryan Prichard
992cfcb363 Remove a copy of OsModule from ConsoleFont
This exact same class exists in src/shared.  It only compiles because the
copy in ConsoleFont is in an anonymous namespace.
2016-01-05 06:43:27 -06:00
Ryan Prichard
9086097c5c Fix a typo: this constant should have been unsigned.
Should have no effect at runtime.
2016-01-04 19:09:51 -06:00
Ryan Prichard
8292a8ef4f Flush winpty-agent --show-input output
This is useful when winpty-agent is invoked from the Win32-OpenSSH server,
which uses a proper console for STDIN, but sockets(!) for STDOUT and
STDERR.  The C++ runtime uses block buffering on the socket output, so
flush explicitly.
2016-01-04 19:09:50 -06:00
Ryan Prichard
eebc10bf36 gyp file: Remove the ".lib" suffix from "-luser32.lib" and document.
gyp tolerates all of:

  'user32'
  'user32.lib'
  '-luser32'
  '-luser32.lib'

With the --format=make generator, the exact string value is passed to gcc,
which only accepts the '-luser32' syntax.  The MSVC generator is also
happy with this format, so that's what I'll use.

With this change, it's possible to use the gyp file to build the C++
components.  I'm not sure if that's useful, but why not?  The resulting
Makefile can be configured by passing settings like CXX and LDFLAGS on the
make command-line.

Also: document use of gyp a bit.
2016-01-03 17:29:09 -06:00
Ryan Prichard
b45220b00d Mark *.gypi as text 2015-12-29 18:40:08 -06:00
Ryan Prichard
2ae966521e gyp improvements:
* Add a src/configurations.gypi file that can be included on the gyp
   command-line to enable 32-bit and 64-bit builds in the generated project
   files.

 * Make winpty.gyp work if gyp is run with Cygwin python.  It still works
   with normal python.
2015-12-29 18:33:55 -06:00
Ryan Prichard
f5e8b4cd28 Fix a possible concurrency issue with CancelIo and winpty shutdown.
CancelIo requests that the I/O operation end, but the I/O operation may
still be going when the function returns.

https://blogs.msdn.microsoft.com/oldnewthing/20110202-00/?p=11613/
2015-12-28 21:57:12 -06:00
Ryan Prichard
0fb98c03fa Recompile everything if VERSION.txt changes
The contents of that file are included on the compiler command-line for
every file.
2015-12-28 21:57:11 -06:00
Ryan Prichard
1c3f54caf4 Bump the version 2015-12-28 21:57:10 -06:00
Ryan Prichard
6720daa07a Avoid a possible buffer overflow in winpty-debugserver.exe
Also: use fwrite directly instead of printf; maybe it's a bit faster.
2015-12-24 21:25:06 -06:00
Ryan Prichard
6c8b7effe5 Add a TimeMeasurement class useful for measuring the run-time of code 2015-12-21 00:43:26 -06:00
Ryan Prichard
12935a722b Minor code fixup:
* Explicitly call the Unicode versions of various APIs

 * Add const in a couple of places

 * Improve a few assert error messages

 * Either initialize BackgroundDesktop fully or leave all its fields NULL
2015-12-20 23:56:24 -06:00
Ryan Prichard
83b6e9281d 0.2.1 -- update VERSION and changelog 2015-12-20 00:02:45 -08:00
Ryan Prichard
2cc2480b38 For --mouse: start by disabling mode 1005.
AFAIK, this change doesn't affect any actual terminals, but in theory, it
could matter.
2015-12-19 23:58:13 -08:00
Ryan Prichard
75fe19ae96 Respect the console's Quick Edit mode -- it suppresses mouse events
* winpty-agent: Respect the ENABLE_QUICK_EDIT_MODE flag.  If it's set,
   then mouse events are not generated (because they're supposed to control
   selection).

 * winpty-agent: Because of the above, turn ENABLE_QUICK_EDIT_MODE off at
   startup.

 * winpty-agent --show-input: Enable ENABLE_WINDOW_INPUT so we can see
   buffer resize events.

 * winpty-agent --show-input: Disable ENABLE_QUICK_EDIT_MODE with
   --with-mouse.  When Quick Edit mode is enabled, the mouse controls
   selection and does not produce mouse events in the input queue.
2015-12-16 19:52:45 -06:00
Ryan Prichard
f7e5e1f69a Update the release notes 2015-12-16 06:30:58 -06:00
Ryan Prichard
63ed815319 Get build/trivial_test.exe building again. 2015-12-16 06:22:25 -06:00
Ryan Prichard
4e6f0c852f Update the release notes for mouse support 2015-12-16 06:22:25 -06:00
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