Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

linenoise.c File Reference

#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "linenoise.h"

Go to the source code of this file.

Compounds

struct  abuf
struct  linenoiseState

Defines

#define LINENOISE_DEFAULT_HISTORY_MAX_LEN   100
#define LINENOISE_MAX_LINE   4096
#define lndebug(fmt,)
#define LINENOISE_HISTORY_NEXT   0
#define LINENOISE_HISTORY_PREV   1

Enumerations

enum  KEY_ACTION {
  KEY_NULL = 0, CTRL_A = 1, CTRL_B = 2, CTRL_C = 3,
  CTRL_D = 4, CTRL_E = 5, CTRL_F = 6, CTRL_H = 8,
  TAB = 9, CTRL_K = 11, CTRL_L = 12, ENTER = 13,
  CTRL_N = 14, CTRL_P = 16, CTRL_T = 20, CTRL_U = 21,
  CTRL_W = 23, ESC = 27, BACKSPACE = 127
}

Functions

void linenoiseAtExit (void)
int linenoiseHistoryAdd (const char *line)
void refreshLine (struct linenoiseState *l)
void linenoiseMaskModeEnable (void)
void linenoiseMaskModeDisable (void)
void linenoiseSetMultiLine (int ml)
int isUnsupportedTerm (void)
int enableRawMode (int fd, int flush)
void disableRawMode (int fd, int flush)
int getCursorPosition (int ifd, int ofd)
int getColumns (int ifd, int ofd)
void linenoiseClearScreen (void)
void linenoiseBeep (void)
void freeCompletions (linenoiseCompletions *lc)
int completeLine (struct linenoiseState *ls)
void linenoiseSetCompletionCallback (void *uctx, linenoiseCompletionCallback *fn)
void linenoiseSetHintsCallback (void *uctx, linenoiseHintsCallback *fn)
void linenoiseSetFreeHintsCallback (void *uctx, linenoiseFreeHintsCallback *fn)
void linenoiseAddCompletion (linenoiseCompletions *lc, const char *str)
void abInit (struct abuf *ab)
void abAppend (struct abuf *ab, const char *s, int len)
void abFree (struct abuf *ab)
void refreshShowHints (struct abuf *ab, struct linenoiseState *l, int plen)
void refreshSingleLine (struct linenoiseState *l)
void refreshMultiLine (struct linenoiseState *l)
int linenoiseEditInsert (struct linenoiseState *l, char c)
void linenoiseEditMoveLeft (struct linenoiseState *l)
void linenoiseEditMoveRight (struct linenoiseState *l)
void linenoiseEditMoveHome (struct linenoiseState *l)
void linenoiseEditMoveEnd (struct linenoiseState *l)
void linenoiseEditHistoryNext (struct linenoiseState *l, int dir)
void linenoiseEditDelete (struct linenoiseState *l)
void linenoiseEditBackspace (struct linenoiseState *l)
void linenoiseEditDeletePrevWord (struct linenoiseState *l)
int linenoiseEdit (int stdin_fd, int stdout_fd, char *buf, size_t buflen, const char *prompt)
void linenoisePrintKeyCodes (void)
int linenoiseRaw (char *buf, size_t buflen, const char *prompt)
char * linenoiseNoTTY (void)
char * linenoise (const char *prompt)
void linenoiseFree (void *ptr)
void freeHistory (void)
int linenoiseHistorySetMaxLen (int len)
int linenoiseHistorySave (const char *filename)
int linenoiseHistoryLoad (const char *filename)

Variables

char * unsupported_term [] = {"dumb","cons25","emacs",NULL}
linenoiseCompletionCallback * completionCallback = NULL
void * completionCallbackCtx = NULL
linenoiseHintsCallbackhintsCallback = NULL
void * hintsCallbackCtx = NULL
linenoiseFreeHintsCallback * freeHintsCallback = NULL
void * freeHintsCallbackCtx = NULL
termios orig_termios
int maskmode = 0
int rawmode = 0
int mlmode = 0
int atexit_registered = 0
int history_max_len = LINENOISE_DEFAULT_HISTORY_MAX_LEN
int history_len = 0
char ** history = NULL


Define Documentation

#define LINENOISE_DEFAULT_HISTORY_MAX_LEN   100
 

Definition at line 140 of file linenoise.c.

#define LINENOISE_HISTORY_NEXT   0
 

Definition at line 750 of file linenoise.c.

Referenced by linenoiseEdit.

#define LINENOISE_HISTORY_PREV   1
 

Definition at line 751 of file linenoise.c.

Referenced by linenoiseEdit, and linenoiseEditHistoryNext.

#define LINENOISE_MAX_LINE   4096
 

