CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Properties | List of all members
ctkConsole Class Reference

#include <Libs/Widgets/ctkConsole.h>

Inheritance diagram for ctkConsole:
Inheritance graph
[legend]
Collaboration diagram for ctkConsole:
Collaboration graph
[legend]

Public Types

enum  EditorHint { NoHints = 0x00, AutomaticIndentation = 0x01, RemoveTrailingSpaces = 0x02, SplitCopiedTextByLine = 0x4 }
 
enum  RunFileOption { NoRunFileUserInterface = 0x00, RunFileButton = 0x01, RunFileShortcut = 0x02 }
 
typedef QWidget Superclass
 

Public Slots

virtual void clear ()
 Clears the contents of the console. More...
 
virtual void exec (const QString &)
 
virtual void printHelp ()
 Print the console help with shortcuts. More...
 
virtual void reset ()
 Clears the contents of the console and display welcome message. More...
 
virtual void runFile (const QString &filePath)
 
virtual void runFile ()
 

Signals

void aboutToExecute (const QString &)
 This signal emitted before and after a command is executed. More...
 
void executed (const QString &)
 

Public Member Functions

void addCompleterShortcut (const QKeySequence &key)
 
QColor backgroundColor () const
 
QColor commandTextColor () const
 
ctkConsoleCompletercompleter () const
 Return the completer of this console. More...
 
QList< QKeySequence > completerShortcuts () const
 
 ctkConsole (QWidget *parentObject=0)
 
EditorHints editorHints () const
 
QColor errorTextColor () const
 
QTextCharFormat getFormat () const
 Returns the current formatting that will be used by printMessage() More...
 
QColor outputTextColor () const
 
void printMessage (const QString &message, const QColor &color)
 Prints text on the console. More...
 
QColor promptColor () const
 
virtual QString ps1 () const
 Returns the string used as primary prompt. More...
 
virtual QString ps2 () const
 Returns the string used as secondary prompt. More...
 
RunFileOptions runFileOptions () const
 
Qt::ScrollBarPolicy scrollBarPolicy () const
 
void setBackgroundColor (const QColor &newColor)
 
void setCommandTextColor (const QColor &newColor)
 
void setCompleter (ctkConsoleCompleter *completer)
 Set a completer for this console. More...
 
void setCompleterShortcuts (const QList< QKeySequence > &keys)
 
void setEditorHints (const EditorHints &newEditorHints)
 
void setErrorTextColor (const QColor &newColor)
 
void setFormat (const QTextCharFormat &Format)
 Sets formatting that will be used by printMessage() More...
 
void setOutputTextColor (const QColor &newColor)
 
void setPromptColor (const QColor &newColor)
 
virtual void setPs1 (const QString &newPs1)
 Set the string used as primary prompt. More...
 
virtual void setPs2 (const QString &newPs2)
 Set the string used as secondary prompt. More...
 
void setRunFileOptions (const RunFileOptions &newOptions)
 
void setScrollBarPolicy (const Qt::ScrollBarPolicy &newScrollBarPolicy)
 
void setShellFont (const QFont &font)
 Sets font of python shell. More...
 
void setStdinTextColor (const QColor &newColor)
 
void setWelcomeTextColor (const QColor &newColor)
 
QFont shellFont () const
 Returns current font of python shell. More...
 
QColor stdinTextColor () const
 
QColor welcomeTextColor () const
 
virtual ~ctkConsole ()
 

Static Public Member Functions

static QString stdInRedirectCallBack (void *callData)
 

Protected Member Functions

 ctkConsole (ctkConsolePrivate *pimpl, QWidget *parentObject)
 
virtual void executeCommand (const QString &Command)
 Called whenever the user enters a command. More...
 
QString readInputLine ()
 Prompt the user for input. More...
 

Protected Attributes

QScopedPointer< ctkConsolePrivate > d_ptr
 

Properties

QColor backgroundColor
 
QColor commandTextColor
 
