# eric6.QScintilla.Shell

Module implementing a graphical Python shell.

### Global Attributes

None

### Classes

Shell | Class implementing a graphical Python shell.
ShellAssembly | Class implementing the containing widget for the shell.
ShellHistoryStyle | Class defining the shell history styles.

### Functions

None

## Shell

Class implementing a graphical Python shell.

A user can enter commands that are executed in the remote Python interpreter.

### Signals

historyStyleChanged(ShellHistoryStyle)
  emitted to indicate a change of the history style
searchStringFound(bool)
  emitted to indicate the search result

### Derived from

QsciScintillaCompat

### Class Attributes

None

### Class Methods

None

### Methods

Shell | Constructor
__QScintillaAutoCompletionCommand | Private method to handle a command for autocompletion only.
__QScintillaCancel | Private method to handle the ESC command.
__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.
__QScintillaCommand | Private method to send the command to QScintilla.
__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.
__QScintillaHistoryDown | Private method to handle the history down command.
__QScintillaHistoryUp | Private method to handle the history up 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 cursor down command.
__QScintillaLineEnd | Private method to handle the End key.
__QScintillaLineUp | Private method to handle the cursor up command.
__QScintillaNewline | Private method to handle the Return key.
__QScintillaRightCommand | Private method to handle a QScintilla command working to the right.
__QScintillaTab | Private method to handle the Tab key.
__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.
__clientCapabilities | Private slot to handle the reporting of the clients capabilities.
__clientError | Private method to handle an error in the client.
__clientException | Private method to handle an exception of the client.
__clientSignal | Private method to handle a signal generated on the client side.
__clientStatement | Private method to handle the response from the debugger client.
__clientSyntaxError | Private method to handle a syntax error in the debugged program.
__completionListSelected | Private slot to handle the selection from the completion list.
__configure | Private method to open the configuration dialog.
__executeCommand | Private slot to execute a command.
__find | Private slot to show the find widget.
__getBanner | Private method to get the banner for the remote interpreter.
__getEndPos | Private method to return the line and column of the last character.
__initialise | Private method to get ready for a new remote interpreter.
__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.
__insertTextNoEcho | Private method to insert some text at the end of the buffer without echoing it.
__isCursorOnLastLine | Private method to check, if the cursor is on the last line.
__isHistoryIndexValid | Private method to test, if the history index is valid.
__middleMouseButton | Private method to handle the middle mouse button press.
__raw_input | Private method to handle raw input.
__reset | Private slot to handle the 'reset' context menu entry.
__resetAndClear | Private slot to handle the 'reset and clear' context menu entry.
__resetIncrementalHistorySearch | Private method to reset the incremental history search.
__resizeLinenoMargin | Private slot to resize the line numbers margin.
__rsearchHistory | Private method used to reverse search the history.
__searchHistory | Private method used to search the history.
__searchNext | Private method to search for the next occurrence.
__searchPrev | Private method to search for the next occurrence.
__setAutoCompletion | Private method to configure the autocompletion function.
__setCallTips | Private method to configure the calltips function.
__setHistoryIndex | Private method to set the initial history index.
__setMargin0 | Private method to configure margin 0.
__setMonospaced | Private method to set/reset a monospaced font.
__setTextDisplay | Private method to configure the text display.
__setupCursorKeys | Private method to setup the cursor up and down mode.
__showCompletions | Private method to display the possible completions.
__showLanguageMenu | Private slot to prepare the language submenu.
__startDebugClient | Private slot to start a debug client according to the action triggered.
__useHistory | Private method to display a command from the history.
__write | Private method to display some text.
__writeBanner | Private method to write a banner with info from the debug client.
__writePrompt | Private method to write the prompt.
__writeStdErr | Private method to display some text with StdErr label.
__writeStdOut | Private method to display some text with StdOut label.
clear | Public slot to clear the display.
clearAllHistories | Public method to clear all available histories and sync them.
clearHistory | Public slot to clear the current history.
closeShell | Public method to shutdown the shell.
contextMenuEvent | Protected method to show our own context menu.
dragEnterEvent | Protected method to handle the drag enter event.
dragLeaveEvent | Protected method to handle the drag leave event.
dragMoveEvent | Protected method to handle the drag move event.
dropEvent | Protected method to handle the drop event.
editorCommand | Public method to perform an editor command.
event | Public method handling events.
executeLines | Public method to execute a set of lines as multiple commands.
focusInEvent | Protected method called when the shell receives focus.
focusNextPrevChild | Public method to stop Tab moving to the next window.
focusOutEvent | Protected method called when the shell loses focus.
gestureEvent | Protected method handling gesture events.
getClientType | Public slot to get the clients type.
getHistory | Public method to get the history for the given client type.
getHistoryIndex | Public method to get the current value of the history index.
handlePreferencesChanged | Public slot to handle the preferencesChanged signal.
historyStyle | Public method to get the shell history style.
insert | Public slot to insert text at the current cursor position.
isHistoryEnabled | Public method to check, if the history is enabled.
keyPressEvent | Protected method to handle the user input a key at a time.
loadHistory | Public method to load the history for the given client type.
mousePressEvent | Protected method to handle the mouse press event.
paste | Public slot to handle the paste action.
reloadHistory | Public method to reload the history of the currently selected client type.
saveHistory | Public method to save the history for the given client type.
searchNext | Public method to search the next occurrence of the given text.
searchPrev | Public method to search the previous occurrence of the given text.
selectHistory | Public slot to select a history entry to execute.
setDebuggerUI | Public method to set the debugger UI.
showHistory | Public slot to show the shell history dialog.
wheelEvent | Protected method to handle wheel events.

