Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

readline.cpp File Reference

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <assert.h>
#include <string.h>
#include <malloc.h>
#include "readline.h"

Go to the source code of this file.

Defines

#define HISTORY_SIZE   8

Functions

void addline (char *s)
 Add a new line to the history buffer.

char * getline (int line)
 Get a line from the history buffer.

char * readline (char *s, int n)
 A simple version of the GNU readline function.


Variables

char * history [HISTORY_SIZE]
int numlines = 0


Define Documentation

#define HISTORY_SIZE   8
 

Definition at line 29 of file readline.cpp.

Referenced by addline().


Function Documentation

void addline char *    s [static]
 

Add a new line to the history buffer.

If the history is already full, the oldest entry gets discarded.

Parameters:
s  string to add

Definition at line 42 of file readline.cpp.

References history, HISTORY_SIZE, and numlines.

Referenced by readline().

char* getline int    line [static]
 

Get a line from the history buffer.

Parameters:
line  line number to get
Returns:
string from the history, or NULL if line was out of bounds.

Definition at line 63 of file readline.cpp.

References history, and numlines.

Referenced by readline().

char* readline char *    s,
int    n
 

A simple version of the GNU readline function.

Only the most basic editing functions are implemented.

Parameters:
s  pointer to string to read into
n  maximum length (including \0)
Returns:
pointer to string
Bug:
there's still a bug when pressing cursor up or down while the history buffer is empty (try it right after the program is started - it will copy garbage to the current line)

Definition at line 85 of file readline.cpp.

References addline(), getline(), and numlines.


Variable Documentation

char* history[HISTORY_SIZE] [static]
 

Definition at line 31 of file readline.cpp.

Referenced by addline(), and getline().

int numlines = 0 [static]
 

Definition at line 32 of file readline.cpp.

Referenced by addline(), getline(), and readline().


Generated on Sun Aug 4 21:47:40 2002 for k/os mp3v2 by doxygen1.2.16