]> git.lizzy.rs Git - linenoise.git/commitdiff
New feature: Provide a public accessor to the getWindowSize() functionality.
authorAndreas Kupries <akupries@shaw.ca>
Thu, 21 Feb 2013 00:31:39 +0000 (16:31 -0800)
committerAndreas Kupries <akupries@shaw.ca>
Thu, 21 Feb 2013 00:31:39 +0000 (16:31 -0800)
The accessor returns only the number of columns, i.e. window width.

linenoise.c
linenoise.h

index 9b4fed89f269105fb6159b6066f1ef1c4ace29d5..dc9d2a2ccd4030806baa64bf89ec86fe2605e126 100644 (file)
@@ -1253,6 +1253,15 @@ history_navigation:
     return current->len;
 }
 
+int linenoiseColumns(void)
+{
+    struct current current;
+    enableRawMode (&current);
+    getWindowSize (&current);
+    disableRawMode (&current);
+    return current.cols;
+}
+
 char *linenoise(const char *prompt)
 {
     int count;
index 1e81863b79ce17b5a43b67ece099123fd2a545f7..7ebf244ee80e7f0bd92a551f3bb29de43ae7835a 100644 (file)
@@ -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 */