Definition at line 141 of file linenoise.c.

Referenced by linenoise, and linenoiseHistoryLoad.

#define lndebug fmt   
 

Definition at line 219 of file linenoise.c.

Referenced by refreshMultiLine.


Enumeration Type Documentation

enum KEY_ACTION
 

Enumeration values:
KEY_NULL 
CTRL_A 
CTRL_B 
CTRL_C 
CTRL_D 
CTRL_E 
CTRL_F 
CTRL_H 
TAB 
CTRL_K 
CTRL_L 
ENTER 
CTRL_N 
CTRL_P 
CTRL_T 
CTRL_U 
CTRL_W 
ESC 
BACKSPACE 

Definition at line 177 of file linenoise.c.


Function Documentation

void abAppend struct abuf   ab,
const char *    s,
int    len
[static]
 

Definition at line 501 of file linenoise.c.

References abuf::b, abuf::len, and NULL.

Referenced by refreshMultiLine, refreshShowHints, and refreshSingleLine.

void abFree struct abuf   ab [static]
 

Definition at line 510 of file linenoise.c.

References abuf::b.

Referenced by refreshMultiLine, and refreshSingleLine.

void abInit struct abuf   ab [static]
 

Definition at line 496 of file linenoise.c.

References abuf::b, abuf::len, and NULL.

Referenced by refreshMultiLine, and refreshSingleLine.

int completeLine struct linenoiseState   ls [static]
 

Definition at line 387 of file linenoise.c.

References linenoiseState::buf, linenoiseState::buflen, completionCallback, completionCallbackCtx, linenoiseCompletions::cvec, freeCompletions, linenoiseState::ifd, linenoiseState::len, linenoiseCompletions::len, linenoiseBeep, NULL, linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

void disableRawMode int    fd,
int    flush
 

Definition at line 290 of file linenoise.c.

References orig_termios, and rawmode.

int enableRawMode int    fd,
int    flush
 

Definition at line 255 of file linenoise.c.

References atexit_registered, ECHO, linenoiseAtExit, orig_termios, and rawmode.

void freeCompletions linenoiseCompletions   lc [static]
 

Definition at line 373 of file linenoise.c.

References linenoiseCompletions::cvec, linenoiseCompletions::len, and NULL.

Referenced by completeLine.

void freeHistory void    [static]
 

Definition at line 1129 of file linenoise.c.

References history, and history_len.

Referenced by linenoiseAtExit.

int getColumns int    ifd,
int    ofd
[static]
 

Definition at line 323 of file linenoise.c.

References getCursorPosition.

Referenced by linenoiseEdit.

int getCursorPosition int    ifd,
int    ofd
[static]
 

Definition at line 299 of file linenoise.c.

References ESC.

Referenced by getColumns.

int isUnsupportedTerm void    [static]
 

Definition at line 244 of file linenoise.c.

References NULL, and unsupported_term.

Referenced by linenoise.

char* linenoise const char *    prompt
 

Definition at line 1090 of file linenoise.c.

References isUnsupportedTerm, LINENOISE_MAX_LINE, linenoiseNoTTY, linenoiseRaw, and NULL.

void linenoiseAddCompletion linenoiseCompletions   lc,
const char *    str
 

Definition at line 469 of file linenoise.c.

References linenoiseCompletions::cvec, linenoiseCompletions::len, and NULL.

void linenoiseAtExit void    [static]
 

Definition at line 1140 of file linenoise.c.

References disableRawMode, and freeHistory.

Referenced by enableRawMode.

void linenoiseBeep void    [static]
 

Definition at line 365 of file linenoise.c.

Referenced by completeLine.

void linenoiseClearScreen void   
 

Definition at line 357 of file linenoise.c.

Referenced by linenoiseEdit.

int linenoiseEdit int    stdin_fd,
int    stdout_fd,
char *    buf,
size_t    buflen,
const char *    prompt
[static]
 

Definition at line 820 of file linenoise.c.

References BACKSPACE, linenoiseState::buf, linenoiseState::buflen, linenoiseState::cols, completeLine, completionCallback, CTRL_A, CTRL_B, CTRL_C, CTRL_D, CTRL_E, CTRL_F, CTRL_K, CTRL_L, CTRL_N, CTRL_P, CTRL_T, CTRL_U, CTRL_W, ENTER, ESC, getColumns, hintsCallback, history, linenoiseState::history_index, history_len, linenoiseState::ifd, linenoiseState::len, LINENOISE_HISTORY_NEXT, LINENOISE_HISTORY_PREV, linenoiseClearScreen, linenoiseEditBackspace, linenoiseEditDelete, linenoiseEditDeletePrevWord, linenoiseEditHistoryNext, linenoiseEditInsert, linenoiseEditMoveEnd, linenoiseEditMoveHome, linenoiseEditMoveLeft, linenoiseEditMoveRight, linenoiseHintsCallback, linenoiseHistoryAdd, linenoiseState::maxrows, NULL, linenoiseState::ofd, linenoiseState::oldpos, linenoiseState::plen, linenoiseState::pos, linenoiseState::prompt, and refreshLine.