### Static Methods

None

#### Shell (Constructor)

Shell(dbs, vm, windowedVariant, parent=None)

Constructor

dbs
  reference to the debug server object
vm
  reference to the viewmanager object
windowedVariant
  flag indicating the shell window variant (boolean)
parent
  parent widget (QWidget)

#### Shell.__QScintillaAutoCompletionCommand

__QScintillaAutoCompletionCommand(cmd)

Private method to handle a command for autocompletion only.

cmd
  QScintilla command

#### Shell.__QScintillaCancel

__QScintillaCancel()

Private method to handle the ESC command.

#### Shell.__QScintillaCharLeft

__QScintillaCharLeft()

Private method to handle the Cursor Left command.

#### Shell.__QScintillaCharLeftExtend

__QScintillaCharLeftExtend()

Private method to handle the Extend Selection Left command.

#### Shell.__QScintillaCharRight

__QScintillaCharRight()

Private method to handle the Cursor Right command.

#### Shell.__QScintillaCommand

__QScintillaCommand(cmd)

Private method to send the command to QScintilla.

cmd
  QScintilla command

#### Shell.__QScintillaDelete

__QScintillaDelete()

Private method to handle the delete command.

#### Shell.__QScintillaDeleteBack

__QScintillaDeleteBack()

Private method to handle the Backspace key.

#### Shell.__QScintillaDeleteLineLeft

__QScintillaDeleteLineLeft()

Private method to handle the Delete Line Left command.

#### Shell.__QScintillaDeleteLineRight

__QScintillaDeleteLineRight()

Private method to handle the Delete Line Right command.

#### Shell.__QScintillaDeleteWordLeft

__QScintillaDeleteWordLeft()

Private method to handle the Delete Word Left command.

#### Shell.__QScintillaDeleteWordRight

__QScintillaDeleteWordRight()

Private method to handle the Delete Word Right command.

#### Shell.__QScintillaHistoryDown

__QScintillaHistoryDown(cmd)

Private method to handle the history down command.

cmd
  QScintilla command

#### Shell.__QScintillaHistoryUp

__QScintillaHistoryUp(cmd)

Private method to handle the history up command.

cmd
  QScintilla command

#### Shell.__QScintillaLeftCommand

__QScintillaLeftCommand(method, allLinesAllowed=False)

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

method
  shell method to execute
allLinesAllowed
  flag indicating that the command may be executed on any line (boolean)

#### Shell.__QScintillaLeftDeleteCommand

__QScintillaLeftDeleteCommand(method)

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

method
  shell method to execute

#### Shell.__QScintillaLineDown

__QScintillaLineDown(cmd)

Private method to handle the cursor down command.

cmd
  QScintilla command

#### Shell.__QScintillaLineEnd

__QScintillaLineEnd(cmd)

Private method to handle the End key.

cmd
  QScintilla command

#### Shell.__QScintillaLineUp

__QScintillaLineUp(cmd)

Private method to handle the cursor up command.

cmd
  QScintilla command

#### Shell.__QScintillaNewline

__QScintillaNewline(cmd)

Private method to handle the Return key.

cmd
  QScintilla command

#### Shell.__QScintillaRightCommand

__QScintillaRightCommand(method)

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

method
  shell method to execute

#### Shell.__QScintillaTab

__QScintillaTab(cmd)

Private method to handle the Tab key.

