@@ -834,6 +834,10 @@ def p_key(self, key):
834834 elif key == 'KEY_BTAB' :
835835 return self .tab (back = True )
836836
837+ elif key in key_dispatch [config .suspend_key ]:
838+ self .suspend ()
839+ return ''
840+
837841 elif len (key ) == 1 and not unicodedata .category (key ) == 'Cc' :
838842 self .addstr (key )
839843 self .print_line (self .s )
@@ -1142,6 +1146,11 @@ def size(self):
11421146 self .h = h - 1
11431147 self .x = 0
11441148
1149+ def suspend (self ):
1150+ """Suspend the current process for shell job control."""
1151+ curses .endwin ()
1152+ os .kill (os .getpid (), signal .SIGSTOP )
1153+
11451154 def tab (self , back = False ):
11461155 """Process the tab key being hit. If there's only whitespace
11471156 in the line or the line is blank then process a normal tab,
@@ -1403,6 +1412,10 @@ def sigwinch(unused_scr):
14031412 global DO_RESIZE
14041413 DO_RESIZE = True
14051414
1415+ def sigcont (unused_scr ):
1416+ sigwinch (unused_scr )
1417+ # Forces the redraw
1418+ curses .ungetch ('' )
14061419
14071420def gethw ():
14081421 """I found this code on a usenet post, and snipped out the bit I needed,
@@ -1524,6 +1537,8 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
15241537
15251538 old_sigwinch_handler = signal .signal (signal .SIGWINCH ,
15261539 lambda * _ : sigwinch (scr ))
1540+ # redraw window after being suspended
1541+ old_sigcont_handler = signal .signal (signal .SIGCONT , lambda * _ : sigcont (scr ))
15271542
15281543 stdscr = scr
15291544 try :
@@ -1576,8 +1591,9 @@ def main_curses(scr, args, config, interactive=True, locals_=None,
15761591 statusbar .win .refresh ()
15771592 curses .raw (False )
15781593
1579- # Restore SIGWINCH handler
1594+ # Restore signal handlers
15801595 signal .signal (signal .SIGWINCH , old_sigwinch_handler )
1596+ signal .signal (signal .SIGCONT , old_sigcont_handler )
15811597
15821598 return repl .getstdout ()
15831599
0 commit comments