Commit Graph

327 Commits

Author SHA1 Message Date
Ryan Prichard
e19c29bd03 Avoid setting lpDesktop if there we didn't actually create a new desktop.
* Add debug information.

 * This change fixed a bug where the new winpty-agent.exe process
   successfully started, but immediately exited without reaching main().
   The bug occurred while SSH'ing into the Cygwin SSH server.
2015-09-29 02:32:57 -05:00
Ryan Prichard
d4640890cf Rewrite resize logic, introduce "direct mode", and tweak scroll scraping.
* Unfreeze the console while changing the buffer size.  Changing the
   buffer size hangs conhost.exe.  See:
    - https://github.com/rprichard/winpty/issues/31
    - https://wpdev.uservoice.com/forums/266908-command-prompt/suggestions/9941292-conhost-exe-hangs-in-win10-if-setconsolescreenbuff

 * Detect buffer size changes and switch to a "direct mode".  Direct mode
   makes no attempt to track incremental console changes.  Instead, the
   content of the current console window is printed.  This mode is
   intended for full-screen apps that resize the console.

 * Reopen CONOUT$, which detects apps that change the active screen buffer.
   Fixes https://github.com/rprichard/winpty/issues/34.

 * In the scroll scraping (scrollingScrapeOutput), consider a line changed
   if the new content is truncated relative to the content previously
   output.  Previously, we only compared against the line-buffer up to the
   current console width.  e.g.

   If this:
      |C:\Program|

   turns into:
      |C:\Prog|
      |ram    |

   we previously left |C:\Program| in the line-buffer for the first line
   and did not re-output the first line.

   We *should* reoutput the first line at this point so that, if the line
   scrolls upward, and the terminal is later expanded, we will have
   output an "Erase in Line" CSI command to clear the obscured "ram" text.

   We need to update the line-buffer for the sake of Windows 10 combined
   with terminals like xterm and putty.  On such a terminal, if the
   terminal later widened, Windows 10 will restore the console to the
   first state.  At that point, we need to reoutput the line, because
   xterm and putty do not save and restore truncated line content extending
   past the current terminal width.
