def from_tmux_pane(cls, pane): import tmux lines = tmux.all_lines(pane) history_height = len(tmux.scrollback(pane)) print('tmux.all_contents:', tmux.all_contents(pane)) print('tmux.visible:', tmux.visible(pane)) print('history_height:', history_height) print('tmux.scrollback:', tmux.scrollback(pane)) width, height = tmux.width(pane), tmux.height(pane) cursor_row, cursor_col = tmux.cursor_pos(pane) #TODO deal with cursors not at the bottom termstate = TerminalState( lines=lines, cursor_line=len(lines) - 1, cursor_offset=len(lines[-1]), width=width, height=height, history_height=history_height) print(termstate) #assert termstate.cursor_row == cursor_row #assert termstate.cursor_column == cursor_col return termstate
def test_contents(self): with tmux.TmuxPane(20, 5) as t: tmux.send_command(t, 'echo 01234567890123456789') tmux.send_command(t, 'echo 01234567890123456789') self.assertEqual(tmux.all_contents(t), ['$echo 01234567890123', '456789', '01234567890123456789', '$echo 01234567890123', '456789', '01234567890123456789', '$']) self.assertEqual(tmux.all_lines(t), ['$echo 01234567890123' '456789', '01234567890123456789', '$echo 01234567890123' '456789', '01234567890123456789', '$'])