GUAC-717: Add GUAC_CHAR_CONTINUATION sentinel. Add width property to characters.

This commit is contained in:
Michael Jumper 2014-06-04 11:23:07 -07:00
parent c84a88d35a
commit 91f1148e8f
4 changed files with 25 additions and 4 deletions

View File

@ -21,6 +21,7 @@
*/ */
#include "config.h" #include "config.h"
#include "types.h"
#include <stdbool.h> #include <stdbool.h>
#include <unistd.h> #include <unistd.h>
@ -83,7 +84,8 @@ int guac_terminal_encode_utf8(int codepoint, char* utf8) {
bool guac_terminal_has_glyph(int codepoint) { bool guac_terminal_has_glyph(int codepoint) {
return return
codepoint != 0 codepoint != 0
&& codepoint != ' '; && codepoint != ' '
&& codepoint != GUAC_CHAR_CONTINUATION;
} }
int guac_terminal_write_all(int fd, const char* buffer, int size) { int guac_terminal_write_all(int fd, const char* buffer, int size) {

View File

@ -585,7 +585,8 @@ void guac_terminal_display_resize(guac_terminal_display* display, int width, int
.attributes = { .attributes = {
.foreground = 0, .foreground = 0,
.background = 0 .background = 0
} },
.width = 1
}; };
/* Free old operations buffer */ /* Free old operations buffer */

View File

@ -96,7 +96,8 @@ guac_terminal* guac_terminal_create(guac_client* client,
.bold = false, .bold = false,
.reverse = false, .reverse = false,
.underscore = false .underscore = false
}}; },
.width = 1};
guac_terminal* term = malloc(sizeof(guac_terminal)); guac_terminal* term = malloc(sizeof(guac_terminal));
term->client = client; term->client = client;

View File

@ -28,6 +28,15 @@
#include <stdbool.h> #include <stdbool.h>
/**
* A character which is not truly a character, but rather part of an
* existing character which spans multiple columns. The original
* character will be somewhere earlier in the row, separated from
* this character by a contiguous string of zero of more
* GUAC_CHAR_CONTINUATION characters.
*/
#define GUAC_CHAR_CONTINUATION -1
/** /**
* An RGB color, where each component ranges from 0 to 255. * An RGB color, where each component ranges from 0 to 255.
*/ */
@ -95,7 +104,9 @@ typedef struct guac_terminal_attributes {
typedef struct guac_terminal_char { typedef struct guac_terminal_char {
/** /**
* The Unicode codepoint of the character to display. * The Unicode codepoint of the character to display, or
* GUAC_CHAR_CONTINUATION if this character is part of
* another character which spans multiple columns.
*/ */
int value; int value;
@ -104,6 +115,12 @@ typedef struct guac_terminal_char {
*/ */
guac_terminal_attributes attributes; guac_terminal_attributes attributes;
/**
* The number of columns this character occupies. If the character is
* GUAC_CHAR_CONTINUATION, this value is undefined and not applicable.
*/
int width;
} guac_terminal_char; } guac_terminal_char;
#endif #endif