Skip to content

Commit 70aa06b

Browse files
committed
Merge pull request #227 from slarosa/master
[New Python Console] - added delete key for pressing event + other minor fixes
2 parents 80c03e5 + a090559 commit 70aa06b

File tree

3 files changed

+37
-22
lines changed

3 files changed

+37
-22
lines changed

python/console_sci.py

+31-20
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ def check_selection(self):
286286
Check if selected text is r/w,
287287
otherwise remove read-only parts of selection
288288
"""
289-
if self.current_prompt_pos is None:
290-
self.move_cursor_to_end()
291-
return
289+
#if self.current_prompt_pos is None:
290+
#self.move_cursor_to_end()
291+
#return
292292
line_from, index_from, line_to, index_to = self.getSelection()
293-
pline, pindex = self.current_prompt_pos
293+
pline, pindex = self.getCursorPosition()
294294
if line_from < pline or \
295295
(line_from == pline and index_from < pindex):
296296
self.setSelection(pline, pindex, line_to, index_to)
@@ -377,27 +377,38 @@ def keyPressEvent(self, e):
377377
elif e.key() == Qt.Key_Left:
378378
e.accept()
379379
if e.modifiers() & Qt.ShiftModifier:
380-
if e.modifiers() & Qt.ControlModifier:
381-
self.SendScintilla(QsciScintilla.SCI_WORDLEFTEXTEND)
382-
else:
383-
self.SendScintilla(QsciScintilla.SCI_CHARLEFTEXTEND)
380+
if index > 4:
381+
if e.modifiers() & Qt.ControlModifier:
382+
self.SendScintilla(QsciScintilla.SCI_WORDLEFTEXTEND)
383+
else:
384+
self.SendScintilla(QsciScintilla.SCI_CHARLEFTEXTEND)
384385
else:
385-
if e.modifiers() & Qt.ControlModifier:
386-
self.SendScintilla(QsciScintilla.SCI_WORDLEFT)
387-
else:
388-
self.SendScintilla(QsciScintilla.SCI_CHARLEFT)
386+
if index > 4:
387+
if e.modifiers() & Qt.ControlModifier:
388+
self.SendScintilla(QsciScintilla.SCI_WORDLEFT)
389+
else:
390+
self.SendScintilla(QsciScintilla.SCI_CHARLEFT)
389391
elif e.key() == Qt.Key_Right:
390392
e.accept()
391393
if e.modifiers() & Qt.ShiftModifier:
392-
if e.modifiers() & Qt.ControlModifier:
393-
self.SendScintilla(QsciScintilla.SCI_WORDRIGHTEXTEND)
394-
else:
395-
self.SendScintilla(QsciScintilla.SCI_CHARRIGHTEXTEND)
394+
if index >= 4:
395+
if e.modifiers() & Qt.ControlModifier:
396+
self.SendScintilla(QsciScintilla.SCI_WORDRIGHTEXTEND)
397+
else:
398+
self.SendScintilla(QsciScintilla.SCI_CHARRIGHTEXTEND)
396399
else:
397-
if e.modifiers() & Qt.ControlModifier:
398-
self.SendScintilla(QsciScintilla.SCI_WORDRIGHT)
399-
else:
400-
self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
400+
if index >= 4:
401+
if e.modifiers() & Qt.ControlModifier:
402+
self.SendScintilla(QsciScintilla.SCI_WORDRIGHT)
403+
else:
404+
self.SendScintilla(QsciScintilla.SCI_CHARRIGHT)
405+
elif e.key() == Qt.Key_Delete:
406+
if self.hasSelectedText():
407+
self.check_selection()
408+
self.removeSelectedText()
409+
elif self.is_cursor_on_last_line():
410+
self.SendScintilla(QsciScintilla.SCI_CLEAR)
411+
event.accept()
401412
## TODO: press event for auto-completion file directory
402413
#elif e.key() == Qt.Key_Tab:
403414
#self.show_file_completion()

python/help.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self):
1111
self.setupUi()
1212

1313
def setupUi(self):
14-
self.resize(500, 300)
14+
self.resize(400, 300)
1515
self.webView = QtWebKit.QWebView()
1616
self.setWindowTitle("Help Python Console")
1717
self.verticalLayout= QtGui.QVBoxLayout()

python/helpConsole/help.htm

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ <h2>Python Console for QGIS</h2>
2222
</tr>
2323
</table>
2424
<p align="justify">
25+
Now you can use auto-completion for syntax in console!!!
26+
<br>
27+
(Thanks to Larry Shaffer who provided the API files)
28+
<br><br>
2529
To access Quantum GIS environment from this console
2630
use qgis.utils.iface object (instance of QgisInterface class).
2731
To import the class QgisInterface can also use the dedicated
@@ -52,7 +56,7 @@ <h2>Python Console for QGIS</h2>
5256
</tr>
5357
<tr>
5458
<td><img src="../iconConsole/iconRunConsole.png" /></td>
55-
<td>Run commnand (like Enter key pressed)</td>
59+
<td>Run command (like Enter key pressed)</td>
5660
</tr>
5761
</table>
5862
</body>

0 commit comments

Comments
 (0)