| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Extend ANSI emulation to include:
ESC[38;2;R;G;Bm 24-bit foreground colour
ESC[48;2;R;G;Bm 24-bit background colour
ESC[38;5;Nm 8-bit foreground colour
ESC[48;5;Nm 8-bit background colour
The colours are selected from the 16 standard console colours.
This is unlikely to be aesthetically pleasing but at least it's
better than raw escape sequences.
Also, add ESC[9m (strike through) as a known but unsupported
sequence.
|
|
|
|
|
|
|
|
|
| |
Change the default 'skip ANSI emulation' setting which is used when
the environment variable BB_SKIP_ANSI_EMULATION is unset. Previously
it was 0 (always emulate) now it's 2 (detect whether or not the
terminal supports ANSI escape sequences and behave accordingly).
The default value is also now a build-time option.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Perform code page translation for fputc(3). It's only used in a
few places but is needed to fix things like:
$ echo € | dos2unix
Ç
$ paste -d € file1 file2
1Ç2
Unfortunately it breaks the inventive use of dos2unix in GitHub
issue #203.
|
|
|
|
| |
Modern versions of MinGW-w64 define more console modes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Change the meaning of the BB_SKIP_ANSI_EMULATION variable:
- if it isn't set or if it has any value other than 1 or 2, use
ANSI emulation;
- if it's set to 1, always emit ANSI escape codes;
- if it's set to 2, attempt to enable virtual terminal processing in
the current console. If that works emit ANSI escape codes, if not
revert to ANSI emulation.
On all platforms I've tested (Windows 10, Windows 8.1, ReactOS 0.4.13,
plus ConEmu) BB_SKIP_ANSI_EMULATION=2 does the right thing.
|
|
|
|
|
| |
Update the skip status on the first call to skip_ansi_emulation()
and whenever the BB_SKIP_ANSI_EMULATION variable changes.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Closing 'vi' in Windows 7 resulted in the console window failing to
echo any output correctly until the 'reset' builtin was run. This
didn't happen in Windows XP, 8 or 10.
The problem is fixed by only duplicating the console handle when switching
*to* the alternate screen buffer.
Add sanity checks so that switching to the alternate buffer requires
the cached handled to be invalid, while it must be valid when switching
from the alternate buffer.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rework the ANSI emulation code to reduce its size.
- Fetch console attributes when required rather than caching them.
The init() function is no longer required; the only remaining
initialisation is now performed in is_console().
- Turning off inverse video (ESC[27m) didn't work properly. This has
been improved though it still doesn't work in some unlikely cases
(ESC[7;27m).
These changes save 180 bytes.
|
|
|
|
|
|
|
|
|
| |
As reported in GitHub issue #178 the last colour set by the ls command
is retained in the console.
This is due to the previous commit reinitialising the stored attributes
more frequently than it should. Attriubutes should only be initialised
once.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
As reported in GitHub issue #177, ANSI escape sequences don't work
reliably after shell redirection.
The problem appears to be due to a change in the behaviour of dup2()
in Windows 10 release 1809. The escape handling code kept a copy of
the console handle for internal use. Prior to Windows 10 release 1809
this worked; since then unwinding shell redirections results in the actual
console handle changing from time to time for reasons that are unknowable
without access to the source code.
Fix this by always fetching the console handle instead of caching it.
|
|
|
|
|
|
|
| |
Implement the "ESC[?1049h" and "ESC[?1049l" ANSI escape sequences
to switch between the alternate and normal screen buffers.
This allows vi to restore the original screen contents on exit.
|
|
|
|
| |
Add a common function to clear a section of the screen buffer.
|
|
|
|
|
|
|
|
|
| |
Use INVALID_HANDLE_VALUE (not NULL) to indicate that the console and
console_in handles haven't been initialised.
Replace many explicit comparisons against INVALID_HANDLE_VALUE with
tests on the return value of GetConsoleScreenBufferInfo() which
fails for an invalid handle.
|
|
|
|
|
|
|
|
| |
Commit 399b1dd64 (winansi: support escape sequence to set window
title) failed to handle some invalid escape sequences correctly.
Make the code more robust.
Fixes GitHub issue #153.
|
|
|
|
|
|
|
|
| |
To set the window title from the command line:
echo -en '\e]0;Hello World\007'
The same sequence can be used in the shell's prompt (PS1).
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The euro currency symbol was added to some OEM code pages. See:
https://www.aivosto.com/articles/charsets-codepages-dos.html
Add a configuration option (enabled by default) to support this.
When enabled:
- The read_key() function requests wide character key events. This
allows the euro symbol to be entered regardless of the console OEM
code page, though it needs to be available in the ANSI code page.
- Conversions between OEM and ANSI code pages in winansi.c are
modified to work around a bug in the Microsoft routines.
- If the OEM code page is 850 when BusyBox starts it's changed to
858. This is the only currently supported OEM code page.
Also, the shell read builtin is modified to use read_key() whenever
input is being taken from the console.
|
|
|
|
|
| |
The Microsoft C runtime may include a defective version of vsnprintf.
Implement a standards-compliant replacement.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The code to check whether a write error is due to a broken pipe
can now either:
- return with error EPIPE;
- cause the process to exit with code 128+SIGPIPE.
The default is the latter but the behaviour can be changed by issuing
signal(SIGPIPE, SIG_IGN) and signal(SIGPIPE, SIG_DFL) calls.
No actual signal is involved so kill can't send SIGPIPE and handlers
other than SIG_IGN and SIG_DFL aren't supported.
This does, however, avoid unsightly 'broken pipe' errors from commands
like the example in GitHub issue #99:
dd if=/dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
|
|
|
|
|
|
|
|
| |
- move winansi_get_terminal_width_height from winansi.c to ioctl.c,
the only caller;
- check both stdout and stderr for a connection to a console;
- omit unnecessary code in get_terminal_width_height (because the
WIN32 implementation ignores the file descriptor).
|
|
|
|
|
| |
Don't treat input and output file descriptors differently: if we
aren't connected to a console GetConsoleMode will fail for either.
|
|
|
|
|
|
|
| |
write(2) is commonly used in applets like cat and tr so we should
check for broken pipes there too.
See issue #99.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Microsoft Windows doesn't support SIGPIPE and its support for the
EPIPE error is somewhat inadequate. Most of the time a broken pipe
leads to an EINVAL error which is misleading:
$ yes hello | head -1
hello
yes: Invalid argument
Add a function to test for the underlying Windows error that indicates
a broken pipe and set errno to EPIPE. Call this function in a few
strategic places.
|
|
|
|
|
|
|
| |
Rewrite winansi_puts using winansi_fputs and putchar. There's no
need to use winansi_putchar.
Improve error return values from winansi_fputs and winansi_fwrite.
|
|
|
|
| |
Also tighten up the code slightly.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently /dev/zero is handled as a special case in dd. Add hacks
to the open and read functions in mingw.c to handle the zero and
urandom devices.
- Opening /dev/zero or /dev/urandom actually opens the special
Windows file 'nul' which behaves like /dev/null. This allows
manipulation of the file descriptor with things like seek and
close
- When /dev/zero or /dev/urandom is opened the resulting file
descriptor is stored and used to override the behaviour of read.
- No attempt is made to track duplicated file descriptors, so using
these devices for redirections in the shell isn't going to work
and won't be permitted. (Could be, but won't.)
- Limited control of the special file descriptors is provided by
allowing the internal variables to be changed.
- The numbers from /dev/urandom aren't very random.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
On Windows, isatty(fd) determines whether the file descriptor refers to
a character device.
The thing is: even NUL or a printer is a character device. BusyBox
thinks, however, that isatty() only returns non-zero for an interactive
terminal.
So let's shadow isatty() by a version that answers the question BusyBox
wants to have answered.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Ron Yorston <rmy@pobox.com>
|
|
|
|
|
| |
vfprintf is used in ash_vmsg. It should be passed through the
codepage conversion in winansi.c.
|
|
|
|
|
| |
If the environment variable BB_SKIP_ANSI_EMULATION is set (the value
doesn't matter) escape sequences are passed through to the terminal.
|
| |
|
|
|
|
|
|
|
| |
vsnprintf can return -1. I've seen it do this when writing to a small
buffer while vsnprintf(NULL, 0, ...) returns a valid length. I'd prefer
not to rely on the latter working with arbitrary old Windows runtimes
so just skip ANSI emulation if -1 is returned.
|
|
|
|
|
|
|
|
|
|
|
|
| |
Recent changes to make the Windows console behave more like a *nix
terminal didn't work too well for vi/less. On *nix the terminal
buffer can't be scrolled while such screen-based applications are
running. In the Windows console this remained possible and led to
confusion.
Add a new routine to allow vi/less to revert to their previous
behaviour where the cursor is positioned at the top of the buffer
and the entire buffer is cleared.
|
|
|
|
|
|
| |
When a normal *nix terminal has been scrolled back through its
buffer, any keypress will return to the cursor position. Add code
to lineedit.c to do the same for the Windows console.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Various tasks on the shell command line (e.g. backspace, DEL,
reverse search) were found to be slow when the console screen
buffer was very large. This was because the entire buffer was
being cleared in erase_till_end_of_screen().
Rewrite erase_till_end_of_screen() to only clear to the end of the
visible screen and to be tidier. (Based on a suggestion by GitHub
user avih.)
Also, modify move_cursor to use coordinates relative to the current
display (as ANSI escapes expect) rather than relative to the screen
buffer.
|
|
|
|
|
|
|
|
|
|
| |
It seems that the cursor positioning escape sequence 'ESC[n;mH'
allows n and m values of 0 or 1 to represent the leftmost/topmost
position. Allow for this and also fix handling of missing values.
When the screen is cleared using FillConsoleOutputCharacterA it's
also necessary to make explicit calls to FillConsoleOutputAttribute
to reset attributes.
|
| |
|
|
|
|
|
| |
These escape sequences are required for proper handling of line
editing when the input exceeds the console width.
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Windows console applications use different codepages for console I/O
and the rest of the API:
http://msdn.microsoft.com/en-us/goglobal/bb688114.aspx#E2F
Attempt to workaround this by converting characters when they're read from
and written to the console. Not all possible paths are handled.
|
| |
|
| |
|
| |
|
| |
|