Console class reference
[Base module]

Declaration  

#include <QtLua/Console>

namespace QtLua {
class Console;
};

This class is a member of the QtLua namespace.

Description  

This class provides an easy to use console widget for use in QtLua based applications.

This widget is a general purpose console widget with history and completion capabilities.

The qtlua interpreter uses this widget.

When used with a State lua interpreter object, it only needs a few signals connections to get a working lua based shell:

// code from examples/cpp/console/console.cc:25

MainWindow::MainWindow()
: QMainWindow()
{
state = new QtLua::State();
console = new QtLua::Console();

setCentralWidget(console);

connect(console, SIGNAL(line_validate(const QString&)),
state, SLOT(exec(const QString&)));

connect(console, SIGNAL(get_completion_list(const QString &, QStringList &, int &)),
state, SLOT(fill_completion_list(const QString &, QStringList &, int &)));

connect(state, SIGNAL(output(const QString&)),
console, SLOT(print(const QString&)));
}

Members  

Functions  

Slot  

  • void print(const QString &str)

Signals  

Members detail  

Console(QWidget *parent = 0, const QString &prompt = QString("$"), const QStringList &history = QStringList())  

Create a console widget and restore history

void get_completion_list(const QString &prefix, QStringList &list, int &cursor_offset)  

This member is a Qt signal.

Signal emited to query completion list.

Parameters list:

  • prefix: text extracted before cursor.
  • list: must be filled with completion matches by completion slot function.
  • cursor_offset: may be decreased by completion slot function to move cursor backward on completed text. (only used on single match)

const QStringList & get_history() const  

Get current history.

int get_history_size() const  

Get console max history entries count

const QString & get_prompt() const  

Get console prompt.

int get_scroll_back() const  

Get number of lines in the scrollback buffer.

int get_text_height() const  

Get console height in character count

int get_text_width() const  

Get console width in character count

void line_validate(const QString &str)  

This member is a Qt signal.

Signal emited when text line is validated with enter key

void load_history(QSettings &s, const QString &key = "qtlua_console_history")  

Load history from QSettings object and keep a QPointer to QSettings for subsequent call to the Console::save_history function.

void print(const QString &str)  

This member is a Qt slot.

Display text on the console

void save_history(QSettings &s, const QString &key = "qtlua_console_history") const  

Save history using QSettings object previously passed to Console::load_history function.

void set_completion_regexp(const QRegExp &regexp)  

Set Qt regular expression used to extract text before cursor to pass to completion signal.

The default regexp [_.:a-zA-Z0-9]+$ is suited to extract lua identifiers and table member access statements.

void set_history(const QStringList &h)  

Set current history.

void set_history_size(int history_size)  

Set console max history entries count

void set_prompt(const QString &p)  

Set console prompt.

void set_scroll_back(int scroll_back)  

Set number of lines in the scrollback buffer. Changes will take effect next time a line is entered or a Console::print is performed. Default value is 1000.

void set_text_height(int height)  

Set console height in character count

void set_text_width(int width)  

Set console width in character count

Valid XHTML 1.0 StrictGenerated by diaxen on Sat Mar 30 15:29:54 2013 using MkDoc