1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-06-13 17:46:15 +02:00
git/compat
Johannes Schindelin a5e46e6b01 terminal: add a new function to read a single keystroke
Typically, input on the command-line is line-based. It is actually not
really easy to get single characters (or better put: keystrokes).

We provide two implementations here:

- One that handles `/dev/tty` based systems as well as native Windows.
  The former uses the `tcsetattr()` function to put the terminal into
  "raw mode", which allows us to read individual keystrokes, one by one.
  The latter uses `stty.exe` to do the same, falling back to direct
  Win32 Console access.

  Thanks to the refactoring leading up to this commit, this is a single
  function, with the platform-specific details hidden away in
  conditionally-compiled code blocks.

- A fall-back which simply punts and reads back an entire line.

Note that the function writes the keystroke into an `strbuf` rather than
a `char`, in preparation for reading Escape sequences (e.g. when the
user hit an arrow key). This is also required for UTF-8 sequences in
case the keystroke corresponds to a non-ASCII letter.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2020-01-15 12:06:17 -08:00
..
nedmalloc nedmalloc: avoid compiler warning about unused value 2019-08-07 11:54:55 -07:00
poll Merge branch 'js/mingw-use-utf8' 2019-07-11 15:16:49 -07:00
regex compat/regex/regcomp.c: define intptr_t and uintptr_t on NonStop 2019-01-03 14:16:20 -08:00
vcbuild msvc: handle DEVELOPER=1 2019-10-06 09:07:44 +09:00
win32 Merge branch 'dl/compat-cleanup' 2019-10-18 11:40:47 +09:00
access.c git-compat-util: work around for access(X_OK) under root 2019-04-25 17:49:44 +09:00
apple-common-crypto.h
basename.c
bswap.h compat/bswap: add include header guards 2019-03-07 07:42:14 +09:00
fileno.c git-compat-util: work around for access(X_OK) under root 2019-04-25 17:49:44 +09:00
fopen.c
gmtime.c
hstrerror.c
inet_ntop.c
inet_pton.c
memmem.c
mingw.c Merge branch 'js/mingw-needs-hiding-fix' 2019-10-30 15:13:13 +09:00
mingw.h compat/*.[ch]: remove extern from function declarations using spatch 2019-09-05 11:05:45 -07:00
mkdir.c
mkdtemp.c
mmap.c compat: make sure git_mmap is not expected to write 2018-10-25 18:51:03 +09:00
msvc.c
msvc.h msvc: add pragmas for common warnings 2019-06-25 10:46:57 -07:00
obstack.c compat/obstack: fix -Wcast-function-type warnings 2019-01-17 11:13:38 -08:00
obstack.h obstack: fix compiler warning 2019-06-20 14:03:05 -07:00
pread.c
precompose_utf8.c Support working-tree-encoding "UTF-16LE-BOM" 2019-01-31 10:27:52 -08:00
precompose_utf8.h compat/precompose_utf8.h: use more common include guard style 2018-08-15 11:52:09 -07:00
qsort_s.c
setenv.c
sha1-chunked.c
sha1-chunked.h
snprintf.c
stat.c
strcasestr.c
strdup.c
strlcpy.c
strtoimax.c
strtoumax.c
terminal.c terminal: add a new function to read a single keystroke 2020-01-15 12:06:17 -08:00
terminal.h terminal: add a new function to read a single keystroke 2020-01-15 12:06:17 -08:00
unsetenv.c
win32.h
win32mmap.c
winansi.c winansi: use FLEX_ARRAY to avoid compiler warning 2019-10-06 09:07:44 +09:00