--- /dev/null
+/* linenoise.h -- guerrilla line editing library against the idea that a
+ * line editing lib needs to be 20,000 lines of C code.
+ *
+ * See linenoise.m for more information.
+ *
+ * ------------------------------------------------------------------------
+ *
+ * Copyright (c) 2010, Salvatore Sanfilippo <antirez at gmail dot com>
+ * Copyright (c) 2010, Pieter Noordhuis <pcnoordhuis at gmail dot com>
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <ObjFW/ObjFW.h>
+
+#include <termios.h>
+#include <unistd.h>
+
+typedef void(linenoiseCompletionCallback)(OFString *, OFList*);
+
+enum linenoiseDirection {
+ LINENOISE_HISTORY_NEXT,
+ LINENOISE_HISTORY_PREV
+};
+
+@interface Linenoise : OFObject <OFApplicationDelegate>
+{
+ bool _multiline;
+
+ bool _rawmode; // For atexit() function to check if restore is needed
+ struct termios _orig_termios; // In order to restore at exit
+
+ linenoiseCompletionCallback *_completionCallback;
+
+ size_t _maximalHistoryLength;
+ ssize_t _historyIndex; // The history index we are currently editing
+ OFMutableArray *_history;
+
+ OFFile *_term; // Terminal file descriptor
+
+ OFMutableString *_buf; // Edited line buffer
+ OFString *_prompt; // Prompt to display
+
+ size_t _pos; // Current cursor position
+ size_t _oldpos; // Previous refresh cursor position
+
+ size_t _cols; // Number of columns in terminal
+ size_t _maxrows; // Maximum num of rows used so far (multiline)
+}
+@property (assign) bool multiline;
+@property (assign) size_t maximalHistoryLength;
+@property (assign) linenoiseCompletionCallback *completionCallback;
+
++ (Linenoise*)sharedLinenoise;
+
+- (OFString*)readInputWithPrompt: (OFString*)prompt;
+- (void)refreshLine;
+- (void)clearScreen;
+- (void)setCompletionCallback: (linenoiseCompletionCallback*)fn;
+- (int)addHistoryItem: (OFString*)line;
+- (void)saveHistoryToFile: (OFString*)filename;
+- (void)loadHistoryFromFile: (OFString*)filename;
+
+- (int)LN_editInsertCharacter: (int)c;
+- (void)LN_editMoveLeft;
+- (void)LN_editMoveRight;
+- (void)LN_editHistoryNextInDirection: (enum linenoiseDirection)dir;
+- (void)LN_editDelete;
+- (void)LN_editDeletePreviousWord;
+- (OFString*)LN_editWithFD: (int)fd
+ prompt: (OFString*)prompt;
+- (OFString*)LN_editRawWithPrompt: (OFString*)prompt;
+
+- (int)LN_completeLine;
+- (void)LN_refreshSingleLine;
+- (void)LN_refreshMultiLine;
+- (bool)LN_isUnsupportedTerm;
+- (int)LN_enableRawModeForFD: (int)fd;
+- (void)LN_disableRawModeForFD: (int)fd;
+- (int)LN_getColumns;
+- (void)LN_beep;
+@end