From 320255ade1bf3992d7b91c29b36defcb85b41a3c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 1 Apr 2013 01:10:47 -0700 Subject: [PATCH] Partially implement copy for buffers, add logging to simulate scrollback push. --- protocols/ssh/src/terminal.c | 56 +++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/protocols/ssh/src/terminal.c b/protocols/ssh/src/terminal.c index 15982453..7faddc88 100644 --- a/protocols/ssh/src/terminal.c +++ b/protocols/ssh/src/terminal.c @@ -466,6 +466,28 @@ int guac_terminal_scroll_up(guac_terminal* term, /* Calculate height of scroll region */ int height = end_row - start_row + 1; + /* If scroll region is entire screen, push rows into scrollback */ + if (start_row == 0 && end_row == term->term_height-1) { + + /* STUB: Test, for sake of logging */ + char test_str[1024]; + int column; + + /* Generate test string */ + guac_terminal_char* current = term->buffer->characters; + for (column=0; column < term->buffer->width; column++) { + test_str[column] = current->value; + current++; + } + test_str[column] = 0; + + /* Log string version of row that WOULD have been scrolled into the + * scrollback */ + guac_client_log_info(term->client, + "scroll: %s", test_str); + + } + return /* Move rows within scroll region up by the given amount */ @@ -1038,7 +1060,39 @@ void guac_terminal_buffer_copy(guac_terminal_buffer* buffer, int dst_row, int dst_column, int src_row, int src_column, int w, int h) { - /* STUB */ + + int row, column; + + /* FIXME: Handle intersections between src and dst rects */ + + guac_terminal_char* current_row = + &(buffer->characters[dst_row*buffer->width + dst_column]); + + guac_terminal_char* src_current_row = + &(buffer->characters[src_row*buffer->width + src_column]); + + /* Set rectangle to copy operations */ + for (row=0; rowwidth; + src_current_row += buffer->width; + + } + } void guac_terminal_buffer_set_rect(guac_terminal_buffer* buffer,