def _resize_handler(self, *args, **kwarg):  
<EOL>try:<EOL><INDENT>assert self.resize_lock<EOL><DEDENT>except AssertionError:<EOL><INDENT>self.resize_lock = True<EOL>term = self.term<EOL>term.clear_cache()<EOL>newHeight = term.height<EOL>newWidth = term.width<EOL>lastHeight = lastWidth = <NUM_LIT:0><EOL>while newHeight != lastHeight or newWidth != lastWidth:<EOL><INDENT>lastHeight = newHeight<EOL>lastWidth = newWidth<EOL>time.sleep(<NUM_LIT>)<EOL>term.clear_cache()<EOL>newHeight = term.height<EOL>newWidth = term.width<EOL><DEDENT>if newWidth < self.width:<EOL><INDENT>offset = (self.scroll_offset - <NUM_LIT:1>) * (<NUM_LIT:1> + self.width // newWidth)<EOL>term.move_to(<NUM_LIT:0>, max(<NUM_LIT:0>, newHeight - offset))<EOL>self.stream.write(term.clear_eos)<EOL><DEDENT>self.width = newWidth<EOL>self._set_scroll_area(force=True)<EOL>for cter in self.counters:<EOL><INDENT>cter.refresh(flush=False)<EOL><DEDENT>self.stream.flush()<EOL>self.resize_lock = False<EOL><DEDENT>
Called when a window resize signal is detected

Resets the scroll window