Referenced by linenoiseRaw.

void linenoiseEditBackspace struct linenoiseState   l
 

Definition at line 786 of file linenoise.c.

References linenoiseState::buf, linenoiseState::len, linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

void linenoiseEditDelete struct linenoiseState   l
 

Definition at line 776 of file linenoise.c.

References linenoiseState::buf, linenoiseState::len, linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

void linenoiseEditDeletePrevWord struct linenoiseState   l
 

Definition at line 798 of file linenoise.c.

References linenoiseState::buf, linenoiseState::len, linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

void linenoiseEditHistoryNext struct linenoiseState   l,
int    dir
 

Definition at line 752 of file linenoise.c.

References linenoiseState::buf, linenoiseState::buflen, history, linenoiseState::history_index, history_len, linenoiseState::len, LINENOISE_HISTORY_PREV, linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

int linenoiseEditInsert struct linenoiseState   l,
char    c
 

Definition at line 689 of file linenoise.c.

References linenoiseState::buf, linenoiseState::buflen, linenoiseState::cols, hintsCallback, linenoiseState::len, maskmode, mlmode, linenoiseState::ofd, linenoiseState::plen, linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

void linenoiseEditMoveEnd struct linenoiseState   l
 

Definition at line 741 of file linenoise.c.

References linenoiseState::len, linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

void linenoiseEditMoveHome struct linenoiseState   l
 

Definition at line 733 of file linenoise.c.

References linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

void linenoiseEditMoveLeft struct linenoiseState   l
 

Definition at line 717 of file linenoise.c.

References linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

void linenoiseEditMoveRight struct linenoiseState   l
 

Definition at line 725 of file linenoise.c.

References linenoiseState::len, linenoiseState::pos, and refreshLine.

Referenced by linenoiseEdit.

void linenoiseFree void *    ptr
 

Definition at line 1121 of file linenoise.c.

int linenoiseHistoryAdd const char *    line
 

Definition at line 1152 of file linenoise.c.

References history, history_len, history_max_len, and NULL.

int linenoiseHistoryLoad const char *    filename
 

Definition at line 1235 of file linenoise.c.

References LINENOISE_MAX_LINE, linenoiseHistoryAdd, and NULL.

int linenoiseHistorySave const char *    filename
 

Definition at line 1215 of file linenoise.c.

References history, history_len, and NULL.

int linenoiseHistorySetMaxLen int    len
 

Definition at line 1185 of file linenoise.c.

References history, history_len, history_max_len, and NULL.

void linenoiseMaskModeDisable void   
 

Definition at line 233 of file linenoise.c.

References maskmode.

void linenoiseMaskModeEnable void   
 

Definition at line 228 of file linenoise.c.

References maskmode.

char* linenoiseNoTTY void    [static]
 

Definition at line 1054 of file linenoise.c.

References NULL.

Referenced by linenoise.

void linenoisePrintKeyCodes void   
 

Definition at line 1007 of file linenoise.c.

References disableRawMode, and enableRawMode.

int linenoiseRaw char *    buf,
size_t    buflen,
const char *    prompt
[static]
 

Definition at line 1034 of file linenoise.c.

References disableRawMode, enableRawMode, and linenoiseEdit.

Referenced by linenoise.

void linenoiseSetCompletionCallback void *    uctx,
linenoiseCompletionCallback *    fn
 

Definition at line 446 of file linenoise.c.

References completionCallback, and completionCallbackCtx.

void linenoiseSetFreeHintsCallback void *    uctx,
linenoiseFreeHintsCallback *    fn
 

Definition at line 460 of file linenoise.c.

References freeHintsCallback, and freeHintsCallbackCtx.

void linenoiseSetHintsCallback void *    uctx,
linenoiseHintsCallback   fn
 

Definition at line 453 of file linenoise.c.

References hintsCallback, hintsCallbackCtx, and linenoiseHintsCallback.

void linenoiseSetMultiLine int    ml
 

Definition at line 238 of file linenoise.c.

References mlmode.

void refreshLine struct linenoiseState   l [static]
 

Definition at line 679 of file linenoise.c.