QList< QKeySequence > completerShortcuts
 
EditorHints editorHints
 
QColor errorTextColor
 
QColor outputTextColor
 
QColor promptColor
 
QString ps1
 
QString ps2
 
RunFileOptions runFileOptions
 
Qt::ScrollBarPolicy scrollBarPolicy
 
QColor stdinTextColor
 
QColor welcomeTextColor
 

Detailed Description

QWidget that provides an interactive console

Definition at line 67 of file ctkConsole.h.

Member Typedef Documentation

typedef QWidget ctkConsole::Superclass

Definition at line 107 of file ctkConsole.h.

Member Enumeration Documentation

Enumerator
NoHints 
AutomaticIndentation 

Align cursor based an indentation of the previous command

RemoveTrailingSpaces 

Remove trailing spaces of the entered command

SplitCopiedTextByLine 

Copied text is split by lines and each one is executed (expected the last one)

Definition at line 89 of file ctkConsole.h.

Enumerator
NoRunFileUserInterface 
RunFileButton 

Show a button at the bottom of the console to run a file

RunFileShortcut 

Add the shortcut CTRL+r to run a file

Definition at line 98 of file ctkConsole.h.

Constructor & Destructor Documentation

ctkConsole::ctkConsole ( QWidget *  parentObject = 0)
virtual ctkConsole::~ctkConsole ( )
virtual
ctkConsole::ctkConsole ( ctkConsolePrivate *  pimpl,
QWidget *  parentObject 
)
protected

Member Function Documentation

void ctkConsole::aboutToExecute ( const QString &  )
signal

This signal emitted before and after a command is executed.

void ctkConsole::addCompleterShortcut ( const QKeySequence &  key)

Convenience method to add a key sequence to the list of shortcuts that show the completion options.

See also
completerShortcuts(), setCompleterShortcuts()
QColor ctkConsole::backgroundColor ( ) const
virtual void ctkConsole::clear ( )
virtualslot

Clears the contents of the console.

QColor ctkConsole::commandTextColor ( ) const
ctkConsoleCompleter* ctkConsole::completer ( ) const

Return the completer of this console.

QList<QKeySequence> ctkConsole::completerShortcuts ( ) const

Get the list of shortcuts that trigger the completion options.

See also
setCompleterShortcuts(), addCompleterShortcut()
EditorHints ctkConsole::editorHints ( ) const
QColor ctkConsole::errorTextColor ( ) const
virtual void ctkConsole::exec ( const QString &  )
virtualslot

Exec the contents of the last console line

See also
openFile(), runFile(QString)
virtual void ctkConsole::executeCommand ( const QString &  Command)
protectedvirtual

Called whenever the user enters a command.

Reimplemented in ctkPythonConsole.

void ctkConsole::executed ( const QString &  )
signal
QTextCharFormat ctkConsole::getFormat ( ) const

Returns the current formatting that will be used by printMessage()

QColor ctkConsole::outputTextColor ( ) const
virtual void ctkConsole::printHelp ( )
virtualslot

Print the console help with shortcuts.

void ctkConsole::printMessage ( const QString &  message,
const QColor &  color 
)

Prints text on the console.

QColor ctkConsole::promptColor ( ) const
virtual QString ctkConsole::ps1 ( ) const
virtual

Returns the string used as primary prompt.

Reimplemented in ctkPythonConsole.

virtual QString ctkConsole::ps2 ( ) const
virtual

Returns the string used as secondary prompt.

Reimplemented in ctkPythonConsole.

QString ctkConsole::readInputLine ( )
protected

Prompt the user for input.

virtual void ctkConsole::reset ( )
virtualslot

Clears the contents of the console and display welcome message.

virtual void ctkConsole::runFile ( const QString &  filePath)
virtualslot

Exec line by line the content of a file.

See also
openFile(), exec()
virtual void ctkConsole::runFile ( )
virtualslot

