From: Vsevolod Stakhov Date: Tue, 24 Apr 2018 17:12:17 +0000 (+0100) Subject: [Minor] Export function to get terminal width from linenoise X-Git-Tag: 1.7.4~40 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9e9785cf2d9b591bbe421c914b93c44d5d506b2e;p=rspamd.git [Minor] Export function to get terminal width from linenoise --- 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