Cadabra
Computer algebra system for field theory problems
|
A text cell editor widget with support for editing Python and LaTeX.
CodeInput is essentially a TextView with some additional i/o logic.
#include <CodeInput.hh>
Classes | |
class | exp_input_tv |
The actual text widget used by CodeInput. More... | |
Public Types | |
using | Prefs = cadabra::DocumentThread::Prefs |
Public Member Functions | |
CodeInput (DTree::iterator, Glib::RefPtr< Gtk::TextBuffer >, double scale, const Prefs &prefs) | |
Initialise with existing TextBuffer and a pointer to the Datacell corresponding to this CodeInput widget. More... | |
CodeInput (DTree::iterator, const std::string &, double scale, const Prefs &prefs) | |
Initialise with a new TextBuffer (to be created by CodeInput), filling it with the content of the given string. More... | |
void | enable_highlighting (DataCell::CellType cell_type, const Prefs &prefs) |
Set highlighting modes. More... | |
void | disable_highlighting () |
void | relay_cursor_pos (std::function< void(int, int)> callback) |
bool | handle_button_press (GdkEventButton *) |
Handle mouse buttons. More... | |
void | handle_insert (const Gtk::TextIter &pos, const Glib::ustring &text, int bytes) |
Handle an insert event, which can consist of one or more inserted characters. More... | |
void | handle_erase (const Gtk::TextIter &start, const Gtk::TextIter &end) |
Handle an erase event. More... | |
void | update_buffer () |
Ensure that the visual representation matches the DTree cell. More... | |
void | slice_cell (std::string &before, std::string &after) |
Return two strings corresponding to the text before and after the current cursor position. More... | |
Public Attributes | |
Glib::RefPtr< Gtk::TextBuffer > | buffer |
We cannot edit the content of the DataCell directly, because Gtk needs a Gtk::TextBuffer. More... | |
exp_input_tv | edit |
Private Member Functions | |
void | init (const Prefs &prefs) |
void | highlight_python () |
void | highlight_latex () |
Private Attributes | |
sigc::connection | hl_conn |
CodeInput::CodeInput | ( | DTree::iterator | it, |
Glib::RefPtr< Gtk::TextBuffer > | tb, | ||
double | scale, | ||
const Prefs & | prefs | ||
) |
Initialise with existing TextBuffer and a pointer to the Datacell corresponding to this CodeInput widget.
CodeInput is not allowed to modify this DataCell directly, but can read properties from it (e.g. in order to know when to display a 'busy' indicator). The scale parameter refers to hdpi scaling.
CodeInput::CodeInput | ( | DTree::iterator | it, |
const std::string & | txt, | ||
double | scale, | ||
const Prefs & | prefs | ||
) |
Initialise with a new TextBuffer (to be created by CodeInput), filling it with the content of the given string.
void CodeInput::disable_highlighting | ( | ) |
void CodeInput::enable_highlighting | ( | DataCell::CellType | cell_type, |
const Prefs & | prefs | ||
) |
Set highlighting modes.
bool CodeInput::handle_button_press | ( | GdkEventButton * | button | ) |
Handle mouse buttons.
void CodeInput::handle_erase | ( | const Gtk::TextIter & | start, |
const Gtk::TextIter & | end | ||
) |
Handle an erase event.
This function will just massage that data and then feed it through to the notebook window class by emitting a signal on content_erase (done like this to separate DTree modification from the widget).
void CodeInput::handle_insert | ( | const Gtk::TextIter & | pos, |
const Glib::ustring & | text, | ||
int | bytes | ||
) |
Handle an insert event, which can consist of one or more inserted characters.
This function will just massage that data and then feed it through to the notebook window class by emitting a signal on content_insert (done like this to separate DTree modification from the widget).
|
private |
|
private |
|
private |
void CodeInput::relay_cursor_pos | ( | std::function< void(int, int)> | callback | ) |
void CodeInput::slice_cell | ( | std::string & | before, |
std::string & | after | ||
) |
Return two strings corresponding to the text before and after the current cursor position.
void CodeInput::update_buffer | ( | ) |
Ensure that the visual representation matches the DTree cell.
Glib::RefPtr<Gtk::TextBuffer> cadabra::CodeInput::buffer |
exp_input_tv cadabra::CodeInput::edit |
|
private |