Open a file dialog to select a file and run it. Shortcut: CTRL+O

See also
runFile(QString), exec()
RunFileOptions ctkConsole::runFileOptions ( ) const
Qt::ScrollBarPolicy ctkConsole::scrollBarPolicy ( ) const
void ctkConsole::setBackgroundColor ( const QColor &  newColor)
void ctkConsole::setCommandTextColor ( const QColor &  newColor)
void ctkConsole::setCompleter ( ctkConsoleCompleter completer)

Set a completer for this console.

void ctkConsole::setCompleterShortcuts ( const QList< QKeySequence > &  keys)

Set the list of shortcuts showing the completion options. Default is simply Qt::Key_Tab.

See also
completerShortcuts(), addCompleterShortcut()
void ctkConsole::setEditorHints ( const EditorHints &  newEditorHints)
See also
editorHints()
void ctkConsole::setErrorTextColor ( const QColor &  newColor)
void ctkConsole::setFormat ( const QTextCharFormat &  Format)

Sets formatting that will be used by printMessage()

void ctkConsole::setOutputTextColor ( const QColor &  newColor)
void ctkConsole::setPromptColor ( const QColor &  newColor)
See also
promptColor()
virtual void ctkConsole::setPs1 ( const QString &  newPs1)
virtual

Set the string used as primary prompt.

Reimplemented in ctkPythonConsole.

virtual void ctkConsole::setPs2 ( const QString &  newPs2)
virtual

Set the string used as secondary prompt.

Reimplemented in ctkPythonConsole.

void ctkConsole::setRunFileOptions ( const RunFileOptions &  newOptions)

Set which options to run file are enabled. Default is RunFileShortcut.

See also
runFileOptions()
void ctkConsole::setScrollBarPolicy ( const Qt::ScrollBarPolicy &  newScrollBarPolicy)
void ctkConsole::setShellFont ( const QFont &  font)

Sets font of python shell.

void ctkConsole::setStdinTextColor ( const QColor &  newColor)
void ctkConsole::setWelcomeTextColor ( const QColor &  newColor)
QFont ctkConsole::shellFont ( ) const

Returns current font of python shell.

static QString ctkConsole::stdInRedirectCallBack ( void *  callData)
static
QColor ctkConsole::stdinTextColor ( ) const
QColor ctkConsole::welcomeTextColor ( ) const

Member Data Documentation

QScopedPointer<ctkConsolePrivate> ctkConsole::d_ptr
protected

Definition at line 251 of file ctkConsole.h.

Property Documentation

QColor ctkConsole::backgroundColor
readwrite

Definition at line 76 of file ctkConsole.h.

QColor ctkConsole::commandTextColor
readwrite

Definition at line 74 of file ctkConsole.h.

QList<QKeySequence> ctkConsole::completerShortcuts
readwrite

Definition at line 83 of file ctkConsole.h.

EditorHints ctkConsole::editorHints
readwrite

Definition at line 80 of file ctkConsole.h.

QColor ctkConsole::errorTextColor
readwrite

Definition at line 72 of file ctkConsole.h.

QColor ctkConsole::outputTextColor
readwrite

Definition at line 71 of file ctkConsole.h.

QColor ctkConsole::promptColor
readwrite

Definition at line 70 of file ctkConsole.h.

QString ctkConsole::ps1
readwrite

Definition at line 77 of file ctkConsole.h.

QString ctkConsole::ps2
readwrite

Definition at line 78 of file ctkConsole.h.

RunFileOptions ctkConsole::runFileOptions
readwrite

Definition at line 85 of file ctkConsole.h.

Qt::ScrollBarPolicy ctkConsole::scrollBarPolicy
readwrite

Definition at line 82 of file ctkConsole.h.

QColor ctkConsole::stdinTextColor
readwrite

Definition at line 73 of file ctkConsole.h.

QColor ctkConsole::welcomeTextColor
readwrite

Definition at line 75 of file ctkConsole.h.


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