From: Andreas Kupries Date: Thu, 21 Feb 2013 00:31:39 +0000 (-0800) Subject: New feature: Provide a public accessor to the getWindowSize() functionality. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=63bf10a3834a5555f482884c8ff32e2e500845f3;p=linenoise.git New feature: Provide a public accessor to the getWindowSize() functionality. The accessor returns only the number of columns, i.e. window width. --- 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 */