cmd
  QScintilla command

#### Shell.__QScintillaVCHome

__QScintillaVCHome(cmd)

Private method to handle the Home key.

cmd
  QScintilla command

#### Shell.__QScintillaVCHomeExtend

__QScintillaVCHomeExtend()

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

#### Shell.__QScintillaWordLeft

__QScintillaWordLeft()

Private method to handle the Cursor Word Left command.

#### Shell.__QScintillaWordLeftExtend

__QScintillaWordLeftExtend()

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

#### Shell.__QScintillaWordRight

__QScintillaWordRight()

Private method to handle the Cursor Word Right command.

#### Shell.__bindLexer

__bindLexer(language='Python3')

Private slot to set the lexer.

language
  lexer language to set (string)

#### Shell.__clearCurrentLine

__clearCurrentLine()

Private method to clear the line containing the cursor.

#### Shell.__clientCapabilities

__clientCapabilities(cap, clType)

Private slot to handle the reporting of the clients capabilities.

cap
  client capabilities (integer)
clType
  type of the debug client (string)

#### Shell.__clientError

__clientError()

Private method to handle an error in the client.

#### Shell.__clientException

__clientException(exceptionType, exceptionMessage, stackTrace)

Private method to handle an exception of the client.

exceptionType
  type of exception raised (string)
exceptionMessage
  message given by the exception (string)
stackTrace
  list of stack entries (list of string)

#### Shell.__clientSignal

__clientSignal(message, filename, lineNo, funcName, funcArgs)

Private method to handle a signal generated on the client side.

message (str)
  message of the syntax error
filename (str)
  translated filename of the syntax error position
lineNo (int)
  line number of the syntax error position
funcName (str)
  name of the function causing the signal
funcArgs (str)
  function arguments

#### Shell.__clientStatement

__clientStatement(more)

Private method to handle the response from the debugger client.

more
  flag indicating that more user input is required (boolean)

#### Shell.__clientSyntaxError

__clientSyntaxError(message, filename, lineNo, characterNo)

Private method to handle a syntax error in the debugged program.

message
  message of the syntax error (string)
filename
  translated filename of the syntax error position (string)
lineNo
  line number of the syntax error position (integer)
characterNo
  character number of the syntax error position (integer)

#### Shell.__completionListSelected

__completionListSelected(listId, txt)

Private slot to handle the selection from the completion list.

listId
  the ID of the user list (should be 1) (integer)
txt
  the selected text (string)

#### Shell.__configure

__configure()

Private method to open the configuration dialog.

#### Shell.__executeCommand

__executeCommand(cmd, historyIndex=None)

Private slot to execute a command.

cmd (str)
  command to be executed by debug client
historyIndex (int)
  history index to be set

#### Shell.__find

__find()

Private slot to show the find widget.

#### Shell.__getBanner

__getBanner()

Private method to get the banner for the remote interpreter.

It requests the interpreter version and platform running on the debug client side.

#### Shell.__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

#### Shell.__initialise

__initialise()

Private method to get ready for a new remote interpreter.

#### Shell.__insertHistory

__insertHistory(cmd)

Private method to insert a command selected from the history.

cmd
  history entry to be inserted (string)

#### Shell.__insertText

__insertText(s)

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

s
  text to be inserted (string)

#### Shell.__insertTextAtEnd

__insertTextAtEnd(s)

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

s
  text to be inserted (string)

#### Shell.__insertTextNoEcho

__insertTextNoEcho(s)

Private method to insert some text at the end of the buffer without echoing it.

s
  text to be inserted (string)

#### Shell.__isCursorOnLastLine

__isCursorOnLastLine()

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

Returns:
  flag indicating that the cursor is on the last line (boolean)

#### Shell.__isHistoryIndexValid

__isHistoryIndexValid()

Private method to test, if the history index is valid.

Returns:
  flag indicating validity

Return Type:
  bool

#### Shell.__middleMouseButton

__middleMouseButton()

Private method to handle the middle mouse button press.

#### Shell.__raw_input

__raw_input(s, echo)

Private method to handle raw input.

s
  prompt to be displayed (string)
echo
  Flag indicating echoing of the input (boolean)

#### Shell.__reset

__reset()

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

#### Shell.__resetAndClear

__resetAndClear()

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

#### Shell.__resetIncrementalHistorySearch

__resetIncrementalHistorySearch()

Private method to reset the incremental history search.

#### Shell.__resizeLinenoMargin

__resizeLinenoMargin()

Private slot to resize the line numbers margin.

