Commit Graph

390 Commits

Author SHA1 Message Date
Ryan Prichard
abf54bc454 Add a function for querying an NT handle's underlying object pointer. 2015-10-22 19:03:49 -05:00
Ryan Prichard
38cc0bf3fe Reorganize buffer-tests/Makefile and permit tests that aren't checked in 2015-10-22 19:00:00 -05:00
Ryan Prichard
e3a148ccf5 Add notes on CREATE_NO_WINDOW to console-handles.md. 2015-10-22 18:48:48 -05:00
Ryan Prichard
0264277bcd Move more things from tests into the test harness. 2015-10-22 18:39:33 -05:00
Ryan Prichard
fb7a19c4f1 Split TestCommon -> Remote{Worker,Handle} and add TestCommon.h uber-header
* TestCommon.h is a convenience header for the test cases.  It aliases
   Remote{Worker,Handle} back to {Worker,Handle}, and it includes many
   basic C/C++ headers, as well as the parts of the harness suitable for
   test cases.
2015-10-22 18:16:47 -05:00
Ryan Prichard
6c5a5aa670 Rename Worker.cc->WorkerProgram.cc and WorkerApi.h->Command.h
* Fix some of the rules in the Makefile to use build/% instead of %
2015-10-22 17:47:35 -05:00
Ryan Prichard
fdeb2e5cb5 Add a comment to TestHandleInheritance 2015-10-22 17:34:06 -05:00
Ryan Prichard
c3484b5355 First draft of console-handles.md. 2015-10-22 17:34:05 -05:00
Ryan Prichard
4a31202c9a Ignore GCC precompiled output 2015-10-22 17:32:45 -05:00
Ryan Prichard
55bea51430 Implement precompiled headers in misc/buffer-tests
* I'm still going to try to include what is used in each module.

 * At some point, I should implement these in the main project.  It will
   need more testing on the various compilers.  It really needs to be
   on-by-default everywhere.  If it's off, then at least pch.h should be
   included everywhere, to minimize configuration differences between my
   checkout and other people's checkouts.

 * There should be some way to configure it off to check whether includes
   are correct.

 * The change reduces build times from 27.6s to 15.2s on a single-core VM.
2015-10-22 03:18:47 -05:00
Ryan Prichard
2b7df627eb Expand the Test_AttachConsole_And_CreateProcess_Inheritance test a little 2015-10-22 03:18:46 -05:00
Ryan Prichard
a697017eb7 Allow Worker user to override CREATE_NEW_CONSOLE; reduce verbosity 2015-10-22 03:18:46 -05:00
Ryan Prichard
17f5f9e960 Rename getTitle to title, add consoleProcessList. 2015-10-21 23:11:37 -05:00
Ryan Prichard
3e4086cb39 Turn off -Wformat checking within buffer-tests so %I64x warnings stop 2015-10-21 23:10:56 -05:00
Ryan Prichard
1e164a8630 Update a comment about GetConsoleTitleW.
Also: Make the logic in Win32Console::title easier for me to follow.
2015-10-21 20:45:03 -05:00
Ryan Prichard
00ea69db7a Try to end line ending problems by marking text files in .gitattributes
* The files in the repo are natively LF.

 * These days, I'm using Cygwin git, which is creating a checkout full of
   LF files.

 * I think this .gitattributes file will instruct git to use the default
   line ending for almost all the files.  I'm forcing LF on shell scripts,
   because Cygwin/MSYS chokes on CRLF shell scripts.

 * For my Cygwin git checkouts, the default is LF.  I'll get a warning if
   I try to checkin an CRLF file, but that's OK.
