* 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
* 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.
* 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.
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.