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 ()
 
virtual void runFile (const QString &filePath)
 

Signals

void aboutToExecute (const QString &)
 This signal emitted before and after a command is executed. More...
 
void cursorPositionChanged ()
 
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)
 
int cursorColumn () const
 
int cursorLine () const
 
int cursorPosition () const
 
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
 
int cursorColumn
 
int cursorLine
 
int cursorPosition
 
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

◆ Superclass

typedef QWidget ctkConsole::Superclass

Definition at line 110 of file ctkConsole.h.

Member Enumeration Documentation

◆ EditorHint

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 92 of file ctkConsole.h.

◆ RunFileOption

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 101 of file ctkConsole.h.

Constructor & Destructor Documentation

◆ ctkConsole() [1/2]

ctkConsole::ctkConsole ( QWidget *  parentObject = 0)

◆ ~ctkConsole()

virtual ctkConsole::~ctkConsole ( )
virtual

◆ ctkConsole() [2/2]

ctkConsole::ctkConsole ( ctkConsolePrivate *  pimpl,
QWidget *  parentObject 
)
protected

Member Function Documentation

◆ aboutToExecute

void ctkConsole::aboutToExecute ( const QString &  )
signal

This signal emitted before and after a command is executed.

◆ addCompleterShortcut()

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

◆ backgroundColor()

QColor ctkConsole::backgroundColor ( ) const

◆ clear

virtual void ctkConsole::clear ( )
virtualslot

Clears the contents of the console.

◆ commandTextColor()

QColor ctkConsole::commandTextColor ( ) const

◆ completer()

ctkConsoleCompleter* ctkConsole::completer ( ) const

Return the completer of this console.

◆ completerShortcuts()

QList<QKeySequence> ctkConsole::completerShortcuts ( ) const

Get the list of shortcuts that trigger the completion options.

See also
setCompleterShortcuts(), addCompleterShortcut()

◆ cursorColumn()

int ctkConsole::cursorColumn ( ) const

Returns the column of the cursor within the console.

See also
cursorPositionChanged(int)

◆ cursorLine()

int ctkConsole::cursorLine ( ) const

Returns the line of the cursor within the console.

See also
cursorPositionChanged(int)

◆ cursorPosition()

int ctkConsole::cursorPosition ( ) const

Returns the absolute position of the cursor within the console.

See also
cursorPositionChanged(int)

◆ cursorPositionChanged

void ctkConsole::cursorPositionChanged ( )
signal

This signal is emitted whenever the position of the cursor changed.

See also
cursorPosition()

◆ editorHints()

EditorHints ctkConsole::editorHints ( ) const

◆ errorTextColor()

QColor ctkConsole::errorTextColor ( ) const

◆ exec

virtual void ctkConsole::exec ( const QString &  )
virtualslot

Exec the contents of the last console line

See also
openFile(), runFile(QString)

◆ executeCommand()

virtual void ctkConsole::executeCommand ( const QString &  Command)
protectedvirtual

Called whenever the user enters a command.

Reimplemented in ctkPythonConsole.

◆ executed

void ctkConsole::executed ( const QString &  )
signal

◆ getFormat()

QTextCharFormat ctkConsole::getFormat ( ) const

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

◆ outputTextColor()

QColor ctkConsole::outputTextColor ( ) const

◆ printHelp

virtual void ctkConsole::printHelp ( )
virtualslot

Print the console help with shortcuts.

◆ printMessage()

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

Prints text on the console.

◆ promptColor()

QColor ctkConsole::promptColor ( ) const

◆ ps1()

virtual QString ctkConsole::ps1 ( ) const
virtual

Returns the string used as primary prompt.

Reimplemented in ctkPythonConsole.

◆ ps2()

virtual QString ctkConsole::ps2 ( ) const
virtual

Returns the string used as secondary prompt.

Reimplemented in ctkPythonConsole.

◆ readInputLine()

QString ctkConsole::readInputLine ( )
protected

Prompt the user for input.

◆ reset

virtual void ctkConsole::reset ( )
virtualslot

Clears the contents of the console and display welcome message.

◆ runFile [1/2]

virtual void ctkConsole::runFile ( )
virtualslot

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

See also
runFile(QString), exec()

◆ runFile [2/2]

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

Exec line by line the content of a file.

See also
openFile(), exec()

◆ runFileOptions()

RunFileOptions ctkConsole::runFileOptions ( ) const

◆ scrollBarPolicy()

Qt::ScrollBarPolicy ctkConsole::scrollBarPolicy ( ) const

◆ setBackgroundColor()

