FIXME: support lines that wrap FIXME: better controls maybe

FIXME: support multi-line "lines" and some form of line continuation, both from the user (if permitted) and from the application, so like the user hits "class foo { \n" and the app says "that line needs continuation" automatically.

FIXME: fix lengths on prompt and suggestion

A note on history:

To save history, you must call LineGetter.dispose() when you're done with it. History will not be automatically saved without that call!

The history saving and loading as a trivially encountered race condition: if you open two programs that use the same one at the same time, the one that closes second will overwrite any history changes the first closer saved.

GNU Getline does this too... and it actually kinda drives me nuts. But I don't know what a good fix is except for doing a transactional commit straight to the file every time and that seems like hitting the disk way too often.

We could also do like a history server like a database daemon that keeps the order correct but I don't actually like that either because I kinda like different bashes to have different history, I just don't like it all to get lost.

Regardless though, this isn't even used in bash anyway, so I don't think I care enough to put that much effort into it. Just using separate files for separate tasks is good enough I think.


this(Terminal* tty, string historyFilename = null)

Make sure that the parent terminal struct remains in scope for the duration of LineGetter's lifetime, as it does hold on to and use the passed pointer throughout.



void addChar(dchar ch)

Adds a character at the current position in the line. You can call this too if you hook events for hotkeys or something. You'll probably want to call redraw() after adding chars.

void addString(string s)


void deleteChar()

Deletes the character at the current position in the line. You'll probably want to call redraw() after deleting chars.

void deleteToEndOfLine()
void dispose()

Call this before letting LineGetter die so it can do any necessary cleanup and save the updated history to a file.

string getline(RealTimeConsoleInput* input = null)

One-call shop for the main workhorse If you already have a RealTimeConsoleInput ready to go, you should pass a pointer to yours here. Otherwise, LineGetter will make its own.

string historyFileDirectory()

Override this to change the directory where history files are stored

string historyFilter(string candidate)

Override this if you don't want all lines added to the history. You can return null to not add it at all, or you can transform it.

void loadSettingsAndHistoryFromFile()

You may override this to do nothing

void saveSettingsAndHistoryToFile()

You may override this to do nothing

void showTabCompleteList(string[] list)

Override this to provide a custom display of the tab completion list

void startGettingLine()

Starts getting a new line. Call workOnLine and finishGettingLine afterward.

string[] tabComplete(in dchar[] candidate)

Override this to provide tab completion. You may use the candidate argument to filter the list, but you don't have to (LineGetter will do it for you on the values you return).

bool workOnLine(InputEvent e)

for integrating into another event loop you can pass individual events to this and the line getter will work on it


bool autoSuggest;

Turn on auto suggest if you want a greyed thing of what tab would be able to fill in as you type.

Color background;


string prompt;

Set this if you want a prompt to be drawn with the line. It does NOT support color in string.

Color regularForeground;


Color suggestionForeground;

You can customize the colors here. You should set these after construction, but before calling startGettingLine or getline.

Suggestion Box / Bug Report