From 1d30e5cc67dbf36c638cf6a089a2307cd7ac1e21 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Mon, 11 Aug 2014 22:58:53 -0700 Subject: Skeleton of editline support. --- .gitmodules | 3 +++ editline | 1 + includes/BReadline.h | 20 +++++++++++++++++++- src/Readline.cc | 29 +++++++++++++++++++++++++++-- 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 160000 editline diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..8aeb724 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "editline"] + path = editline + url = https://github.com/pixelxeno/editline.git diff --git a/editline b/editline new file mode 160000 index 0000000..73bd3bf --- /dev/null +++ b/editline @@ -0,0 +1 @@ +Subproject commit 73bd3bf3f962d74ca1295a3fc90353bf795242ed diff --git a/includes/BReadline.h b/includes/BReadline.h index 0d39f8b..31babd3 100644 --- a/includes/BReadline.h +++ b/includes/BReadline.h @@ -1,12 +1,28 @@ #pragma once +#ifdef USE_EDITLINE +#include +#include + +class Readline { + public: + Readline(const Balau::String & program); + ~Readline(); + Balau::String gets(); + bool gotEOF(); + void setPrompt(const Balau::String & prompt); +}; + +#endif + +#ifdef USE_HISTEDIT #include #include #include class Readline { public: - Readline(const Balau::String & program, Balau::IO); + Readline(const Balau::String & program); ~Readline(); Balau::String gets(); bool gotEOF() { return m_eof; } @@ -23,3 +39,5 @@ class Readline { static int elGetCFN(EditLine *, char * c); int elGetCFN(char * c); }; + +#endif diff --git a/src/Readline.cc b/src/Readline.cc index 9a2c791..917bb7b 100644 --- a/src/Readline.cc +++ b/src/Readline.cc @@ -3,8 +3,32 @@ using namespace Balau; -Readline::Readline(const String & program, IO in) - : m_in(in) +#ifdef USE_EDITLINE + +Readline::Readline(const Balau::String & program) { +} + +Readline::~Readline() { +} + +Balau::String Readline::gets() { + return ""; +} + +bool Readline::gotEOF() { + return true; +} + +void Readline::setPrompt(const Balau::String & prompt) { +} + +#endif + +#ifdef USE_HISTEDIT +#include + +Readline::Readline(const String & program) + : m_in(new StdIn()) { HistEvent ev; m_hist = history_init(); @@ -58,3 +82,4 @@ int Readline::elGetCFN(EditLine * el, char * c) { int Readline::elGetCFN(char * c) { return m_in->read(c, 1); } +#endif -- cgit v1.2.3