summaryrefslogtreecommitdiff
path: root/includes/BReadline.h
blob: 0d39f8b26c4f8ac500cd1c7f067ce4c83bb712a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once

#include <histedit.h>
#include <BString.h>
#include <Handle.h>

class Readline {
  public:
      Readline(const Balau::String & program, Balau::IO<Balau::Handle>);
      ~Readline();
    Balau::String gets();
    bool gotEOF() { return m_eof; }
    void setPrompt(const Balau::String & prompt);
  private:
    EditLine * m_el = NULL;
    History * m_hist = NULL;
    Balau::IO<Balau::Handle> m_in;
    bool m_eof = false;
    Balau::String m_prompt = "> ";

    static const char * elPrompt(EditLine *);
    const char * elPrompt() { return m_prompt.to_charp(); }
    static int elGetCFN(EditLine *, char * c);
    int elGetCFN(char * c);
};