summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--con.c14
-rw-r--r--con.h7
-rw-r--r--nav.c2
3 files changed, 16 insertions, 7 deletions
diff --git a/con.c b/con.c
index f00d379..f9dae8a 100644
--- a/con.c
+++ b/con.c
@@ -1,14 +1,18 @@
 #include <sys/ioctl.h>
 #include <unistd.h>
 
-unsigned con_lines(void) {
+#include "con.h"
+
+struct consz con_size(void) {
 	struct winsize w;
 	ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
-	return w.ws_row;
+	return (struct consz) { w.ws_row, w.ws_col };
+}
+
+unsigned con_rows(void) {
+	return con_size().rows;
 }
 
 unsigned con_cols(void) {
-	struct winsize w;
-	ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
-	return w.ws_col;
+	return con_size().cols;
 }
diff --git a/con.h b/con.h
index 0c6fa33..ab2f16a 100644
--- a/con.h
+++ b/con.h
@@ -1,7 +1,12 @@
 #ifndef CON_H
 #define CON_H
 
-unsigned con_lines(void);
+struct consz {
+	unsigned rows, cols;
+};
+
+struct consz con_size(void);
+unsigned con_rows(void);
 unsigned con_cols(void);
 
 #endif
diff --git a/nav.c b/nav.c
index 7d5af9e..1067c8b 100644
--- a/nav.c
+++ b/nav.c
@@ -51,7 +51,7 @@ void nav_next(struct nav_state *ns) {
 /* paging */
 
 size_t pg_lines(void) {
-	return con_lines() - 1;
+	return con_rows() - 1;
 }
 
 struct doc_line *nav_cur_line(struct nav_state *ns) {