summaryrefslogtreecommitdiff
path: root/includes/BReadline.h
blob: 73756c464af51a20e2861ef7bd657757bf20c2b1 (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
#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;
    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);
};