Remove scroll logging, reset scroll upon typing.

This commit is contained in:
Michael Jumper 2013-04-08 00:47:08 -07:00
parent 7897be9316
commit c20fe79ace
3 changed files with 24 additions and 27 deletions

View File

@ -45,6 +45,8 @@
#include <guacamole/client.h>
#define GUAC_SSH_WHEEL_SCROLL_AMOUNT 3
typedef struct guac_terminal guac_terminal;
/**
@ -606,16 +608,18 @@ guac_terminal_scrollback_row* guac_terminal_scrollback_buffer_get_row(
guac_terminal_scrollback_buffer* buffer, int row);
/**
* Scroll down the display by one row, replacing the new space with data from
* the scrollback.
* Scroll down the display by the given amount, replacing the new space with
* data from the scrollback. If not enough data is available, the maximum
* amount will be scrolled.
*/
void guac_terminal_scroll_display_down(guac_terminal* terminal);
void guac_terminal_scroll_display_down(guac_terminal* terminal, int amount);
/**
* Scroll up the display by one row, replacing the new space with data from
* either the scrollback or the terminal buffer.
* Scroll up the display by the given amount, replacing the new space with data
* from either the scrollback or the terminal buffer. If not enough data is
* available, the maximum amount will be scrolled.
*/
void guac_terminal_scroll_display_up(guac_terminal* terminal);
void guac_terminal_scroll_display_up(guac_terminal* terminal, int amount);
#endif

View File

@ -164,14 +164,14 @@ int ssh_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) {
/* Scroll up if wheel moved up */
if (released_mask & GUAC_CLIENT_MOUSE_SCROLL_UP) {
pthread_mutex_lock(&(term->lock));
guac_terminal_scroll_display_up(term);
guac_terminal_scroll_display_up(term, GUAC_SSH_WHEEL_SCROLL_AMOUNT);
pthread_mutex_unlock(&(term->lock));
}
/* Scroll down if wheel moved down */
if (released_mask & GUAC_CLIENT_MOUSE_SCROLL_DOWN) {
pthread_mutex_lock(&(term->lock));
guac_terminal_scroll_display_down(term);
guac_terminal_scroll_display_down(term, GUAC_SSH_WHEEL_SCROLL_AMOUNT);
pthread_mutex_unlock(&(term->lock));
}
@ -182,6 +182,7 @@ int ssh_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) {
int ssh_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data;
guac_terminal* term = client_data->term;
/* Track modifiers */
if (keysym == 0xFFE3) {
@ -191,6 +192,13 @@ int ssh_guac_client_key_handler(guac_client* client, int keysym, int pressed) {
/* If key pressed */
else if (pressed) {
/* Reset scroll */
if (term->scroll_offset != 0) {
pthread_mutex_lock(&(term->lock));
guac_terminal_scroll_display_down(term, term->scroll_offset);
pthread_mutex_unlock(&(term->lock));
}
/* If simple ASCII key */
if (keysym >= 0x00 && keysym <= 0xFF) {
char data = (char) keysym;

View File

@ -1219,16 +1219,10 @@ void guac_terminal_scrollback_buffer_append(
if (buffer->length > buffer->rows)
buffer->length = buffer->rows;
/* Log string version of row that WOULD have been scrolled into the
* scrollback */
guac_client_log_info(terminal->client,
"scrollback->top=%i (length=%i/%i)", buffer->top, buffer->length, buffer->rows);
}
void guac_terminal_scroll_display_down(guac_terminal* terminal) {
int scroll_amount = 3;
void guac_terminal_scroll_display_down(guac_terminal* terminal,
int scroll_amount) {
int start_row, end_row;
int dest_row;
@ -1257,10 +1251,6 @@ void guac_terminal_scroll_display_down(guac_terminal* terminal) {
start_row = end_row - scroll_amount + 1;
dest_row = terminal->term_height - scroll_amount;
guac_client_log_info(terminal->client,
"Scrolling rows %i through %i into view (scroll down)",
start_row, end_row);
/* Draw new rows from scrollback */
for (row=start_row; row<=end_row; row++) {
@ -1304,9 +1294,8 @@ void guac_terminal_scroll_display_down(guac_terminal* terminal) {
}
void guac_terminal_scroll_display_up(guac_terminal* terminal) {
int scroll_amount = 3;
void guac_terminal_scroll_display_up(guac_terminal* terminal,
int scroll_amount) {
int start_row, end_row;
int dest_row;
@ -1336,10 +1325,6 @@ void guac_terminal_scroll_display_up(guac_terminal* terminal) {
end_row = start_row + scroll_amount - 1;
dest_row = 0;
guac_client_log_info(terminal->client,
"Scrolling rows %i through %i into view (scroll up)",
start_row, end_row);
/* Draw new rows from scrollback */
for (row=start_row; row<=end_row; row++) {