Skip to content
Permalink
Browse files

Merge pull request #311 from slarosa/master

python console: add splitter and scrollbars, fix for DEL and Backspace key
  • Loading branch information
brushtyler committed Nov 1, 2012
2 parents 98e8ba4 + 66368f9 commit 29ed4017691d4a4b22f3d9550374d28b5db7d4a5
Showing with 23 additions and 20 deletions.
  1. +15 −12 python/console.py
  2. +2 −1 python/console_output.py
  3. +6 −7 python/console_sci.py
@@ -88,6 +88,11 @@ def __init__(self, parent=None):

self.options = optionsDialog(self)

self.splitter = QSplitter(self)
self.splitter.setOrientation(Qt.Vertical)
self.splitter.setHandleWidth(3)
self.splitter.setChildrenCollapsible(False)

self.toolBar = QToolBar()
self.toolBar.setEnabled(True)
self.toolBar.setFocusPolicy(Qt.NoFocus)
@@ -262,25 +267,23 @@ def __init__(self, parent=None):
sizePolicy.setHeightForWidth(self.widgetButton.sizePolicy().hasHeightForWidth())
self.widgetButton.setSizePolicy(sizePolicy)

self.consoleFrame = QFrame(self)
self.consoleFrame.setObjectName("consoleFrame")
self.consoleLayout = QVBoxLayout(self.consoleFrame)
self.consoleLayout.setSpacing(0)
self.consoleLayout.setMargin(0)
self.splitter.addWidget(self.textEditOut)
self.splitter.addWidget(self.edit)

sizes = self.splitter.sizes()
self.splitter.setSizes(sizes)

self.f.addWidget(self.widgetButton, 0, 0)
self.f.addWidget(self.splitter, 0, 1)

sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.textEditOut.sizePolicy().hasHeightForWidth())
self.textEditOut.setSizePolicy(sizePolicy)
self.consoleLayout.addWidget(self.textEditOut)

self.edit.setMinimumSize(QSize(0, 32))
self.edit.setMaximumSize(QSize(16777215, 32))
self.consoleLayout.addWidget(self.edit)

self.f.addWidget(self.widgetButton, 0, 0)
self.f.addWidget(self.consoleFrame, 0, 1)
self.textEditOut.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.edit.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)

self.clearButton.triggered.connect(self.textEditOut.clearConsole)
self.optionsButton.triggered.connect(self.openSettings)
@@ -94,6 +94,7 @@ def __init__(self, parent=None):
self.setCaretLineVisible(True)
self.setCaretLineBackgroundColor(QColor("#fcf3ed"))

self.setMinimumHeight(80)

# Folding
#self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
@@ -105,7 +106,7 @@ def __init__(self, parent=None):
#self.setEdgeColumn(80)
#self.setEdgeColor(QColor("#FF0000"))

self.SendScintilla(QsciScintilla.SCI_SETWRAPMODE, 2)
self.setWrapMode(QsciScintilla.WrapCharacter)
self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)

self.runShortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
@@ -50,7 +50,7 @@ def __init__(self, parent=None):

self.buffer = []

#self.insertInitText()
self.insertInitText()
self.displayPrompt(False)

for line in _init_commands:
@@ -92,14 +92,12 @@ def __init__(self, parent=None):
# Use raw message to Scintilla here (all messages are documented
# here: http://www.scintilla.org/ScintillaDoc.html)
self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
self.SendScintilla(QsciScintilla.SCI_SETVSCROLLBAR, 0)


# not too small
#self.setMinimumSize(500, 300)
self.setMinimumHeight(32)
self.SendScintilla(QsciScintilla.SCI_SETWRAPMODE, 2)
self.setMinimumHeight(50)

self.setWrapMode(QsciScintilla.WrapCharacter)
self.SendScintilla(QsciScintilla.SCI_EMPTYUNDOBUFFER)

## Disable command key
@@ -394,6 +392,7 @@ def keyPressEvent(self, e):
# fix the cursor position
self.insert( cmd[:3-newindex] + " " )
self.setCursorPosition(line, 4)
self.recolor()

elif e.modifiers() & (Qt.ControlModifier | Qt.MetaModifier) and \
e.key() == Qt.Key_V:
@@ -553,6 +552,6 @@ def write(self, txt):

def write_stdout(self, txt):
if len(txt) > 0:
getCmdString = self.text()
getCmdString = self.text(2)
prompt = getCmdString[0:4]
sys.stdout.write(prompt+txt+'\n')

0 comments on commit 29ed401

Please sign in to comment.
You can’t perform that action at this time.