diff options
author | Rich Felker <dalias@aerifal.cx> | 2006-10-03 01:37:17 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2006-10-03 01:37:17 +0000 |
commit | 0fe28fd69dd15006ccd684d563699420aadde61a (patch) | |
tree | 77a419dc56462f39c975b6c043a7bf344fc3f3e6 /uuterm.h |
first working version of uuterm!
- at this point it is purely experimental. only ascii characters are
visible (using builtin font) although all characters are processed.
- there are known bugs, including crashes.
- there are major missing features.
- but it works. ^_^
Diffstat (limited to 'uuterm.h')
-rw-r--r-- | uuterm.h | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/uuterm.h b/uuterm.h new file mode 100644 index 0000000..f392bda --- /dev/null +++ b/uuterm.h @@ -0,0 +1,100 @@ +/* uuterm, Copyright (C) 2006 Rich Felker; licensed under GNU GPL v2 only */ + +#include <stddef.h> +#include <wchar.h> /* for mbstate_t... */ + +struct uucell +{ + unsigned short a; + unsigned char c[8]; +}; + +struct uurow +{ + int idx; + int x1, x2; /* dirty region */ + struct uucell cells[1]; +}; + +#define UU_ATTR_DIM 0x0100 +#define UU_ATTR_UL 0x0200 +#define UU_ATTR_REV 0x0400 + +#define UU_ATTR_BOLD 0x0008 +#define UU_ATTR_FG 0x0007 + +#define UU_ATTR_BLINK 0x0080 +#define UU_ATTR_BG 0x0070 + +struct uuterm +{ + struct uurow **rows; + int w, h; + + // all members past this point are zero-filled on reset! + int reset; + + // output state + int x, y; + int attr; + int sr_y1, sr_y2; + int ins :1; + int am :1; + int noam :1; + + // input state + int ckp :1; + int kp :1; + char reslen; + char res[16]; + + // saved state + int save_x, save_y; + int save_attr, save_fg, save_bg; + + // escape sequence processing + int esc; + unsigned param[16]; + int nparam; + + // multibyte parsing + mbstate_t mbs; +}; + +struct uudisp +{ + int cell_w, cell_h; + int w, h; + int inlen; + unsigned char *intext; + unsigned char inbuf[16]; + int blink; + long priv[64]; +}; + +#define UU_FULLWIDTH 0xfffe + +#define UU_ROW_SIZE(w) (sizeof(struct uurow) + (w)*sizeof(struct uucell)) +#define UU_BUF_SIZE(w, h) ( (h) * (sizeof(struct uurow *) * UU_ROW_SIZE((w))) ) + +void uuterm_reset(struct uuterm *); +void uuterm_replace_buffer(struct uuterm *, int, int, void *); +void uuterm_stuff_byte(struct uuterm *, unsigned char); + +void uuterm_refresh_row(struct uudisp *, struct uurow *, int, int); + +int uu_combine_involution(unsigned, unsigned); + +int uudisp_open(struct uudisp *); +int uudisp_fd_set(struct uudisp *, int, void *); +void uudisp_next_event(struct uudisp *, void *); +void uudisp_close(struct uudisp *); +void uudisp_refresh(struct uudisp *, struct uuterm *); +void uudisp_draw_glyph(struct uudisp *, int, int, const void *, int); + +void *uuterm_alloc(size_t); +void uuterm_free(void *); +void *uuterm_buf_alloc(int, int); + +void uutty_resize(int, int, int); +int uutty_open(char **, int, int); |