Electroneum
Loading...
Searching...
No Matches
readline_buffer.h
Go to the documentation of this file.
1#pragma once
2
3#include <streambuf>
4#include <sstream>
5#include <vector>
6
7namespace rdln
8{
9 typedef enum { empty, partial, full } linestatus;
10 class readline_buffer : public std::stringbuf
11 {
12 public:
14 void start();
15 void stop();
16 bool is_running() const
17 {
18 return m_cout_buf != NULL;
19 }
20 linestatus get_line(std::string& line) const;
21 void set_prompt(const std::string& prompt);
22 static void add_completion(const std::string& command);
23 static const std::vector<std::string>& get_completions();
24
25 protected:
26 virtual int sync();
27
28 private:
29 std::streambuf* m_cout_buf;
30 size_t m_prompt_length;
31 static std::vector<std::string>& completion_commands();
32 };
33
35 {
36 public:
39 private:
40 readline_buffer* m_buffer;
41 bool m_restart;
42 };
43}
44
static const std::vector< std::string > & get_completions()
void set_prompt(const std::string &prompt)
static void add_completion(const std::string &command)
linestatus get_line(std::string &line) const