te::qt::widgets::IOWidget Class Reference

#include <IOWidget.h>

Inheritance diagram for te::qt::widgets::IOWidget:
QPlainTextEdit

Public Slots

void addPrompt ()
 addPrompt Adds the prompt to the text edit and unlocks the widget for input More...
 
void append (QString text)
 append Appends the given text to the text edit and locks the widget for input More...
 

Signals

void command (QString command)
 command Signal emitted when input is entered. More...
 

Public Member Functions

 IOWidget (QWidget *parent=0)
 
QString prompt () const
 prompt Retrieves the current prompt. More...
 
void setPrompt (const QString &prompt)
 setPrompt Sets a new prompt from a given string. More...
 

Protected Member Functions

void keyPressEvent (QKeyEvent *e)
 

Private Member Functions

void clearLine ()
 clearLine Clears the line under the cursor. More...
 
QString getCommand () const
 getCommand Gets the input from the user. More...
 
int getIndex (const QTextCursor &cursor)
 getIndex Gets the index of a given cursor. More...
 
void handleEnter ()
 handleEnter Handles Enter and Return key press. More...
 
void handleHome ()
 handleHome Handles Home key press. More...
 
void handleLeft (QKeyEvent *event)
 handleLeft Handles Left arrow key press. More...
 
bool isWritable (const QTextCursor &cursor)
 isWritable Checks if a given cursor is at a writable position. More...
 

Private Attributes

int lastIndex
 lastIndex The index of the last character. More...
 
bool locked
 locked False if the text edit can receive input, true otherwise. More...
 
QString userPrompt
 userPrompt prompt to indicate that the text edit is waiting for input More...
 

Detailed Description

Definition at line 46 of file IOWidget.h.

Constructor & Destructor Documentation

te::qt::widgets::IOWidget::IOWidget ( QWidget parent = 0)

Definition at line 37 of file IOWidget.cpp.

References getIndex(), and lastIndex.

Member Function Documentation

void te::qt::widgets::IOWidget::addPrompt ( )
slot

addPrompt Adds the prompt to the text edit and unlocks the widget for input

Definition at line 88 of file IOWidget.cpp.

References locked, and userPrompt.

void te::qt::widgets::IOWidget::append ( QString  text)
slot

append Appends the given text to the text edit and locks the widget for input

Parameters
textString to be appended

Definition at line 96 of file IOWidget.cpp.

References getIndex(), lastIndex, and locked.

Referenced by te::ce::CodeEditorDialog::onRunFinished().

void te::qt::widgets::IOWidget::clearLine ( )
private

clearLine Clears the line under the cursor.

Definition at line 104 of file IOWidget.cpp.

Referenced by setPrompt().

void te::qt::widgets::IOWidget::command ( QString  command)
signal

command Signal emitted when input is entered.

Parameters
commandString to be emitted.

Referenced by handleEnter().

QString te::qt::widgets::IOWidget::getCommand ( ) const
private

getCommand Gets the input from the user.

Definition at line 111 of file IOWidget.cpp.

References lastIndex, and userPrompt.

Referenced by handleEnter().

int te::qt::widgets::IOWidget::getIndex ( const QTextCursor &  cursor)
private

getIndex Gets the index of a given cursor.

Parameters
cursorCursor used to retrieve the index.

Definition at line 139 of file IOWidget.cpp.

References b.

Referenced by append(), handleEnter(), handleLeft(), IOWidget(), and isWritable().

void te::qt::widgets::IOWidget::handleEnter ( )
private

handleEnter Handles Enter and Return key press.

Definition at line 68 of file IOWidget.cpp.

References command(), getCommand(), getIndex(), lastIndex, and prompt().

Referenced by keyPressEvent().

void te::qt::widgets::IOWidget::handleHome ( )
private

handleHome Handles Home key press.

Definition at line 130 of file IOWidget.cpp.

References te::at::Right, and userPrompt.

Referenced by keyPressEvent().

void te::qt::widgets::IOWidget::handleLeft ( QKeyEvent *  event)
private

handleLeft Handles Left arrow key press.

Parameters
eventThe received event.

Definition at line 122 of file IOWidget.cpp.

References getIndex(), and userPrompt.

Referenced by keyPressEvent().

bool te::qt::widgets::IOWidget::isWritable ( const QTextCursor &  cursor)
private

isWritable Checks if a given cursor is at a writable position.

Parameters
cursorCursor that will be checked.

Definition at line 159 of file IOWidget.cpp.

References te::at::End, getIndex(), locked, and prompt().

Referenced by keyPressEvent().

void te::qt::widgets::IOWidget::keyPressEvent ( QKeyEvent *  e)
protected

Definition at line 44 of file IOWidget.cpp.

References handleEnter(), handleHome(), handleLeft(), and isWritable().

QString te::qt::widgets::IOWidget::prompt ( ) const

prompt Retrieves the current prompt.

Definition at line 154 of file IOWidget.cpp.

References userPrompt.

Referenced by handleEnter(), isWritable(), and setPrompt().

void te::qt::widgets::IOWidget::setPrompt ( const QString &  prompt)

setPrompt Sets a new prompt from a given string.

Parameters
promptString of the new prompt

Definition at line 148 of file IOWidget.cpp.

References clearLine(), prompt(), and userPrompt.

Member Data Documentation

int te::qt::widgets::IOWidget::lastIndex
private

lastIndex The index of the last character.

Definition at line 121 of file IOWidget.h.

Referenced by append(), getCommand(), handleEnter(), and IOWidget().

bool te::qt::widgets::IOWidget::locked
private

locked False if the text edit can receive input, true otherwise.

Definition at line 116 of file IOWidget.h.

Referenced by addPrompt(), append(), and isWritable().

QString te::qt::widgets::IOWidget::userPrompt
private

userPrompt prompt to indicate that the text edit is waiting for input

Definition at line 110 of file IOWidget.h.

Referenced by addPrompt(), getCommand(), handleHome(), handleLeft(), prompt(), and setPrompt().


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