2015-09-29 02:32:49 -05:00
Ryan Prichard
6c9c7bb985 Allow col and row to be specified to VeryLargeRead.cc and add server OSs 2015-09-26 00:13:31 -05:00
Ryan Prichard
9fc1b70fa4 Fix a character-handling defect in TestUtil.cc, startChildProcess
- Formatting a wchar_t* argument with %s does not work with MinGW's
   swprintf.  (Apparently it does with MSVC?  Sigh.)  AFAICT, %ls does
   the right thing with both MinGW and MSVC.  (I didn't test MSVC.)
2015-09-25 23:41:08 -05:00
Ryan Prichard
f4ef2a0d0b Document the largest allowed ReadConsoleOutputW call on various client OSs 2015-09-25 05:51:34 -05:00
Ryan Prichard
0907855b87 Make VeryLargeRead.cc work better on Windows XP.
Avoid zero-initializing the buffer to accommodate VMs that have
little RAM.  Use a smaller buffer size (9000x9000 ==> 324MB
buffer) that still demonstrates the read-size limit on XP.
2015-09-25 00:25:51 -07:00
Ryan Prichard
3a4a602ac8 Add a test case that performs a very large read. 2015-09-24 23:58:31 -07:00
Ryan Prichard
6121265f58 Refactor cursorPosition to use bufferInfo(). 2015-09-24 23:58:30 -07:00
Ryan Prichard
f605aaf4de Factor out a Win32Console::bufferInfo() function.
I don't know if this is necessary, but an atomic accessor function
returning buffer size and window position seems like it could be
convenient.
2015-09-24 23:58:29 -07:00
Ryan Prichard
6122f0d989 Expand on the Win10ResizeWhileFrozen comment. 2015-09-24 23:58:28 -07:00
Ryan Prichard
06a81be1fc Add a setCursorPos convenience function. 2015-09-24 23:58:26 -07:00
Ryan Prichard
fb95353703 Improve setSmallConsoleFontVista debug output 2015-09-24 05:43:40 -05:00
Ryan Prichard
bf34a4d8fa Rewrite Win32Console::setSmallFont for better Unicode compatibility.
Try to use a TrueType font rather than a raster font.  The strategy is:
 - [NEW] Try to use 6pt Consolas, then
 - [NEW] Try to use 6pt Lucida Console, then
 - Try to use the smallest font using SetCurrentConsoleFontEx, then
 - Try to use the smallest font using the undocumented SetConsoleFont
   XP API.

When a raster font is active, the console turns most/all non-ASCII
characters into '?' characters.  We need to select a TrueType font to
preserve these characters.
2015-09-24 05:09:40 -05:00
Ryan Prichard
bb5edfb2fd Add a test program that writes and reads a non-ASCII character. 2015-09-23 17:38:12 -05:00
Ryan Prichard
72557cb8c4 Read and write UTF-16, not Ascii. 2015-09-23 17:37:35 -05:00
Ryan Prichard
0f7a5656e3 Merge pull request #37 from dscho/fix-locale
Set the appropriate locale
2015-09-23 13:47:28 -05:00
Johannes Schindelin
ec385e8d1b Set the appropriate locale
By calling `setlocale(LC_ALL, "");`, we give the user a chance to
override the ASCII-only default so that non-ASCII arguments are
converted into UTF-16 properly, which is required to pass them
correctly to the actual Win32 executable.

This is necessary because POSIX dictates that we start up with the C
locale, ignoring all environment variables, until that `setlocale()`
call.

This fixes https://github.com/git-for-windows/git/issues/412

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2015-09-23 15:39:41 +00:00
Ryan Prichard
0c1e064172 Fix trivial_test
Apparently the non-w64 mingw32 does not have an swprintf function, though
it does have an snwprintf function.  In any case, the function takes a
second argument which is a buffer size.

Also include cwchar and cctype.

Print a message when building the test.
2015-08-23 23:13:20 -05:00
Ryan Prichard
6e696f8828 Allow winpty to function with a visible console.
* If a new window station can't be created, keep going anyway.  I *think*
   this is what IntelliJ's fork is doing.  Perhaps the window should be
   marked SW_HIDE in this case?

 * Rename WINPYDBG to WINPTY_DEBUG.

 * Add an environment variable WINPTY_SHOW_CONSOLE.  If non-empty, the
   console window is placed on the same window station and is visible.
   It's intended for testing purposes.
2015-08-23 23:13:20 -05:00
Ryan Prichard
6591f03d55 Include the sync marker counter in two debugging messages. 2015-08-23 23:13:20 -05:00
Ryan Prichard
947548215d When setting a sync marker, clear the lines containing the marker.
* This behavior is necessary for Windows 10 to ensure that line rewrapping
   does not corrupt the marker.
2015-08-23 23:13:20 -05:00
Ryan Prichard
ccd1406dd8 Add a test program demonstrating how to clear (part of) the console buffer. 2015-08-23 23:13:20 -05:00
Ryan Prichard
e123a4e7c8 Add a test program. 2015-08-23 16:02:23 -07:00
Ryan Prichard
95fe71a501 Add a few more experiments 2015-08-22 20:56:24 -07:00
Ryan Prichard
380828dee5 Add a test case demonstrating the Win10 hang on resize-during-selection 2015-08-21 14:45:50 -07:00
Ryan Prichard
9a9c148043 Remove trailing whitespace. 2014-09-17 14:57:03 -07:00
Ryan Prichard
1f95cce913 Change package name from gcc4-g++ to gcc-g++.
Thanks to shiek on GitHub for pointing this out.
2014-09-17 14:56:45 -07:00
Ryan Prichard
ce9f480e5c Remove trailing whitespace. 2014-09-17 14:55:28 -07:00
Ryan Prichard
d0e8764666 Work around what I think is a typo in a MinGW header.
Address the Cygwin part of GitHub issue 27.
2014-09-17 14:55:19 -07:00
Ryan Prichard
47a69d0d59 Merge pull request #26 from yol0/master
Fix configure for 64-bit Cygwin  and verified on recent Cygwin versions
2014-08-31 22:50:51 -07:00
Haoming Zhu
793ff925a2 Fix configure for 64-bit Cygwin. 2014-09-01 13:37:26 +08:00
Ryan Prichard
4e51f8ce17 Merge pull request #25 from cjfromthesea/patch-2
Include <algorithm> for std::min and std::max
2014-08-07 18:38:38 -07:00
Christian Howe
fd1e76de5d Include <algorithm> for std::min and std::max 2014-08-07 21:20:16 -04:00
Ryan Prichard
7b878ad2e8 Propagate the console title to the terminal. 2014-05-12 10:53:44 +01:00
Ryan Prichard
470fa4449a Merge pull request #15 from ustieber/patch-2-ConsoleMode
Add support for a non-terminal console mode
2013-12-07 15:10:32 -08:00
Uwe Stieber
c170d6167f Add support for a non-terminal console mode
If a process is running under control of winpty, the output of the process is decorated with ESC sequences to control a terminal to print the process output nicely. In some environments however, the client showing the output to the user is not a full terminal emulation, the Eclipse CDT debug console view in example, and the ESC sequences are printed as output additional to the real process output. This commit is adding an API function to switch into a mode where winpty is not decorating the process output with ESC sequences. The console mode is designated to pass on the process output to the client as is.
2013-12-06 15:32:23 +01:00
Ryan Prichard
bfc6336358 Merge pull request #14 from ustieber/patch-1-GetProcessId
Add API to access the process id of the started process
2013-09-24 04:39:36 -07:00
Uwe Stieber
6f1d6a5dbe Fixed indentation
Fixed indentation by replacing TABs by 4 spaces.
2013-09-24 13:37:00 +02:00
Uwe Stieber
d6498a63b8 Simplify patch by using GetProcessId
GetProcessId simplifies the code as it avoids to add the additional member variable 'm_childProcessId'. Cleaned up the indentation.
2013-09-24 13:11:48 +02:00
Uwe Stieber
03fbed5fc2 Add API to access the process id of the started process
Added new agent message "GetProcessId" and a API "winpty_get_process_id"
to allow access to the process id of the started process. The process id
is needed to integrate "winpty" with Eclipse CDT to launch native Windows
console applications inside the Eclipse UI.
2013-09-24 10:09:01 +02:00
Ryan Prichard
bd11b6581d Merge pull request #11 from sschuberth/master
Actually say which license this is (MIT)
2013-07-18 03:07:52 -07:00
Sebastian Schuberth
4f1ebbaba7 Actually say which license this is (MIT) 2013-07-18 10:22:22 +02:00
Ryan Prichard
878ceba45d Remove CRLF line endings from README.rst.
* None of the other text files in the repository have CRLF line endings.
2012-12-20 04:20:11 -08:00
Ryan Prichard
274086bbf5 In winpty-agent, print an error message if the arguments are invalid.
* Some users might think they could run winpty-agent.exe.

 * Right now, when I run winpty-agent.exe from a cmd.exe command prompt
   window, it looks like winpty-agent.exe is segfaulting.  It *ought* to
   print an assertion failed dialog box.
2012-12-20 04:20:10 -08:00
Ryan Prichard
91ccab1443 Add a gyp project that can build winpty-agent and libwinpty.dll with MSVC.
Peter Rekdal submitted the original version of this file.  I made some
minor changes.

Update the .gitignore file to ignore files generated by building winpty
with MSVC.
2012-12-20 04:20:09 -08:00
Ryan Prichard
d02cccb256 MSVC compatibility: Remove the {Agent,WinPty}DebugClient.cc hack.
* With this hack, it's impossible to add all the .cc files to an MSVC
   project, because MSVC understandably thinks that
   agent/AgentDebugClient.cc and shared/DebugClient.cc are two separate
   C++ translation units.  I could rename DebugClient.cc, but it's better
   to just fix the problem with the Makefile.
2012-12-20 04:07:57 -08:00
Ryan Prichard
41e7c31387 MSVC compatibility: Deal with snprintf and vsnprintf.
* When building with MSVC, there is no snprintf function, but there are
   _snprintf, vsnprintf, and _vsnprintf functions (as well as many
   variations on these).  The MSVC _snprintf is not the same as C99's
   snprintf, and in particular, it does not guarantee that the buffer is
   NUL-terminated, whereas C99 does guarantee this.  I want the C99
   behavior, so add a c99_[v]snprintf functions in shared/c99_snprintf.h
   that provide C99 behavior.

 * Details:
   http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010
2012-12-20 04:07:56 -08:00
Ryan Prichard
549472ec78 unix-adapter: Link statically with cyggcc_s-1.dll and cygstdc++-6.dll.
* At least for now, I'm shipping Cygwin/MSYS binaries.  On Cygwin (but
   not MSYS), the console.exe executable previously linked dynamically
   to cyggcc_s-1.dll and cygstdc++-6.dll.

   Linking dynamically with cygstdc++-6.dll seems risky for a binary
   not distributed by Cygwin, because G++'s Windows ABI is unstable, at
   least as of G++ 4.7, which turned on the __thiscall calling
   convention.  If a binary I ship ever comes into contact with a
   4.7-versioned cygstdc++-6.dll, then my binary will (very likely)
   segfault.

   So far, I've only observed this ABI incompatibility with MinGW,
   where a sufficiently upgraded MinGW configuration comes with a
   libstdc++-6.dll that is completely incompatible with every previous
   libstdc++-6.dll, so that every program built against the older
   libstdc++-6.dll segfaults immediately.  For now, Cygwin seems stuck
   at G++ 4.5, and my impression (possibly incorrect), is that G++'s
   Windows ABI was stable prior to 4.7.  I think G++'s Linux ABI is
   stable.  Presumably Cygwin will eventually update its compiler,
   though, so it makes sense to fix the problem early.

   I believe I originally chose to dynamically link the libraries
   because it was the default behavior, and I was afraid that a
   non-default option would break something.  It turns out that
   linking statically with cygstdc++-6 *does* break something -- it
   causes linker errors if the code uses std::cerr.  The workaround
   is not to use std::cerr.  This is not a problem for the
   unix-adapter, which already has to put up with MSYS' gimpy G++ 3.4
   compiler.
2012-12-20 04:07:55 -08:00
Ryan Prichard
bb42d17941 Copy the Unix environment to the Win32 environment in the unix-adapter.
This should fix issue 5.

The copying appeared to be necessary only for Cygwin, not for MSYS.  I'm
not sure why this is.  I added a call to cygwin_internal(CW_SYNC_WINENV)
for both anyway, because I didn't think it would hurt.
2012-07-29 00:35:24 +01:00
Ryan Prichard
9b09d3230f Merge pull request #4 from holtrop/master
added an "install" Makefile target
2012-07-13 00:41:04 -07:00