mirror of
https://github.com/troglobit/libite.git
synced 2026-12-04 21:48:22 +00:00
conio.h: Minor refactor, cleanup
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
6904f6e0fe
commit
5b2eee6aff
1 file changed
+6
-9
@@ -49,7 +49,7 @@
|
|||||||
#define WHITE 0x17
|
#define WHITE 0x17
|
||||||
|
|
||||||
#ifndef SCREEN_WIDTH
|
#ifndef SCREEN_WIDTH
|
||||||
#define SCREEN_WIDTH 80 /* Override as #define SCREEN_WIDTH tty_width() */
|
#define SCREEN_WIDTH 80 /* Override using, e.g. #define SCREEN_WIDTH tty_width() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Esc[2JEsc[1;1H - Clear screen and move cursor to 1,1 (upper left) pos. */
|
/* Esc[2JEsc[1;1H - Clear screen and move cursor to 1,1 (upper left) pos. */
|
||||||
@@ -87,15 +87,13 @@ static inline void printheader(FILE *fp, const char *line, int nl)
|
|||||||
/* Requries: #inlude <termios.h> and #include <poll.h> */
|
/* Requries: #inlude <termios.h> and #include <poll.h> */
|
||||||
static inline void initscr(int *row, int *col)
|
static inline void initscr(int *row, int *col)
|
||||||
{
|
{
|
||||||
#if defined(TCSANOW) && defined(POLLIN)
|
|
||||||
struct termios tc, saved;
|
|
||||||
struct pollfd fd = { STDIN_FILENO, POLLIN, 0 };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!row || !col)
|
if (!row || !col)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if defined(TCSANOW) && defined(POLLIN)
|
#if defined(TCSANOW) && defined(POLLIN)
|
||||||
|
struct termios tc, saved;
|
||||||
|
struct pollfd fd = { STDIN_FILENO, POLLIN, 0 };
|
||||||
|
|
||||||
/* Disable echo to terminal while probing */
|
/* Disable echo to terminal while probing */
|
||||||
tcgetattr(STDERR_FILENO, &tc);
|
tcgetattr(STDERR_FILENO, &tc);
|
||||||
saved = tc;
|
saved = tc;
|
||||||
@@ -128,11 +126,10 @@ static inline void initscr(int *row, int *col)
|
|||||||
tcsetattr(STDERR_FILENO, TCSANOW, &saved);
|
tcsetattr(STDERR_FILENO, TCSANOW, &saved);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
#endif
|
#else
|
||||||
fallback:
|
|
||||||
|
|
||||||
*row = 24;
|
*row = 24;
|
||||||
*col = 80;
|
*col = 80;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONIO_H_ */
|
#endif /* CONIO_H_ */
|
||||||
|
|||||||
Reference in new issue
Block a user