Skip to content

Commit

Permalink
feat(libmd): drop readline
Browse files Browse the repository at this point in the history
  • Loading branch information
RossComputerGuy committed Feb 8, 2025
1 parent 855582c commit 3db2113
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 30 deletions.
8 changes: 0 additions & 8 deletions src/libcmd/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ readline_flavor = get_option('readline-flavor')
if readline_flavor == 'editline'
editline = dependency('libeditline', 'editline', version : '>=1.14')
deps_private += editline
elif readline_flavor == 'readline'
readline = dependency('readline')
deps_private += readline
configdata.set(
'USE_READLINE',
1,
description: 'Use readline instead of editline',
)
elif readline_flavor == 'zig'
configdata.set(
'USE_ZIG_REPL',
Expand Down
4 changes: 2 additions & 2 deletions src/libcmd/meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option(
option(
'readline-flavor',
type : 'combo',
choices : ['editline', 'readline', 'zig'],
value : 'editline',
choices : ['editline', 'zig'],
value : 'zig',
description : 'Which library to use for nice line editing with the Nix language REPL',
)
11 changes: 2 additions & 9 deletions src/libcmd/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
nix-flake,
nix-main,
editline,
readline,
lowdown,
nlohmann_json,

Expand All @@ -28,13 +27,7 @@
#
# - editline (default)
# - readline
readlineFlavor ?
if stdenv.hostPlatform.isWindows then
"readline"
else if stdenv.hostPlatform.isLinux then
"zig"
else
"editline",
readlineFlavor ? if stdenv.hostPlatform.isLinux then "zig" else "editline",
}:

let
Expand Down Expand Up @@ -63,7 +56,7 @@ mkMesonLibrary (finalAttrs: {
buildInputs = [
(
{
inherit editline readline;
inherit editline;
zig = null;
}
.${readlineFlavor}
Expand Down
13 changes: 2 additions & 11 deletions src/libcmd/repl-interacter.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include <cstdio>

#ifdef USE_READLINE
#include <readline/history.h>
#include <readline/readline.h>
#else
#ifdef USE_ZIG_REPL
extern "C" char* readline(const char* prompt);
#else
Expand All @@ -16,7 +12,6 @@ extern "C" {
#include <editline.h>
}
#endif
#endif

#include "signals.hh"
#include "finally.hh"
Expand All @@ -39,7 +34,6 @@ void sigintHandler(int signo)

static detail::ReplCompleterMixin * curRepl; // ugly

#ifndef USE_READLINE
static char * completionCallback(char * s, int * match)
{
auto possible = curRepl->completePrefix(s);
Expand Down Expand Up @@ -106,7 +100,6 @@ static int listPossibleCallback(char * s, char *** avp)

return ac;
}
#endif

ReadlineLikeInteracter::Guard ReadlineLikeInteracter::init(detail::ReplCompleterMixin * repl)
{
Expand All @@ -119,7 +112,7 @@ ReadlineLikeInteracter::Guard ReadlineLikeInteracter::init(detail::ReplCompleter
} catch (SystemError & e) {
logWarning(e.info());
}
#if !defined(USE_READLINE) && !defined(USE_ZIG_REPL)
#ifndef USE_ZIG_REPL
el_hist_size = 1000;
#endif
#ifndef USE_ZIG_REPL
Expand All @@ -128,7 +121,7 @@ ReadlineLikeInteracter::Guard ReadlineLikeInteracter::init(detail::ReplCompleter
auto oldRepl = curRepl;
curRepl = repl;
Guard restoreRepl([oldRepl] { curRepl = oldRepl; });
#if !defined(USE_READLINE) && !defined(USE_ZIG_REPL)
#ifndef USE_ZIG_REPL
rl_set_complete_func(completionCallback);
rl_set_list_possib_func(listPossibleCallback);
#endif
Expand Down Expand Up @@ -191,11 +184,9 @@ bool ReadlineLikeInteracter::getLine(std::string & input, ReplPromptType promptT
// quite useful for reading the test output, so we add it here.
if (auto e = getEnv("_NIX_TEST_REPL_ECHO"); s && e && *e == "1")
{
#ifndef USE_READLINE
// This is probably not right for multi-line input, but we don't use that
// in the characterisation tests, so it's fine.
std::cout << promptForType(promptType) << s << std::endl;
#endif
}

if (!s)
Expand Down

0 comments on commit 3db2113

Please sign in to comment.