void ctkConsole::setBackgroundColor ( const QColor &  newColor)

◆ setCommandTextColor()

void ctkConsole::setCommandTextColor ( const QColor &  newColor)

◆ setCompleter()

void ctkConsole::setCompleter ( ctkConsoleCompleter completer)

Set a completer for this console.

◆ setCompleterShortcuts()

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

◆ setEditorHints()

void ctkConsole::setEditorHints ( const EditorHints &  newEditorHints)
See also
editorHints()

◆ setErrorTextColor()

void ctkConsole::setErrorTextColor ( const QColor &  newColor)

◆ setFormat()

void ctkConsole::setFormat ( const QTextCharFormat &  Format)

Sets formatting that will be used by printMessage()

◆ setOutputTextColor()

void ctkConsole::setOutputTextColor ( const QColor &  newColor)

◆ setPromptColor()

void ctkConsole::setPromptColor ( const QColor &  newColor)
See also
promptColor()

◆ setPs1()

virtual void ctkConsole::setPs1 ( const QString &  newPs1)
virtual

Set the string used as primary prompt.

Reimplemented in ctkPythonConsole.

◆ setPs2()

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

Set the string used as secondary prompt.

Reimplemented in ctkPythonConsole.

◆ setRunFileOptions()

void ctkConsole::setRunFileOptions ( const RunFileOptions &  newOptions)

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

See also
runFileOptions()

◆ setScrollBarPolicy()

void ctkConsole::setScrollBarPolicy ( const Qt::ScrollBarPolicy &  newScrollBarPolicy)

◆ setShellFont()

void ctkConsole::setShellFont ( const QFont &  font)

Sets font of python shell.

◆ setStdinTextColor()

void ctkConsole::setStdinTextColor ( const QColor &  newColor)

◆ setWelcomeTextColor()

void ctkConsole::setWelcomeTextColor ( const QColor &  newColor)

◆ shellFont()

QFont ctkConsole::shellFont ( ) const

Returns current font of python shell.

◆ stdInRedirectCallBack()

static QString ctkConsole::stdInRedirectCallBack ( void *  callData)
static

◆ stdinTextColor()

QColor ctkConsole::stdinTextColor ( ) const

◆ welcomeTextColor()

QColor ctkConsole::welcomeTextColor ( ) const

Member Data Documentation

◆ d_ptr

QScopedPointer<ctkConsolePrivate> ctkConsole::d_ptr
protected

Definition at line 270 of file ctkConsole.h.

Property Documentation

◆ backgroundColor

QColor ctkConsole::backgroundColor
readwrite

Definition at line 277 of file ctkConsole.h.

◆ commandTextColor

QColor ctkConsole::commandTextColor
readwrite

Definition at line 277 of file ctkConsole.h.

◆ completerShortcuts

QList<QKeySequence> ctkConsole::completerShortcuts
readwrite

Definition at line 277 of file ctkConsole.h.

◆ cursorColumn

int ctkConsole::cursorColumn
read

Definition at line 277 of file ctkConsole.h.

◆ cursorLine

int ctkConsole::cursorLine
read

Definition at line 277 of file ctkConsole.h.

◆ cursorPosition

int ctkConsole::cursorPosition
read

Definition at line 277 of file ctkConsole.h.

◆ editorHints

EditorHints ctkConsole::editorHints
readwrite

Definition at line 277 of file ctkConsole.h.

◆ errorTextColor

QColor ctkConsole::errorTextColor
readwrite

Definition at line 277 of file ctkConsole.h.

◆ outputTextColor

QColor ctkConsole::outputTextColor
readwrite

Definition at line 277 of file ctkConsole.h.

◆ promptColor

QColor ctkConsole::promptColor
readwrite

Definition at line 277 of file ctkConsole.h.

◆ ps1

QString ctkConsole::ps1
readwrite

Definition at line 277 of file ctkConsole.h.

◆ ps2

QString ctkConsole::ps2
readwrite

Definition at line 277 of file ctkConsole.h.

◆ runFileOptions

RunFileOptions ctkConsole::runFileOptions
readwrite

Definition at line 277 of file ctkConsole.h.

◆ scrollBarPolicy

Qt::ScrollBarPolicy ctkConsole::scrollBarPolicy
readwrite

Definition at line 277 of file ctkConsole.h.

◆ stdinTextColor

QColor ctkConsole::stdinTextColor
readwrite

Definition at line 277 of file ctkConsole.h.

◆ welcomeTextColor

QColor ctkConsole::welcomeTextColor
readwrite

Definition at line 277 of file ctkConsole.h.


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