diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-04-24 18:12:17 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-04-24 18:12:17 +0100 |
commit | 9e9785cf2d9b591bbe421c914b93c44d5d506b2e (patch) | |
tree | 9e10e7d7f8c35c7f1e244632eb9c8ab52605e949 | |
parent | da89d96176879b02a1f7d71a6c3478cd55058b5d (diff) | |
download | rspamd-9e9785cf2d9b591bbe421c914b93c44d5d506b2e.tar.gz rspamd-9e9785cf2d9b591bbe421c914b93c44d5d506b2e.zip |
[Minor] Export function to get terminal width from linenoise
-rw-r--r-- | contrib/linenoise/linenoise.c | 4 | ||||
-rw-r--r-- | contrib/linenoise/linenoise.h | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/contrib/linenoise/linenoise.c b/contrib/linenoise/linenoise.c index f84d80984..8e7ba9688 100644 --- a/contrib/linenoise/linenoise.c +++ b/contrib/linenoise/linenoise.c @@ -282,7 +282,7 @@ static int getCursorPosition(int ifd, int ofd) { /* Try to get the number of columns in the current terminal, or assume 80 * if it fails. */ -static int getColumns(int ifd, int ofd) { +int linenoiseGetColumns(int ifd, int ofd) { struct winsize ws; if (ioctl(1, TIOCGWINSZ, &ws) == -1 || ws.ws_col == 0) { @@ -778,7 +778,7 @@ static int linenoiseEdit(int stdin_fd, int stdout_fd, char *buf, size_t buflen, l.plen = strlen(prompt); l.oldpos = l.pos = 0; l.len = 0; - l.cols = getColumns(stdin_fd, stdout_fd); + l.cols = linenoiseGetColumns(stdin_fd, stdout_fd); l.maxrows = 0; l.history_index = 0; diff --git a/contrib/linenoise/linenoise.h b/contrib/linenoise/linenoise.h index ed20232c5..ca855f0b1 100644 --- a/contrib/linenoise/linenoise.h +++ b/contrib/linenoise/linenoise.h @@ -66,6 +66,9 @@ void linenoiseClearScreen(void); void linenoiseSetMultiLine(int ml); void linenoisePrintKeyCodes(void); +/* Rspamd specific */ +int linenoiseGetColumns(int ifd, int ofd); + #ifdef __cplusplus } #endif |