Cadabra
Computer algebra system for field theory problems
Console.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <gtkmm.h>
4 #include <json/json.h>
5 #include <queue>
6 #include <list>
7 
8 namespace cadabra {
9  class Console;
10 
11  class TextViewProxy : public Gtk::TextView {
12  public:
14 
16 
17  bool on_key_press_event(GdkEventKey* key_event) override;
18 
19  private:
21 
22  std::string temp_in;
23  std::list<std::string> history;
24  std::list<std::string>::iterator history_ptr;
25  };
26 
27  class Console : public Gtk::Box {
28  public:
29  Console(sigc::slot<void> run_slot);
30  ~Console();
31 
32  void initialize();
33 
34  void set_input(const Glib::ustring& line, size_t range_start = std::string::npos, size_t range_end = std::string::npos);
35  std::string grab_input();
36  void send_input(const std::string& code);
37  void signal_message(const Json::Value& msg);
38 
39  void set_height(int px);
40 
41  void scroll_to_bottom();
42  uint64_t get_id() const;
43  Glib::RefPtr<Gtk::TextBuffer> get_buffer();
44 
45  private:
46  void insert_text(const std::string& text, Glib::RefPtr<Gtk::TextTag> tag);
47  void insert_graphic(const std::string& bytes);
48  void prompt(bool continuation, bool newline = false);
49 
50  void process_message_queue();
51 
52  Glib::Dispatcher dispatch_message;
53  Glib::Dispatcher run;
54  uint64_t id_;
55 
57  std::string collect;
58  std::queue<Json::Value> message_queue;
59  std::queue<std::string> run_queue;
60  Gtk::ScrolledWindow win;
62  Gtk::TextView tv;
63  Glib::RefPtr<Gtk::TextBuffer::Mark> input_begin, prompt_begin;
64  Glib::RefPtr<Gtk::TextTag> input_tag, output_tag, warning_tag, error_tag;
65  };
66 
67  }
cadabra::Console::output_tag
Glib::RefPtr< Gtk::TextTag > output_tag
Definition: Console.hh:64
cadabra::Console::~Console
~Console()
Definition: Console.cc:158
cadabra::Console::collect
std::string collect
Definition: Console.hh:57
cadabra::Console::set_input
void set_input(const Glib::ustring &line, size_t range_start=std::string::npos, size_t range_end=std::string::npos)
Definition: Console.cc:291
cadabra::Console::insert_text
void insert_text(const std::string &text, Glib::RefPtr< Gtk::TextTag > tag)
Definition: Console.cc:309
cadabra::Console::Console
Console(sigc::slot< void > run_slot)
Definition: Console.cc:100
cadabra::Console::grab_input
std::string grab_input()
Definition: Console.cc:210
cadabra::Console::warning_tag
Glib::RefPtr< Gtk::TextTag > warning_tag
Definition: Console.hh:64
cadabra::Console::get_id
uint64_t get_id() const
Definition: Console.cc:341
cadabra::Console::insert_graphic
void insert_graphic(const std::string &bytes)
Definition: Console.cc:317
cadabra::Console::prompt_begin
Glib::RefPtr< Gtk::TextBuffer::Mark > prompt_begin
Definition: Console.hh:63
cadabra::Console::input_begin
Glib::RefPtr< Gtk::TextBuffer::Mark > input_begin
Definition: Console.hh:63
cadabra::Console::error_tag
Glib::RefPtr< Gtk::TextTag > error_tag
Definition: Console.hh:64
cadabra::TextViewProxy::parent
Console & parent
Definition: Console.hh:20
cadabra::TextViewProxy
Definition: Console.hh:11
cadabra::Console::get_buffer
Glib::RefPtr< Gtk::TextBuffer > get_buffer()
Definition: Console.cc:286
cadabra::Console::input
TextViewProxy input
Definition: Console.hh:61
cadabra::Console::prompt
void prompt(bool continuation, bool newline=false)
Definition: Console.cc:331
cadabra::Console::set_height
void set_height(int px)
Definition: Console.cc:171
cadabra::TextViewProxy::TextViewProxy
TextViewProxy(Console &parent)
Definition: Console.cc:23
cadabra::Console::signal_message
void signal_message(const Json::Value &msg)
Definition: Console.cc:217
cadabra::Console::send_input
void send_input(const std::string &code)
Definition: Console.cc:180
cadabra::Console::needs_focus
bool needs_focus
Definition: Console.hh:56
cadabra::TextViewProxy::on_key_press_event
bool on_key_press_event(GdkEventKey *key_event) override
Definition: Console.cc:31
cadabra::Console::initialize
void initialize()
Definition: Console.cc:163
cadabra::TextViewProxy::history
std::list< std::string > history
Definition: Console.hh:23
cadabra::Console
Definition: Console.hh:27
cadabra
Functions to handle the exchange properties of two or more symbols in a product.
Definition: Adjform.cc:80
cadabra::Console::dispatch_message
Glib::Dispatcher dispatch_message
Definition: Console.hh:52
cadabra::Console::tv
Gtk::TextView tv
Definition: Console.hh:62
cadabra::Console::run
Glib::Dispatcher run
Definition: Console.hh:53
cadabra::Console::id_
uint64_t id_
Definition: Console.hh:54
cadabra::Console::run_queue
std::queue< std::string > run_queue
Definition: Console.hh:59
cadabra::Console::input_tag
Glib::RefPtr< Gtk::TextTag > input_tag
Definition: Console.hh:64
cadabra::TextViewProxy::history_max_length
size_t history_max_length
Definition: Console.hh:15
cadabra::TextViewProxy::temp_in
std::string temp_in
Definition: Console.hh:22
cadabra::Console::win
Gtk::ScrolledWindow win
Definition: Console.hh:60
cadabra::Console::process_message_queue
void process_message_queue()
Definition: Console.cc:223
cadabra::Console::scroll_to_bottom
void scroll_to_bottom()
Definition: Console.cc:152
cadabra::Console::message_queue
std::queue< Json::Value > message_queue
Definition: Console.hh:58
cadabra::TextViewProxy::history_ptr
std::list< std::string >::iterator history_ptr
Definition: Console.hh:24