[Minor] Export function to get terminal width from linenoise

This commit is contained in:
Vsevolod Stakhov 2018-04-24 18:12:17 +01:00
parent da89d96176
commit 9e9785cf2d
2 changed files with 5 additions and 2 deletions

View File

@ -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;

View File

@ -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