Rename delta to display.
This commit is contained in:
parent
396bba6ea3
commit
32e6a07f59
@ -44,7 +44,7 @@ libguac_client_ssh_la_SOURCES = \
|
||||
src/blank.c \
|
||||
src/buffer.c \
|
||||
src/cursor.c \
|
||||
src/delta.c \
|
||||
src/display.c \
|
||||
src/ibar.c \
|
||||
src/ssh_client.c \
|
||||
src/ssh_handlers.c \
|
||||
@ -55,7 +55,7 @@ noinst_HEADERS = \
|
||||
include/blank.h \
|
||||
include/buffer.h \
|
||||
include/cursor.h \
|
||||
include/delta.h \
|
||||
include/display.h \
|
||||
include/ibar.h \
|
||||
include/ssh_client.h \
|
||||
include/ssh_handlers.h \
|
||||
|
@ -35,8 +35,8 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _SSH_GUAC_DELTA_H
|
||||
#define _SSH_GUAC_DELTA_H
|
||||
#ifndef _SSH_GUAC_DISPLAY_H
|
||||
#define _SSH_GUAC_DISPLAY_H
|
||||
|
||||
#include <pango/pangocairo.h>
|
||||
#include <guacamole/client.h>
|
||||
@ -105,10 +105,10 @@ typedef struct guac_terminal_operation {
|
||||
/**
|
||||
* Set of all pending operations for the currently-visible screen area.
|
||||
*/
|
||||
typedef struct guac_terminal_delta {
|
||||
typedef struct guac_terminal_display {
|
||||
|
||||
/**
|
||||
* The Guacamole client this delta will use for rendering.
|
||||
* The Guacamole client this display will use for rendering.
|
||||
*/
|
||||
guac_client* client;
|
||||
|
||||
@ -180,49 +180,49 @@ typedef struct guac_terminal_delta {
|
||||
*/
|
||||
guac_layer* filled_glyphs;
|
||||
|
||||
} guac_terminal_delta;
|
||||
} guac_terminal_display;
|
||||
|
||||
/**
|
||||
* Allocates a new delta having the given dimensions.
|
||||
* Allocates a new display having the given dimensions.
|
||||
*/
|
||||
guac_terminal_delta* guac_terminal_delta_alloc(guac_client* client, int width, int height,
|
||||
guac_terminal_display* guac_terminal_display_alloc(guac_client* client, int width, int height,
|
||||
int foreground, int background);
|
||||
|
||||
/**
|
||||
* Frees the given delta.
|
||||
* Frees the given display.
|
||||
*/
|
||||
void guac_terminal_delta_free(guac_terminal_delta* delta);
|
||||
void guac_terminal_display_free(guac_terminal_display* display);
|
||||
|
||||
/**
|
||||
* Copies the given range of columns to a new location, offset from
|
||||
* the original by the given number of columns.
|
||||
*/
|
||||
void guac_terminal_delta_copy_columns(guac_terminal_delta* delta, int row,
|
||||
void guac_terminal_display_copy_columns(guac_terminal_display* display, int row,
|
||||
int start_column, int end_column, int offset);
|
||||
|
||||
/**
|
||||
* Copies the given range of rows to a new location, offset from the
|
||||
* original by the given number of rows.
|
||||
*/
|
||||
void guac_terminal_delta_copy_rows(guac_terminal_delta* delta, int src_row, int rows,
|
||||
void guac_terminal_display_copy_rows(guac_terminal_display* display, int src_row, int rows,
|
||||
int start_row, int end_row, int offset);
|
||||
|
||||
/**
|
||||
* Sets the given range of columns within the given row to the given
|
||||
* character.
|
||||
*/
|
||||
void guac_terminal_delta_set_columns(guac_terminal_delta* delta, int row,
|
||||
void guac_terminal_display_set_columns(guac_terminal_display* display, int row,
|
||||
int start_column, int end_column, guac_terminal_char* character);
|
||||
|
||||
/**
|
||||
* Resize the terminal to the given dimensions.
|
||||
*/
|
||||
void guac_terminal_delta_resize(guac_terminal_delta* delta, int rows, int cols);
|
||||
void guac_terminal_display_resize(guac_terminal_display* display, int rows, int cols);
|
||||
|
||||
/**
|
||||
* Flushes all pending operations within the given guac_terminal_delta.
|
||||
* Flushes all pending operations within the given guac_terminal_display.
|
||||
*/
|
||||
void guac_terminal_delta_flush(guac_terminal_delta* delta);
|
||||
void guac_terminal_display_flush(guac_terminal_display* display);
|
||||
|
||||
#endif
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include <guacamole/client.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "delta.h"
|
||||
#include "display.h"
|
||||
#include "buffer.h"
|
||||
|
||||
#define GUAC_SSH_WHEEL_SCROLL_AMOUNT 3
|
||||
@ -133,11 +133,11 @@ struct guac_terminal {
|
||||
* The difference between the currently-rendered screen and the current
|
||||
* state of the terminal.
|
||||
*/
|
||||
guac_terminal_delta* delta;
|
||||
guac_terminal_display* display;
|
||||
|
||||
/**
|
||||
* Current terminal display state. All characters present on the screen
|
||||
* are within this buffer. This has nothing to do with the delta, which
|
||||
* are within this buffer. This has nothing to do with the display, which
|
||||
* facilitates transfer of a set of changes to the remote display.
|
||||
*/
|
||||
guac_terminal_buffer* buffer;
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <guacamole/protocol.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "delta.h"
|
||||
#include "display.h"
|
||||
|
||||
const guac_terminal_color guac_terminal_palette[16] = {
|
||||
|
||||
@ -73,18 +73,18 @@ const guac_terminal_color guac_terminal_palette[16] = {
|
||||
* and thus must be multiplied by the glyph width to obtain the actual
|
||||
* location within the glyph cache layer.
|
||||
*/
|
||||
int __guac_terminal_get_glyph(guac_terminal_delta* delta, char c) {
|
||||
int __guac_terminal_get_glyph(guac_terminal_display* display, char c) {
|
||||
|
||||
guac_socket* socket = delta->client->socket;
|
||||
guac_socket* socket = display->client->socket;
|
||||
int location;
|
||||
|
||||
/* Use foreground color */
|
||||
const guac_terminal_color* color =
|
||||
&guac_terminal_palette[delta->glyph_foreground];
|
||||
&guac_terminal_palette[display->glyph_foreground];
|
||||
|
||||
/* Use background color */
|
||||
const guac_terminal_color* background =
|
||||
&guac_terminal_palette[delta->glyph_background];
|
||||
&guac_terminal_palette[display->glyph_background];
|
||||
|
||||
cairo_surface_t* surface;
|
||||
cairo_t* cairo;
|
||||
@ -92,20 +92,20 @@ int __guac_terminal_get_glyph(guac_terminal_delta* delta, char c) {
|
||||
PangoLayout* layout;
|
||||
|
||||
/* Return glyph if exists */
|
||||
if (delta->glyphs[(int) c])
|
||||
return delta->glyphs[(int) c] - 1;
|
||||
if (display->glyphs[(int) c])
|
||||
return display->glyphs[(int) c] - 1;
|
||||
|
||||
location = delta->next_glyph++;
|
||||
location = display->next_glyph++;
|
||||
|
||||
/* Otherwise, draw glyph */
|
||||
surface = cairo_image_surface_create(
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
delta->char_width, delta->char_height);
|
||||
display->char_width, display->char_height);
|
||||
cairo = cairo_create(surface);
|
||||
|
||||
/* Get layout */
|
||||
layout = pango_cairo_create_layout(cairo);
|
||||
pango_layout_set_font_description(layout, delta->font_desc);
|
||||
pango_layout_set_font_description(layout, display->font_desc);
|
||||
pango_layout_set_text(layout, &c, 1);
|
||||
|
||||
/* Draw */
|
||||
@ -123,23 +123,23 @@ int __guac_terminal_get_glyph(guac_terminal_delta* delta, char c) {
|
||||
cairo_destroy(cairo);
|
||||
|
||||
/* Send glyph and update filled flyphs */
|
||||
guac_protocol_send_png(socket, GUAC_COMP_OVER, delta->glyph_stroke, location * delta->char_width, 0, surface);
|
||||
guac_protocol_send_png(socket, GUAC_COMP_OVER, display->glyph_stroke, location * display->char_width, 0, surface);
|
||||
|
||||
guac_protocol_send_rect(socket, delta->filled_glyphs,
|
||||
location * delta->char_width, 0,
|
||||
delta->char_width, delta->char_height);
|
||||
guac_protocol_send_rect(socket, display->filled_glyphs,
|
||||
location * display->char_width, 0,
|
||||
display->char_width, display->char_height);
|
||||
|
||||
guac_protocol_send_cfill(socket, GUAC_COMP_OVER, delta->filled_glyphs,
|
||||
guac_protocol_send_cfill(socket, GUAC_COMP_OVER, display->filled_glyphs,
|
||||
background->red,
|
||||
background->green,
|
||||
background->blue,
|
||||
0xFF);
|
||||
|
||||
guac_protocol_send_copy(socket, delta->glyph_stroke,
|
||||
location * delta->char_width, 0, delta->char_width, delta->char_height,
|
||||
GUAC_COMP_OVER, delta->filled_glyphs, location * delta->char_width, 0);
|
||||
guac_protocol_send_copy(socket, display->glyph_stroke,
|
||||
location * display->char_width, 0, display->char_width, display->char_height,
|
||||
GUAC_COMP_OVER, display->filled_glyphs, location * display->char_width, 0);
|
||||
|
||||
delta->glyphs[(int) c] = location+1;
|
||||
display->glyphs[(int) c] = location+1;
|
||||
|
||||
cairo_surface_destroy(surface);
|
||||
|
||||
@ -152,10 +152,10 @@ int __guac_terminal_get_glyph(guac_terminal_delta* delta, char c) {
|
||||
* Sets the attributes of the glyph cache layer such that future copies from
|
||||
* this layer will display as expected.
|
||||
*/
|
||||
int __guac_terminal_set_colors(guac_terminal_delta* delta,
|
||||
int __guac_terminal_set_colors(guac_terminal_display* display,
|
||||
guac_terminal_attributes* attributes) {
|
||||
|
||||
guac_socket* socket = delta->client->socket;
|
||||
guac_socket* socket = display->client->socket;
|
||||
const guac_terminal_color* background_color;
|
||||
int background, foreground;
|
||||
|
||||
@ -177,18 +177,18 @@ int __guac_terminal_set_colors(guac_terminal_delta* delta,
|
||||
background_color = &guac_terminal_palette[background];
|
||||
|
||||
/* If foreground different from current, colorize */
|
||||
if (foreground != delta->glyph_foreground) {
|
||||
if (foreground != display->glyph_foreground) {
|
||||
|
||||
/* Get color */
|
||||
const guac_terminal_color* color =
|
||||
&guac_terminal_palette[foreground];
|
||||
|
||||
/* Colorize letter */
|
||||
guac_protocol_send_rect(socket, delta->glyph_stroke,
|
||||
guac_protocol_send_rect(socket, display->glyph_stroke,
|
||||
0, 0,
|
||||
delta->char_width * delta->next_glyph, delta->char_height);
|
||||
display->char_width * display->next_glyph, display->char_height);
|
||||
|
||||
guac_protocol_send_cfill(socket, GUAC_COMP_ATOP, delta->glyph_stroke,
|
||||
guac_protocol_send_cfill(socket, GUAC_COMP_ATOP, display->glyph_stroke,
|
||||
color->red,
|
||||
color->green,
|
||||
color->blue,
|
||||
@ -197,33 +197,33 @@ int __guac_terminal_set_colors(guac_terminal_delta* delta,
|
||||
}
|
||||
|
||||
/* If any color change at all, update filled */
|
||||
if (foreground != delta->glyph_foreground
|
||||
|| background != delta->glyph_background) {
|
||||
if (foreground != display->glyph_foreground
|
||||
|| background != display->glyph_background) {
|
||||
|
||||
/* Set background */
|
||||
guac_protocol_send_rect(socket, delta->filled_glyphs,
|
||||
guac_protocol_send_rect(socket, display->filled_glyphs,
|
||||
0, 0,
|
||||
delta->char_width * delta->next_glyph, delta->char_height);
|
||||
display->char_width * display->next_glyph, display->char_height);
|
||||
|
||||
guac_protocol_send_cfill(socket, GUAC_COMP_OVER, delta->filled_glyphs,
|
||||
guac_protocol_send_cfill(socket, GUAC_COMP_OVER, display->filled_glyphs,
|
||||
background_color->red,
|
||||
background_color->green,
|
||||
background_color->blue,
|
||||
255);
|
||||
|
||||
/* Copy stroke */
|
||||
guac_protocol_send_copy(socket, delta->glyph_stroke,
|
||||
guac_protocol_send_copy(socket, display->glyph_stroke,
|
||||
|
||||
0, 0,
|
||||
delta->char_width * delta->next_glyph, delta->char_height,
|
||||
display->char_width * display->next_glyph, display->char_height,
|
||||
|
||||
GUAC_COMP_OVER, delta->filled_glyphs,
|
||||
GUAC_COMP_OVER, display->filled_glyphs,
|
||||
0, 0);
|
||||
|
||||
}
|
||||
|
||||
delta->glyph_foreground = foreground;
|
||||
delta->glyph_background = background;
|
||||
display->glyph_foreground = foreground;
|
||||
display->glyph_background = background;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -231,25 +231,25 @@ int __guac_terminal_set_colors(guac_terminal_delta* delta,
|
||||
|
||||
/**
|
||||
* Sends the given character to the terminal at the given row and column,
|
||||
* rendering the charater immediately. This bypasses the guac_terminal_delta
|
||||
* rendering the charater immediately. This bypasses the guac_terminal_display
|
||||
* mechanism and is intended for flushing of updates only.
|
||||
*/
|
||||
int __guac_terminal_set(guac_terminal_delta* delta, int row, int col, char c) {
|
||||
int __guac_terminal_set(guac_terminal_display* display, int row, int col, char c) {
|
||||
|
||||
guac_socket* socket = delta->client->socket;
|
||||
int location = __guac_terminal_get_glyph(delta, c);
|
||||
guac_socket* socket = display->client->socket;
|
||||
int location = __guac_terminal_get_glyph(display, c);
|
||||
|
||||
return guac_protocol_send_copy(socket,
|
||||
delta->filled_glyphs,
|
||||
location * delta->char_width, 0, delta->char_width, delta->char_height,
|
||||
display->filled_glyphs,
|
||||
location * display->char_width, 0, display->char_width, display->char_height,
|
||||
GUAC_COMP_OVER, GUAC_DEFAULT_LAYER,
|
||||
delta->char_width * col,
|
||||
delta->char_height * row);
|
||||
display->char_width * col,
|
||||
display->char_height * row);
|
||||
|
||||
}
|
||||
|
||||
|
||||
guac_terminal_delta* guac_terminal_delta_alloc(guac_client* client, int width, int height,
|
||||
guac_terminal_display* guac_terminal_display_alloc(guac_client* client, int width, int height,
|
||||
int foreground, int background) {
|
||||
|
||||
guac_terminal_operation* current;
|
||||
@ -260,55 +260,55 @@ guac_terminal_delta* guac_terminal_delta_alloc(guac_client* client, int width, i
|
||||
PangoFontMetrics* metrics;
|
||||
PangoContext* context;
|
||||
|
||||
/* Allocate delta */
|
||||
guac_terminal_delta* delta = malloc(sizeof(guac_terminal_delta));
|
||||
delta->client = client;
|
||||
/* Allocate display */
|
||||
guac_terminal_display* display = malloc(sizeof(guac_terminal_display));
|
||||
display->client = client;
|
||||
|
||||
memset(delta->glyphs, 0, sizeof(delta->glyphs));
|
||||
delta->glyph_stroke = guac_client_alloc_buffer(client);
|
||||
delta->filled_glyphs = guac_client_alloc_buffer(client);
|
||||
memset(display->glyphs, 0, sizeof(display->glyphs));
|
||||
display->glyph_stroke = guac_client_alloc_buffer(client);
|
||||
display->filled_glyphs = guac_client_alloc_buffer(client);
|
||||
|
||||
/* Get font */
|
||||
delta->font_desc = pango_font_description_new();
|
||||
pango_font_description_set_family(delta->font_desc, "monospace");
|
||||
pango_font_description_set_weight(delta->font_desc, PANGO_WEIGHT_NORMAL);
|
||||
pango_font_description_set_size(delta->font_desc, 12*PANGO_SCALE);
|
||||
display->font_desc = pango_font_description_new();
|
||||
pango_font_description_set_family(display->font_desc, "monospace");
|
||||
pango_font_description_set_weight(display->font_desc, PANGO_WEIGHT_NORMAL);
|
||||
pango_font_description_set_size(display->font_desc, 12*PANGO_SCALE);
|
||||
|
||||
font_map = pango_cairo_font_map_get_default();
|
||||
context = pango_font_map_create_context(font_map);
|
||||
|
||||
font = pango_font_map_load_font(font_map, context, delta->font_desc);
|
||||
font = pango_font_map_load_font(font_map, context, display->font_desc);
|
||||
if (font == NULL) {
|
||||
guac_client_log_error(delta->client, "Unable to get font.");
|
||||
guac_client_log_error(display->client, "Unable to get font.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
metrics = pango_font_get_metrics(font, NULL);
|
||||
if (metrics == NULL) {
|
||||
guac_client_log_error(delta->client, "Unable to get font metrics.");
|
||||
guac_client_log_error(display->client, "Unable to get font metrics.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
delta->glyph_foreground = foreground;
|
||||
delta->glyph_background = background;
|
||||
display->glyph_foreground = foreground;
|
||||
display->glyph_background = background;
|
||||
|
||||
/* Calculate character dimensions */
|
||||
delta->char_width =
|
||||
display->char_width =
|
||||
pango_font_metrics_get_approximate_digit_width(metrics) / PANGO_SCALE;
|
||||
delta->char_height =
|
||||
display->char_height =
|
||||
(pango_font_metrics_get_descent(metrics)
|
||||
+ pango_font_metrics_get_ascent(metrics)) / PANGO_SCALE;
|
||||
|
||||
/* Set width and height */
|
||||
delta->width = width;
|
||||
delta->height = height;
|
||||
display->width = width;
|
||||
display->height = height;
|
||||
|
||||
/* Alloc operations */
|
||||
delta->operations = malloc(width * height *
|
||||
display->operations = malloc(width * height *
|
||||
sizeof(guac_terminal_operation));
|
||||
|
||||
/* Init each operation buffer row */
|
||||
current = delta->operations;
|
||||
current = display->operations;
|
||||
for (y=0; y<height; y++) {
|
||||
|
||||
/* Init entire row to NOP */
|
||||
@ -318,56 +318,56 @@ guac_terminal_delta* guac_terminal_delta_alloc(guac_client* client, int width, i
|
||||
}
|
||||
|
||||
/* Alloc scratch area */
|
||||
delta->scratch = malloc(width * height * sizeof(guac_terminal_operation));
|
||||
display->scratch = malloc(width * height * sizeof(guac_terminal_operation));
|
||||
|
||||
/* Send initial display size */
|
||||
guac_protocol_send_size(client->socket,
|
||||
GUAC_DEFAULT_LAYER,
|
||||
delta->char_width * width,
|
||||
delta->char_height * height);
|
||||
display->char_width * width,
|
||||
display->char_height * height);
|
||||
|
||||
return delta;
|
||||
return display;
|
||||
|
||||
}
|
||||
|
||||
void guac_terminal_delta_free(guac_terminal_delta* delta) {
|
||||
void guac_terminal_display_free(guac_terminal_display* display) {
|
||||
|
||||
/* Free operations buffers */
|
||||
free(delta->operations);
|
||||
free(delta->scratch);
|
||||
free(display->operations);
|
||||
free(display->scratch);
|
||||
|
||||
/* Free delta */
|
||||
free(delta);
|
||||
/* Free display */
|
||||
free(display);
|
||||
|
||||
}
|
||||
|
||||
void guac_terminal_delta_copy_columns(guac_terminal_delta* delta, int row,
|
||||
void guac_terminal_display_copy_columns(guac_terminal_display* display, int row,
|
||||
int start_column, int end_column, int offset) {
|
||||
/* STUB */
|
||||
}
|
||||
|
||||
void guac_terminal_delta_copy_rows(guac_terminal_delta* delta, int src_row, int rows,
|
||||
void guac_terminal_display_copy_rows(guac_terminal_display* display, int src_row, int rows,
|
||||
int start_row, int end_row, int offset) {
|
||||
/* STUB */
|
||||
}
|
||||
|
||||
void guac_terminal_delta_set_columns(guac_terminal_delta* delta, int row,
|
||||
void guac_terminal_display_set_columns(guac_terminal_display* display, int row,
|
||||
int start_column, int end_column, guac_terminal_char* character) {
|
||||
/* STUB */
|
||||
}
|
||||
|
||||
void guac_terminal_delta_resize(guac_terminal_delta* delta, int rows, int cols) {
|
||||
void guac_terminal_display_resize(guac_terminal_display* display, int rows, int cols) {
|
||||
/* STUB */
|
||||
}
|
||||
|
||||
void __guac_terminal_delta_flush_copy(guac_terminal_delta* delta) {
|
||||
void __guac_terminal_display_flush_copy(guac_terminal_display* display) {
|
||||
|
||||
guac_terminal_operation* current = delta->operations;
|
||||
guac_terminal_operation* current = display->operations;
|
||||
int row, col;
|
||||
|
||||
/* For each operation */
|
||||
for (row=0; row<delta->height; row++) {
|
||||
for (col=0; col<delta->width; col++) {
|
||||
for (row=0; row<display->height; row++) {
|
||||
for (col=0; col<display->width; col++) {
|
||||
|
||||
/* If operation is a copy operation */
|
||||
if (current->type == GUAC_CHAR_COPY) {
|
||||
@ -393,13 +393,13 @@ void __guac_terminal_delta_flush_copy(guac_terminal_delta* delta) {
|
||||
/* Determine bounds of rectangle */
|
||||
rect_current_row = current;
|
||||
expected_row = current->row;
|
||||
for (rect_row=row; rect_row<delta->height; rect_row++) {
|
||||
for (rect_row=row; rect_row<display->height; rect_row++) {
|
||||
|
||||
guac_terminal_operation* rect_current = rect_current_row;
|
||||
expected_col = current->column;
|
||||
|
||||
/* Find width */
|
||||
for (rect_col=col; rect_col<delta->width; rect_col++) {
|
||||
for (rect_col=col; rect_col<display->width; rect_col++) {
|
||||
|
||||
/* If not identical operation, stop */
|
||||
if (rect_current->type != GUAC_CHAR_COPY
|
||||
@ -425,7 +425,7 @@ void __guac_terminal_delta_flush_copy(guac_terminal_delta* delta) {
|
||||
detected_right = rect_col - 1;
|
||||
|
||||
/* Next row */
|
||||
rect_current_row += delta->width;
|
||||
rect_current_row += display->width;
|
||||
expected_row++;
|
||||
|
||||
}
|
||||
@ -457,24 +457,24 @@ void __guac_terminal_delta_flush_copy(guac_terminal_delta* delta) {
|
||||
}
|
||||
|
||||
/* Next row */
|
||||
rect_current_row += delta->width;
|
||||
rect_current_row += display->width;
|
||||
expected_row++;
|
||||
|
||||
}
|
||||
|
||||
/* Send copy */
|
||||
guac_protocol_send_copy(delta->client->socket,
|
||||
guac_protocol_send_copy(display->client->socket,
|
||||
|
||||
GUAC_DEFAULT_LAYER,
|
||||
current->column * delta->char_width,
|
||||
current->row * delta->char_height,
|
||||
rect_width * delta->char_width,
|
||||
rect_height * delta->char_height,
|
||||
current->column * display->char_width,
|
||||
current->row * display->char_height,
|
||||
rect_width * display->char_width,
|
||||
rect_height * display->char_height,
|
||||
|
||||
GUAC_COMP_OVER,
|
||||
GUAC_DEFAULT_LAYER,
|
||||
col * delta->char_width,
|
||||
row * delta->char_height);
|
||||
col * display->char_width,
|
||||
row * display->char_height);
|
||||
|
||||
} /* end if copy operation */
|
||||
|
||||
@ -486,14 +486,14 @@ void __guac_terminal_delta_flush_copy(guac_terminal_delta* delta) {
|
||||
|
||||
}
|
||||
|
||||
void __guac_terminal_delta_flush_clear(guac_terminal_delta* delta) {
|
||||
void __guac_terminal_display_flush_clear(guac_terminal_display* display) {
|
||||
|
||||
guac_terminal_operation* current = delta->operations;
|
||||
guac_terminal_operation* current = display->operations;
|
||||
int row, col;
|
||||
|
||||
/* For each operation */
|
||||
for (row=0; row<delta->height; row++) {
|
||||
for (col=0; col<delta->width; col++) {
|
||||
for (row=0; row<display->height; row++) {
|
||||
for (col=0; col<display->width; col++) {
|
||||
|
||||
/* If operation is a cler operation (set to space) */
|
||||
if (current->type == GUAC_CHAR_SET &&
|
||||
@ -525,12 +525,12 @@ void __guac_terminal_delta_flush_clear(guac_terminal_delta* delta) {
|
||||
|
||||
/* Determine bounds of rectangle */
|
||||
rect_current_row = current;
|
||||
for (rect_row=row; rect_row<delta->height; rect_row++) {
|
||||
for (rect_row=row; rect_row<display->height; rect_row++) {
|
||||
|
||||
guac_terminal_operation* rect_current = rect_current_row;
|
||||
|
||||
/* Find width */
|
||||
for (rect_col=col; rect_col<delta->width; rect_col++) {
|
||||
for (rect_col=col; rect_col<display->width; rect_col++) {
|
||||
|
||||
int joining_color;
|
||||
if (rect_current->character.attributes.reverse)
|
||||
@ -561,7 +561,7 @@ void __guac_terminal_delta_flush_clear(guac_terminal_delta* delta) {
|
||||
detected_right = rect_col - 1;
|
||||
|
||||
/* Next row */
|
||||
rect_current_row += delta->width;
|
||||
rect_current_row += display->width;
|
||||
|
||||
}
|
||||
|
||||
@ -595,19 +595,19 @@ void __guac_terminal_delta_flush_clear(guac_terminal_delta* delta) {
|
||||
}
|
||||
|
||||
/* Next row */
|
||||
rect_current_row += delta->width;
|
||||
rect_current_row += display->width;
|
||||
|
||||
}
|
||||
|
||||
/* Send rect */
|
||||
guac_protocol_send_rect(delta->client->socket,
|
||||
guac_protocol_send_rect(display->client->socket,
|
||||
GUAC_DEFAULT_LAYER,
|
||||
col * delta->char_width,
|
||||
row * delta->char_height,
|
||||
rect_width * delta->char_width,
|
||||
rect_height * delta->char_height);
|
||||
col * display->char_width,
|
||||
row * display->char_height,
|
||||
rect_width * display->char_width,
|
||||
rect_height * display->char_height);
|
||||
|
||||
guac_protocol_send_cfill(delta->client->socket,
|
||||
guac_protocol_send_cfill(display->client->socket,
|
||||
GUAC_COMP_OVER,
|
||||
GUAC_DEFAULT_LAYER,
|
||||
guac_color->red, guac_color->green, guac_color->blue,
|
||||
@ -623,24 +623,24 @@ void __guac_terminal_delta_flush_clear(guac_terminal_delta* delta) {
|
||||
|
||||
}
|
||||
|
||||
void __guac_terminal_delta_flush_set(guac_terminal_delta* delta) {
|
||||
void __guac_terminal_display_flush_set(guac_terminal_display* display) {
|
||||
|
||||
guac_terminal_operation* current = delta->operations;
|
||||
guac_terminal_operation* current = display->operations;
|
||||
int row, col;
|
||||
|
||||
/* For each operation */
|
||||
for (row=0; row<delta->height; row++) {
|
||||
for (col=0; col<delta->width; col++) {
|
||||
for (row=0; row<display->height; row++) {
|
||||
for (col=0; col<display->width; col++) {
|
||||
|
||||
/* Perform given operation */
|
||||
if (current->type == GUAC_CHAR_SET) {
|
||||
|
||||
/* Set attributes */
|
||||
__guac_terminal_set_colors(delta,
|
||||
__guac_terminal_set_colors(display,
|
||||
&(current->character.attributes));
|
||||
|
||||
/* Send character */
|
||||
__guac_terminal_set(delta, row, col,
|
||||
__guac_terminal_set(display, row, col,
|
||||
current->character.value);
|
||||
|
||||
/* Mark operation as handled */
|
||||
@ -656,12 +656,12 @@ void __guac_terminal_delta_flush_set(guac_terminal_delta* delta) {
|
||||
|
||||
}
|
||||
|
||||
void guac_terminal_delta_flush(guac_terminal_delta* delta) {
|
||||
void guac_terminal_display_flush(guac_terminal_display* display) {
|
||||
|
||||
/* Flush operations, copies first, then clears, then sets. */
|
||||
__guac_terminal_delta_flush_copy(delta);
|
||||
__guac_terminal_delta_flush_clear(delta);
|
||||
__guac_terminal_delta_flush_set(delta);
|
||||
__guac_terminal_display_flush_copy(display);
|
||||
__guac_terminal_display_flush_clear(display);
|
||||
__guac_terminal_display_flush_set(display);
|
||||
|
||||
}
|
||||
|
@ -117,8 +117,8 @@ int ssh_guac_client_handle_messages(guac_client* client) {
|
||||
client_data->term->cursor_row,
|
||||
client_data->term->cursor_col);
|
||||
|
||||
/* Flush terminal delta */
|
||||
guac_terminal_delta_flush(client_data->term->delta);
|
||||
/* Flush terminal display */
|
||||
guac_terminal_display_flush(client_data->term->display);
|
||||
|
||||
/* Unlock terminal access */
|
||||
pthread_mutex_unlock(&(client_data->term->lock));
|
||||
@ -186,8 +186,8 @@ int ssh_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) {
|
||||
/* Otherwise, just update */
|
||||
else
|
||||
guac_terminal_select_update(term,
|
||||
y / term->delta->char_height - term->scroll_offset,
|
||||
x / term->delta->char_width);
|
||||
y / term->display->char_height - term->scroll_offset,
|
||||
x / term->display->char_width);
|
||||
|
||||
pthread_mutex_unlock(&(term->lock));
|
||||
}
|
||||
@ -197,8 +197,8 @@ int ssh_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) {
|
||||
pthread_mutex_lock(&(term->lock));
|
||||
|
||||
guac_terminal_select_start(term,
|
||||
y / term->delta->char_height - term->scroll_offset,
|
||||
x / term->delta->char_width);
|
||||
y / term->display->char_height - term->scroll_offset,
|
||||
x / term->display->char_width);
|
||||
|
||||
pthread_mutex_unlock(&(term->lock));
|
||||
}
|
||||
|
@ -49,7 +49,7 @@
|
||||
|
||||
#include "types.h"
|
||||
#include "buffer.h"
|
||||
#include "delta.h"
|
||||
#include "display.h"
|
||||
#include "terminal.h"
|
||||
#include "terminal_handlers.h"
|
||||
|
||||
@ -71,8 +71,8 @@ guac_terminal* guac_terminal_create(guac_client* client,
|
||||
term->buffer = guac_terminal_buffer_alloc(1000);
|
||||
term->scroll_offset = 0;
|
||||
|
||||
/* Init delta */
|
||||
term->delta = guac_terminal_delta_alloc(client,
|
||||
/* Init display */
|
||||
term->display = guac_terminal_display_alloc(client,
|
||||
term->term_width, term->term_height,
|
||||
default_attributes.foreground,
|
||||
default_attributes.background);
|
||||
@ -84,8 +84,8 @@ guac_terminal* guac_terminal_create(guac_client* client,
|
||||
term->cursor_row = 0;
|
||||
term->cursor_col = 0;
|
||||
|
||||
term->term_width = width / term->delta->char_width;
|
||||
term->term_height = height / term->delta->char_height;
|
||||
term->term_width = width / term->display->char_width;
|
||||
term->term_height = height / term->display->char_height;
|
||||
term->char_handler = guac_terminal_echo;
|
||||
|
||||
term->scroll_start = 0;
|
||||
@ -106,8 +106,8 @@ guac_terminal* guac_terminal_create(guac_client* client,
|
||||
|
||||
void guac_terminal_free(guac_terminal* term) {
|
||||
|
||||
/* Free delta */
|
||||
guac_terminal_delta_free(term->delta);
|
||||
/* Free display */
|
||||
guac_terminal_display_free(term->display);
|
||||
|
||||
/* Free buffer */
|
||||
guac_terminal_buffer_free(term->buffer);
|
||||
@ -123,9 +123,9 @@ int guac_terminal_set(guac_terminal* term, int row, int col, char c) {
|
||||
guac_char.value = c;
|
||||
guac_char.attributes = term->current_attributes;
|
||||
|
||||
/* Set delta */
|
||||
if (scrolled_row < term->delta->height)
|
||||
guac_terminal_delta_set_columns(term->delta, scrolled_row, col, col, &guac_char);
|
||||
/* Set display */
|
||||
if (scrolled_row < term->display->height)
|
||||
guac_terminal_display_set_columns(term->display, scrolled_row, col, col, &guac_char);
|
||||
|
||||
/* Set buffer */
|
||||
guac_terminal_buffer_set_columns(term->buffer, row, col, col, &guac_char);
|
||||
@ -145,9 +145,9 @@ int guac_terminal_toggle_reverse(guac_terminal* term, int row, int col) {
|
||||
/* Toggle reverse */
|
||||
guac_char->attributes.reverse = !(guac_char->attributes.reverse);
|
||||
|
||||
/* Set delta */
|
||||
if (scrolled_row < term->delta->height)
|
||||
guac_terminal_delta_set(term->delta, scrolled_row, col, guac_char);
|
||||
/* Set display */
|
||||
if (scrolled_row < term->display->height)
|
||||
guac_terminal_display_set(term->display, scrolled_row, col, guac_char);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -174,22 +174,22 @@ int guac_terminal_copy(guac_terminal* term,
|
||||
int scrolled_rows = rows;
|
||||
|
||||
/* FIXME: If source (but not dest) is partially scrolled out of view, then
|
||||
* the delta will not be updated properly. We need to pull the data
|
||||
* the display will not be updated properly. We need to pull the data
|
||||
* from the buffer in such a case.
|
||||
*/
|
||||
|
||||
if (scrolled_src_row < term->delta->height &&
|
||||
scrolled_dst_row < term->delta->height) {
|
||||
if (scrolled_src_row < term->display->height &&
|
||||
scrolled_dst_row < term->display->height) {
|
||||
|
||||
/* Adjust delta rect height if scrolled out of view */
|
||||
if (scrolled_src_row + scrolled_rows > term->delta->height)
|
||||
scrolled_rows = term->delta->height - scrolled_src_row;
|
||||
/* Adjust display rect height if scrolled out of view */
|
||||
if (scrolled_src_row + scrolled_rows > term->display->height)
|
||||
scrolled_rows = term->display->height - scrolled_src_row;
|
||||
|
||||
if (scrolled_dst_row + scrolled_rows > term->delta->height)
|
||||
scrolled_rows = term->delta->height - scrolled_dst_row;
|
||||
if (scrolled_dst_row + scrolled_rows > term->display->height)
|
||||
scrolled_rows = term->display->height - scrolled_dst_row;
|
||||
|
||||
/* Update delta */
|
||||
guac_terminal_delta_copy(term->delta,
|
||||
/* Update display */
|
||||
guac_terminal_display_copy(term->display,
|
||||
scrolled_dst_row, dst_col,
|
||||
scrolled_src_row, src_col,
|
||||
cols, rows);
|
||||
@ -218,14 +218,14 @@ int guac_terminal_clear(guac_terminal* term,
|
||||
character.value = ' ';
|
||||
character.attributes = term->current_attributes;
|
||||
|
||||
if (scrolled_row < term->delta->height) {
|
||||
if (scrolled_row < term->display->height) {
|
||||
|
||||
/* Adjust delta rect height if scrolled out of view */
|
||||
if (scrolled_row + scrolled_rows > term->delta->height)
|
||||
scrolled_rows = term->delta->height - scrolled_row;
|
||||
/* Adjust display rect height if scrolled out of view */
|
||||
if (scrolled_row + scrolled_rows > term->display->height)
|
||||
scrolled_rows = term->display->height - scrolled_row;
|
||||
|
||||
/* Fill with color */
|
||||
guac_terminal_delta_set_rect(term->delta,
|
||||
guac_terminal_display_set_rect(term->display,
|
||||
scrolled_row, col, cols, scrolled_rows, &character);
|
||||
|
||||
}
|
||||
@ -324,11 +324,11 @@ int guac_terminal_clear_range(guac_terminal* term,
|
||||
}
|
||||
|
||||
|
||||
void guac_terminal_delta_set(guac_terminal_delta* delta, int r, int c,
|
||||
void guac_terminal_display_set(guac_terminal_display* display, int r, int c,
|
||||
guac_terminal_char* character) {
|
||||
|
||||
/* Get operation at coordinate */
|
||||
guac_terminal_operation* op = &(delta->operations[r*delta->width + c]);
|
||||
guac_terminal_operation* op = &(display->operations[r*display->width + c]);
|
||||
|
||||
/* Store operation */
|
||||
op->type = GUAC_CHAR_SET;
|
||||
@ -336,7 +336,7 @@ void guac_terminal_delta_set(guac_terminal_delta* delta, int r, int c,
|
||||
|
||||
}
|
||||
|
||||
void guac_terminal_delta_copy(guac_terminal_delta* delta,
|
||||
void guac_terminal_display_copy(guac_terminal_display* display,
|
||||
int dst_row, int dst_column,
|
||||
int src_row, int src_column,
|
||||
int w, int h) {
|
||||
@ -345,14 +345,14 @@ void guac_terminal_delta_copy(guac_terminal_delta* delta,
|
||||
|
||||
/* FIXME: Handle intersections between src and dst rects */
|
||||
|
||||
memcpy(delta->scratch, delta->operations,
|
||||
sizeof(guac_terminal_operation) * delta->width * delta->height);
|
||||
memcpy(display->scratch, display->operations,
|
||||
sizeof(guac_terminal_operation) * display->width * display->height);
|
||||
|
||||
guac_terminal_operation* current_row =
|
||||
&(delta->operations[dst_row*delta->width + dst_column]);
|
||||
&(display->operations[dst_row*display->width + dst_column]);
|
||||
|
||||
guac_terminal_operation* src_current_row =
|
||||
&(delta->scratch[src_row*delta->width + src_column]);
|
||||
&(display->scratch[src_row*display->width + src_column]);
|
||||
|
||||
/* Set rectangle to copy operations */
|
||||
for (row=0; row<h; row++) {
|
||||
@ -362,7 +362,7 @@ void guac_terminal_delta_copy(guac_terminal_delta* delta,
|
||||
|
||||
for (column=0; column<w; column++) {
|
||||
|
||||
/* If copying existing delta operation, just copy that rather
|
||||
/* If copying existing display operation, just copy that rather
|
||||
* than create a new copy op */
|
||||
if (src_current->type != GUAC_CHAR_NOP)
|
||||
*current = *src_current;
|
||||
@ -381,8 +381,8 @@ void guac_terminal_delta_copy(guac_terminal_delta* delta,
|
||||
}
|
||||
|
||||
/* Next row */
|
||||
current_row += delta->width;
|
||||
src_current_row += delta->width;
|
||||
current_row += display->width;
|
||||
src_current_row += display->width;
|
||||
|
||||
}
|
||||
|
||||
@ -390,12 +390,12 @@ void guac_terminal_delta_copy(guac_terminal_delta* delta,
|
||||
|
||||
}
|
||||
|
||||
void guac_terminal_delta_set_rect(guac_terminal_delta* delta,
|
||||
void guac_terminal_display_set_rect(guac_terminal_display* display,
|
||||
int row, int column, int w, int h,
|
||||
guac_terminal_char* character) {
|
||||
|
||||
guac_terminal_operation* current_row =
|
||||
&(delta->operations[row*delta->width + column]);
|
||||
&(display->operations[row*display->width + column]);
|
||||
|
||||
/* Set rectangle contents to given character */
|
||||
for (row=0; row<h; row++) {
|
||||
@ -414,7 +414,7 @@ void guac_terminal_delta_set_rect(guac_terminal_delta* delta,
|
||||
}
|
||||
|
||||
/* Next row */
|
||||
current_row += delta->width;
|
||||
current_row += display->width;
|
||||
|
||||
}
|
||||
|
||||
@ -494,7 +494,7 @@ void guac_terminal_scroll_display_down(guac_terminal* terminal,
|
||||
|
||||
/* Shift screen up */
|
||||
if (terminal->term_height > scroll_amount)
|
||||
guac_terminal_delta_copy(terminal->delta,
|
||||
guac_terminal_display_copy(terminal->display,
|
||||
0, 0, /* Destination row, col */
|
||||
scroll_amount, 0, /* source row,col */
|
||||
terminal->term_width, terminal->term_height - scroll_amount);
|
||||
@ -514,7 +514,7 @@ void guac_terminal_scroll_display_down(guac_terminal* terminal,
|
||||
guac_terminal_char* current = guac_terminal_get_row(terminal, row, &length);
|
||||
|
||||
for (column=0; column<length; column++)
|
||||
guac_terminal_delta_set(terminal->delta, dest_row, column,
|
||||
guac_terminal_display_set(terminal->display, dest_row, column,
|
||||
current++);
|
||||
|
||||
/* Next row */
|
||||
@ -523,7 +523,7 @@ void guac_terminal_scroll_display_down(guac_terminal* terminal,
|
||||
}
|
||||
|
||||
/* FIXME: Should flush somewhere more sensible */
|
||||
guac_terminal_delta_flush(terminal->delta, terminal);
|
||||
guac_terminal_display_flush(terminal->display, terminal);
|
||||
guac_socket_flush(terminal->client->socket);
|
||||
|
||||
}
|
||||
@ -546,7 +546,7 @@ void guac_terminal_scroll_display_up(guac_terminal* terminal,
|
||||
|
||||
/* Shift screen down */
|
||||
if (terminal->term_height > scroll_amount)
|
||||
guac_terminal_delta_copy(terminal->delta,
|
||||
guac_terminal_display_copy(terminal->display,
|
||||
scroll_amount, 0, /* Destination row,col */
|
||||
0, 0, /* Source row, col */
|
||||
terminal->term_width, terminal->term_height - scroll_amount);
|
||||
@ -570,7 +570,7 @@ void guac_terminal_scroll_display_up(guac_terminal* terminal,
|
||||
/* FIXME: Clear row first */
|
||||
guac_terminal_char* current = scrollback_row->characters;
|
||||
for (column=0; column<scrollback_row->length; column++)
|
||||
guac_terminal_delta_set(terminal->delta, dest_row, column,
|
||||
guac_terminal_display_set(terminal->display, dest_row, column,
|
||||
current++);
|
||||
|
||||
/* Next row */
|
||||
@ -579,7 +579,7 @@ void guac_terminal_scroll_display_up(guac_terminal* terminal,
|
||||
}
|
||||
|
||||
/* FIXME: Should flush somewhere more sensible */
|
||||
guac_terminal_delta_flush(terminal->delta, terminal);
|
||||
guac_terminal_display_flush(terminal->display, terminal);
|
||||
guac_socket_flush(terminal->client->socket);
|
||||
|
||||
}
|
||||
@ -610,14 +610,14 @@ void guac_terminal_select_start(guac_terminal* terminal, int row, int column) {
|
||||
|
||||
/* Get char and operation */
|
||||
guac_char = &(terminal->buffer->characters[terminal->buffer->width * row + column]);
|
||||
guac_operation = &(terminal->delta->operations[terminal->delta->width * row + column]);
|
||||
guac_operation = &(terminal->display->operations[terminal->display->width * row + column]);
|
||||
|
||||
/* Set character as selected */
|
||||
guac_char->attributes.selected = true;
|
||||
guac_operation->type = GUAC_CHAR_SET;
|
||||
guac_operation->character = *guac_char;
|
||||
|
||||
guac_terminal_delta_flush(terminal->delta, terminal);
|
||||
guac_terminal_display_flush(terminal->display, terminal);
|
||||
guac_socket_flush(terminal->client->socket);
|
||||
|
||||
}
|
||||
@ -676,7 +676,7 @@ void guac_terminal_select_update(guac_terminal* terminal, int row, int column) {
|
||||
|
||||
/* Get first character */
|
||||
guac_char = &(terminal->buffer->characters[search_index_a]);
|
||||
guac_operation = &(terminal->delta->operations[search_index_a]);
|
||||
guac_operation = &(terminal->display->operations[search_index_a]);
|
||||
|
||||
/* Invert modified area */
|
||||
for (i=search_index_a; i<=search_index_b; i++) {
|
||||
@ -710,7 +710,7 @@ void guac_terminal_select_update(guac_terminal* terminal, int row, int column) {
|
||||
terminal->selection_end_row = row;
|
||||
terminal->selection_end_column = column;
|
||||
|
||||
guac_terminal_delta_flush(terminal->delta, terminal);
|
||||
guac_terminal_display_flush(terminal->display, terminal);
|
||||
guac_socket_flush(terminal->client->socket);
|
||||
|
||||
}
|
||||
@ -743,7 +743,7 @@ void guac_terminal_select_end(guac_terminal* terminal) {
|
||||
|
||||
/* Get first character */
|
||||
guac_char = &(terminal->buffer->characters[start_index]);
|
||||
guac_operation = &(terminal->delta->operations[start_index]);
|
||||
guac_operation = &(terminal->display->operations[start_index]);
|
||||
|
||||
/* Restore state from buffer */
|
||||
for (i=start_index; i<=end_index; i++) {
|
||||
@ -761,7 +761,7 @@ void guac_terminal_select_end(guac_terminal* terminal) {
|
||||
|
||||
terminal->text_selected = false;
|
||||
|
||||
guac_terminal_delta_flush(terminal->delta, terminal);
|
||||
guac_terminal_display_flush(terminal->display, terminal);
|
||||
guac_socket_flush(terminal->client->socket);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user