mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-10 00:04:23 -04:00
[pyqgis-console] cleaning up code and minor fixes
This commit is contained in:
parent
b67d360fc5
commit
07abb34ebe
@ -169,8 +169,6 @@ class Editor(QsciScintilla):
|
||||
def autoComplete(self):
|
||||
self.autoCompleteFromAll()
|
||||
|
||||
#self.modificationChanged.connect(self.textEdited)
|
||||
|
||||
def on_margin_clicked(self, nmargin, nline, modifiers):
|
||||
# Toggle marker for the line the margin was clicked on
|
||||
if self.markersAtLine(nline) != 0:
|
||||
@ -340,6 +338,7 @@ class Editor(QsciScintilla):
|
||||
def hideEditor(self):
|
||||
Ed = self.parent.pc.widgetEditor
|
||||
Ed.hide()
|
||||
self.parent.pc.showEditorButton.setChecked(False)
|
||||
|
||||
def commentEditorCode(self, commentCheck):
|
||||
if self.hasSelectedText():
|
||||
@ -357,7 +356,6 @@ class Editor(QsciScintilla):
|
||||
else:
|
||||
self.insert(selCmd)
|
||||
self.setCursorPosition(endLine, selCmd.length() - 2)
|
||||
|
||||
else:
|
||||
line, pos = self.getCursorPosition()
|
||||
selCmd = self.text(line)
|
||||
@ -471,20 +469,6 @@ class EditorTab(QWidget):
|
||||
self.keyFilter = KeyFilter(parent, self)
|
||||
self.setEventFilter(self.keyFilter)
|
||||
|
||||
# def openFile(self):
|
||||
# scriptFile = QFileDialog.getOpenFileName(
|
||||
# self, "Open File", "", "Script file (*.py)")
|
||||
# if os.path.exists(scriptFile):
|
||||
# self.newEditor.setText(open(scriptFile, "r").read())
|
||||
# self.newEditor.setModified(False)
|
||||
# fN = scriptFile.split('/')[-1]
|
||||
# if fN:
|
||||
# self.mw.setTabTitle(self, fN)
|
||||
# self.path = scriptFile
|
||||
# index = self.mw.currentIndex()
|
||||
# idx = unicode(index)
|
||||
# self.fileExcuteList[idx] = unicode(scriptFile)
|
||||
|
||||
def save(self):
|
||||
if self.path is None:
|
||||
self.path = str(QFileDialog().getSaveFileName(self,
|
||||
@ -608,8 +592,6 @@ class EditorTabWidget(QTabWidget):
|
||||
self.fileTabButton.setPopupMode(QToolButton.InstantPopup)
|
||||
self.fileTabButton.setMenu(self.fileTabMenu)
|
||||
self.setCornerWidget(self.fileTabButton, Qt.TopRightCorner)
|
||||
#self.connect(self.closeTabButton, SIGNAL('clicked()'), self.buttonClosePressed)
|
||||
|
||||
self.connect(self, SIGNAL("tabCloseRequested(int)"), self._removeTab)
|
||||
|
||||
# Open button
|
||||
|
@ -119,8 +119,6 @@ class ShellOutputScintilla(QsciScintilla):
|
||||
self.setWrapMode(QsciScintilla.WrapCharacter)
|
||||
self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0)
|
||||
|
||||
#self.runShortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_E), self)
|
||||
#self.runShortcut.activated.connect(self.enteredSelected)
|
||||
# Reimplemeted copy action to prevent paste prompt (>>>,...) in command view
|
||||
self.copyShortcut = QShortcut(QKeySequence.Copy, self)
|
||||
self.copyShortcut.activated.connect(self.copy)
|
||||
@ -128,11 +126,6 @@ class ShellOutputScintilla(QsciScintilla):
|
||||
self.selectAllShortcut.activated.connect(self.selectAll)
|
||||
|
||||
def insertInitText(self):
|
||||
# txtInit = QCoreApplication.translate("PythonConsole",
|
||||
# "## To access Quantum GIS environment from this console\n"
|
||||
# "## use iface object (instance of QgisInterface class).\n"
|
||||
# "## Type help(iface) for more info and list of methods.\n\n")
|
||||
# initText = self.setText(txtInit)
|
||||
txtInit = QCoreApplication.translate("PythonConsole",
|
||||
"Python %1 on %2\n"
|
||||
"## Type help(iface) for more info and list of methods.\n").arg(sys.version, socket.gethostname())
|
||||
@ -162,13 +155,7 @@ class ShellOutputScintilla(QsciScintilla):
|
||||
|
||||
self.setLexer(self.lexer)
|
||||
|
||||
# def getTextFromEditor(self):
|
||||
# text = self.text()
|
||||
# textList = text.split("\n")
|
||||
# return textList
|
||||
|
||||
def clearConsole(self):
|
||||
#self.SendScintilla(QsciScintilla.SCI_CLEARALL)
|
||||
self.setText('')
|
||||
self.insertInitText()
|
||||
self.shell.setFocus()
|
||||
@ -224,6 +211,7 @@ class ShellOutputScintilla(QsciScintilla):
|
||||
Ed = self.parent.widgetEditor
|
||||
if not Ed.isVisible():
|
||||
Ed.show()
|
||||
self.parent.showEditorButton.setChecked(True)
|
||||
self.shell.setFocus()
|
||||
|
||||
def copy(self):
|
||||
@ -255,4 +243,3 @@ class ShellOutputScintilla(QsciScintilla):
|
||||
def widgetMessageBar(self, iface, text):
|
||||
timeout = iface.messageTimeout()
|
||||
self.infoBar.pushMessage('Console', text, QgsMessageBar.INFO, timeout)
|
||||
|
||||
|
@ -245,20 +245,6 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter):
|
||||
def refreshLexerProperties(self):
|
||||
self.setLexers()
|
||||
|
||||
#def check_selection(self):
|
||||
#"""
|
||||
#Check if selected text is r/w,
|
||||
#otherwise remove read-only parts of selection
|
||||
#"""
|
||||
##if self.current_prompt_pos is None:
|
||||
##self.move_cursor_to_end()
|
||||
##return
|
||||
#line_from, index_from, line_to, index_to = self.getSelection()
|
||||
#pline, pindex = self.getCursorPosition()
|
||||
#if line_from < pline or \
|
||||
#(line_from == pline and index_from < pindex):
|
||||
#self.setSelection(pline, pindex, line_to, index_to)
|
||||
|
||||
def displayPrompt(self, more=False):
|
||||
self.append("... ") if more else self.append(">>> ")
|
||||
self.move_cursor_to_end()
|
||||
@ -338,7 +324,6 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter):
|
||||
if e.key() in (Qt.Key_Left, Qt.Key_Right, Qt.Key_Home, Qt.Key_End):
|
||||
QsciScintilla.keyPressEvent(self, e)
|
||||
return
|
||||
|
||||
# all other keystrokes get sent to the input line
|
||||
self.move_cursor_to_end()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user