Clean up code ... rename ssh_guac_terminal to guac_terminal (preparing for generic).
This commit is contained in:
parent
baa6d98724
commit
80a56bc9fd
@ -40,7 +40,17 @@ ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
lib_LTLIBRARIES = libguac-client-ssh.la
|
||||
|
||||
libguac_client_ssh_la_SOURCES = src/ssh_client.c src/ssh_handlers.c src/ssh_terminal.c src/ssh_terminal_handlers.c
|
||||
libguac_client_ssh_la_SOURCES = \
|
||||
src/ssh_client.c \
|
||||
src/ssh_handlers.c \
|
||||
src/terminal.c \
|
||||
src/terminal_handlers.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
include/ssh_client.h \
|
||||
include/ssh_handlers.h \
|
||||
include/terminal.h \
|
||||
include/terminal_handlers.h
|
||||
|
||||
libguac_client_ssh_la_CFLAGS = -Werror -Wall -pedantic -Iinclude @PANGO_CFLAGS@ @PANGOCAIRO_CFLAGS@
|
||||
libguac_client_ssh_la_LIBADD = @PANGO_LIBS@ @PANGOCAIRO_LIBS@
|
||||
|
@ -45,14 +45,14 @@
|
||||
|
||||
#include "ssh_client.h"
|
||||
#include "ssh_handlers.h"
|
||||
#include "ssh_terminal.h"
|
||||
#include "terminal.h"
|
||||
|
||||
typedef struct ssh_guac_client_data {
|
||||
|
||||
ssh_session session;
|
||||
ssh_channel term_channel;
|
||||
|
||||
ssh_guac_terminal* term;
|
||||
guac_terminal* term;
|
||||
|
||||
char * clipboard_data;
|
||||
|
||||
|
@ -42,20 +42,20 @@
|
||||
|
||||
#include <guacamole/client.h>
|
||||
|
||||
typedef struct ssh_guac_terminal ssh_guac_terminal;
|
||||
typedef struct guac_terminal guac_terminal;
|
||||
|
||||
/**
|
||||
* Handler for characters printed to the terminal. When a character is printed,
|
||||
* the current char handler for the terminal is called and given that
|
||||
* character.
|
||||
*/
|
||||
typedef int ssh_guac_terminal_char_handler(ssh_guac_terminal* term, char c);
|
||||
typedef int guac_terminal_char_handler(guac_terminal* term, char c);
|
||||
|
||||
/**
|
||||
* Represents a single character for display in a terminal, including actual
|
||||
* character value, foreground color, and background color.
|
||||
*/
|
||||
typedef struct ssh_guac_terminal_char {
|
||||
typedef struct guac_terminal_char {
|
||||
|
||||
/**
|
||||
* The character value of the character to display.
|
||||
@ -72,13 +72,13 @@ typedef struct ssh_guac_terminal_char {
|
||||
*/
|
||||
int background;
|
||||
|
||||
} ssh_guac_terminal_char;
|
||||
} guac_terminal_char;
|
||||
|
||||
/**
|
||||
* Represents a terminal emulator which uses a given Guacamole client to
|
||||
* render itself.
|
||||
*/
|
||||
struct ssh_guac_terminal {
|
||||
struct guac_terminal {
|
||||
|
||||
/**
|
||||
* The Guacamole client this terminal emulator will use for rendering.
|
||||
@ -126,7 +126,7 @@ struct ssh_guac_terminal {
|
||||
* Array of scrollback buffer rows, where each row is an array of
|
||||
* characters.
|
||||
*/
|
||||
ssh_guac_terminal_char** scrollback;
|
||||
guac_terminal_char** scrollback;
|
||||
|
||||
/**
|
||||
* The width of each character, in pixels.
|
||||
@ -182,46 +182,46 @@ struct ssh_guac_terminal {
|
||||
int default_foreground;
|
||||
int default_background;
|
||||
|
||||
ssh_guac_terminal_char_handler* char_handler;
|
||||
guac_terminal_char_handler* char_handler;
|
||||
|
||||
};
|
||||
|
||||
typedef struct ssh_guac_terminal_color {
|
||||
typedef struct guac_terminal_color {
|
||||
int red;
|
||||
int green;
|
||||
int blue;
|
||||
} ssh_guac_terminal_color;
|
||||
} guac_terminal_color;
|
||||
|
||||
extern const ssh_guac_terminal_color ssh_guac_terminal_palette[16];
|
||||
extern const guac_terminal_color guac_terminal_palette[16];
|
||||
|
||||
ssh_guac_terminal* ssh_guac_terminal_create(guac_client* client,
|
||||
guac_terminal* guac_terminal_create(guac_client* client,
|
||||
int width, int height);
|
||||
|
||||
void ssh_guac_terminal_free(ssh_guac_terminal* term);
|
||||
void guac_terminal_free(guac_terminal* term);
|
||||
|
||||
int ssh_guac_terminal_write(ssh_guac_terminal* term, const char* c, int size);
|
||||
int guac_terminal_write(guac_terminal* term, const char* c, int size);
|
||||
|
||||
int ssh_guac_terminal_redraw_cursor(ssh_guac_terminal* term);
|
||||
int guac_terminal_redraw_cursor(guac_terminal* term);
|
||||
|
||||
int ssh_guac_terminal_set_colors(ssh_guac_terminal* term,
|
||||
int guac_terminal_set_colors(guac_terminal* term,
|
||||
int foreground, int background);
|
||||
|
||||
int ssh_guac_terminal_set(ssh_guac_terminal* term, int row, int col, char c);
|
||||
int guac_terminal_set(guac_terminal* term, int row, int col, char c);
|
||||
|
||||
int ssh_guac_terminal_copy(ssh_guac_terminal* term,
|
||||
int guac_terminal_copy(guac_terminal* term,
|
||||
int src_row, int src_col, int rows, int cols,
|
||||
int dst_row, int dst_col);
|
||||
|
||||
int ssh_guac_terminal_clear(ssh_guac_terminal* term,
|
||||
int guac_terminal_clear(guac_terminal* term,
|
||||
int row, int col, int rows, int cols, int background_color);
|
||||
|
||||
int ssh_guac_terminal_scroll_up(ssh_guac_terminal* term,
|
||||
int guac_terminal_scroll_up(guac_terminal* term,
|
||||
int start_row, int end_row, int amount);
|
||||
|
||||
int ssh_guac_terminal_scroll_down(ssh_guac_terminal* term,
|
||||
int guac_terminal_scroll_down(guac_terminal* term,
|
||||
int start_row, int end_row, int amount);
|
||||
|
||||
int ssh_guac_terminal_clear_range(ssh_guac_terminal* term,
|
||||
int guac_terminal_clear_range(guac_terminal* term,
|
||||
int start_row, int start_col,
|
||||
int end_row, int end_col, int background_color);
|
||||
|
@ -38,13 +38,13 @@
|
||||
#ifndef _SSH_GUAC_TERMINAL_HANDLERS
|
||||
#define _SSH_GUAC_TERMINAL_HANDLERS
|
||||
|
||||
#include "ssh_terminal.h"
|
||||
#include "terminal.h"
|
||||
|
||||
int ssh_guac_terminal_echo(ssh_guac_terminal* term, char c);
|
||||
int ssh_guac_terminal_escape(ssh_guac_terminal* term, char c);
|
||||
int ssh_guac_terminal_charset(ssh_guac_terminal* term, char c);
|
||||
int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c);
|
||||
int ssh_guac_terminal_osc(ssh_guac_terminal* term, char c);
|
||||
int guac_terminal_echo(guac_terminal* term, char c);
|
||||
int guac_terminal_escape(guac_terminal* term, char c);
|
||||
int guac_terminal_charset(guac_terminal* term, char c);
|
||||
int guac_terminal_csi(guac_terminal* term, char c);
|
||||
int guac_terminal_osc(guac_terminal* term, char c);
|
||||
|
||||
#endif
|
||||
|
@ -47,7 +47,7 @@
|
||||
|
||||
#include "ssh_client.h"
|
||||
#include "ssh_handlers.h"
|
||||
#include "ssh_terminal.h"
|
||||
#include "terminal.h"
|
||||
|
||||
/* Client plugin arguments */
|
||||
const char* GUAC_CLIENT_ARGS[] = {
|
||||
@ -68,8 +68,8 @@ int ssh_guac_client_password_key_handler(guac_client* client, int keysym, int pr
|
||||
if (keysym >= 0x00 && keysym <= 0xFF) {
|
||||
/* Add to password */
|
||||
client_data->password[client_data->password_length++] = keysym;
|
||||
ssh_guac_terminal_write(client_data->term, "*", 1);
|
||||
ssh_guac_terminal_redraw_cursor(client_data->term);
|
||||
guac_terminal_write(client_data->term, "*", 1);
|
||||
guac_terminal_redraw_cursor(client_data->term);
|
||||
guac_socket_flush(client->socket);
|
||||
}
|
||||
else if (keysym == 0xFF08) {
|
||||
@ -78,8 +78,8 @@ int ssh_guac_client_password_key_handler(guac_client* client, int keysym, int pr
|
||||
client_data->password_length--;
|
||||
|
||||
/* Backspace */
|
||||
ssh_guac_terminal_write(client_data->term, "\x08\x1B[K", 4);
|
||||
ssh_guac_terminal_redraw_cursor(client_data->term);
|
||||
guac_terminal_write(client_data->term, "\x08\x1B[K", 4);
|
||||
guac_terminal_redraw_cursor(client_data->term);
|
||||
guac_socket_flush(client->socket);
|
||||
}
|
||||
|
||||
@ -90,8 +90,8 @@ int ssh_guac_client_password_key_handler(guac_client* client, int keysym, int pr
|
||||
client_data->password[client_data->password_length] = '\0';
|
||||
|
||||
/* Clear screen */
|
||||
ssh_guac_terminal_write(client_data->term, "\x1B[2J\x1B[1;1H", 10);
|
||||
ssh_guac_terminal_redraw_cursor(client_data->term);
|
||||
guac_terminal_write(client_data->term, "\x1B[2J\x1B[1;1H", 10);
|
||||
guac_terminal_redraw_cursor(client_data->term);
|
||||
guac_socket_flush(client->socket);
|
||||
|
||||
return ssh_guac_client_auth(client, client_data->password);
|
||||
@ -109,7 +109,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
||||
guac_socket* socket = client->socket;
|
||||
|
||||
ssh_guac_client_data* client_data = malloc(sizeof(ssh_guac_client_data));
|
||||
ssh_guac_terminal* term = ssh_guac_terminal_create(client,
|
||||
guac_terminal* term = guac_terminal_create(client,
|
||||
client->info.optimal_width, client->info.optimal_height);
|
||||
|
||||
/* Init client data */
|
||||
@ -165,8 +165,8 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
|
||||
else {
|
||||
|
||||
client_data->password_length = 0;
|
||||
ssh_guac_terminal_write(client_data->term, "Password: ", 10);
|
||||
ssh_guac_terminal_redraw_cursor(client_data->term);
|
||||
guac_terminal_write(client_data->term, "Password: ", 10);
|
||||
guac_terminal_redraw_cursor(client_data->term);
|
||||
guac_socket_flush(client->socket);
|
||||
|
||||
client->key_handler = ssh_guac_client_password_key_handler;
|
||||
@ -182,7 +182,7 @@ int ssh_guac_client_auth(guac_client* client, const char* password) {
|
||||
|
||||
guac_socket* socket = client->socket;
|
||||
ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data;
|
||||
ssh_guac_terminal* term = client_data->term;
|
||||
guac_terminal* term = client_data->term;
|
||||
|
||||
/* Authenticate */
|
||||
if (ssh_userauth_password(client_data->session, NULL, password) != SSH_AUTH_SUCCESS) {
|
||||
|
@ -90,8 +90,8 @@ int ssh_guac_client_handle_messages(guac_client* client) {
|
||||
&& !channel_is_eof(client_data->term_channel)
|
||||
&& (bytes_read = channel_read_nonblocking(client_data->term_channel, buffer, sizeof(buffer), 0)) > 0) {
|
||||
|
||||
if (ssh_guac_terminal_write(client_data->term, buffer, bytes_read)
|
||||
|| ssh_guac_terminal_redraw_cursor(client_data->term)
|
||||
if (guac_terminal_write(client_data->term, buffer, bytes_read)
|
||||
|| guac_terminal_redraw_cursor(client_data->term)
|
||||
|| guac_socket_flush(socket))
|
||||
return 1;
|
||||
|
||||
@ -206,7 +206,7 @@ int ssh_guac_client_free_handler(guac_client* client) {
|
||||
ssh_guac_client_data* guac_client_data = (ssh_guac_client_data*) client->data;
|
||||
|
||||
/* Free terminal */
|
||||
ssh_guac_terminal_free(guac_client_data->term);
|
||||
guac_terminal_free(guac_client_data->term);
|
||||
|
||||
/* Free clipboard data */
|
||||
free(guac_client_data->clipboard_data);
|
||||
|
@ -46,10 +46,10 @@
|
||||
#include <guacamole/protocol.h>
|
||||
#include <guacamole/client.h>
|
||||
|
||||
#include "ssh_terminal.h"
|
||||
#include "ssh_terminal_handlers.h"
|
||||
#include "terminal.h"
|
||||
#include "terminal_handlers.h"
|
||||
|
||||
const ssh_guac_terminal_color ssh_guac_terminal_palette[16] = {
|
||||
const guac_terminal_color guac_terminal_palette[16] = {
|
||||
|
||||
/* Normal colors */
|
||||
{0x00, 0x00, 0x00}, /* Black */
|
||||
@ -73,7 +73,7 @@ const ssh_guac_terminal_color ssh_guac_terminal_palette[16] = {
|
||||
|
||||
};
|
||||
|
||||
ssh_guac_terminal* ssh_guac_terminal_create(guac_client* client,
|
||||
guac_terminal* guac_terminal_create(guac_client* client,
|
||||
int width, int height) {
|
||||
|
||||
int row, col;
|
||||
@ -83,7 +83,7 @@ ssh_guac_terminal* ssh_guac_terminal_create(guac_client* client,
|
||||
PangoFontMetrics* metrics;
|
||||
PangoContext* context;
|
||||
|
||||
ssh_guac_terminal* term = malloc(sizeof(ssh_guac_terminal));
|
||||
guac_terminal* term = malloc(sizeof(guac_terminal));
|
||||
term->client = client;
|
||||
|
||||
term->glyph_foreground = term->foreground = term->default_foreground = 7; /* White */
|
||||
@ -131,20 +131,20 @@ ssh_guac_terminal* ssh_guac_terminal_create(guac_client* client,
|
||||
|
||||
term->term_width = width / term->char_width;
|
||||
term->term_height = height / term->char_height;
|
||||
term->char_handler = ssh_guac_terminal_echo;
|
||||
term->char_handler = guac_terminal_echo;
|
||||
|
||||
term->scroll_start = 0;
|
||||
term->scroll_end = term->term_height - 1;
|
||||
|
||||
/* Create scrollback buffer */
|
||||
term->scrollback = malloc(term->term_height * sizeof(ssh_guac_terminal_char*));
|
||||
term->scrollback = malloc(term->term_height * sizeof(guac_terminal_char*));
|
||||
|
||||
/* Init buffer */
|
||||
for (row = 0; row < term->term_height; row++) {
|
||||
|
||||
/* Create row */
|
||||
ssh_guac_terminal_char* current_row =
|
||||
term->scrollback[row] = malloc(term->term_width * sizeof(ssh_guac_terminal_char));
|
||||
guac_terminal_char* current_row =
|
||||
term->scrollback[row] = malloc(term->term_width * sizeof(guac_terminal_char));
|
||||
|
||||
/* Init row */
|
||||
for (col = 0; col < term->term_width; col++) {
|
||||
@ -159,7 +159,7 @@ ssh_guac_terminal* ssh_guac_terminal_create(guac_client* client,
|
||||
}
|
||||
|
||||
/* Clear with background color */
|
||||
ssh_guac_terminal_clear(term,
|
||||
guac_terminal_clear(term,
|
||||
0, 0, term->term_height, term->term_width,
|
||||
term->background);
|
||||
|
||||
@ -167,7 +167,7 @@ ssh_guac_terminal* ssh_guac_terminal_create(guac_client* client,
|
||||
|
||||
}
|
||||
|
||||
void ssh_guac_terminal_free(ssh_guac_terminal* term) {
|
||||
void guac_terminal_free(guac_terminal* term) {
|
||||
|
||||
/* Free scrollback buffer */
|
||||
for (int row = 0; row < term->term_height; row++)
|
||||
@ -176,18 +176,18 @@ void ssh_guac_terminal_free(ssh_guac_terminal* term) {
|
||||
free(term->scrollback);
|
||||
}
|
||||
|
||||
int __ssh_guac_terminal_get_glyph(ssh_guac_terminal* term, char c) {
|
||||
int __guac_terminal_get_glyph(guac_terminal* term, char c) {
|
||||
|
||||
guac_socket* socket = term->client->socket;
|
||||
int location;
|
||||
|
||||
/* Use foreground color */
|
||||
const ssh_guac_terminal_color* color =
|
||||
&ssh_guac_terminal_palette[term->glyph_foreground];
|
||||
const guac_terminal_color* color =
|
||||
&guac_terminal_palette[term->glyph_foreground];
|
||||
|
||||
/* Use background color */
|
||||
const ssh_guac_terminal_color* background =
|
||||
&ssh_guac_terminal_palette[term->glyph_background];
|
||||
const guac_terminal_color* background =
|
||||
&guac_terminal_palette[term->glyph_background];
|
||||
|
||||
cairo_surface_t* surface;
|
||||
cairo_t* cairo;
|
||||
@ -251,7 +251,7 @@ int __ssh_guac_terminal_get_glyph(ssh_guac_terminal* term, char c) {
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_redraw_cursor(ssh_guac_terminal* term) {
|
||||
int guac_terminal_redraw_cursor(guac_terminal* term) {
|
||||
|
||||
guac_socket* socket = term->client->socket;
|
||||
|
||||
@ -267,21 +267,21 @@ int ssh_guac_terminal_redraw_cursor(ssh_guac_terminal* term) {
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_set_colors(ssh_guac_terminal* term,
|
||||
int guac_terminal_set_colors(guac_terminal* term,
|
||||
int foreground, int background) {
|
||||
|
||||
guac_socket* socket = term->client->socket;
|
||||
const ssh_guac_terminal_color* background_color;
|
||||
const guac_terminal_color* background_color;
|
||||
|
||||
/* Get background color */
|
||||
background_color = &ssh_guac_terminal_palette[background];
|
||||
background_color = &guac_terminal_palette[background];
|
||||
|
||||
/* If foreground different from current, colorize */
|
||||
if (foreground != term->glyph_foreground) {
|
||||
|
||||
/* Get color */
|
||||
const ssh_guac_terminal_color* color =
|
||||
&ssh_guac_terminal_palette[foreground];
|
||||
const guac_terminal_color* color =
|
||||
&guac_terminal_palette[foreground];
|
||||
|
||||
/* Colorize letter */
|
||||
guac_protocol_send_rect(socket, term->glyph_stroke,
|
||||
@ -328,10 +328,10 @@ int ssh_guac_terminal_set_colors(ssh_guac_terminal* term,
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_set(ssh_guac_terminal* term, int row, int col, char c) {
|
||||
int guac_terminal_set(guac_terminal* term, int row, int col, char c) {
|
||||
|
||||
guac_socket* socket = term->client->socket;
|
||||
int location = __ssh_guac_terminal_get_glyph(term, c);
|
||||
int location = __guac_terminal_get_glyph(term, c);
|
||||
|
||||
return guac_protocol_send_copy(socket,
|
||||
term->filled_glyphs,
|
||||
@ -342,7 +342,7 @@ int ssh_guac_terminal_set(ssh_guac_terminal* term, int row, int col, char c) {
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_write(ssh_guac_terminal* term, const char* c, int size) {
|
||||
int guac_terminal_write(guac_terminal* term, const char* c, int size) {
|
||||
|
||||
while (size > 0) {
|
||||
term->char_handler(term, *(c++));
|
||||
@ -353,7 +353,7 @@ int ssh_guac_terminal_write(ssh_guac_terminal* term, const char* c, int size) {
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_copy(ssh_guac_terminal* term,
|
||||
int guac_terminal_copy(guac_terminal* term,
|
||||
int src_row, int src_col, int rows, int cols,
|
||||
int dst_row, int dst_col) {
|
||||
|
||||
@ -372,12 +372,12 @@ int ssh_guac_terminal_copy(ssh_guac_terminal* term,
|
||||
}
|
||||
|
||||
|
||||
int ssh_guac_terminal_clear(ssh_guac_terminal* term,
|
||||
int guac_terminal_clear(guac_terminal* term,
|
||||
int row, int col, int rows, int cols, int background_color) {
|
||||
|
||||
guac_socket* socket = term->client->socket;
|
||||
const ssh_guac_terminal_color* color =
|
||||
&ssh_guac_terminal_palette[background_color];
|
||||
const guac_terminal_color* color =
|
||||
&guac_terminal_palette[background_color];
|
||||
|
||||
/* Fill with color */
|
||||
return
|
||||
@ -390,7 +390,7 @@ int ssh_guac_terminal_clear(ssh_guac_terminal* term,
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_scroll_up(ssh_guac_terminal* term,
|
||||
int guac_terminal_scroll_up(guac_terminal* term,
|
||||
int start_row, int end_row, int amount) {
|
||||
|
||||
/* Calculate height of scroll region */
|
||||
@ -399,19 +399,19 @@ int ssh_guac_terminal_scroll_up(ssh_guac_terminal* term,
|
||||
return
|
||||
|
||||
/* Move rows within scroll region up by the given amount */
|
||||
ssh_guac_terminal_copy(term,
|
||||
guac_terminal_copy(term,
|
||||
start_row + amount, 0,
|
||||
height - amount, term->term_width,
|
||||
start_row, 0)
|
||||
|
||||
/* Fill new rows with background */
|
||||
|| ssh_guac_terminal_clear(term,
|
||||
|| guac_terminal_clear(term,
|
||||
end_row - amount + 1, 0, amount, term->term_width,
|
||||
term->background);
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_scroll_down(ssh_guac_terminal* term,
|
||||
int guac_terminal_scroll_down(guac_terminal* term,
|
||||
int start_row, int end_row, int amount) {
|
||||
|
||||
/* Calculate height of scroll region */
|
||||
@ -420,19 +420,19 @@ int ssh_guac_terminal_scroll_down(ssh_guac_terminal* term,
|
||||
return
|
||||
|
||||
/* Move rows within scroll region down by the given amount */
|
||||
ssh_guac_terminal_copy(term,
|
||||
guac_terminal_copy(term,
|
||||
start_row, 0,
|
||||
height - amount, term->term_width,
|
||||
start_row + amount, 0)
|
||||
|
||||
/* Fill new rows with background */
|
||||
|| ssh_guac_terminal_clear(term,
|
||||
|| guac_terminal_clear(term,
|
||||
start_row, 0, amount, term->term_width,
|
||||
term->background);
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_clear_range(ssh_guac_terminal* term,
|
||||
int guac_terminal_clear_range(guac_terminal* term,
|
||||
int start_row, int start_col,
|
||||
int end_row, int end_col, int background_color) {
|
||||
|
||||
@ -440,7 +440,7 @@ int ssh_guac_terminal_clear_range(ssh_guac_terminal* term,
|
||||
if (start_col > 0) {
|
||||
|
||||
/* Clear from start_col to far right */
|
||||
if (ssh_guac_terminal_clear(term,
|
||||
if (guac_terminal_clear(term,
|
||||
start_row, start_col, 1, term->term_width - start_col,
|
||||
background_color))
|
||||
return 1;
|
||||
@ -453,7 +453,7 @@ int ssh_guac_terminal_clear_range(ssh_guac_terminal* term,
|
||||
if (end_col < term->term_width - 1) {
|
||||
|
||||
/* Clear from far left to end_col */
|
||||
if (ssh_guac_terminal_clear(term,
|
||||
if (guac_terminal_clear(term,
|
||||
end_row, 0, 1, end_col + 1,
|
||||
background_color))
|
||||
return 1;
|
||||
@ -466,7 +466,7 @@ int ssh_guac_terminal_clear_range(ssh_guac_terminal* term,
|
||||
/* Remaining region now guaranteed rectangular. Clear, if possible */
|
||||
if (start_row <= end_row) {
|
||||
|
||||
if (ssh_guac_terminal_clear(term,
|
||||
if (guac_terminal_clear(term,
|
||||
start_row, 0, end_row - start_row + 1, term->term_width,
|
||||
background_color))
|
||||
return 1;
|
@ -37,10 +37,10 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ssh_terminal.h"
|
||||
#include "ssh_terminal_handlers.h"
|
||||
#include "terminal.h"
|
||||
#include "terminal_handlers.h"
|
||||
|
||||
int ssh_guac_terminal_echo(ssh_guac_terminal* term, char c) {
|
||||
int guac_terminal_echo(guac_terminal* term, char c) {
|
||||
|
||||
int foreground = term->foreground;
|
||||
int background = term->background;
|
||||
@ -71,14 +71,14 @@ int ssh_guac_terminal_echo(ssh_guac_terminal* term, char c) {
|
||||
term->cursor_row = term->scroll_end;
|
||||
|
||||
/* Scroll up by one row */
|
||||
ssh_guac_terminal_scroll_up(term, term->scroll_start, term->scroll_end, 1);
|
||||
guac_terminal_scroll_up(term, term->scroll_start, term->scroll_end, 1);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
/* ESC */
|
||||
case 0x1B:
|
||||
term->char_handler = ssh_guac_terminal_escape;
|
||||
term->char_handler = guac_terminal_escape;
|
||||
break;
|
||||
|
||||
/* Displayable chars */
|
||||
@ -95,7 +95,7 @@ int ssh_guac_terminal_echo(ssh_guac_terminal* term, char c) {
|
||||
term->cursor_row = term->scroll_end;
|
||||
|
||||
/* Scroll up by one row */
|
||||
ssh_guac_terminal_scroll_up(term, term->scroll_start, term->scroll_end, 1);
|
||||
guac_terminal_scroll_up(term, term->scroll_start, term->scroll_end, 1);
|
||||
|
||||
}
|
||||
|
||||
@ -110,10 +110,10 @@ int ssh_guac_terminal_echo(ssh_guac_terminal* term, char c) {
|
||||
if (term->bold && foreground <= 7)
|
||||
foreground += 8;
|
||||
|
||||
ssh_guac_terminal_set_colors(term,
|
||||
guac_terminal_set_colors(term,
|
||||
foreground, background);
|
||||
|
||||
ssh_guac_terminal_set(term,
|
||||
guac_terminal_set(term,
|
||||
term->cursor_row,
|
||||
term->cursor_col,
|
||||
c);
|
||||
@ -127,25 +127,25 @@ int ssh_guac_terminal_echo(ssh_guac_terminal* term, char c) {
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_escape(ssh_guac_terminal* term, char c) {
|
||||
int guac_terminal_escape(guac_terminal* term, char c) {
|
||||
|
||||
switch (c) {
|
||||
|
||||
case '(':
|
||||
term->char_handler = ssh_guac_terminal_charset;
|
||||
term->char_handler = guac_terminal_charset;
|
||||
break;
|
||||
|
||||
case ']':
|
||||
term->char_handler = ssh_guac_terminal_osc;
|
||||
term->char_handler = guac_terminal_osc;
|
||||
break;
|
||||
|
||||
case '[':
|
||||
term->char_handler = ssh_guac_terminal_csi;
|
||||
term->char_handler = guac_terminal_csi;
|
||||
break;
|
||||
|
||||
default:
|
||||
guac_client_log_info(term->client, "Unhandled ESC sequence: %c", c);
|
||||
term->char_handler = ssh_guac_terminal_echo;
|
||||
term->char_handler = guac_terminal_echo;
|
||||
|
||||
}
|
||||
|
||||
@ -153,12 +153,12 @@ int ssh_guac_terminal_escape(ssh_guac_terminal* term, char c) {
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_charset(ssh_guac_terminal* term, char c) {
|
||||
term->char_handler = ssh_guac_terminal_echo;
|
||||
int guac_terminal_charset(guac_terminal* term, char c) {
|
||||
term->char_handler = guac_terminal_echo;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
int guac_terminal_csi(guac_terminal* term, char c) {
|
||||
|
||||
/* CSI function arguments */
|
||||
static int argc = 0;
|
||||
@ -361,21 +361,21 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
|
||||
/* Erase from cursor to end of display */
|
||||
if (argv[0] == 0)
|
||||
ssh_guac_terminal_clear_range(term,
|
||||
guac_terminal_clear_range(term,
|
||||
term->cursor_row, term->cursor_col,
|
||||
term->term_height-1, term->term_width-1,
|
||||
term->background);
|
||||
|
||||
/* Erase from start to cursor */
|
||||
else if (argv[0] == 1)
|
||||
ssh_guac_terminal_clear_range(term,
|
||||
guac_terminal_clear_range(term,
|
||||
0, 0,
|
||||
term->cursor_row, term->cursor_col,
|
||||
term->background);
|
||||
|
||||
/* Entire screen */
|
||||
else if (argv[0] == 2)
|
||||
ssh_guac_terminal_clear(term,
|
||||
guac_terminal_clear(term,
|
||||
0, 0, term->term_height, term->term_width,
|
||||
term->background);
|
||||
|
||||
@ -386,7 +386,7 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
|
||||
/* Erase from cursor to end of line */
|
||||
if (argv[0] == 0)
|
||||
ssh_guac_terminal_clear(term,
|
||||
guac_terminal_clear(term,
|
||||
term->cursor_row, term->cursor_col,
|
||||
1, term->term_width - term->cursor_col,
|
||||
term->background);
|
||||
@ -394,14 +394,14 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
|
||||
/* Erase from start to cursor */
|
||||
else if (argv[0] == 1)
|
||||
ssh_guac_terminal_clear(term,
|
||||
guac_terminal_clear(term,
|
||||
term->cursor_row, 0,
|
||||
1, term->cursor_col + 1,
|
||||
term->background);
|
||||
|
||||
/* Erase line */
|
||||
else if (argv[0] == 2)
|
||||
ssh_guac_terminal_clear(term,
|
||||
guac_terminal_clear(term,
|
||||
term->cursor_row, 0,
|
||||
1, term->term_width,
|
||||
term->background);
|
||||
@ -414,7 +414,7 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
amount = argv[0];
|
||||
if (amount == 0) amount = 1;
|
||||
|
||||
ssh_guac_terminal_scroll_down(term,
|
||||
guac_terminal_scroll_down(term,
|
||||
term->cursor_row, term->scroll_end, amount);
|
||||
|
||||
break;
|
||||
@ -425,7 +425,7 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
amount = argv[0];
|
||||
if (amount == 0) amount = 1;
|
||||
|
||||
ssh_guac_terminal_scroll_up(term,
|
||||
guac_terminal_scroll_up(term,
|
||||
term->cursor_row, term->scroll_end, amount);
|
||||
|
||||
break;
|
||||
@ -438,14 +438,14 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
|
||||
/* Scroll left by amount */
|
||||
if (term->cursor_col + amount < term->term_width)
|
||||
ssh_guac_terminal_copy(term,
|
||||
guac_terminal_copy(term,
|
||||
term->cursor_row, term->cursor_col + amount,
|
||||
1,
|
||||
term->term_width - term->cursor_col - amount,
|
||||
term->cursor_row, term->cursor_col);
|
||||
|
||||
/* Clear right */
|
||||
ssh_guac_terminal_clear(term,
|
||||
guac_terminal_clear(term,
|
||||
term->cursor_row, term->term_width - amount,
|
||||
1, amount,
|
||||
term->background);
|
||||
@ -460,13 +460,13 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
|
||||
/* Scroll right by amount */
|
||||
if (term->cursor_col + amount < term->term_width)
|
||||
ssh_guac_terminal_copy(term,
|
||||
guac_terminal_copy(term,
|
||||
term->cursor_row, term->cursor_col,
|
||||
1, term->term_width - term->cursor_col - amount,
|
||||
term->cursor_row, term->cursor_col + amount);
|
||||
|
||||
/* Clear left */
|
||||
ssh_guac_terminal_clear(term,
|
||||
guac_terminal_clear(term,
|
||||
term->cursor_row, term->cursor_col,
|
||||
1, amount,
|
||||
term->background);
|
||||
@ -482,7 +482,7 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
|
||||
/* If not a semicolon, end of CSI sequence */
|
||||
if (c != ';') {
|
||||
term->char_handler = ssh_guac_terminal_echo;
|
||||
term->char_handler = guac_terminal_echo;
|
||||
|
||||
/* Reset parameters */
|
||||
for (i=0; i<argc; i++)
|
||||
@ -499,10 +499,10 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) {
|
||||
|
||||
}
|
||||
|
||||
int ssh_guac_terminal_osc(ssh_guac_terminal* term, char c) {
|
||||
int guac_terminal_osc(guac_terminal* term, char c) {
|
||||
/* TODO: Implement OSC */
|
||||
if (c == 0x9C || c == 0x5C || c == 0x07) /* ECMA-48 ST (String Terminator */
|
||||
term->char_handler = ssh_guac_terminal_echo;
|
||||
term->char_handler = guac_terminal_echo;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user