References refreshMultiLine, and refreshSingleLine.

Referenced by completeLine, linenoiseEdit, linenoiseEditBackspace, linenoiseEditDelete, linenoiseEditDeletePrevWord, linenoiseEditHistoryNext, linenoiseEditInsert, linenoiseEditMoveEnd, linenoiseEditMoveHome, linenoiseEditMoveLeft, and linenoiseEditMoveRight.

void refreshMultiLine struct linenoiseState   l [static]
 

Definition at line 589 of file linenoise.c.

References abAppend, abFree, abInit, abuf::b, linenoiseState::buf, linenoiseState::cols, abuf::len, linenoiseState::len, lndebug, maskmode, linenoiseState::maxrows, linenoiseState::ofd, linenoiseState::oldpos, linenoiseState::pos, linenoiseState::prompt, and refreshShowHints.

Referenced by refreshLine.

void refreshShowHints struct abuf   ab,
struct linenoiseState   l,
int    plen
 

Definition at line 516 of file linenoise.c.

References abAppend, linenoiseState::buf, linenoiseState::cols, freeHintsCallback, freeHintsCallbackCtx, hintsCallback, hintsCallbackCtx, and linenoiseState::len.

Referenced by refreshMultiLine, and refreshSingleLine.

void refreshSingleLine struct linenoiseState   l [static]
 

Definition at line 544 of file linenoise.c.

References abAppend, abFree, abInit, abuf::b, linenoiseState::buf, linenoiseState::cols, abuf::len, linenoiseState::len, maskmode, linenoiseState::ofd, linenoiseState::pos, linenoiseState::prompt, and refreshShowHints.

Referenced by refreshLine.


Variable Documentation

int atexit_registered = 0 [static]
 

Definition at line 154 of file linenoise.c.

Referenced by enableRawMode.

linenoiseCompletionCallback* completionCallback = NULL [static]
 

Definition at line 143 of file linenoise.c.

Referenced by completeLine, linenoiseEdit, and linenoiseSetCompletionCallback.

void* completionCallbackCtx = NULL [static]
 

Definition at line 144 of file linenoise.c.

Referenced by completeLine, and linenoiseSetCompletionCallback.

linenoiseFreeHintsCallback* freeHintsCallback = NULL [static]
 

Definition at line 147 of file linenoise.c.

Referenced by linenoiseSetFreeHintsCallback, and refreshShowHints.

void* freeHintsCallbackCtx = NULL [static]
 

Definition at line 148 of file linenoise.c.

Referenced by linenoiseSetFreeHintsCallback, and refreshShowHints.

linenoiseHintsCallback* hintsCallback = NULL [static]
 

Definition at line 145 of file linenoise.c.

Referenced by linenoiseEdit, linenoiseEditInsert, linenoiseSetHintsCallback, and refreshShowHints.

void* hintsCallbackCtx = NULL [static]
 

Definition at line 146 of file linenoise.c.

Referenced by linenoiseSetHintsCallback, and refreshShowHints.

char** history = NULL [static]
 

Definition at line 157 of file linenoise.c.

Referenced by freeHistory, linenoiseEdit, linenoiseEditHistoryNext, linenoiseHistoryAdd, linenoiseHistorySave, and linenoiseHistorySetMaxLen.

int history_len = 0 [static]
 

Definition at line 156 of file linenoise.c.

Referenced by freeHistory, linenoiseEdit, linenoiseEditHistoryNext, linenoiseHistoryAdd, linenoiseHistorySave, and linenoiseHistorySetMaxLen.

int history_max_len = LINENOISE_DEFAULT_HISTORY_MAX_LEN [static]
 

Definition at line 155 of file linenoise.c.

Referenced by linenoiseHistoryAdd, and linenoiseHistorySetMaxLen.

int maskmode = 0 [static]
 

Definition at line 151 of file linenoise.c.

Referenced by linenoiseEditInsert, linenoiseMaskModeDisable, linenoiseMaskModeEnable, refreshMultiLine, and refreshSingleLine.

int mlmode = 0 [static]
 

Definition at line 153 of file linenoise.c.

Referenced by linenoiseEditInsert, and linenoiseSetMultiLine.

struct termios orig_termios [static]
 

Definition at line 150 of file linenoise.c.

Referenced by disableRawMode, and enableRawMode.

int rawmode = 0 [static]
 

Definition at line 152 of file linenoise.c.

Referenced by disableRawMode, and enableRawMode.

char* unsupported_term[] = {"dumb","cons25","emacs",NULL} [static]
 

Definition at line 142 of file linenoise.c.

Referenced by isUnsupportedTerm.


Generated on Wed Dec 11 02:46:36 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002