@@ -286,11 +286,11 @@ def check_selection(self):
286
286
Check if selected text is r/w,
287
287
otherwise remove read-only parts of selection
288
288
"""
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
292
292
line_from , index_from , line_to , index_to = self .getSelection ()
293
- pline , pindex = self .current_prompt_pos
293
+ pline , pindex = self .getCursorPosition ()
294
294
if line_from < pline or \
295
295
(line_from == pline and index_from < pindex ):
296
296
self .setSelection (pline , pindex , line_to , index_to )
@@ -377,27 +377,38 @@ def keyPressEvent(self, e):
377
377
elif e .key () == Qt .Key_Left :
378
378
e .accept ()
379
379
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 )
384
385
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 )
389
391
elif e .key () == Qt .Key_Right :
390
392
e .accept ()
391
393
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 )
396
399
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 ()
401
412
## TODO: press event for auto-completion file directory
402
413
#elif e.key() == Qt.Key_Tab:
403
414
#self.show_file_completion()
0 commit comments