Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #227 from slarosa/master
[New Python Console] - added delete key for pressing event + other minor fixes
  • Loading branch information
timlinux committed Sep 11, 2012
2 parents 80c03e5 + a090559 commit 70aa06b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 22 deletions.
51 changes: 31 additions & 20 deletions python/console_sci.py
Expand Up @@ -286,11 +286,11 @@ 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
#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.current_prompt_pos
pline, pindex = self.getCursorPosition()
if line_from < pline or \
(line_from == pline and index_from < pindex):
self.setSelection(pline, pindex, line_to, index_to)
Expand Down Expand Up @@ -377,27 +377,38 @@ def keyPressEvent(self, e):
elif e.key() == Qt.Key_Left:
e.accept()
if e.modifiers() & Qt.ShiftModifier:
if e.modifiers() & Qt.ControlModifier:
self.SendScintilla(QsciScintilla.SCI_WORDLEFTEXTEND)
else:
self.SendScintilla(QsciScintilla.SCI_CHARLEFTEXTEND)
if index > 4:
if e.modifiers() & Qt.ControlModifier:
self.SendScintilla(QsciScintilla.SCI_WORDLEFTEXTEND)
else:
self.SendScintilla(QsciScintilla.SCI_CHARLEFTEXTEND)
else:
if e.modifiers() & Qt.ControlModifier:
self.SendScintilla(QsciScintilla.SCI_WORDLEFT)
else:
self.SendScintilla(QsciScintilla.SCI_CHARLEFT)
if index > 4:
if e.modifiers() & Qt.ControlModifier:
self.SendScintilla(QsciScintilla.SCI_WORDLEFT)
else:
self.SendScintilla(QsciScintilla.SCI_CHARLEFT)
elif e.key() == Qt.Key_Right:
e.accept()
if e.modifiers() & Qt.ShiftModifier:
if e.modifiers() & Qt.ControlModifier:
self.SendScintilla(QsciScintilla.SCI_WORDRIGHTEXTEND)
else:
self.SendScintilla(QsciScintilla.SCI_CHARRIGHTEXTEND)
if index >= 4:
if e.modifiers() & Qt.ControlModifier:
self.SendScintilla(QsciScintilla.SCI_WORDRIGHTEXTEND)
else:
self.SendScintilla(QsciScintilla.SCI_CHARRIGHTEXTEND)
else:
if e.modifiers() & Qt.ControlModifier:
self.SendScintilla(QsciScintilla.SCI_WORDRIGHT)
else:
self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
if index >= 4:
if e.modifiers() & Qt.ControlModifier:
self.SendScintilla(QsciScintilla.SCI_WORDRIGHT)
else:
self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
elif e.key() == Qt.Key_Delete:
if self.hasSelectedText():
self.check_selection()
self.removeSelectedText()
elif self.is_cursor_on_last_line():
self.SendScintilla(QsciScintilla.SCI_CLEAR)
event.accept()
## TODO: press event for auto-completion file directory
#elif e.key() == Qt.Key_Tab:
#self.show_file_completion()
Expand Down
2 changes: 1 addition & 1 deletion python/help.py
Expand Up @@ -11,7 +11,7 @@ def __init__(self):
self.setupUi()

def setupUi(self):
self.resize(500, 300)
self.resize(400, 300)
self.webView = QtWebKit.QWebView()
self.setWindowTitle("Help Python Console")
self.verticalLayout= QtGui.QVBoxLayout()
Expand Down
6 changes: 5 additions & 1 deletion python/helpConsole/help.htm
Expand Up @@ -22,6 +22,10 @@ <h2>Python Console for QGIS</h2>
</tr>
</table>
<p align="justify">
Now you can use auto-completion for syntax in console!!!
<br>
(Thanks to Larry Shaffer who provided the API files)
<br><br>
To access Quantum GIS environment from this console
use qgis.utils.iface object (instance of QgisInterface class).
To import the class QgisInterface can also use the dedicated
Expand Down Expand Up @@ -52,7 +56,7 @@ <h2>Python Console for QGIS</h2>
</tr>
<tr>
<td><img src="../iconConsole/iconRunConsole.png" /></td>
<td>Run commnand (like Enter key pressed)</td>
<td>Run command (like Enter key pressed)</td>
</tr>
</table>
</body>
Expand Down

0 comments on commit 70aa06b

Please sign in to comment.