From 63bf10a3834a5555f482884c8ff32e2e500845f3 Mon Sep 17 00:00:00 2001 From: Andreas Kupries Date: Wed, 20 Feb 2013 16:31:39 -0800 Subject: [PATCH] New feature: Provide a public accessor to the getWindowSize() functionality. The accessor returns only the number of columns, i.e. window width. --- linenoise.c | 9 +++++++++ linenoise.h | 1 + 2 files changed, 10 insertions(+) diff --git a/linenoise.c b/linenoise.c index 9b4fed8..dc9d2a2 100644 --- a/linenoise.c +++ b/linenoise.c @@ -1253,6 +1253,15 @@ history_navigation: return current->len; } +int linenoiseColumns(void) +{ + struct current current; + enableRawMode (¤t); + getWindowSize (¤t); + disableRawMode (¤t); + return current.cols; +} + char *linenoise(const char *prompt) { int count; diff --git a/linenoise.h b/linenoise.h index 1e81863..7ebf244 100644 --- a/linenoise.h +++ b/linenoise.h @@ -56,5 +56,6 @@ int linenoiseHistorySave(const char *filename); int linenoiseHistoryLoad(const char *filename); void linenoiseHistoryFree(void); char **linenoiseHistory(int *len); +int linenoiseColumns(void); #endif /* __LINENOISE_H */ -- 2.44.0