Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit 5bff94b

Browse files
committed
win32: Win32 has no <termios.h>
1 parent ef49b0a commit 5bff94b

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

termkey-internal.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
#ifndef GUARD_TERMKEY_INTERNAL_H_
22
#define GUARD_TERMKEY_INTERNAL_H_
33

4+
//#define HAVE_TERMIOS
5+
6+
#ifdef _WIN32
7+
# undef HAVE_TERMIOS
8+
#endif
9+
410
#include "termkey.h"
511

612
#include <stdint.h>
7-
#include <termios.h>
13+
#ifdef HAVE_TERMIOS
14+
# include <termios.h>
15+
#endif
816

917
#ifdef _MSC_VER
1018
#include <BaseTsd.h>
@@ -46,8 +54,10 @@ struct TermKey {
4654
size_t hightide; /* Position beyond buffstart at which peekkey() should next start
4755
* normally 0, but see also termkey_interpret_csi */
4856

57+
#ifdef HAVE_TERMIOS
4958
struct termios restore_termios;
5059
char restore_termios_valid;
60+
#endif
5161

5262
TermKey_Terminfo_Getstr_Hook *ti_getstr_hook;
5363
void *ti_getstr_hook_data;

termkey.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ static TermKey *termkey_alloc(void)
285285
tk->buffsize = 256; /* bytes */
286286
tk->hightide = 0;
287287

288+
#ifdef HAVE_TERMIOS
288289
tk->restore_termios_valid = 0;
290+
#endif
289291

290292
tk->ti_getstr_hook = NULL;
291293
tk->ti_getstr_hook_data = NULL;
@@ -486,6 +488,7 @@ int termkey_start(TermKey *tk)
486488
if(tk->is_started)
487489
return 1;
488490

491+
#ifdef HAVE_TERMIOS
489492
if(tk->fd != -1 && !(tk->flags & TERMKEY_FLAG_NOTERMIOS)) {
490493
struct termios termios;
491494
if(tcgetattr(tk->fd, &termios) == 0) {
@@ -520,6 +523,7 @@ int termkey_start(TermKey *tk)
520523
tcsetattr(tk->fd, TCSANOW, &termios);
521524
}
522525
}
526+
#endif
523527

524528
struct TermKeyDriverNode *p;
525529
for(p = tk->drivers; p; p = p->next)
@@ -545,8 +549,10 @@ int termkey_stop(TermKey *tk)
545549
if(p->driver->stop_driver)
546550
(*p->driver->stop_driver)(tk, p->info);
547551

552+
#ifdef HAVE_TERMIOS
548553
if(tk->restore_termios_valid)
549554
tcsetattr(tk->fd, TCSANOW, &tk->restore_termios);
555+
#endif
550556

551557
tk->is_started = 0;
552558

0 commit comments

Comments
 (0)