#### Shell.__rsearchHistory

__rsearchHistory(txt, startIdx=-1)

Private method used to reverse search the history.

txt (str)
  text to match at the beginning
startIdx (int)
  index to start search from

Returns:
  tuple containing the index of found entry and a flag indicating that something was found

Return Type:
  tuple of (int, bool)

#### Shell.__searchHistory

__searchHistory(txt, startIdx=-1)

Private method used to search the history.

txt (str)
  text to match at the beginning
startIdx (int)
  index to start search from

Returns:
  tuple containing the index of found entry and a flag indicating that something was found

Return Type:
  tuple of (int, bool)

#### Shell.__searchNext

__searchNext()

Private method to search for the next occurrence.

#### Shell.__searchPrev

__searchPrev()

Private method to search for the next occurrence.

#### Shell.__setAutoCompletion

__setAutoCompletion(language='Python')

Private method to configure the autocompletion function.

language
  of the autocompletion set to set (string)

#### Shell.__setCallTips

__setCallTips(language='Python')

Private method to configure the calltips function.

language
  of the calltips set to set (string)

#### Shell.__setHistoryIndex

__setHistoryIndex(index=None)

Private method to set the initial history index.

index (int or None)
  index value to be set

#### Shell.__setMargin0

__setMargin0()

Private method to configure margin 0.

#### Shell.__setMonospaced

__setMonospaced(on)

Private method to set/reset a monospaced font.

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

#### Shell.__setTextDisplay

__setTextDisplay()

Private method to configure the text display.

#### Shell.__setupCursorKeys

__setupCursorKeys()

Private method to setup the cursor up and down mode.

#### Shell.__showCompletions

__showCompletions(completions, text)

Private method to display the possible completions.

completions
  list of possible completions (list of strings)
text
  text that is about to be completed (string)

#### Shell.__showLanguageMenu

__showLanguageMenu()

Private slot to prepare the language submenu.

#### Shell.__startDebugClient

__startDebugClient(action)

Private slot to start a debug client according to the action triggered.

action
  context menu action that was triggered (QAction)

#### Shell.__useHistory

__useHistory()

Private method to display a command from the history.

#### Shell.__write

__write(s)

Private method to display some text.

s
  text to be displayed (string)

#### Shell.__writeBanner

__writeBanner(version, platform, dbgclient)

Private method to write a banner with info from the debug client.

version
  interpreter version string (string)
platform
  platform of the remote interpreter (string)
dbgclient
  debug client variant used (string)

#### Shell.__writePrompt

__writePrompt()

Private method to write the prompt.

#### Shell.__writeStdErr

__writeStdErr(s)

Private method to display some text with StdErr label.

s
  text to be displayed (string)

#### Shell.__writeStdOut

__writeStdOut(s)

Private method to display some text with StdOut label.

s
  text to be displayed (string)

#### Shell.clear

clear()

Public slot to clear the display.

#### Shell.clearAllHistories

clearAllHistories()

Public method to clear all available histories and sync them.

#### Shell.clearHistory

clearHistory()

Public slot to clear the current history.

#### Shell.closeShell

closeShell()

Public method to shutdown the shell.

#### Shell.contextMenuEvent

contextMenuEvent(ev)

Protected method to show our own context menu.

ev
  context menu event (QContextMenuEvent)

#### Shell.dragEnterEvent

dragEnterEvent(event)

Protected method to handle the drag enter event.

event
  the drag enter event (QDragEnterEvent)

#### Shell.dragLeaveEvent

dragLeaveEvent(event)

Protected method to handle the drag leave event.

event
  the drag leave event (QDragLeaveEvent)

#### Shell.dragMoveEvent

dragMoveEvent(event)

Protected method to handle the drag move event.

event
  the drag move event (QDragMoveEvent)

#### Shell.dropEvent

dropEvent(event)

Protected method to handle the drop event.

event
  the drop event (QDropEvent)

#### Shell.editorCommand

editorCommand(cmd)

Public method to perform an editor command.

cmd
  the scintilla command to be performed

#### Shell.event

event(evt)

Public method handling events.

evt
  reference to the event (QEvent)

Returns:
  flag indicating, if the event was handled (boolean)

#### Shell.executeLines

executeLines(lines, historyIndex=None)

Public method to execute a set of lines as multiple commands.

lines (str)
  multiple lines of text to be executed as single commands
historyIndex (int)
  history index to be set

#### Shell.focusInEvent

focusInEvent(event)

Protected method called when the shell receives focus.

