Cadabra
Computer algebra system for field theory problems
Classes | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
cadabra::CodeInput Class Reference

Description

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>

Inheritance diagram for cadabra::CodeInput:

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
 

Member Typedef Documentation

◆ Prefs

Constructor & Destructor Documentation

◆ CodeInput() [1/2]

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() [2/2]

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.

Member Function Documentation

◆ disable_highlighting()

void CodeInput::disable_highlighting ( )

◆ enable_highlighting()

void CodeInput::enable_highlighting ( DataCell::CellType  cell_type,
const Prefs prefs 
)

Set highlighting modes.

◆ handle_button_press()

bool CodeInput::handle_button_press ( GdkEventButton *  button)

Handle mouse buttons.

◆ handle_erase()

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).

◆ handle_insert()

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).

◆ highlight_latex()

void CodeInput::highlight_latex ( )
private

◆ highlight_python()

void CodeInput::highlight_python ( )
private

◆ init()

void CodeInput::init ( const Prefs prefs)
private

◆ relay_cursor_pos()

void CodeInput::relay_cursor_pos ( std::function< void(int, int)>  callback)

◆ slice_cell()

void CodeInput::slice_cell ( std::string &  before,
std::string &  after 
)

Return two strings corresponding to the text before and after the current cursor position.

◆ update_buffer()

void CodeInput::update_buffer ( )

Ensure that the visual representation matches the DTree cell.

Member Data Documentation

◆ buffer

Glib::RefPtr<Gtk::TextBuffer> cadabra::CodeInput::buffer

We cannot edit the content of the DataCell directly, because Gtk needs a Gtk::TextBuffer.

However, the CodeInput widgets corresponding to a single DataCell all share their TextBuffer.

◆ edit

exp_input_tv cadabra::CodeInput::edit

◆ hl_conn

sigc::connection cadabra::CodeInput::hl_conn
private

The documentation for this class was generated from the following files: