aboutsummaryrefslogtreecommitdiff
path: root/win32/winansi.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* win32: improvements to get_terminal_width_heightRon Yorston2018-04-031-17/+0
| | | | | | | | - 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).
* win32: simplify isatty replacementRon Yorston2018-04-031-5/+1
| | | | | Don't treat input and output file descriptors differently: if we aren't connected to a console GetConsoleMode will fail for either.
* winansi: check for broken pipe in winansi_writeRon Yorston2018-03-091-7/+21
| | | | | | | write(2) is commonly used in applets like cat and tr so we should check for broken pipes there too. See issue #99.
* winansi: check for broken pipeRon Yorston2018-03-061-6/+29
| | | | | | | | | | | | | | 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.
* winansi: changes to puts, fputs and fwriteRon Yorston2018-03-061-18/+3
| | | | | | | 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.
* winansi: improve error return values in ANSI emulationRon Yorston2018-03-061-20/+23
| | | | Also tighten up the code slightly.
* winansi: create and use functions to test for consoleRon Yorston2018-03-061-51/+20
|
* win32: handle /dev/zero and /dev/urandom in open and read functionsRon Yorston2018-02-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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.
* mingw: accommodate for BusyBox' assumptions about isatty()Johannes Schindelin2017-08-241-0/+27
| | | | | | | | | | | | | | | 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>
* Provide vfprintf replacementRon Yorston2017-02-071-0/+1
| | | | | vfprintf is used in ash_vmsg. It should be passed through the codepage conversion in winansi.c.
* win32: allow ANSI emulation to be disabledRon Yorston2016-11-101-2/+15
| | | | | If the environment variable BB_SKIP_ANSI_EMULATION is set (the value doesn't matter) escape sequences are passed through to the terminal.
* win32: don't attempt ANSI emulation on data containing NUL charactersRon Yorston2016-08-161-4/+11
|
* win32: allow for vsnprintf returning -1Ron Yorston2016-07-081-1/+6
| | | | | | | 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.
* winansi: revert to previous console behaviour for vi/lessRon Yorston2016-04-261-0/+18
| | | | | | | | | | | | 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.
* lineedit: move console viewport to cursor on keypressRon Yorston2016-04-261-1/+1
| | | | | | 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.
* winansi: speed up clearing of screenRon Yorston2016-04-261-15/+10
| | | | | | | | | | | | | | | 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.
* winansi: fixes to cursor positioning, screen clearingRon Yorston2015-07-171-4/+15
| | | | | | | | | | 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.
* Implement escape sequence for cursor downRon Yorston2014-04-091-21/+12
|
* Implement ANSI escape sequences for cursor up/forwardRon Yorston2014-04-071-0/+30
| | | | | These escape sequences are required for proper handling of line editing when the input exceeds the console width.
* Implement vprintf replacementRon Yorston2014-03-201-1/+2
|
* Implement getc replacementRon Yorston2014-03-201-0/+24
|
* Implement read replacement to handle OEM codepagesRon Yorston2014-03-201-0/+26
|
* Fixes to write replacementRon Yorston2014-03-201-2/+2
|
* Implement write replacement to handle OEM codepagesRon Yorston2014-03-201-1/+75
|
* Implement puts replacement to handle OEM codepagesRon Yorston2014-03-191-4/+24
|
* Use OEM codepage for console I/ORon Yorston2014-03-191-4/+80
| | | | | | | | | | 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.
* winansi: skip DECTCEM sequence to avoid ugliness in viRon Yorston2012-10-101-0/+7
|
* win32: implement ioctlRon Yorston2012-04-231-1/+1
|
* Add code to find console dimensions in WIN32Ron Yorston2012-02-201-0/+17
|
* Fix off-by-one error in cursor positioningRon Yorston2012-02-171-1/+1
|
* Fix crash in Windows 7 ANSI emulationRon Yorston2012-02-071-2/+3
|
* Work around a regression in Windows 7, causing erase_in_line() to crash ↵Johannes Schindelin2012-02-071-1/+2
| | | | | | | | | | | | | sometimes The function FillConsoleOutputCharacterA() was pretty content in XP to take a NULL pointer if we did not want to store the number of written columns. In Windows 7, it crashes, but only when called from within Git Bash, not from within cmd.exe. Go figure. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* win32: winansi: implement \033[%u;%uHNguyễn Thái Ngọc Duy2010-09-141-0/+7
|
* win32: winansi: implement \033[H (no param)Nguyễn Thái Ngọc Duy2010-09-141-0/+16
|
* win32: winansi: implement \033[%uDNguyễn Thái Ngọc Duy2010-09-141-0/+15
|
* win32: winansi: implement \033[JNguyễn Thái Ngọc Duy2010-09-141-0/+21
|
* win32: Support certain ANSI sequences on cmd.exeNguyễn Thái Ngọc Duy2010-09-101-0/+358
Support sequences are mostly color ones. This was extracted from commit e56b799d6ad8afba4168fffa7218d44c041a72d2 in Git repository. Changes from original version: > diff --git a/home/pclouds/w/git/compat/winansi.c b/tmp/winansi2.c > index 44dc293..e2e7010 100644 > --- a/home/pclouds/w/git/compat/winansi.c > +++ b/tmp/winansi2.c > @@ -2,8 +2,9 @@ > * Copyright 2008 Peter Harris <git@peter.is-a-geek.org> > */ > > +#include "libbb.h" > #include <windows.h> > -#include "../git-compat-util.h" > +#undef PACKED > > /* > Functions to be wrapped: