# eric4.QScintilla.Terminal

Module implementing a simple terminal based on QScintilla.

### Global Attributes

None

### Classes

Terminal | Class implementing a simple terminal based on QScintilla.

### Functions

None

## Terminal

Class implementing a simple terminal based on QScintilla.

A user can enter commands that are executed by a shell process.

### Derived from

QsciScintillaCompat

### Class Attributes

None

### Methods

Terminal | Constructor
__QScintillaCharLeft | Private method to handle the Cursor Left command.
__QScintillaCharLeftExtend | Private method to handle the Extend Selection Left command.
__QScintillaCharRight | Private method to handle the Cursor Right command.
__QScintillaDelete | Private method to handle the delete command.
__QScintillaDeleteBack | Private method to handle the Backspace key.
__QScintillaDeleteLineLeft | Private method to handle the Delete Line Left command.
__QScintillaDeleteLineRight | Private method to handle the Delete Line Right command.
__QScintillaDeleteWordLeft | Private method to handle the Delete Word Left command.
__QScintillaDeleteWordRight | Private method to handle the Delete Word Right command.
__QScintillaLeftCommand | Private method to handle a QScintilla command working to the left.
__QScintillaLeftDeleteCommand | Private method to handle a QScintilla delete command working to the left.
__QScintillaLineDown | Private method to handle the Down key.
__QScintillaLineEnd | Private method to handle the End key.
__QScintillaLineUp | Private method to handle the Up key.
__QScintillaNewline | Private method to handle the Return key.
__QScintillaRightCommand | Private method to handle a QScintilla command working to the right.
__QScintillaVCHome | Private method to handle the Home key.
__QScintillaVCHomeExtend | Private method to handle the Extend Selection to start of line command.
__QScintillaWordLeft | Private method to handle the Cursor Word Left command.
__QScintillaWordLeftExtend | Private method to handle the Extend Selection Left one word command.
__QScintillaWordRight | Private method to handle the Cursor Word Right command.
__bindLexer | Private slot to set the lexer.
__clearCurrentLine | Private method to clear the line containing the cursor.
__clearHistory | Private slot to clear the current history.
__configure | Private method to open the configuration dialog.
__executeCommand | Private slot to execute a command.
__finished | Private method called, when the shell process has finished.
__getEndPos | Private method to return the line and column of the last character.
__insertHistory | Private method to insert a command selected from the history.
__insertText | Private method to insert some text at the current cursor position.
__insertTextAtEnd | Private method to insert some text at the end of the command line.
__isCursorOnLastLine | Private method to check, if the cursor is on the last line.
__readOutput | Private method to process the output of the shell.
__reset | Private slot to handle the 'reset' context menu entry.
__rsearchHistory | Private method used to reverse search the history.
__searchHistory | Private method used to search the history.
__selectHistory | Private slot to select a history entry to execute.
__send | Private method to send data to the shell process.
__sendCtrl | Private slot to send a control command to the shell process.
__setMargin0 | Private method to configure margin 0.
__setMonospaced | Private method to set/reset a monospaced font.
__setTextDisplay | Private method to configure the text display.
__showHistory | Private slot to show the shell history dialog.
__startShell | Private slot to start the shell process.
__started | Private method called, when the shell process has started.
__stopShell | Private slot to stop the shell process.
__useHistory | Private method to display a command from the history.
__write | Private method to display some text.
clear | Public slot to clear the display.
closeTerminal | Public method to shutdown the terminal.
contextMenuEvent | Reimplemented to show our own context menu.
editorCommand | Public method to perform an editor command.
focusInEvent | Public method called when the shell receives focus.
focusOutEvent | Public method called when the shell loses focus.
getHistory | Public method to get the history.
handlePreferencesChanged | Public slot to handle the preferencesChanged signal.
insert | Public slot to insert text at the current cursor position.
keyPressEvent | Re-implemented to handle the user input a key at a time.
loadHistory | Public method to load the history.
mousePressEvent | Protected method to handle the mouse press event.
reloadHistory | Public method to reload the history.
saveHistory | Public method to save the history.

#### Terminal (Constructor)

Terminal(vm, parent = None)

Constructor

vm
  reference to the viewmanager object
parent
  parent widget (QWidget)

#### Terminal.__QScintillaCharLeft

__QScintillaCharLeft()

Private method to handle the Cursor Left command.

#### Terminal.__QScintillaCharLeftExtend

__QScintillaCharLeftExtend()

Private method to handle the Extend Selection Left command.

#### Terminal.__QScintillaCharRight

__QScintillaCharRight()

Private method to handle the Cursor Right command.

#### Terminal.__QScintillaDelete

__QScintillaDelete()

Private method to handle the delete command.

#### Terminal.__QScintillaDeleteBack

__QScintillaDeleteBack()

Private method to handle the Backspace key.

#### Terminal.__QScintillaDeleteLineLeft

__QScintillaDeleteLineLeft()

Private method to handle the Delete Line Left command.

#### Terminal.__QScintillaDeleteLineRight

__QScintillaDeleteLineRight()

Private method to handle the Delete Line Right command.

#### Terminal.__QScintillaDeleteWordLeft

__QScintillaDeleteWordLeft()

Private method to handle the Delete Word Left command.

#### Terminal.__QScintillaDeleteWordRight

__QScintillaDeleteWordRight()

Private method to handle the Delete Word Right command.

#### Terminal.__QScintillaLeftCommand

__QScintillaLeftCommand(method, allLinesAllowed = False)

Private method to handle a QScintilla command working to the left.

method
  shell method to execute

#### Terminal.__QScintillaLeftDeleteCommand

__QScintillaLeftDeleteCommand(method)

Private method to handle a QScintilla delete command working to the left.

method
  shell method to execute

#### Terminal.__QScintillaLineDown

__QScintillaLineDown(cmd)

Private method to handle the Down key.

cmd
  QScintilla command

#### Terminal.__QScintillaLineEnd

__QScintillaLineEnd(cmd)

Private method to handle the End key.

cmd
  QScintilla command

#### Terminal.__QScintillaLineUp

__QScintillaLineUp(cmd)

Private method to handle the Up key.

cmd
  QScintilla command

#### Terminal.__QScintillaNewline

__QScintillaNewline(cmd)

Private method to handle the Return key.

cmd
  QScintilla command

#### Terminal.__QScintillaRightCommand

__QScintillaRightCommand(method)

Private method to handle a QScintilla command working to the right.

method
  shell method to execute

#### Terminal.__QScintillaVCHome

__QScintillaVCHome(cmd)

Private method to handle the Home key.

cmd
  QScintilla command

#### Terminal.__QScintillaVCHomeExtend

__QScintillaVCHomeExtend()

Private method to handle the Extend Selection to start of line command.

#### Terminal.__QScintillaWordLeft

__QScintillaWordLeft()

Private method to handle the Cursor Word Left command.

#### Terminal.__QScintillaWordLeftExtend

__QScintillaWordLeftExtend()

Private method to handle the Extend Selection Left one word command.

#### Terminal.__QScintillaWordRight

__QScintillaWordRight()

Private method to handle the Cursor Word Right command.

#### Terminal.__bindLexer

__bindLexer()

Private slot to set the lexer.

#### Terminal.__clearCurrentLine

__clearCurrentLine()

Private method to clear the line containing the cursor.

#### Terminal.__clearHistory

__clearHistory()

Private slot to clear the current history.

#### Terminal.__configure

__configure()

Private method to open the configuration dialog.

#### Terminal.__executeCommand

__executeCommand(cmd)

Private slot to execute a command.

cmd
  command to be executed by debug client (string)

#### Terminal.__finished

__finished()

Private method called, when the shell process has finished.

#### Terminal.__getEndPos

__getEndPos()

Private method to return the line and column of the last character.

Returns:
  tuple of two values (int, int) giving the line and column

#### Terminal.__insertHistory

__insertHistory(cmd)

Private method to insert a command selected from the history.

cmd
  history entry to be inserted (string or QString)

#### Terminal.__insertText

__insertText(s)

Private method to insert some text at the current cursor position.

s
  text to be inserted (string or QString)

#### Terminal.__insertTextAtEnd

__insertTextAtEnd(s)

Private method to insert some text at the end of the command line.

s
  text to be inserted (string or QString)

#### Terminal.__isCursorOnLastLine

__isCursorOnLastLine()

Private method to check, if the cursor is on the last line.

#### Terminal.__readOutput

__readOutput()

Private method to process the output of the shell.

#### Terminal.__reset

__reset()

Private slot to handle the 'reset' context menu entry.

#### Terminal.__rsearchHistory

__rsearchHistory(txt, startIdx = -1)

Private method used to reverse search the history.

txt
  text to match at the beginning (string or QString)
startIdx
  index to start search from (integer)

Returns:
  index of

#### Terminal.__searchHistory

__searchHistory(txt, startIdx = -1)

Private method used to search the history.

txt
  text to match at the beginning (string or QString)
startIdx
  index to start search from (integer)

Returns:
  index of

#### Terminal.__selectHistory

__selectHistory()

Private slot to select a history entry to execute.

#### Terminal.__send

__send(data)

Private method to send data to the shell process.

data
  data to be sent to the shell process (string or QString)

#### Terminal.__sendCtrl

__sendCtrl(cmd)

Private slot to send a control command to the shell process.

the
  control command to be sent (integer)

#### Terminal.__setMargin0

__setMargin0()

Private method to configure margin 0.

#### Terminal.__setMonospaced

__setMonospaced(on)

Private method to set/reset a monospaced font.

on
  flag to indicate usage of a monospace font (boolean)

#### Terminal.__setTextDisplay

__setTextDisplay()

Private method to configure the text display.

#### Terminal.__showHistory

__showHistory()

Private slot to show the shell history dialog.

#### Terminal.__startShell

__startShell()

Private slot to start the shell process.

#### Terminal.__started

__started()

Private method called, when the shell process has started.

#### Terminal.__stopShell

__stopShell()

Private slot to stop the shell process.

#### Terminal.__useHistory

__useHistory()

Private method to display a command from the history.

#### Terminal.__write

__write(s)

Private method to display some text.

s
  text to be displayed (string or QString)

#### Terminal.clear

clear()

Public slot to clear the display.

#### Terminal.closeTerminal

closeTerminal()

Public method to shutdown the terminal.

#### Terminal.contextMenuEvent

contextMenuEvent(ev)

Reimplemented to show our own context menu.

ev
  context menu event (QContextMenuEvent)

#### Terminal.editorCommand

editorCommand(cmd)

Public method to perform an editor command.

cmd
  the scintilla command to be performed

#### Terminal.focusInEvent

focusInEvent(event)

Public method called when the shell receives focus.

event
  the event object (QFocusEvent)

#### Terminal.focusOutEvent

focusOutEvent(event)

Public method called when the shell loses focus.

event
  the event object (QFocusEvent)

#### Terminal.getHistory

getHistory()

Public method to get the history.

Returns:
  reference to the history list (QStringList)

#### Terminal.handlePreferencesChanged

handlePreferencesChanged()

Public slot to handle the preferencesChanged signal.

#### Terminal.insert

insert(text)

Public slot to insert text at the current cursor position.

The cursor is advanced to the end of the inserted text.

text
  text to be inserted (string or QString)

#### Terminal.keyPressEvent

keyPressEvent(ev)

Re-implemented to handle the user input a key at a time.

ev
  key event (QKeyEvent)

#### Terminal.loadHistory

loadHistory()

Public method to load the history.

#### Terminal.mousePressEvent

mousePressEvent(event)

Protected method to handle the mouse press event.

event
  the mouse press event (QMouseEvent)

#### Terminal.reloadHistory

reloadHistory()

Public method to reload the history.

#### Terminal.saveHistory

saveHistory()

Public method to save the history.

Up