From cbb9f606333774f4de6f639891cd1411419ecf2a Mon Sep 17 00:00:00 2001 From: wrmr Date: Sat, 9 Nov 2024 01:51:42 -0500 Subject: use actual console size for nav_lines(), instead of dummy value --- con.c | 14 ++++++++++++++ con.h | 7 +++++++ nav.c | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 con.c create mode 100644 con.h diff --git a/con.c b/con.c new file mode 100644 index 0000000..f00d379 --- /dev/null +++ b/con.c @@ -0,0 +1,14 @@ +#include +#include + +unsigned con_lines(void) { + struct winsize w; + ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + return w.ws_row; +} + +unsigned con_cols(void) { + struct winsize w; + ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + return w.ws_col; +} diff --git a/con.h b/con.h new file mode 100644 index 0000000..0c6fa33 --- /dev/null +++ b/con.h @@ -0,0 +1,7 @@ +#ifndef CON_H +#define CON_H + +unsigned con_lines(void); +unsigned con_cols(void); + +#endif diff --git a/nav.c b/nav.c index 5e5d8ea..18b21db 100644 --- a/nav.c +++ b/nav.c @@ -5,6 +5,7 @@ #include "net.h" #include "err.h" #include "parse.h" +#include "con.h" /* history */ @@ -50,7 +51,7 @@ void nav_next(struct nav_state *ns) { /* paging */ size_t pg_lines(void) { - return 24; + return con_lines() - 1; } struct doc_line *nav_cur_line(struct nav_state *ns) { -- cgit 1.4.1-2-gfad0