Called by completeLine() and linenoiseShow() to render the current * edited line with the proposed completion. If the current completion table * is already available, it is passed as second argument, otherwise the * function will use the callback to obtain it. * * Flags are the same as refreshLine*(), that is REFRESH_* macros. */
| 746 | return ws.ws_col; |
| 747 | } |
| 748 | |
| 749 | failed: |
| 750 | return 80; |
| 751 | } |
| 752 | |
| 753 | /* Clear the screen. Used to handle ctrl+l */ |
| 754 | void linenoiseClearScreen(void) { |
| 755 | if (write(STDOUT_FILENO,"\x1b[H\x1b[2J",7) <= 0) { |
| 756 | /* nothing to do, just to avoid warning. */ |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | /* Beep, used for completion when there is nothing to complete or when all |
| 761 | * the choices were already shown. */ |
| 762 | static void linenoiseBeep(void) { |
| 763 | fprintf(stderr, "\x7"); |
| 764 | fflush(stderr); |
| 765 | } |
| 766 | |
| 767 | /* ============================== Completion ================================ */ |
| 768 | |
| 769 | /* Free a list of completion option populated by linenoiseAddCompletion(). */ |
| 770 | static void freeCompletions(linenoiseCompletions *lc) { |
| 771 | size_t i; |
| 772 | for (i = 0; i < lc->len; i++) |
| 773 | free(lc->cvec[i]); |
| 774 | if (lc->cvec != NULL) |
| 775 | free(lc->cvec); |
| 776 | } |
no test coverage detected