2015-10-21 20:06:25 -05:00
Ryan Prichard
cb1341b0ef Add a test for GetConsoleTitleW 2015-10-21 19:56:12 -05:00
Ryan Prichard
6310ebb2c8 Move winpty_wcsnlen to shared 2015-10-21 19:56:11 -05:00
Ryan Prichard
3575c55c8c Expand console handle testing for XP through Windows 7.
* The tests are mostly wrong for Windows 8 and up.
2015-10-21 19:56:06 -05:00
Ryan Prichard
4230013a14 Move OsModule and ASSERT from the agent subdirectory into shared. 2015-10-21 19:55:30 -05:00
Ryan Prichard
3bf4703f6a Add tests of screen buffer handles. 2015-10-19 23:32:08 -05:00
Ryan Prichard
4d52166b8c Add OSVersion utility 2015-10-19 23:27:00 -05:00
Ryan Prichard
3b73576ab9 Consolidate console read API calls.
* Instead of reading the output line-by-line, figure out what lines we
   need ahead-of-time and issue as few read calls as possible.  On Windows
   8 and up, we issue just one read call.  On earlier versions, we avoid
   reading more than a certain amount.

 * This change reduces the CPU usage.  e.g. In my Windows 10 VM, the idle
   CPU usage of winpty-agent.exe+conhost.exe combined, with an empty
   console, dropped from ~3.6% to ~1.4%.  In a Windows 7 VM, I measured a
   reduction of CPU from ~1.6% to 0.6%.

 * Increase the MAX_CONSOLE_WIDTH from 500 to 2500.  The limiting factor
   now is that LargeConsoleRead reads at least one line at a line, but we
   don't want to read more than 2500 characters in one call on old operating
   systems.

 * Fix the attribute handling in scanForDirtyLines.  (The assignment to
   newAttr was dead.)

The 2500 limit is arbitrary and could probably be increased.  The actual
hard limit depends on the OS and is around 17000.  My understanding is that
the limit is based upon the need to allocate I/O buffers within a shared
64KiB heap, and I'm worried about heap fragmentation.  I know that 2500
is safe, because winpty has been issuing reads of almost 3000 characters
already to find the sync marker.

Fixes https://github.com/rprichard/winpty/issues/44
2015-10-16 15:26:45 -05:00
Ryan Prichard
195cf0aec5 Fix build issues with MSVC 2015 and add winpty-debugserver to the gyp file 2015-10-15 23:40:12 -05:00
Ryan Prichard
793957e17e Add more line-overwriting tests to color-test.sh. 2015-10-15 17:51:00 -05:00
Ryan Prichard
4fbda64b7e List "make install" files explicitly and use install tool
* Previously, "make tests install" would also copy trivial_test.exe and
   trivial_test.d to /usr/local/bin.

 * The `install` tool seems to be the conventional way of installing files.
   Setting permissions when copying to /usr/local/bin seems like a good
   idea.

 * Invoke install with -s to strip the symbol tables when they're
   installed.
2015-10-15 16:47:00 -05:00
Ryan Prichard
1ddff08321 Reuse the initial windowRect in scanForDirtyLines 2015-10-15 05:25:06 -05:00
Ryan Prichard
9cf13bd41c Use an enum for Agent::resetConsoleTracking and reuse the window rect 2015-10-15 05:18:19 -05:00
Ryan Prichard
8d90670fcc Use the proper built-in va_copy with MSVC 2013 and up. 2015-10-15 05:00:04 -05:00
Ryan Prichard
6ac6db2e51 Refactoring: improve syncMarkerText safety 2015-10-15 04:59:30 -05:00
Ryan Prichard
efb10c4fcf Use Erase-in-Line more carefully
Instead of erasing a whole line before writing a line, simply write the
line.  At the end of the line, issue a CSI 0K to erase from the cursor to
the end of the line.  The erasing serves two purposes:

 * It can clear characters beyond the right end of the terminal, which
   have been obscured by a terminal resize.

 * It sets the background color for the trailing whitespace.

Doing the erasing like so has two benefits:

 * It's more correct.  Previously, the trailing whitespace was colored
   arbitrarily.  Now, it is correctly colored to the last color on the
   line.

 * It should eliminate a lot of flicker.
2015-10-14 04:39:52 -05:00
Ryan Prichard
d4a5d0f5a0 Turn on -O2 when building the agent and libwinpty. 2015-10-14 04:12:19 -05:00
Ryan Prichard
fd8737d3f0 Behave somewhat more sensibly with UTF-16 surrogate pairs
* On output: detect them and transcode them properly into UTF-8.

 * On input: create input records for both halfs of the surrogate pair.

I tested by copying-and-pasting U+20000 (D840 DC00) into a mintty bash
shell.  It works, but the Windows console thinks the character occupies
four cells when it really occupies two, so the cursor position is wrong.
When I press backspace, it doesn't delete the whole character -- instead,
it replaces it with a '?', because it becomes an invalid surrogate pair.

