mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-15 07:19:18 +00:00
Improve Python and Linenoise
This change reinvents all the GNU Readline features I discovered that I couldn't live without, e.g. UTF-8, CTRL-R search and CTRL-Y yanking. It now feels just as good in terms of user interface from the subconscious workflow perspective. It's real nice to finally have an embeddable line reader that's actually good with a 30 kb footprint and a bsd-2 license. This change adds a directory to the examples folder, explaining how the new Python compiler may be used. Some of the bugs with Python binaries have been addressed but overall it's still a work in progress.
This commit is contained in:
parent
ad52387b74
commit
51904e2687
35 changed files with 3541 additions and 8587 deletions
12
third_party/linenoise/README.cosmo
vendored
12
third_party/linenoise/README.cosmo
vendored
|
@ -1,7 +1,7 @@
|
|||
DESCRIPTION
|
||||
|
||||
linenoise is a library for interactive pseudoteletypewriter command
|
||||
sessions using ANSI Standard X3.64 control sequences.
|
||||
Cosmopolitan Linenoise is a library for interactive pseudoteletypewriter
|
||||
command sessions using ANSI Standard X3.64 control sequences.
|
||||
|
||||
ORIGIN
|
||||
|
||||
|
@ -10,3 +10,11 @@ ORIGIN
|
|||
Author: antirez <antirez@gmail.com>
|
||||
Date: Thu Mar 12 15:51:45 2020 +0100
|
||||
Use unsigned int instead of uint like rest of code base.
|
||||
|
||||
DOCUMENTATION
|
||||
|
||||
See linenoise.c
|
||||
|
||||
LOCAL CHANGES
|
||||
|
||||
See linenoise.c
|
||||
|
|
37
third_party/linenoise/ezlinenoise.c
vendored
37
third_party/linenoise/ezlinenoise.c
vendored
|
@ -1,37 +0,0 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/runtime/gc.internal.h"
|
||||
#include "libc/x/x.h"
|
||||
#include "third_party/linenoise/linenoise.h"
|
||||
|
||||
/**
|
||||
* Reads line of input from terminal w/ history file.
|
||||
*/
|
||||
char *ezlinenoise(const char *prompt, const char *prog) {
|
||||
char *p, *h;
|
||||
h = gc(xasprintf("%s/.%s_history", gc(xhomedir()), prog));
|
||||
linenoiseHistoryLoad(h);
|
||||
p = linenoise(prompt);
|
||||
if (p && *p) {
|
||||
linenoiseHistoryLoad(h);
|
||||
linenoiseHistoryAdd(p);
|
||||
linenoiseHistorySave(h);
|
||||
}
|
||||
return p;
|
||||
}
|
2739
third_party/linenoise/linenoise.c
vendored
2739
third_party/linenoise/linenoise.c
vendored
File diff suppressed because it is too large
Load diff
7
third_party/linenoise/linenoise.h
vendored
7
third_party/linenoise/linenoise.h
vendored
|
@ -19,18 +19,17 @@ void linenoiseSetFreeHintsCallback(linenoiseFreeHintsCallback *);
|
|||
void linenoiseAddCompletion(linenoiseCompletions *, const char *);
|
||||
|
||||
char *linenoise(const char *) nodiscard;
|
||||
char *linenoiseRaw(const char *, int, int) nodiscard;
|
||||
char *ezlinenoise(const char *, const char *) nodiscard;
|
||||
int linenoiseHistoryAdd(const char *);
|
||||
int linenoiseHistorySetMaxLen(int);
|
||||
int linenoiseHistorySave(const char *);
|
||||
int linenoiseHistoryLoad(const char *);
|
||||
void linenoiseFreeCompletions(linenoiseCompletions *);
|
||||
void linenoiseHistoryFree(void);
|
||||
void linenoiseClearScreen(void);
|
||||
void linenoiseSetMultiLine(int);
|
||||
void linenoiseClearScreen(int);
|
||||
void linenoiseMaskModeEnable(void);
|
||||
void linenoiseMaskModeDisable(void);
|
||||
void linenoiseDisableRawMode(int);
|
||||
void linenoiseDisableRawMode(void);
|
||||
void linenoiseFree(void *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
2
third_party/linenoise/linenoise.mk
vendored
2
third_party/linenoise/linenoise.mk
vendored
|
@ -25,7 +25,6 @@ THIRD_PARTY_LINENOISE_A_DIRECTDEPS = \
|
|||
LIBC_STDIO \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_SYSV_CALLS \
|
||||
LIBC_X \
|
||||
LIBC_STR \
|
||||
LIBC_UNICODE \
|
||||
LIBC_STUBS
|
||||
|
@ -44,6 +43,7 @@ $(THIRD_PARTY_LINENOISE_A).pkg: \
|
|||
|
||||
$(THIRD_PARTY_LINENOISE_A_OBJS): \
|
||||
OVERRIDE_CFLAGS += \
|
||||
-fno-jump-tables \
|
||||
-ffunction-sections \
|
||||
-fdata-sections
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue