@@ -378,9 +378,16 @@ def keyPressEvent(self, e):
378
378
if not self .is_cursor_on_edition_zone () or startLine < endLine :
379
379
# allow copying and selecting
380
380
if e .modifiers () & (Qt .ControlModifier | Qt .MetaModifier ):
381
- if e .key () in (Qt .Key_C , Qt .Key_A ):
381
+ if e .key () == Qt .Key_C :
382
+ # only catch and return from Ctrl-C here if there's a selection
383
+ if self .hasSelectedText ():
384
+ QsciScintilla .keyPressEvent (self , e )
385
+ return
386
+ elif e .key () == Qt .Key_A :
382
387
QsciScintilla .keyPressEvent (self , e )
383
- return
388
+ return
389
+ else :
390
+ return
384
391
# allow selection
385
392
if e .modifiers () & Qt .ShiftModifier :
386
393
if e .key () in (Qt .Key_Left , Qt .Key_Right , Qt .Key_Home , Qt .Key_End ):
@@ -389,6 +396,11 @@ def keyPressEvent(self, e):
389
396
# all other keystrokes get sent to the input line
390
397
self .move_cursor_to_end ()
391
398
399
+ if e .modifiers () & (Qt .ControlModifier | Qt .MetaModifier ) and e .key () == Qt .Key_C and not self .hasSelectedText ():
400
+ # keyboard interrupt
401
+ sys .stdout .fire_keyboard_interrupt = True
402
+ return
403
+
392
404
line , index = self .getCursorPosition ()
393
405
cmd = self .text (line )
394
406
@@ -602,12 +614,14 @@ def write(self, txt):
602
614
sys .stderr .write (txt )
603
615
604
616
def writeCMD (self , txt ):
617
+ sys .stdout .fire_keyboard_interrupt = False
605
618
if len (txt ) > 0 :
606
619
getCmdString = self .text ()
607
620
prompt = getCmdString [0 :4 ]
608
621
sys .stdout .write (prompt + txt + '\n ' )
609
622
610
623
def runsource (self , source , filename = '<input>' , symbol = 'single' ):
624
+ sys .stdout .fire_keyboard_interrupt = False
611
625
hook = sys .excepthook
612
626
try :
613
627
def excepthook (etype , value , tb ):
0 commit comments