Still, the behavior seems like an improvement.
2015-10-14 04:11:32 -05:00
Ryan Prichard
04d5c1051f Factor out outputSetColor and fixConsolePopupBoxArt functions. 2015-10-13 05:07:44 -05:00
Ryan Prichard
bde8922e08 Fix a C++11 issue: separate string literals and macros with a space. 2015-10-13 04:32:51 -05:00
Ryan Prichard
dd438a9505 Reset the SGR parameters before clearing the terminal on Terminal::reset. 2015-10-13 04:31:26 -05:00
Ryan Prichard
4338e7b687 Add a Bash script that tests terminal color handling 2015-10-13 04:09:44 -05:00
Ryan Prichard
a998bcf207 Rewrite the color translation heuristic.
* Use the Bold(1) SGR parameter in only one case -- White-on-Black.

 * Use the 0x9X and 0x10X SGR parameters to set intense/bright colors for
   both foreground and background.

Detailed changes:

 * DkGray background:
    - Previously, this background was handled identically to the Black
      background.
    - Now it is treated like the non-grayscale colors, and the
      foreground/background are set exactly.

 * Black background:
    - LtGray foreground is unchanged: default text colors
    - White foreground is unchanged: text is bolded
    - DkGray is fixed: instead of concealing the text, set the foreground
      to DkGray, falling back to LtGray.

 * LtGray background:
    - Previously, this background was handled exactly the same way as the
      White background.
    - Now it is treated like any other non-grayscale color.

 * White background:
    - Black foreground is unchanged: only an Invert is output.
    - LtGray: previously, the text was concealed.  Now it is handled like
      Black, and only an Invert is output.
    - DkGray: previously only Invert was output.  Now DkGray is also
      output.
    - White is effectively unchanged; it is still concealed if possible.

Also: set the console colors to LtGray-on-Black on startup.  The
heuristic makes little sense with other colors.

Fixes https://github.com/rprichard/winpty/issues/39
2015-10-13 02:12:59 -05:00
Ryan Prichard
9cf6972860 Fix the Console Popup line-art in Japanese and Korean locales. 2015-10-13 01:05:06 -05:00
Ryan Prichard
208d084c81 Convert UnicodeWideTest1.cc from CRLF to LF for consistency.
The repository probably should be configured somehow to ensure line ending
consistency, particularly across Cygwin and MSYS git.
2015-10-12 04:33:40 -05:00
Ryan Prichard
cce293dd40 Don't output the second CHAR_INFO of a full-width pair.
The second cell can still have a different color than the first cell, and
*maybe* we want to output it.  I'm unsure.  It could perhaps matter for a
character appearing at the end of a line, but it seems unlikely to matter
in practice.

Fixes https://github.com/rprichard/winpty/issues/41
2015-10-11 23:04:07 -05:00
Ryan Prichard
a66de7dc28 Add more tests of full-width characters and rename one of the tests.
* Fix the -std=c++11 narrowing warnings in TestUtil.cc.
2015-10-11 22:44:22 -05:00
Ryan Prichard
c3999b5043 Rewrite console font changing.
* Remove the old "Vista" code path in favor of two code paths:
    - setSmallFontVista: sets a TrueType font to match the code page
    - setSmallFontXP: uses SetConsoleFont to activate the smallest
      viable font in the console's font table

 * Selecting a CJK-specific TrueType font is important so that double-width
   characters occupy two cells in the console, which is important for
   maintaining consistency between the console and the Unix terminal.
   (Perfect consistency here might be impossible, but using the appropriate
   font improves things.)  winpty currently duplicates double-width
   characters, but that will be fixed soon.
2015-10-11 04:42:36 -05:00
Ryan Prichard
31ee484b29 Add notes on fonts, code pages, and East Asian character widths 2015-10-10 19:25:20 -05:00
Ryan Prichard
085aa0a9f0 s/UnicodeTest1/Utf16Echo/ and output arbitrary UTF-16 codepoints. 2015-10-10 15:04:48 -05:00
Ryan Prichard
1ef25fb6c6 Fix UnicodeTest1 to work with TrueType fonts 2015-10-10 04:31:58 -05:00
Ryan Prichard
2751488f18 Fix a build failure 2015-10-10 03:30:58 -05:00
Ryan Prichard
c3701e60d9 Automatically test all three common fonts 2015-10-10 02:29:47 -05:00
Ryan Prichard
f5b15bf274 Fix UnicodeDoubleWidthTest font name output. 2015-10-10 02:22:53 -05:00
Ryan Prichard
fe26bfda5f Create a test program to explore the U+30FC width problem w/Lucida Console 2015-10-10 02:14:31 -05:00