From d2327e2a0f067cedcda3ad1aba8224129634f1c7 Mon Sep 17 00:00:00 2001 From: Evgeniy Dushistov Date: Sat, 6 Jul 2013 13:40:11 +0000 Subject: [PATCH] Import patch from Roman Imankulov: "sdcv" does not set up `rl_readline_name' variable which can be extremely useful for the writing the .inputrc file. Additionally sdcv does not use readline in the "Your choice [-1 to abort]" dialog. This patch fix both these issues, readline_name is set up to "sdcv". This trick allows me to add into the .inputrc $if sdcv "\e\e": "-1\n" $endif and type double-escape in the "Your choice" dialog instead of pretty annoying "-1". --- src/libwrapper.cpp | 18 ++++++++---------- src/readline.cpp | 4 +++- src/readline.hpp | 2 +- src/utils.cpp | 11 ----------- src/utils.hpp | 1 - 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/libwrapper.cpp b/src/libwrapper.cpp index 95e8192..ddc35b0 100644 --- a/src/libwrapper.cpp +++ b/src/libwrapper.cpp @@ -22,9 +22,11 @@ # include "config.h" #endif -#include #include #include +#include + +#include #include "utils.hpp" @@ -348,25 +350,21 @@ bool Library::process_phrase(const char *loc_str, read_line &io, bool force) utf8_output ? res_list[i].def.c_str() : loc_def.c_str()); } int choise; + std::auto_ptr choice_readline(create_readline_object()); for (;;) { string str_choise; - printf(_("Your choice[-1 to abort]: ")); - - if(!stdio_getline(stdin, str_choise)){ - putchar('\n'); - exit(EXIT_SUCCESS); - } + choice_readline->read(_("Your choice[-1 to abort]: "), str_choise); sscanf(str_choise.c_str(), "%d", &choise); if (choise>=0 && choise