init
This commit is contained in:
commit
4dc9e55bbc
8 changed files with 118 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
lib
|
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"editor.insertSpaces": false,
|
||||||
|
"editor.tabSize": 4,
|
||||||
|
"editor.detectIndentation": false
|
||||||
|
}
|
23
LICENSE
Normal file
23
LICENSE
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# linenoise
|
||||||
|
|
||||||
|
Минимальная, самодостаточная замена readline, используемая в проектах вроде Redis, MongoDB и Android.
|
11
dub.json
Normal file
11
dub.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"authors": [
|
||||||
|
"Alexander Zhirov"
|
||||||
|
],
|
||||||
|
"copyright": "Copyright © 2025, Alexander Zhirov",
|
||||||
|
"description": "A small self-contained alternative to readline and libedit.",
|
||||||
|
"license": "BSL-1.0",
|
||||||
|
"name": "linenoise",
|
||||||
|
"targetType": "library",
|
||||||
|
"targetPath": "lib"
|
||||||
|
}
|
5
dub.selections.json
Normal file
5
dub.selections.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"fileVersion": 1,
|
||||||
|
"versions": {
|
||||||
|
}
|
||||||
|
}
|
4
dub.settings.json
Normal file
4
dub.settings.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"defaultArchitecture": "x86_64",
|
||||||
|
"defaultCompiler": "ldc2"
|
||||||
|
}
|
66
source/linenoise.d
Normal file
66
source/linenoise.d
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
module linenoise;
|
||||||
|
|
||||||
|
extern (C) {
|
||||||
|
|
||||||
|
struct LinenoiseState {
|
||||||
|
int in_completion; /* Пользователь нажал TAB, и теперь мы в режиме автодополнения,
|
||||||
|
* так что ввод обрабатывается completeLine(). */
|
||||||
|
size_t completion_idx; /* Индекс следующего предлагаемого дополнения. */
|
||||||
|
int ifd; /* Дескриптор файла stdin терминала. */
|
||||||
|
int ofd; /* Дескриптор файла stdout терминала. */
|
||||||
|
char* buf; /* Буфер редактируемой строки. */
|
||||||
|
size_t buflen; /* Размер буфера редактируемой строки. */
|
||||||
|
const(char)* prompt; /* Приглашение для отображения. */
|
||||||
|
size_t plen; /* Длина приглашения. */
|
||||||
|
size_t pos; /* Текущая позиция курсора. */
|
||||||
|
size_t oldpos; /* Предыдущая позиция курсора при обновлении. */
|
||||||
|
size_t len; /* Текущая длина редактируемой строки. */
|
||||||
|
size_t cols; /* Количество столбцов в терминале. */
|
||||||
|
size_t oldrows; /* Строки, использованные последней обновлённой строкой (многострочный режим) */
|
||||||
|
int history_index; /* Индекс истории, который мы сейчас редактируем. */
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LinenoiseCompletions {
|
||||||
|
size_t len;
|
||||||
|
char** cvec;
|
||||||
|
}
|
||||||
|
|
||||||
|
alias linenoiseCompletionCallback = void function(const(char)*, LinenoiseCompletions*);
|
||||||
|
alias linenoiseHintsCallback = char* function(const(char)*, int* color, int* bold);
|
||||||
|
alias linenoiseFreeHintsCallback = void function(void*);
|
||||||
|
|
||||||
|
@nogc nothrow:
|
||||||
|
|
||||||
|
/* Non blocking API. */
|
||||||
|
int linenoiseEditStart(LinenoiseState* l, int stdin_fd, int stdout_fd, char* buf, size_t buflen, const(char)* prompt);
|
||||||
|
char* linenoiseEditFeed(LinenoiseState* l);
|
||||||
|
void linenoiseEditStop(LinenoiseState* l);
|
||||||
|
void linenoiseHide(LinenoiseState* l);
|
||||||
|
void linenoiseShow(LinenoiseState* l);
|
||||||
|
|
||||||
|
/* Blocking API. */
|
||||||
|
char* linenoise(const(char)* prompt);
|
||||||
|
void linenoiseFree(void* ptr);
|
||||||
|
|
||||||
|
/* Completion API. */
|
||||||
|
void linenoiseSetCompletionCallback(linenoiseCompletionCallback);
|
||||||
|
void linenoiseSetHintsCallback(linenoiseHintsCallback);
|
||||||
|
void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback);
|
||||||
|
void linenoiseAddCompletion(LinenoiseCompletions*, const(char)*);
|
||||||
|
|
||||||
|
/* History API. */
|
||||||
|
int linenoiseHistoryAdd(const(char)* line);
|
||||||
|
int linenoiseHistorySetMaxLen(int len);
|
||||||
|
int linenoiseHistorySave(const(char)* filename);
|
||||||
|
int linenoiseHistoryLoad(const(char)* filename);
|
||||||
|
|
||||||
|
/* Other utilities. */
|
||||||
|
void linenoiseClearScreen();
|
||||||
|
void linenoiseSetMultiLine(int ml);
|
||||||
|
void linenoisePrintKeyCodes();
|
||||||
|
void linenoiseMaskModeEnable();
|
||||||
|
void linenoiseMaskModeDisable();
|
||||||
|
|
||||||
|
extern __gshared char* linenoiseEditMore;
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue