Clear with current attributes (not just background color), use real cursor (not layer).
This commit is contained in:
parent
95923b2752
commit
c95c51a9c1
@ -323,11 +323,6 @@ struct guac_terminal {
|
|||||||
*/
|
*/
|
||||||
int cursor_col;
|
int cursor_col;
|
||||||
|
|
||||||
/**
|
|
||||||
* Simple cursor layer until scrollback, etc. is implemented.
|
|
||||||
*/
|
|
||||||
guac_layer* cursor_layer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The attributes which will be applied to future characters.
|
* The attributes which will be applied to future characters.
|
||||||
*/
|
*/
|
||||||
@ -392,18 +387,18 @@ int guac_terminal_copy(guac_terminal* term,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears a rectangular region of characters, replacing them with the
|
* Clears a rectangular region of characters, replacing them with the
|
||||||
* given background color.
|
* current background color and attributes.
|
||||||
*/
|
*/
|
||||||
int guac_terminal_clear(guac_terminal* term,
|
int guac_terminal_clear(guac_terminal* term,
|
||||||
int row, int col, int rows, int cols, int background_color);
|
int row, int col, int rows, int cols);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears the given region from right-to-left, top-to-bottom, replacing
|
* Clears the given region from right-to-left, top-to-bottom, replacing
|
||||||
* all characters with the given background color.
|
* all characters with the current background color and attributes.
|
||||||
*/
|
*/
|
||||||
int guac_terminal_clear_range(guac_terminal* term,
|
int guac_terminal_clear_range(guac_terminal* term,
|
||||||
int start_row, int start_col,
|
int start_row, int start_col,
|
||||||
int end_row, int end_col, int background_color);
|
int end_row, int end_col);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrolls the terminal's current scroll region up by one row.
|
* Scrolls the terminal's current scroll region up by one row.
|
||||||
@ -417,6 +412,11 @@ int guac_terminal_scroll_up(guac_terminal* term,
|
|||||||
int guac_terminal_scroll_down(guac_terminal* term,
|
int guac_terminal_scroll_down(guac_terminal* term,
|
||||||
int start_row, int end_row, int amount);
|
int start_row, int end_row, int amount);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the reverse attribute of the character at the given location.
|
||||||
|
*/
|
||||||
|
int guac_terminal_toggle_reverse(guac_terminal* term, int row, int col);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocates a new guac_terminal_delta.
|
* Allocates a new guac_terminal_delta.
|
||||||
*/
|
*/
|
||||||
@ -462,11 +462,6 @@ void guac_terminal_delta_set_rect(guac_terminal_delta* delta,
|
|||||||
void guac_terminal_delta_flush(guac_terminal_delta* delta,
|
void guac_terminal_delta_flush(guac_terminal_delta* delta,
|
||||||
guac_terminal* terminal);
|
guac_terminal* terminal);
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the cursor position and contents.
|
|
||||||
*/
|
|
||||||
int guac_terminal_redraw_cursor(guac_terminal* term);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allocates a new character buffer having the given dimensions.
|
* Allocates a new character buffer having the given dimensions.
|
||||||
*/
|
*/
|
||||||
|
@ -122,17 +122,6 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
|||||||
term->char_width * term->term_width,
|
term->char_width * term->term_width,
|
||||||
term->char_height * term->term_height);
|
term->char_height * term->term_height);
|
||||||
|
|
||||||
/* Cursor layer need only be one char */
|
|
||||||
guac_protocol_send_size(socket, term->cursor_layer, term->char_width, term->char_height);
|
|
||||||
|
|
||||||
/* Draw cursor */
|
|
||||||
guac_protocol_send_rect(socket, term->cursor_layer,
|
|
||||||
0, 0, term->char_width, term->char_height);
|
|
||||||
|
|
||||||
guac_protocol_send_cfill(socket,
|
|
||||||
GUAC_COMP_OVER, term->cursor_layer,
|
|
||||||
0x40, 0xFF, 0x80, 0x80);
|
|
||||||
|
|
||||||
guac_socket_flush(socket);
|
guac_socket_flush(socket);
|
||||||
|
|
||||||
/* Open SSH session */
|
/* Open SSH session */
|
||||||
|
@ -85,6 +85,11 @@ int ssh_guac_client_handle_messages(guac_client* client) {
|
|||||||
|
|
||||||
int bytes_read = 0;
|
int bytes_read = 0;
|
||||||
|
|
||||||
|
/* Clear cursor */
|
||||||
|
guac_terminal_toggle_reverse(client_data->term,
|
||||||
|
client_data->term->cursor_row,
|
||||||
|
client_data->term->cursor_col);
|
||||||
|
|
||||||
/* While data available, write to terminal */
|
/* While data available, write to terminal */
|
||||||
while (channel_is_open(client_data->term_channel)
|
while (channel_is_open(client_data->term_channel)
|
||||||
&& !channel_is_eof(client_data->term_channel)
|
&& !channel_is_eof(client_data->term_channel)
|
||||||
@ -102,14 +107,17 @@ int ssh_guac_client_handle_messages(guac_client* client) {
|
|||||||
guac_socket_flush(socket);
|
guac_socket_flush(socket);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Draw cursor */
|
||||||
|
guac_terminal_toggle_reverse(client_data->term,
|
||||||
|
client_data->term->cursor_row,
|
||||||
|
client_data->term->cursor_col);
|
||||||
|
|
||||||
|
/* Flush terminal delta */
|
||||||
|
guac_terminal_delta_flush(client_data->term->delta, client_data->term);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush terminal delta */
|
|
||||||
guac_terminal_delta_flush(client_data->term->delta, client_data->term);
|
|
||||||
|
|
||||||
/* Update cursor */
|
|
||||||
guac_terminal_redraw_cursor(client_data->term);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,6 @@ guac_terminal* guac_terminal_create(guac_client* client,
|
|||||||
|
|
||||||
term->cursor_row = 0;
|
term->cursor_row = 0;
|
||||||
term->cursor_col = 0;
|
term->cursor_col = 0;
|
||||||
term->cursor_layer = guac_client_alloc_layer(client);
|
|
||||||
|
|
||||||
term->term_width = width / term->char_width;
|
term->term_width = width / term->char_width;
|
||||||
term->term_height = height / term->char_height;
|
term->term_height = height / term->char_height;
|
||||||
@ -174,8 +173,7 @@ guac_terminal* guac_terminal_create(guac_client* client,
|
|||||||
|
|
||||||
/* Clear with background color */
|
/* Clear with background color */
|
||||||
guac_terminal_clear(term,
|
guac_terminal_clear(term,
|
||||||
0, 0, term->term_height, term->term_width,
|
0, 0, term->term_height, term->term_width);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
return term;
|
return term;
|
||||||
|
|
||||||
@ -395,6 +393,22 @@ int guac_terminal_set(guac_terminal* term, int row, int col, char c) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int guac_terminal_toggle_reverse(guac_terminal* term, int row, int col) {
|
||||||
|
|
||||||
|
/* Get character from buffer */
|
||||||
|
guac_terminal_char* guac_char =
|
||||||
|
&(term->buffer->characters[row*term->buffer->width + col]);
|
||||||
|
|
||||||
|
/* Toggle reverse */
|
||||||
|
guac_char->attributes.reverse = !(guac_char->attributes.reverse);
|
||||||
|
|
||||||
|
/* Set delta */
|
||||||
|
guac_terminal_delta_set(term->delta, row, col, guac_char);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int guac_terminal_write(guac_terminal* term, const char* c, int size) {
|
int guac_terminal_write(guac_terminal* term, const char* c, int size) {
|
||||||
|
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
@ -428,13 +442,12 @@ int guac_terminal_copy(guac_terminal* term,
|
|||||||
|
|
||||||
|
|
||||||
int guac_terminal_clear(guac_terminal* term,
|
int guac_terminal_clear(guac_terminal* term,
|
||||||
int row, int col, int rows, int cols, int background_color) {
|
int row, int col, int rows, int cols) {
|
||||||
|
|
||||||
/* Build space */
|
/* Build space */
|
||||||
guac_terminal_char character;
|
guac_terminal_char character;
|
||||||
character.value = ' ';
|
character.value = ' ';
|
||||||
character.attributes.reverse = false;
|
character.attributes = term->current_attributes;
|
||||||
character.attributes.background = background_color;
|
|
||||||
|
|
||||||
/* Fill with color */
|
/* Fill with color */
|
||||||
guac_terminal_delta_set_rect(term->delta,
|
guac_terminal_delta_set_rect(term->delta,
|
||||||
@ -463,8 +476,7 @@ int guac_terminal_scroll_up(guac_terminal* term,
|
|||||||
|
|
||||||
/* Fill new rows with background */
|
/* Fill new rows with background */
|
||||||
|| guac_terminal_clear(term,
|
|| guac_terminal_clear(term,
|
||||||
end_row - amount + 1, 0, amount, term->term_width,
|
end_row - amount + 1, 0, amount, term->term_width);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,22 +496,20 @@ int guac_terminal_scroll_down(guac_terminal* term,
|
|||||||
|
|
||||||
/* Fill new rows with background */
|
/* Fill new rows with background */
|
||||||
|| guac_terminal_clear(term,
|
|| guac_terminal_clear(term,
|
||||||
start_row, 0, amount, term->term_width,
|
start_row, 0, amount, term->term_width);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int guac_terminal_clear_range(guac_terminal* term,
|
int guac_terminal_clear_range(guac_terminal* term,
|
||||||
int start_row, int start_col,
|
int start_row, int start_col,
|
||||||
int end_row, int end_col, int background_color) {
|
int end_row, int end_col) {
|
||||||
|
|
||||||
/* If not at far left, must clear sub-region to far right */
|
/* If not at far left, must clear sub-region to far right */
|
||||||
if (start_col > 0) {
|
if (start_col > 0) {
|
||||||
|
|
||||||
/* Clear from start_col to far right */
|
/* Clear from start_col to far right */
|
||||||
if (guac_terminal_clear(term,
|
if (guac_terminal_clear(term,
|
||||||
start_row, start_col, 1, term->term_width - start_col,
|
start_row, start_col, 1, term->term_width - start_col))
|
||||||
background_color))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* One less row to clear */
|
/* One less row to clear */
|
||||||
@ -511,8 +521,7 @@ int guac_terminal_clear_range(guac_terminal* term,
|
|||||||
|
|
||||||
/* Clear from far left to end_col */
|
/* Clear from far left to end_col */
|
||||||
if (guac_terminal_clear(term,
|
if (guac_terminal_clear(term,
|
||||||
end_row, 0, 1, end_col + 1,
|
end_row, 0, 1, end_col + 1))
|
||||||
background_color))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* One less row to clear */
|
/* One less row to clear */
|
||||||
@ -524,8 +533,7 @@ int guac_terminal_clear_range(guac_terminal* term,
|
|||||||
if (start_row <= end_row) {
|
if (start_row <= end_row) {
|
||||||
|
|
||||||
if (guac_terminal_clear(term,
|
if (guac_terminal_clear(term,
|
||||||
start_row, 0, end_row - start_row + 1, term->term_width,
|
start_row, 0, end_row - start_row + 1, term->term_width))
|
||||||
background_color))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -986,22 +994,6 @@ void guac_terminal_delta_flush(guac_terminal_delta* delta,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int guac_terminal_redraw_cursor(guac_terminal* term) {
|
|
||||||
|
|
||||||
guac_socket* socket = term->client->socket;
|
|
||||||
|
|
||||||
/* Erase old cursor */
|
|
||||||
return
|
|
||||||
guac_protocol_send_move(socket,
|
|
||||||
term->cursor_layer,
|
|
||||||
|
|
||||||
GUAC_DEFAULT_LAYER,
|
|
||||||
term->char_width * term->cursor_col,
|
|
||||||
term->char_height * term->cursor_row,
|
|
||||||
1);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
guac_terminal_buffer* guac_terminal_buffer_alloc(int width, int height) {
|
guac_terminal_buffer* guac_terminal_buffer_alloc(int width, int height) {
|
||||||
|
|
||||||
/* Allocate buffer */
|
/* Allocate buffer */
|
||||||
|
@ -348,21 +348,18 @@ int guac_terminal_csi(guac_terminal* term, char c) {
|
|||||||
if (argv[0] == 0)
|
if (argv[0] == 0)
|
||||||
guac_terminal_clear_range(term,
|
guac_terminal_clear_range(term,
|
||||||
term->cursor_row, term->cursor_col,
|
term->cursor_row, term->cursor_col,
|
||||||
term->term_height-1, term->term_width-1,
|
term->term_height-1, term->term_width-1);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
/* Erase from start to cursor */
|
/* Erase from start to cursor */
|
||||||
else if (argv[0] == 1)
|
else if (argv[0] == 1)
|
||||||
guac_terminal_clear_range(term,
|
guac_terminal_clear_range(term,
|
||||||
0, 0,
|
0, 0,
|
||||||
term->cursor_row, term->cursor_col,
|
term->cursor_row, term->cursor_col);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
/* Entire screen */
|
/* Entire screen */
|
||||||
else if (argv[0] == 2)
|
else if (argv[0] == 2)
|
||||||
guac_terminal_clear(term,
|
guac_terminal_clear(term,
|
||||||
0, 0, term->term_height, term->term_width,
|
0, 0, term->term_height, term->term_width);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -373,23 +370,20 @@ int guac_terminal_csi(guac_terminal* term, char c) {
|
|||||||
if (argv[0] == 0)
|
if (argv[0] == 0)
|
||||||
guac_terminal_clear(term,
|
guac_terminal_clear(term,
|
||||||
term->cursor_row, term->cursor_col,
|
term->cursor_row, term->cursor_col,
|
||||||
1, term->term_width - term->cursor_col,
|
1, term->term_width - term->cursor_col);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
|
|
||||||
/* Erase from start to cursor */
|
/* Erase from start to cursor */
|
||||||
else if (argv[0] == 1)
|
else if (argv[0] == 1)
|
||||||
guac_terminal_clear(term,
|
guac_terminal_clear(term,
|
||||||
term->cursor_row, 0,
|
term->cursor_row, 0,
|
||||||
1, term->cursor_col + 1,
|
1, term->cursor_col + 1);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
/* Erase line */
|
/* Erase line */
|
||||||
else if (argv[0] == 2)
|
else if (argv[0] == 2)
|
||||||
guac_terminal_clear(term,
|
guac_terminal_clear(term,
|
||||||
term->cursor_row, 0,
|
term->cursor_row, 0,
|
||||||
1, term->term_width,
|
1, term->term_width);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -432,8 +426,7 @@ int guac_terminal_csi(guac_terminal* term, char c) {
|
|||||||
/* Clear right */
|
/* Clear right */
|
||||||
guac_terminal_clear(term,
|
guac_terminal_clear(term,
|
||||||
term->cursor_row, term->term_width - amount,
|
term->cursor_row, term->term_width - amount,
|
||||||
1, amount,
|
1, amount);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -453,8 +446,7 @@ int guac_terminal_csi(guac_terminal* term, char c) {
|
|||||||
/* Clear left */
|
/* Clear left */
|
||||||
guac_terminal_clear(term,
|
guac_terminal_clear(term,
|
||||||
term->cursor_row, term->cursor_col,
|
term->cursor_row, term->cursor_col,
|
||||||
1, amount,
|
1, amount);
|
||||||
term->current_attributes.background);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user