Setting IRM will cause characters to be inserted, discarding anything
that goes beyond the edge.
Turn off the wrap flag when the cursor moves.
SM/RM allow more than one parameter.
SGR parameters 90-97 are bright foreground (leaving bold unchanged) and
100-107 are bright background (leaving underline/blink unchanged);
`38;5;#` & `48;5;#` will work for the first 16 colors, setting both
foreground & bold or background & underline (0-7 bold/underline off,
8-15 bold/underline on).
Save/restore the attributes and G0 character set (the ANSI version still
only does the cursor).
Add the comment I missed when adding SCS; remove `DEC` from the sequence
descriptions.
Support setting (HTS & DECST8C) and clearing (TBC) tabs, overriding the
console's own tab processing. I've extended TBC with `\e[8g` to restore
console processing and added an extra parameter to DECST8C to set a
particular tab size.
DECSC (Save Cursor) & DECRC (Restore Cursor) are the same as their
ANSI.sys equivalents (`\e[s` & `\e[u`).
DA (Device Attributes) will respond with `\e[?62;1c` - VT220 with 132
columns.
Setting DECCOLM will size the buffer & window to 132 columns; resetting
will restore the original values (NOT set 80 columns). Setting DECNSCM
will prevent the display from being erased; however, the first time
DECCOLM is used will scroll in a new window, if appropriate.
Recognise the xterm ESC]4 & ESC]104 OSC commands to set/reset colors.
Three color specs are recognised: `#RGB`, `#RRGGBB` and `R,G,B`; in
addition, multiple specs can be given (separated by commas) to
automatically increase the index. I also allow `*` to query this index
and all subsequent ones. Reset will restore the colors from when the
DLL was first loaded, not from the Console Properties.
Since ESC is now preserved for unrecognised sequences, I feel able to
use it to escape control characters in order to display them (e.g.
"\e\e" will display a single escape).
Control mode would not display the recognised controls (i.e. BEL, SO and
SI) and would not work if it was turned off in the same string.
Normally the display uses the window height; adding an intermediate
character of `+` will use the buffer height. Report cursor position
will also output `+R` when used with `+n`.
There are some differences from the VT520: volume is ignored (although
silence is honored); duration is in 1/32 of a second up to and including
48 (1.5 seconds), after which it is in milliseconds (but still a maximum
of 8 seconds); notes are 1..25, anything else is frequency.
Windows 7 uses Beep for the bell, which means if you accidentally view
a binary file, the console freezes until all the bells have finished.
Windows 10 uses PlaySound, which avoids the freeze, but prevents the
sound being played at all if the program immediately exits (in its own
host). This uses PlaySound in its own thread, ignoring additional bells
whilst one is currently playing and waiting for it to finish before
terminating.
There are some instances when ESC should just be a normal character
(e.g. TCC uses it in aliases to clear the current line), so if no
sequence is recognised, pass the ESC through.
If console handles are created as GENERIC_WRITE, add GENERIC_READ in
order to be able to retrieve console information. This fixes#93
(redirecting to CON).
ANSICON switches the standard streams to Unicode, but uses its own
routine to write directly to the console when appropriate. However, the
newlines written by -e/-E/-t/-T were still done by the CRT, so when
output was redirected to CON, "\r\0\n\0" was being written.
In v1.70 I had saved the cursor position relative to the window, but
that means should the window scroll, the cursor would appear to be
restored to the wrong position. It will still be wrong should the
*buffer* be scrolled, but that can't really be helped (well, possibly
it could, but it would be more effort than it's worth).
Just copying the history from the source:
recognize the standard handle defines in WriteFile;
minor speed improvement by caching GetConsoleMode;
keep track of three handles (ostensibly stdout, stderr and a file);
test a DOS header exists before writing to e_oemid;
more flexible/robust handling of data directories;
files writing to the console will always succeed;
log: use API file functions and a custom printf;
add a blank line between processes;
set function name for MyWriteConsoleA;
scan imports from "kernel32" (without extension);
added dynamic environment variable CLICOLOR;
removed _hwrite (it's the same address as _lwrite);
join multibyte characters split across separate writes;
remove wcstok, avoiding potential interference with the host;
similarly, use a private heap instead of malloc.
Added support for CHT & CBT (move forward/backward by tabs), DECAWM (don't
wrap at EOL), CRM (display control characters, but still perform newline)
and REP (repeat last character, including BEL, BS, TAB, LF and CR).
It always bugged me that newline would add an unneeded blank line due to
wrap, but not enough to do anything about it. For some reason, adding CRM
got me to thinking about it, so I finally did it.
Stopped \e[K from erasing the first character of the next line.
Restore cursor visibility on unload.
Clear screen (\e[2J) will scroll in a new window the first time it's used,
or the window has scrolled, or the cursor is on the last line of the buffer.
Restore Cursor Position (\e[u) will recognise screen size changes and limit
itself to the new boundaries.
-p uses CreateRemoteThread, determining kernel32.dll & LLW dynamically.
Loading via LoadLibrary will remember the current attributes, restoring them on
unload.
Tweaked log output (remove quotes around CreateProcess command line; add an
underscore to 64-bit addresses).
ansicon.exe will really output (to the console) strings as Unicode.
Fixed ansicon.exe, if installed, restoring the default attributes, not current.
ansicon.exe will start with ANSICON_DEF (if defined and -m not used).
for ANSI-LLW.exe.
Set the code page so ansicon.exe can display some strings properly.
Expand wildcards for -t.
VC6 can now compile the 32-bit version; use it for the release binaries.
Improvements to the VC makefile.
Describe the sequences in a bit more detail.
Added environment variable ANSICON_EXC to specify modules that should not be
hooked. This should work around the nvd3d9wrap.dll issue. Since it helps to
know what the modules are, logging is now always available, controlled by -l
or ANSICON_LOG. A side-effect caused debugstr.c to move to util.c.
GUI programs are once again not hooked, unless run by "ansicon" directly or in
the ANSICON_GUI environment variable. Since not hooking still leaves ANSICON in
the environment, created ANSICON_VER as a dynamic-only variable, which can also
serve as a version check.
Due to an email requesting a reverse video option, realised I always take the
current attributes as default. This means if you turned on reverse and ran a
program, it would take the reverse as its default. Created ANSICON_DEF variable
to explicitly set the default attribute, using the current if it doesn't exist.
The reverse video option is done via a "negative" attribute (e.g. "-m-f0" is
reversed black on white, meaning you'll get white on black, with foreground
sequences changing the background). (The difference from "\e[7m" is that it
won't be reset on "\e[m".)
A child program will inherit the parent's modes (but not shift); the parent will
read the child's modes on exit (but not unload). The exception is "ansicon",
which will always start with the default modes and leave the parent unchanged.
Improved the AutoRun entry, only running "ansicon" if ANSICON_VER doesn't exist.
The "ansicon" command is always first.
Stopped -u implying -p; return the program's exit code; don't restore the
original color when just using -p; output error messages to stderr.