From 962a8482da0eaaf4c50fd558c44b504705a7845b Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Wed, 24 Jul 2013 09:12:27 +0200 Subject: Adding history support to Readline. --- includes/BReadline.h | 1 + src/Readline.cc | 3 +++ 2 files changed, 4 insertions(+) diff --git a/includes/BReadline.h b/includes/BReadline.h index 73756c4..0d39f8b 100644 --- a/includes/BReadline.h +++ b/includes/BReadline.h @@ -13,6 +13,7 @@ class Readline { void setPrompt(const Balau::String & prompt); private: EditLine * m_el = NULL; + History * m_hist = NULL; Balau::IO m_in; bool m_eof = false; Balau::String m_prompt = "> "; diff --git a/src/Readline.cc b/src/Readline.cc index a58719d..ad324ee 100644 --- a/src/Readline.cc +++ b/src/Readline.cc @@ -6,15 +6,18 @@ using namespace Balau; Readline::Readline(const String & program, IO in) : m_in(in) { + m_hist = history_init(); m_el = el_init(program.to_charp(), stdin, stdout, stderr); el_set(m_el, EL_CLIENTDATA, this); el_set(m_el, EL_PROMPT, (const char * (*)(EditLine *)) &Readline::elPrompt); el_set(m_el, EL_SIGNAL, 1); el_set(m_el, EL_GETCFN, (int (*)(EditLine *, char *)) &Readline::elGetCFN); + el_set(m_el, EL_HIST, history, m_hist); } Readline::~Readline() { el_end(m_el); + history_end(m_hist); } void Readline::setPrompt(const String & prompt) { -- cgit v1.2.3