mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-16 18:47:32 -05:00
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long' encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of `termchar' structures, which currently have 32-bit Unicode and 32 attribute bits but which will probably expand further in future. To prevent bloat of the memory footprint, I've introduced a mostly RLE-like compression scheme for storing scrollback: each line is compressed into a compact (but hard to modify) form when it moves into the term->scrollback tree, and is temporarily decompressed when the user wants to scroll back over it. My initial tests suggest that this compression averages about 1/4 of the previous (32 bits per character cell) data size in typical output, which means this is an improvement even without counting the new ability to extend the information stored in each character cell. Another beneficial side effect is that the insane format in which Unicode was passed to front ends through do_text() has now been rendered sane. Testing is incomplete; this _may_ still have instabilities. Windows and Unix front ends both seem to work as far as I've looked, but I haven't yet looked very hard. The Mac front end I've edited (it seemed obvious how to change it) but I can't compile or test it. As an immediate functional effect, the terminal emulator now supports full 32-bit Unicode to whatever extent the host platform allows it to. For example, if you output a 4-or-more-byte UTF-8 character in Unix pterm, it will not display it properly, but it will correctly paste it back out in a UTF8_STRING selection. Windows is more restricted, sadly. [originally from svn r4609]
This commit is contained in:
39
terminal.h
39
terminal.h
@ -29,6 +29,21 @@ struct scrollregion {
|
||||
};
|
||||
#endif /* OPTIMISE_SCROLL */
|
||||
|
||||
typedef struct termchar termchar;
|
||||
typedef struct termline termline;
|
||||
|
||||
struct termchar {
|
||||
unsigned long chr;
|
||||
unsigned long attr;
|
||||
};
|
||||
|
||||
struct termline {
|
||||
unsigned short lattr;
|
||||
int cols;
|
||||
int temporary; /* TRUE if decompressed from scrollback */
|
||||
struct termchar *chars;
|
||||
};
|
||||
|
||||
struct terminal_tag {
|
||||
|
||||
int compatibility_level;
|
||||
@ -40,11 +55,11 @@ struct terminal_tag {
|
||||
int tempsblines; /* number of lines in temporary
|
||||
scrollback */
|
||||
|
||||
unsigned long *cpos; /* cursor position (convenience) */
|
||||
termchar *cpos; /* cursor position (convenience) */
|
||||
|
||||
unsigned long *disptext; /* buffer of text on real screen */
|
||||
unsigned long *dispcurs; /* location of cursor on real screen */
|
||||
unsigned long curstype; /* type of cursor on real screen */
|
||||
termline **disptext; /* buffer of text on real screen */
|
||||
int dispcursx, dispcursy; /* location of cursor on real screen */
|
||||
int curstype; /* type of cursor on real screen */
|
||||
|
||||
#define VBELL_TIMEOUT (TICKSPERSEC/10) /* visual bell lasts 1/10 sec */
|
||||
|
||||
@ -53,18 +68,18 @@ struct terminal_tag {
|
||||
int beep_overloaded;
|
||||
long lastbeep;
|
||||
|
||||
#define TTYPE unsigned long
|
||||
#define TTYPE termchar
|
||||
#define TSIZE (sizeof(TTYPE))
|
||||
#define fix_cpos do { \
|
||||
term->cpos = lineptr(term->curs.y) + term->curs.x; \
|
||||
term->cpos = lineptr(term->curs.y)->chars + term->curs.x; \
|
||||
} while(0)
|
||||
|
||||
#ifdef OPTIMISE_SCROLL
|
||||
struct scrollregion *scrollhead, *scrolltail;
|
||||
#endif /* OPTIMISE_SCROLL */
|
||||
|
||||
unsigned long default_attr, curr_attr, save_attr;
|
||||
unsigned long erase_char;
|
||||
int default_attr, curr_attr, save_attr;
|
||||
termchar basic_erase_char, erase_char;
|
||||
|
||||
bufchain inbuf; /* terminal input buffer */
|
||||
pos curs; /* cursor */
|
||||
@ -112,7 +127,7 @@ struct terminal_tag {
|
||||
int xterm_mouse; /* send mouse messages to app */
|
||||
int mouse_is_down; /* used while tracking mouse buttons */
|
||||
|
||||
unsigned long cset_attr[2];
|
||||
int cset_attr[2];
|
||||
|
||||
/*
|
||||
* Saved settings on the alternate screen.
|
||||
@ -173,7 +188,7 @@ struct terminal_tag {
|
||||
short wordness[256];
|
||||
|
||||
/* Mask of attributes to pay attention to when painting. */
|
||||
unsigned long attr_mask;
|
||||
int attr_mask;
|
||||
|
||||
wchar_t *paste_buffer;
|
||||
int paste_len, paste_pos, paste_hold;
|
||||
@ -212,9 +227,9 @@ struct terminal_tag {
|
||||
/*
|
||||
* These are buffers used by the bidi and Arabic shaping code.
|
||||
*/
|
||||
unsigned long *ltemp;
|
||||
termchar *ltemp;
|
||||
bidi_char *wcFrom, *wcTo;
|
||||
unsigned long **pre_bidi_cache, **post_bidi_cache;
|
||||
termchar **pre_bidi_cache, **post_bidi_cache;
|
||||
int bidi_cache_size;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user