event
  the event object (QFocusEvent)

#### Shell.focusNextPrevChild

focusNextPrevChild(nextChild)

Public method to stop Tab moving to the next window.

While the user is entering a multi-line command, the movement to the next window by the Tab key being pressed is suppressed.

nextChild
  next window

Returns:
  flag indicating the movement

#### Shell.focusOutEvent

focusOutEvent(event)

Protected method called when the shell loses focus.

event
  the event object (QFocusEvent)

#### Shell.gestureEvent

gestureEvent(evt)

Protected method handling gesture events.

evt
  reference to the gesture event (QGestureEvent

#### Shell.getClientType

getClientType()

Public slot to get the clients type.

Returns:
  client type (string)

#### Shell.getHistory

getHistory(clientType)

Public method to get the history for the given client type.

clientType
  type of the debug client (string). If it is None, the current history is returned.

Returns:
  reference to the history list (list of strings)

#### Shell.getHistoryIndex

getHistoryIndex()

Public method to get the current value of the history index.

Returns:
  history index

Return Type:
  int

#### Shell.handlePreferencesChanged

handlePreferencesChanged()

Public slot to handle the preferencesChanged signal.

#### Shell.historyStyle

historyStyle()

Public method to get the shell history style.

Returns:
  shell history style

Return Type:
  ShellHistoryStyle

#### Shell.insert

insert(txt)

Public slot to insert text at the current cursor position.

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

txt
  text to be inserted (string)

#### Shell.isHistoryEnabled

isHistoryEnabled()

Public method to check, if the history is enabled.

Returns:
  flag indicating if history is enabled

Return Type:
  bool

#### Shell.keyPressEvent

keyPressEvent(ev)

Protected method to handle the user input a key at a time.

ev
  key event (QKeyEvent)

#### Shell.loadHistory

loadHistory(clientType)

Public method to load the history for the given client type.

clientType
  type of the debug client (string)

#### Shell.mousePressEvent

mousePressEvent(event)

Protected method to handle the mouse press event.

event
  the mouse press event (QMouseEvent)

#### Shell.paste

paste()

Public slot to handle the paste action.

#### Shell.reloadHistory

reloadHistory()

Public method to reload the history of the currently selected client type.

#### Shell.saveHistory

saveHistory(clientType)

Public method to save the history for the given client type.

clientType
  type of the debug client (string)

#### Shell.searchNext

searchNext(txt, caseSensitive, wholeWord)

Public method to search the next occurrence of the given text.

txt
  text to search for (string)
caseSensitive
  flag indicating to perform a case sensitive search (boolean)
wholeWord
  flag indicating to search for whole words only (boolean)

#### Shell.searchPrev

searchPrev(txt, caseSensitive, wholeWord)

Public method to search the previous occurrence of the given text.

txt
  text to search for (string)
caseSensitive
  flag indicating to perform a case sensitive search (boolean)
wholeWord
  flag indicating to search for whole words only (boolean)

#### Shell.selectHistory

selectHistory()

Public slot to select a history entry to execute.

#### Shell.setDebuggerUI

setDebuggerUI(ui)

Public method to set the debugger UI.

ui
  reference to the debugger UI object (DebugUI)

#### Shell.showHistory

showHistory()

Public slot to show the shell history dialog.

#### Shell.wheelEvent

wheelEvent(evt)

Protected method to handle wheel events.

evt
  reference to the wheel event (QWheelEvent)

Up

## ShellAssembly

Class implementing the containing widget for the shell.

### Derived from

QWidget

### Class Attributes

None

### Class Methods

None

### Methods

ShellAssembly | Constructor
shell | Public method to get a reference to the terminal widget.
showFind | Public method to display the search widget.

### Static Methods

None

#### ShellAssembly (Constructor)

ShellAssembly(dbs, vm, horizontal=True, parent=None)

Constructor

dbs
  reference to the debug server object
vm
  reference to the viewmanager object
horizontal
  flag indicating a horizontal layout (boolean)
parent
  parent widget (QWidget)

#### ShellAssembly.shell

shell()

Public method to get a reference to the terminal widget.

Returns:
  reference to the shell widget (Shell)

#### ShellAssembly.showFind

showFind(txt="")

Public method to display the search widget.

txt
  text to be shown in the combo (string)

Up

## ShellHistoryStyle

Class defining the shell history styles.

### Derived from

Enum

### Class Attributes

Disabled
LinuxStyle
WindowsStyle

### Class Methods

None

### Methods

None

### Static Methods

None

Up