mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Remove the 'Frontend' type and replace it with a vtable.
After the recent Seat and LogContext revamps, _nearly_ all the remaining uses of the type 'Frontend' were in terminal.c, which needs all sorts of interactions with the GUI window the terminal lives in, from the obvious (actually drawing text on the window, reading and writing the clipboard) to the obscure (minimising, maximising and moving the window in response to particular escape sequences). All of those functions are now provided by an abstraction called TermWin. The few remaining uses of Frontend after _that_ are internal to a particular platform directory, so as to spread the implementation of that particular kind of Frontend between multiple source files; so I've renamed all of those so that they take a more specifically named type that refers to the particular implementation rather than the general abstraction. So now the name 'Frontend' no longer exists in the code base at all, and everywhere one used to be used, it's completely clear whether it was operating in one of Frontend's three abstract roles (and if so, which), or whether it was specific to a particular implementation. Another type that's disappeared is 'Context', which used to be a typedef defined to something different on each platform, describing whatever short-lived resources were necessary to draw on the terminal window: the front end would provide a ready-made one when calling term_paint, and the terminal could request one with get_ctx/free_ctx if it wanted to do proactive window updates. Now that drawing context lives inside the TermWin itself, because there was never any need to have two of those contexts live at the same time. (Another minor API change is that the window-title functions - both reading and writing - have had a missing 'const' added to their char * parameters / return values.) I don't expect this change to enable any particularly interesting new functionality (in particular, I have no plans that need more than one implementation of TermWin in the same application). But it completes the tidying-up that began with the Seat and LogContext rework.
This commit is contained in:
parent
291c1b07f2
commit
64f8f68a34
3
defs.h
3
defs.h
@ -57,7 +57,8 @@ typedef struct LogPolicyVtable LogPolicyVtable;
|
||||
typedef struct Seat Seat;
|
||||
typedef struct SeatVtable SeatVtable;
|
||||
|
||||
typedef struct Frontend Frontend;
|
||||
typedef struct TermWin TermWin;
|
||||
typedef struct TermWinVtable TermWinVtable;
|
||||
|
||||
typedef struct Ssh Ssh;
|
||||
|
||||
|
105
fuzzterm.c
105
fuzzterm.c
@ -9,6 +9,8 @@
|
||||
/* For Unix in particular, but harmless if this main() is reused elsewhere */
|
||||
const int buildinfo_gtk_relevant = FALSE;
|
||||
|
||||
static const TermWinVtable fuzz_termwin_vt;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char blk[512];
|
||||
@ -16,6 +18,9 @@ int main(int argc, char **argv)
|
||||
Terminal *term;
|
||||
Conf *conf;
|
||||
struct unicode_data ucsdata;
|
||||
TermWin termwin;
|
||||
|
||||
termwin.vt = &fuzz_termwin_vt;
|
||||
|
||||
conf = conf_new();
|
||||
do_defaults(NULL, conf);
|
||||
@ -23,7 +28,7 @@ int main(int argc, char **argv)
|
||||
conf_get_int(conf, CONF_utf8_override),
|
||||
CS_NONE, conf_get_int(conf, CONF_vtmode));
|
||||
|
||||
term = term_init(conf, &ucsdata, NULL);
|
||||
term = term_init(conf, &ucsdata, &termwin);
|
||||
term_size(term, 24, 80, 10000);
|
||||
term->ldisc = NULL;
|
||||
/* Tell american fuzzy lop that this is a good place to fork. */
|
||||
@ -39,10 +44,10 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* functions required by terminal.c */
|
||||
|
||||
void request_resize(Frontend *frontend, int x, int y) { }
|
||||
void do_text(Context ctx, int x, int y, wchar_t * text, int len,
|
||||
unsigned long attr, int lattr, truecolour tc)
|
||||
static int fuzz_setup_draw_ctx(TermWin *tw) { return TRUE; }
|
||||
static void fuzz_draw_text(
|
||||
TermWin *tw, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attr, int lattr, truecolour tc)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -52,8 +57,9 @@ void do_text(Context ctx, int x, int y, wchar_t * text, int len,
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
void do_cursor(Context ctx, int x, int y, wchar_t * text, int len,
|
||||
unsigned long attr, int lattr, truecolour tc)
|
||||
static void fuzz_draw_cursor(
|
||||
TermWin *tw, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attr, int lattr, truecolour tc)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -63,38 +69,69 @@ void do_cursor(Context ctx, int x, int y, wchar_t * text, int len,
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
int char_width(Context ctx, int uc) { return 1; }
|
||||
void set_title(Frontend *frontend, char *t) { }
|
||||
void set_icon(Frontend *frontend, char *t) { }
|
||||
void set_sbar(Frontend *frontend, int a, int b, int c) { }
|
||||
static int fuzz_char_width(TermWin *tw, int uc) { return 1; }
|
||||
static void fuzz_free_draw_ctx(TermWin *tw) {}
|
||||
static void fuzz_set_cursor_pos(TermWin *tw, int x, int y) {}
|
||||
static void fuzz_set_raw_mouse_mode(TermWin *tw, int enable) {}
|
||||
static void fuzz_set_scrollbar(TermWin *tw, int total, int start, int page) {}
|
||||
static void fuzz_bell(TermWin *tw, int mode) {}
|
||||
static void fuzz_clip_write(
|
||||
TermWin *tw, int clipboard, wchar_t *text, int *attrs,
|
||||
truecolour *colours, int len, int must_deselect) {}
|
||||
static void fuzz_clip_request_paste(TermWin *tw, int clipboard) {}
|
||||
static void fuzz_refresh(TermWin *tw) {}
|
||||
static void fuzz_request_resize(TermWin *tw, int w, int h) {}
|
||||
static void fuzz_set_title(TermWin *tw, const char *title) {}
|
||||
static void fuzz_set_icon_title(TermWin *tw, const char *icontitle) {}
|
||||
static void fuzz_set_minimised(TermWin *tw, int minimised) {}
|
||||
static int fuzz_is_minimised(TermWin *tw) { return FALSE; }
|
||||
static void fuzz_set_maximised(TermWin *tw, int maximised) {}
|
||||
static void fuzz_move(TermWin *tw, int x, int y) {}
|
||||
static void fuzz_set_zorder(TermWin *tw, int top) {}
|
||||
static int fuzz_palette_get(TermWin *tw, int n, int *r, int *g, int *b)
|
||||
{ return FALSE; }
|
||||
static void fuzz_palette_set(TermWin *tw, int n, int r, int g, int b) {}
|
||||
static void fuzz_palette_reset(TermWin *tw) {}
|
||||
static void fuzz_get_pos(TermWin *tw, int *x, int *y) { *x = *y = 0; }
|
||||
static void fuzz_get_pixels(TermWin *tw, int *x, int *y) { *x = *y = 0; }
|
||||
static const char *fuzz_get_title(TermWin *tw, int icon) { return "moo"; }
|
||||
static int fuzz_is_utf8(TermWin *tw) { return TRUE; }
|
||||
|
||||
static const TermWinVtable fuzz_termwin_vt = {
|
||||
fuzz_setup_draw_ctx,
|
||||
fuzz_draw_text,
|
||||
fuzz_draw_cursor,
|
||||
fuzz_char_width,
|
||||
fuzz_free_draw_ctx,
|
||||
fuzz_set_cursor_pos,
|
||||
fuzz_set_raw_mouse_mode,
|
||||
fuzz_set_scrollbar,
|
||||
fuzz_bell,
|
||||
fuzz_clip_write,
|
||||
fuzz_clip_request_paste,
|
||||
fuzz_refresh,
|
||||
fuzz_request_resize,
|
||||
fuzz_set_title,
|
||||
fuzz_set_icon_title,
|
||||
fuzz_set_minimised,
|
||||
fuzz_is_minimised,
|
||||
fuzz_set_maximised,
|
||||
fuzz_move,
|
||||
fuzz_set_zorder,
|
||||
fuzz_palette_get,
|
||||
fuzz_palette_set,
|
||||
fuzz_palette_reset,
|
||||
fuzz_get_pos,
|
||||
fuzz_get_pixels,
|
||||
fuzz_get_title,
|
||||
fuzz_is_utf8,
|
||||
};
|
||||
|
||||
void ldisc_send(Ldisc *ldisc, const void *buf, int len, int interactive) {}
|
||||
void ldisc_echoedit_update(Ldisc *ldisc) {}
|
||||
Context get_ctx(Frontend *frontend) { return NULL; }
|
||||
void free_ctx(Context ctx) { }
|
||||
void palette_set(Frontend *frontend, int a, int b, int c, int d) { }
|
||||
void palette_reset(Frontend *frontend) { }
|
||||
int palette_get(Frontend *frontend, int n, int *r, int *g, int *b) {return FALSE;}
|
||||
void write_clip(Frontend *frontend, int clipboard,
|
||||
wchar_t *a, int *b, truecolour *c, int d, int e) { }
|
||||
void set_raw_mouse_mode(Frontend *frontend, int m) { }
|
||||
void frontend_request_paste(Frontend *frontend, int clipboard) { }
|
||||
void do_beep(Frontend *frontend, int a) { }
|
||||
void sys_cursor(Frontend *frontend, int x, int y) { }
|
||||
void modalfatalbox(const char *fmt, ...) { exit(0); }
|
||||
void nonfatal(const char *fmt, ...) { }
|
||||
|
||||
void set_iconic(Frontend *frontend, int iconic) { }
|
||||
void move_window(Frontend *frontend, int x, int y) { }
|
||||
void set_zorder(Frontend *frontend, int top) { }
|
||||
void refresh_window(Frontend *frontend) { }
|
||||
void set_zoomed(Frontend *frontend, int zoomed) { }
|
||||
int is_iconic(Frontend *frontend) { return 0; }
|
||||
void get_window_pos(Frontend *frontend, int *x, int *y) { *x = 0; *y = 0; }
|
||||
void get_window_pixels(Frontend *frontend, int *x, int *y) { *x = 0; *y = 0; }
|
||||
char *get_window_title(Frontend *frontend, int icon) { return "moo"; }
|
||||
int frontend_is_utf8(Frontend *frontend) { return TRUE; }
|
||||
|
||||
/* needed by timing.c */
|
||||
void timer_change_notify(unsigned long next) { }
|
||||
|
||||
@ -173,5 +210,3 @@ char *x_get_default(const char *key)
|
||||
{
|
||||
return NULL; /* this is a stub */
|
||||
}
|
||||
|
||||
|
||||
|
165
putty.h
165
putty.h
@ -1012,46 +1012,139 @@ int console_confirm_weak_cached_hostkey(
|
||||
int filexfer_get_userpass_input(Seat *seat, prompts_t *p, bufchain *input);
|
||||
|
||||
/*
|
||||
* Exports from the front end.
|
||||
* Data type 'TermWin', which is a vtable encapsulating all the
|
||||
* functionality that Terminal expects from its containing terminal
|
||||
* window.
|
||||
*/
|
||||
struct TermWin {
|
||||
const struct TermWinVtable *vt;
|
||||
};
|
||||
struct TermWinVtable {
|
||||
/*
|
||||
* All functions listed here between setup_draw_ctx and
|
||||
* free_draw_ctx expect to be _called_ between them too, so that
|
||||
* the TermWin has a drawing context currently available.
|
||||
*
|
||||
* (Yes, even char_width, because e.g. the Windows implementation
|
||||
* of TermWin handles it by loading the currently configured font
|
||||
* into the HDC and doing a GDI query.)
|
||||
*/
|
||||
int (*setup_draw_ctx)(TermWin *);
|
||||
/* Draw text in the window, during a painting operation */
|
||||
void (*draw_text)(TermWin *, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attrs, int line_attrs, truecolour tc);
|
||||
/* Draw the visible cursor. Expects you to have called do_text
|
||||
* first (because it might just draw an underline over a character
|
||||
* presumed to exist already), but also expects you to pass in all
|
||||
* the details of the character under the cursor (because it might
|
||||
* redraw it in different colours). */
|
||||
void (*draw_cursor)(TermWin *, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attrs, int line_attrs, truecolour tc);
|
||||
int (*char_width)(TermWin *, int uc);
|
||||
void (*free_draw_ctx)(TermWin *);
|
||||
|
||||
void (*set_cursor_pos)(TermWin *, int x, int y);
|
||||
|
||||
void (*set_raw_mouse_mode)(TermWin *, int enable);
|
||||
|
||||
void (*set_scrollbar)(TermWin *, int total, int start, int page);
|
||||
|
||||
void (*bell)(TermWin *, int mode);
|
||||
|
||||
void (*clip_write)(TermWin *, int clipboard, wchar_t *text, int *attrs,
|
||||
truecolour *colours, int len, int must_deselect);
|
||||
void (*clip_request_paste)(TermWin *, int clipboard);
|
||||
|
||||
void (*refresh)(TermWin *);
|
||||
|
||||
void (*request_resize)(TermWin *, int w, int h);
|
||||
|
||||
void (*set_title)(TermWin *, const char *title);
|
||||
void (*set_icon_title)(TermWin *, const char *icontitle);
|
||||
/* set_minimised and set_maximised are assumed to set two
|
||||
* independent settings, rather than a single three-way
|
||||
* {min,normal,max} switch. The idea is that when you un-minimise
|
||||
* the window it remembers whether to go back to normal or
|
||||
* maximised. */
|
||||
void (*set_minimised)(TermWin *, int minimised);
|
||||
int (*is_minimised)(TermWin *);
|
||||
void (*set_maximised)(TermWin *, int maximised);
|
||||
void (*move)(TermWin *, int x, int y);
|
||||
void (*set_zorder)(TermWin *, int top);
|
||||
|
||||
int (*palette_get)(TermWin *, int n, int *r, int *g, int *b);
|
||||
void (*palette_set)(TermWin *, int n, int r, int g, int b);
|
||||
void (*palette_reset)(TermWin *);
|
||||
|
||||
void (*get_pos)(TermWin *, int *x, int *y);
|
||||
void (*get_pixels)(TermWin *, int *x, int *y);
|
||||
const char *(*get_title)(TermWin *, int icon);
|
||||
int (*is_utf8)(TermWin *);
|
||||
};
|
||||
|
||||
#define win_setup_draw_ctx(win) \
|
||||
((win)->vt->setup_draw_ctx(win))
|
||||
#define win_draw_text(win, x, y, text, len, attrs, lattrs, tc) \
|
||||
((win)->vt->draw_text(win, x, y, text, len, attrs, lattrs, tc))
|
||||
#define win_draw_cursor(win, x, y, text, len, attrs, lattrs, tc) \
|
||||
((win)->vt->draw_cursor(win, x, y, text, len, attrs, lattrs, tc))
|
||||
#define win_char_width(win, uc) \
|
||||
((win)->vt->char_width(win, uc))
|
||||
#define win_free_draw_ctx(win) \
|
||||
((win)->vt->free_draw_ctx(win))
|
||||
#define win_set_cursor_pos(win, x, y) \
|
||||
((win)->vt->set_cursor_pos(win, x, y))
|
||||
#define win_set_raw_mouse_mode(win, enable) \
|
||||
((win)->vt->set_raw_mouse_mode(win, enable))
|
||||
#define win_set_scrollbar(win, total, start, page) \
|
||||
((win)->vt->set_scrollbar(win, total, start, page))
|
||||
#define win_bell(win, mode) \
|
||||
((win)->vt->bell(win, mode))
|
||||
#define win_clip_write(win, clipboard, text, attrs, colours, len, desel) \
|
||||
((win)->vt->clip_write(win, clipboard, text, attrs, colours, len, desel))
|
||||
#define win_clip_request_paste(win, clipboard) \
|
||||
((win)->vt->clip_request_paste(win, clipboard))
|
||||
#define win_refresh(win) \
|
||||
((win)->vt->refresh(win))
|
||||
#define win_request_resize(win, w, h) \
|
||||
((win)->vt->request_resize(win, w, h))
|
||||
#define win_set_title(win, title) \
|
||||
((win)->vt->set_title(win, title))
|
||||
#define win_set_icon_title(win, ititle) \
|
||||
((win)->vt->set_icon_title(win, ititle))
|
||||
#define win_set_minimised(win, minimised) \
|
||||
((win)->vt->set_minimised(win, minimised))
|
||||
#define win_is_minimised(win) \
|
||||
((win)->vt->is_minimised(win))
|
||||
#define win_set_maximised(win, maximised) \
|
||||
((win)->vt->set_maximised(win, maximised))
|
||||
#define win_move(win, x, y) \
|
||||
((win)->vt->move(win, x, y))
|
||||
#define win_set_zorder(win, top) \
|
||||
((win)->vt->set_zorder(win, top))
|
||||
#define win_palette_get(win, n, r, g, b) \
|
||||
((win)->vt->palette_get(win, n, r, g, b))
|
||||
#define win_palette_set(win, n, r, g, b) \
|
||||
((win)->vt->palette_set(win, n, r, g, b))
|
||||
#define win_palette_reset(win) \
|
||||
((win)->vt->palette_reset(win))
|
||||
#define win_get_pos(win, x, y) \
|
||||
((win)->vt->get_pos(win, x, y))
|
||||
#define win_get_pixels(win, x, y) \
|
||||
((win)->vt->get_pixels(win, x, y))
|
||||
#define win_get_title(win, icon) \
|
||||
((win)->vt->get_title(win, icon))
|
||||
#define win_is_utf8(win) \
|
||||
((win)->vt->is_utf8(win))
|
||||
|
||||
/*
|
||||
* Global functions not specific to a connection instance.
|
||||
*/
|
||||
void request_resize(Frontend *frontend, int, int);
|
||||
void do_text(Context, int, int, wchar_t *, int, unsigned long, int,
|
||||
truecolour);
|
||||
void do_cursor(Context, int, int, wchar_t *, int, unsigned long, int,
|
||||
truecolour);
|
||||
int char_width(Context ctx, int uc);
|
||||
void set_title(Frontend *frontend, char *);
|
||||
void set_icon(Frontend *frontend, char *);
|
||||
void set_sbar(Frontend *frontend, int, int, int);
|
||||
Context get_ctx(Frontend *frontend);
|
||||
void free_ctx(Context);
|
||||
void palette_set(Frontend *frontend, int, int, int, int);
|
||||
void palette_reset(Frontend *frontend);
|
||||
int palette_get(Frontend *frontend, int n, int *r, int *g, int *b);
|
||||
void write_clip(Frontend *frontend, int clipboard, wchar_t *, int *,
|
||||
truecolour *, int, int);
|
||||
void optimised_move(Frontend *frontend, int, int, int);
|
||||
void set_raw_mouse_mode(Frontend *frontend, int);
|
||||
void nonfatal(const char *, ...);
|
||||
void modalfatalbox(const char *, ...);
|
||||
#ifdef macintosh
|
||||
#pragma noreturn(modalfatalbox)
|
||||
#endif
|
||||
void do_beep(Frontend *frontend, int);
|
||||
void sys_cursor(Frontend *frontend, int x, int y);
|
||||
void frontend_request_paste(Frontend *frontend, int clipboard);
|
||||
|
||||
void set_iconic(Frontend *frontend, int iconic);
|
||||
void move_window(Frontend *frontend, int x, int y);
|
||||
void set_zorder(Frontend *frontend, int top);
|
||||
void refresh_window(Frontend *frontend);
|
||||
void set_zoomed(Frontend *frontend, int zoomed);
|
||||
int is_iconic(Frontend *frontend);
|
||||
void get_window_pos(Frontend *frontend, int *x, int *y);
|
||||
void get_window_pixels(Frontend *frontend, int *x, int *y);
|
||||
char *get_window_title(Frontend *frontend, int icon);
|
||||
int frontend_is_utf8(Frontend *frontend);
|
||||
|
||||
void cleanup_exit(int);
|
||||
|
||||
/*
|
||||
@ -1407,10 +1500,10 @@ FontSpec *platform_default_fontspec(const char *name);
|
||||
* Exports from terminal.c.
|
||||
*/
|
||||
|
||||
Terminal *term_init(Conf *, struct unicode_data *, Frontend *);
|
||||
Terminal *term_init(Conf *, struct unicode_data *, TermWin *);
|
||||
void term_free(Terminal *);
|
||||
void term_size(Terminal *, int, int, int);
|
||||
void term_paint(Terminal *, Context, int, int, int, int, int);
|
||||
void term_paint(Terminal *, int, int, int, int, int);
|
||||
void term_scroll(Terminal *, int, int);
|
||||
void term_scroll_to_selection(Terminal *, int);
|
||||
void term_pwron(Terminal *, int);
|
||||
|
165
terminal.c
165
terminal.c
@ -101,7 +101,7 @@ static void resizeline(Terminal *, termline *, int);
|
||||
static termline *lineptr(Terminal *, int, int, int);
|
||||
static void unlineptr(termline *);
|
||||
static void check_line_size(Terminal *, termline *);
|
||||
static void do_paint(Terminal *, Context);
|
||||
static void do_paint(Terminal *);
|
||||
static void erase_lots(Terminal *, int, int, int);
|
||||
static int find_last_nonempty_line(Terminal *, tree234 *);
|
||||
static void swap_screen(Terminal *, int, int, int);
|
||||
@ -1317,7 +1317,7 @@ static void power_on(Terminal *term, int clear)
|
||||
term->xterm_mouse = 0;
|
||||
term->xterm_extended_mouse = 0;
|
||||
term->urxvt_extended_mouse = 0;
|
||||
set_raw_mouse_mode(term->frontend, FALSE);
|
||||
win_set_raw_mouse_mode(term->win, FALSE);
|
||||
term->bracketed_paste = FALSE;
|
||||
{
|
||||
int i;
|
||||
@ -1348,12 +1348,9 @@ static void power_on(Terminal *term, int clear)
|
||||
*/
|
||||
void term_update(Terminal *term)
|
||||
{
|
||||
Context ctx;
|
||||
|
||||
term->window_update_pending = FALSE;
|
||||
|
||||
ctx = get_ctx(term->frontend);
|
||||
if (ctx) {
|
||||
if (win_setup_draw_ctx(term->win)) {
|
||||
int need_sbar_update = term->seen_disp_event;
|
||||
if (term->seen_disp_event && term->scroll_on_disp) {
|
||||
term->disptop = 0; /* return to main screen */
|
||||
@ -1363,9 +1360,10 @@ void term_update(Terminal *term)
|
||||
|
||||
if (need_sbar_update)
|
||||
update_sbar(term);
|
||||
do_paint(term, ctx);
|
||||
sys_cursor(term->frontend, term->curs.x, term->curs.y - term->disptop);
|
||||
free_ctx(ctx);
|
||||
do_paint(term);
|
||||
win_set_cursor_pos(
|
||||
term->win, term->curs.x, term->curs.y - term->disptop);
|
||||
win_free_draw_ctx(term->win);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1568,7 +1566,7 @@ void term_reconfig(Terminal *term, Conf *conf)
|
||||
swap_screen(term, 0, FALSE, FALSE);
|
||||
if (conf_get_int(term->conf, CONF_no_mouse_rep)) {
|
||||
term->xterm_mouse = 0;
|
||||
set_raw_mouse_mode(term->frontend, 0);
|
||||
win_set_raw_mouse_mode(term->win, 0);
|
||||
}
|
||||
if (conf_get_int(term->conf, CONF_no_remote_charset)) {
|
||||
term->cset_attr[0] = term->cset_attr[1] = CSET_ASCII;
|
||||
@ -1635,8 +1633,7 @@ const optionalrgb optionalrgb_none = {0, 0, 0, 0};
|
||||
/*
|
||||
* Initialise the terminal.
|
||||
*/
|
||||
Terminal *term_init(Conf *myconf, struct unicode_data *ucsdata,
|
||||
Frontend *frontend)
|
||||
Terminal *term_init(Conf *myconf, struct unicode_data *ucsdata, TermWin *win)
|
||||
{
|
||||
Terminal *term;
|
||||
|
||||
@ -1645,7 +1642,7 @@ Terminal *term_init(Conf *myconf, struct unicode_data *ucsdata,
|
||||
* that need it.
|
||||
*/
|
||||
term = snew(Terminal);
|
||||
term->frontend = frontend;
|
||||
term->win = win;
|
||||
term->ucsdata = ucsdata;
|
||||
term->conf = conf_copy(myconf);
|
||||
term->logctx = NULL;
|
||||
@ -1712,8 +1709,8 @@ Terminal *term_init(Conf *myconf, struct unicode_data *ucsdata,
|
||||
term->last_selected_attr = NULL;
|
||||
term->last_selected_tc = NULL;
|
||||
term->last_selected_len = 0;
|
||||
/* frontends will typically extend these with clipboard ids they
|
||||
* know about */
|
||||
/* TermWin implementations will typically extend these with
|
||||
* clipboard ids they know about */
|
||||
term->mouse_select_clipboards[0] = CLIP_LOCAL;
|
||||
term->n_mouse_select_clipboards = 1;
|
||||
term->mouse_paste_clipboard = CLIP_NULL;
|
||||
@ -2097,8 +2094,8 @@ static void swap_screen(Terminal *term, int which, int reset, int keep_cur_pos)
|
||||
static void update_sbar(Terminal *term)
|
||||
{
|
||||
int nscroll = sblines(term);
|
||||
set_sbar(term->frontend, nscroll + term->rows,
|
||||
nscroll + term->disptop, term->rows);
|
||||
win_set_scrollbar(term->win, nscroll + term->rows,
|
||||
nscroll + term->disptop, term->rows);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2533,7 +2530,7 @@ static void toggle_mode(Terminal *term, int mode, int query, int state)
|
||||
case 3: /* DECCOLM: 80/132 columns */
|
||||
deselect(term);
|
||||
if (!term->no_remote_resize)
|
||||
request_resize(term->frontend, state ? 132 : 80, term->rows);
|
||||
win_request_resize(term->win, state ? 132 : 80, term->rows);
|
||||
term->reset_132 = state;
|
||||
term->alt_t = term->marg_t = 0;
|
||||
term->alt_b = term->marg_b = term->rows - 1;
|
||||
@ -2585,11 +2582,11 @@ static void toggle_mode(Terminal *term, int mode, int query, int state)
|
||||
break;
|
||||
case 1000: /* xterm mouse 1 (normal) */
|
||||
term->xterm_mouse = state ? 1 : 0;
|
||||
set_raw_mouse_mode(term->frontend, state);
|
||||
win_set_raw_mouse_mode(term->win, state);
|
||||
break;
|
||||
case 1002: /* xterm mouse 2 (inc. button drags) */
|
||||
term->xterm_mouse = state ? 2 : 0;
|
||||
set_raw_mouse_mode(term->frontend, state);
|
||||
win_set_raw_mouse_mode(term->win, state);
|
||||
break;
|
||||
case 1006: /* xterm extended mouse */
|
||||
term->xterm_extended_mouse = state ? 1 : 0;
|
||||
@ -2659,20 +2656,20 @@ static void do_osc(Terminal *term)
|
||||
case 0:
|
||||
case 1:
|
||||
if (!term->no_remote_wintitle)
|
||||
set_icon(term->frontend, term->osc_string);
|
||||
win_set_icon_title(term->win, term->osc_string);
|
||||
if (term->esc_args[0] == 1)
|
||||
break;
|
||||
/* fall through: parameter 0 means set both */
|
||||
case 2:
|
||||
case 21:
|
||||
if (!term->no_remote_wintitle)
|
||||
set_title(term->frontend, term->osc_string);
|
||||
win_set_title(term->win, term->osc_string);
|
||||
break;
|
||||
case 4:
|
||||
if (term->ldisc && !strcmp(term->osc_string, "?")) {
|
||||
int r, g, b;
|
||||
if (palette_get(term->frontend, toint(term->esc_args[1]),
|
||||
&r, &g, &b)) {
|
||||
if (win_palette_get(term->win, toint(term->esc_args[1]),
|
||||
&r, &g, &b)) {
|
||||
char *reply_buf = dupprintf(
|
||||
"\033]4;%u;rgb:%04x/%04x/%04x\007",
|
||||
term->esc_args[1],
|
||||
@ -3182,7 +3179,7 @@ static void term_out(Terminal *term)
|
||||
* Perform an actual beep if we're not overloaded.
|
||||
*/
|
||||
if (!term->bellovl || !term->beep_overloaded) {
|
||||
do_beep(term->frontend, term->beep);
|
||||
win_bell(term->win, term->beep);
|
||||
|
||||
if (term->beep == BELL_VISUAL) {
|
||||
term_schedule_vbell(term, FALSE, 0);
|
||||
@ -3383,7 +3380,7 @@ static void term_out(Terminal *term)
|
||||
ldisc_echoedit_update(term->ldisc);
|
||||
if (term->reset_132) {
|
||||
if (!term->no_remote_resize)
|
||||
request_resize(term->frontend, 80, term->rows);
|
||||
win_request_resize(term->win, 80, term->rows);
|
||||
term->reset_132 = 0;
|
||||
}
|
||||
if (term->scroll_on_disp)
|
||||
@ -4027,8 +4024,8 @@ static void term_out(Terminal *term)
|
||||
term->esc_args[0] >= 24)) {
|
||||
compatibility(VT340TEXT);
|
||||
if (!term->no_remote_resize)
|
||||
request_resize(term->frontend, term->cols,
|
||||
def(term->esc_args[0], 24));
|
||||
win_request_resize(term->win, term->cols,
|
||||
def(term->esc_args[0], 24));
|
||||
deselect(term);
|
||||
} else if (term->esc_nargs >= 1 &&
|
||||
term->esc_args[0] >= 1 &&
|
||||
@ -4040,17 +4037,17 @@ static void term_out(Terminal *term)
|
||||
char buf[80];
|
||||
const char *p;
|
||||
case 1:
|
||||
set_iconic(term->frontend, FALSE);
|
||||
win_set_minimised(term->win, FALSE);
|
||||
break;
|
||||
case 2:
|
||||
set_iconic(term->frontend, TRUE);
|
||||
win_set_minimised(term->win, TRUE);
|
||||
break;
|
||||
case 3:
|
||||
if (term->esc_nargs >= 3) {
|
||||
if (!term->no_remote_resize)
|
||||
move_window(term->frontend,
|
||||
def(term->esc_args[1], 0),
|
||||
def(term->esc_args[2], 0));
|
||||
win_move(term->win,
|
||||
def(term->esc_args[1], 0),
|
||||
def(term->esc_args[2], 0));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
@ -4061,38 +4058,41 @@ static void term_out(Terminal *term)
|
||||
break;
|
||||
case 5:
|
||||
/* move to top */
|
||||
set_zorder(term->frontend, TRUE);
|
||||
win_set_zorder(term->win, TRUE);
|
||||
break;
|
||||
case 6:
|
||||
/* move to bottom */
|
||||
set_zorder(term->frontend, FALSE);
|
||||
win_set_zorder(term->win, FALSE);
|
||||
break;
|
||||
case 7:
|
||||
refresh_window(term->frontend);
|
||||
win_refresh(term->win);
|
||||
break;
|
||||
case 8:
|
||||
if (term->esc_nargs >= 3) {
|
||||
if (!term->no_remote_resize)
|
||||
request_resize(term->frontend,
|
||||
def(term->esc_args[2], term->conf_width),
|
||||
def(term->esc_args[1], term->conf_height));
|
||||
win_request_resize(
|
||||
term->win,
|
||||
def(term->esc_args[2],
|
||||
term->conf_width),
|
||||
def(term->esc_args[1],
|
||||
term->conf_height));
|
||||
}
|
||||
break;
|
||||
case 9:
|
||||
if (term->esc_nargs >= 2)
|
||||
set_zoomed(term->frontend,
|
||||
term->esc_args[1] ?
|
||||
TRUE : FALSE);
|
||||
win_set_maximised(
|
||||
term->win,
|
||||
term->esc_args[1] ? TRUE : FALSE);
|
||||
break;
|
||||
case 11:
|
||||
if (term->ldisc)
|
||||
ldisc_send(term->ldisc,
|
||||
is_iconic(term->frontend) ?
|
||||
win_is_minimised(term->win) ?
|
||||
"\033[2t" : "\033[1t", 4, 0);
|
||||
break;
|
||||
case 13:
|
||||
if (term->ldisc) {
|
||||
get_window_pos(term->frontend, &x, &y);
|
||||
win_get_pos(term->win, &x, &y);
|
||||
len = sprintf(buf, "\033[3;%u;%ut",
|
||||
(unsigned)x,
|
||||
(unsigned)y);
|
||||
@ -4101,7 +4101,7 @@ static void term_out(Terminal *term)
|
||||
break;
|
||||
case 14:
|
||||
if (term->ldisc) {
|
||||
get_window_pixels(term->frontend, &x, &y);
|
||||
win_get_pixels(term->win, &x, &y);
|
||||
len = sprintf(buf, "\033[4;%d;%dt", y, x);
|
||||
ldisc_send(term->ldisc, buf, len, 0);
|
||||
}
|
||||
@ -4134,7 +4134,7 @@ static void term_out(Terminal *term)
|
||||
if (term->ldisc &&
|
||||
term->remote_qtitle_action != TITLE_NONE) {
|
||||
if(term->remote_qtitle_action == TITLE_REAL)
|
||||
p = get_window_title(term->frontend, TRUE);
|
||||
p = win_get_title(term->win, TRUE);
|
||||
else
|
||||
p = EMPTY_WINDOW_TITLE;
|
||||
len = strlen(p);
|
||||
@ -4148,7 +4148,7 @@ static void term_out(Terminal *term)
|
||||
if (term->ldisc &&
|
||||
term->remote_qtitle_action != TITLE_NONE) {
|
||||
if(term->remote_qtitle_action == TITLE_REAL)
|
||||
p = get_window_title(term->frontend, FALSE);
|
||||
p = win_get_title(term->win, FALSE);
|
||||
else
|
||||
p = EMPTY_WINDOW_TITLE;
|
||||
len = strlen(p);
|
||||
@ -4187,9 +4187,9 @@ static void term_out(Terminal *term)
|
||||
compatibility(VT420);
|
||||
if (term->esc_nargs == 1 && term->esc_args[0] > 0) {
|
||||
if (!term->no_remote_resize)
|
||||
request_resize(term->frontend, term->cols,
|
||||
def(term->esc_args[0],
|
||||
term->conf_height));
|
||||
win_request_resize(term->win, term->cols,
|
||||
def(term->esc_args[0],
|
||||
term->conf_height));
|
||||
deselect(term);
|
||||
}
|
||||
break;
|
||||
@ -4202,10 +4202,10 @@ static void term_out(Terminal *term)
|
||||
compatibility(VT340TEXT);
|
||||
if (term->esc_nargs <= 1) {
|
||||
if (!term->no_remote_resize)
|
||||
request_resize(term->frontend,
|
||||
def(term->esc_args[0],
|
||||
term->conf_width),
|
||||
term->rows);
|
||||
win_request_resize(
|
||||
term->win,
|
||||
def(term->esc_args[0], term->conf_width),
|
||||
term->rows);
|
||||
deselect(term);
|
||||
}
|
||||
break;
|
||||
@ -4413,9 +4413,9 @@ static void term_out(Terminal *term)
|
||||
if (!has_compat(VT420) && has_compat(VT100)) {
|
||||
if (!term->no_remote_resize) {
|
||||
if (term->reset_132)
|
||||
request_resize(132, 24);
|
||||
win_request_resize(term->win, 132, 24);
|
||||
else
|
||||
request_resize(80, 24);
|
||||
win_request_resize(term->win, 80, 24);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -4430,7 +4430,7 @@ static void term_out(Terminal *term)
|
||||
term->osc_strlen = 0;
|
||||
break;
|
||||
case 'R': /* Linux palette reset */
|
||||
palette_reset(term->frontend);
|
||||
win_palette_reset(term->win);
|
||||
term_invalidate(term);
|
||||
term->termstate = TOPLEVEL;
|
||||
break;
|
||||
@ -4528,10 +4528,11 @@ static void term_out(Terminal *term)
|
||||
}
|
||||
term->osc_string[term->osc_strlen++] = val;
|
||||
if (term->osc_strlen >= 7) {
|
||||
palette_set(term->frontend, term->osc_string[0],
|
||||
term->osc_string[1] * 16 + term->osc_string[2],
|
||||
term->osc_string[3] * 16 + term->osc_string[4],
|
||||
term->osc_string[5] * 16 + term->osc_string[6]);
|
||||
win_palette_set(
|
||||
term->win, term->osc_string[0],
|
||||
term->osc_string[1] * 16 + term->osc_string[2],
|
||||
term->osc_string[3] * 16 + term->osc_string[4],
|
||||
term->osc_string[5] * 16 + term->osc_string[6]);
|
||||
term_invalidate(term);
|
||||
term->termstate = TOPLEVEL;
|
||||
}
|
||||
@ -5024,7 +5025,7 @@ static termchar *term_bidi_line(Terminal *term, struct termline *ldata,
|
||||
/*
|
||||
* Given a context, update the window.
|
||||
*/
|
||||
static void do_paint(Terminal *term, Context ctx)
|
||||
static void do_paint(Terminal *term)
|
||||
{
|
||||
int i, j, our_curs_y, our_curs_x;
|
||||
int rv, cursor;
|
||||
@ -5209,7 +5210,8 @@ static void do_paint(Terminal *term, Context ctx)
|
||||
if (tchar != term->disptext[i]->chars[j].chr ||
|
||||
tattr != (term->disptext[i]->chars[j].attr &~
|
||||
(ATTR_NARROW | DATTR_MASK))) {
|
||||
if ((tattr & ATTR_WIDE) == 0 && char_width(ctx, tchar) == 2)
|
||||
if ((tattr & ATTR_WIDE) == 0 &&
|
||||
win_char_width(term->win, tchar) == 2)
|
||||
tattr |= ATTR_NARROW;
|
||||
} else if (term->disptext[i]->chars[j].attr & ATTR_NARROW)
|
||||
tattr |= ATTR_NARROW;
|
||||
@ -5324,10 +5326,11 @@ static void do_paint(Terminal *term, Context ctx)
|
||||
|
||||
if (break_run) {
|
||||
if ((dirty_run || last_run_dirty) && ccount > 0) {
|
||||
do_text(ctx, start, i, ch, ccount, attr, ldata->lattr, tc);
|
||||
win_draw_text(term->win, start, i, ch, ccount,
|
||||
attr, ldata->lattr, tc);
|
||||
if (attr & (TATTR_ACTCURS | TATTR_PASCURS))
|
||||
do_cursor(ctx, start, i, ch, ccount, attr,
|
||||
ldata->lattr, tc);
|
||||
win_draw_cursor(term->win, start, i, ch, ccount, attr,
|
||||
ldata->lattr, tc);
|
||||
}
|
||||
start = j;
|
||||
ccount = 0;
|
||||
@ -5423,9 +5426,11 @@ static void do_paint(Terminal *term, Context ctx)
|
||||
}
|
||||
}
|
||||
if (dirty_run && ccount > 0) {
|
||||
do_text(ctx, start, i, ch, ccount, attr, ldata->lattr, tc);
|
||||
win_draw_text(term->win, start, i, ch, ccount,
|
||||
attr, ldata->lattr, tc);
|
||||
if (attr & (TATTR_ACTCURS | TATTR_PASCURS))
|
||||
do_cursor(ctx, start, i, ch, ccount, attr, ldata->lattr, tc);
|
||||
win_draw_cursor(term->win, start, i, ch, ccount,
|
||||
attr, ldata->lattr, tc);
|
||||
}
|
||||
|
||||
unlineptr(ldata);
|
||||
@ -5452,7 +5457,7 @@ void term_invalidate(Terminal *term)
|
||||
/*
|
||||
* Paint the window in response to a WM_PAINT message.
|
||||
*/
|
||||
void term_paint(Terminal *term, Context ctx,
|
||||
void term_paint(Terminal *term,
|
||||
int left, int top, int right, int bottom, int immediately)
|
||||
{
|
||||
int i, j;
|
||||
@ -5471,7 +5476,7 @@ void term_paint(Terminal *term, Context ctx,
|
||||
}
|
||||
|
||||
if (immediately) {
|
||||
do_paint (term, ctx);
|
||||
do_paint(term);
|
||||
} else {
|
||||
term_schedule_update(term);
|
||||
}
|
||||
@ -5722,9 +5727,9 @@ static void clipme(Terminal *term, pos top, pos bottom, int rect, int desel,
|
||||
if (clipboards[i] == CLIP_LOCAL) {
|
||||
clip_local = TRUE;
|
||||
} else if (clipboards[i] != CLIP_NULL) {
|
||||
write_clip(term->frontend, clipboards[i],
|
||||
buf.textbuf, buf.attrbuf, buf.tcbuf, buf.bufpos,
|
||||
desel);
|
||||
win_clip_write(
|
||||
term->win, clipboards[i], buf.textbuf, buf.attrbuf,
|
||||
buf.tcbuf, buf.bufpos, desel);
|
||||
}
|
||||
}
|
||||
if (clip_local) {
|
||||
@ -5767,12 +5772,10 @@ void term_request_copy(Terminal *term, const int *clipboards, int n_clipboards)
|
||||
for (i = 0; i < n_clipboards; i++) {
|
||||
assert(clipboards[i] != CLIP_LOCAL);
|
||||
if (clipboards[i] != CLIP_NULL) {
|
||||
write_clip(term->frontend, clipboards[i],
|
||||
term->last_selected_text,
|
||||
term->last_selected_attr,
|
||||
term->last_selected_tc,
|
||||
term->last_selected_len,
|
||||
FALSE);
|
||||
win_clip_write(term->win, clipboards[i],
|
||||
term->last_selected_text, term->last_selected_attr,
|
||||
term->last_selected_tc, term->last_selected_len,
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5787,7 +5790,7 @@ void term_request_paste(Terminal *term, int clipboard)
|
||||
queue_toplevel_callback(paste_from_clip_local, term);
|
||||
break;
|
||||
default:
|
||||
frontend_request_paste(term->frontend, clipboard);
|
||||
win_clip_request_paste(term->win, clipboard);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -6582,7 +6585,7 @@ char *term_get_ttymode(Terminal *term, const char *mode)
|
||||
if (strcmp(mode, "ERASE") == 0) {
|
||||
val = term->bksp_is_delete ? "^?" : "^H";
|
||||
} else if (strcmp(mode, "IUTF8") == 0) {
|
||||
val = frontend_is_utf8(term->frontend) ? "yes" : "no";
|
||||
val = win_is_utf8(term->win) ? "yes" : "no";
|
||||
}
|
||||
/* FIXME: perhaps we should set ONLCR based on lfhascr as well? */
|
||||
/* FIXME: or ECHO and friends based on local echo state? */
|
||||
|
@ -218,7 +218,7 @@ struct terminal_tag {
|
||||
|
||||
Ldisc *ldisc;
|
||||
|
||||
Frontend *frontend;
|
||||
TermWin *win;
|
||||
|
||||
LogContext *logctx;
|
||||
|
||||
|
@ -99,7 +99,7 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "GtkApplication frontend doesn't work pre-GTK3\n");
|
||||
return 1;
|
||||
}
|
||||
GtkWidget *make_gtk_toplevel_window(Frontend *frontend) { return NULL; }
|
||||
GtkWidget *make_gtk_toplevel_window(GtkFrontend *frontend) { return NULL; }
|
||||
void launch_duplicate_session(Conf *conf) {}
|
||||
void launch_new_session(void) {}
|
||||
void launch_saved_session(const char *str) {}
|
||||
@ -204,7 +204,7 @@ WIN_ACTION_LIST(WIN_ACTION_ENTRY)
|
||||
};
|
||||
|
||||
static GtkApplication *app;
|
||||
GtkWidget *make_gtk_toplevel_window(Frontend *frontend)
|
||||
GtkWidget *make_gtk_toplevel_window(GtkFrontend *frontend)
|
||||
{
|
||||
GtkWidget *win = gtk_application_window_new(app);
|
||||
g_action_map_add_action_entries(G_ACTION_MAP(win),
|
||||
|
@ -549,7 +549,7 @@ int do_cmdline(int argc, char **argv, int do_everything, Conf *conf)
|
||||
return err;
|
||||
}
|
||||
|
||||
GtkWidget *make_gtk_toplevel_window(Frontend *frontend)
|
||||
GtkWidget *make_gtk_toplevel_window(GtkFrontend *frontend)
|
||||
{
|
||||
return gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
}
|
||||
|
630
unix/gtkwin.c
630
unix/gtkwin.c
File diff suppressed because it is too large
Load Diff
@ -65,8 +65,6 @@ struct FontSpec {
|
||||
};
|
||||
struct FontSpec *fontspec_new(const char *name);
|
||||
|
||||
typedef struct draw_ctx *Context;
|
||||
|
||||
extern const struct BackendVtable pty_backend;
|
||||
|
||||
#define BROKEN_PIPE_ERROR_CODE EPIPE /* used in sshshare.c */
|
||||
@ -158,7 +156,7 @@ unsigned long getticks(void);
|
||||
#endif
|
||||
|
||||
/* The per-session frontend structure managed by gtkwin.c */
|
||||
struct gui_data;
|
||||
typedef struct GtkFrontend GtkFrontend;
|
||||
|
||||
/* Callback when a dialog box finishes, and a no-op implementation of it */
|
||||
typedef void (*post_dialog_fn_t)(void *ctx, int result);
|
||||
@ -175,7 +173,7 @@ void launch_saved_session(const char *str);
|
||||
void session_window_closed(void);
|
||||
void window_setup_error(const char *errmsg);
|
||||
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
||||
GtkWidget *make_gtk_toplevel_window(Frontend *frontend);
|
||||
GtkWidget *make_gtk_toplevel_window(GtkFrontend *frontend);
|
||||
#endif
|
||||
|
||||
const struct BackendVtable *select_backend(Conf *conf);
|
||||
@ -189,7 +187,7 @@ enum MenuAction {
|
||||
MA_RESTART_SESSION, MA_CHANGE_SETTINGS, MA_CLEAR_SCROLLBACK,
|
||||
MA_RESET_TERMINAL, MA_EVENT_LOG
|
||||
};
|
||||
void app_menu_action(Frontend *frontend, enum MenuAction);
|
||||
void app_menu_action(GtkFrontend *frontend, enum MenuAction);
|
||||
|
||||
/* Things gtkdlg.c needs from pterm.c */
|
||||
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
||||
|
@ -156,7 +156,7 @@ static INT_PTR CALLBACK LogProc(HWND hwnd, UINT msg,
|
||||
memcpy(p, sel_nl, sizeof(sel_nl));
|
||||
p += sizeof(sel_nl);
|
||||
}
|
||||
write_aclip(NULL, CLIP_SYSTEM, clipdata, size, TRUE);
|
||||
write_aclip(CLIP_SYSTEM, clipdata, size, TRUE);
|
||||
sfree(clipdata);
|
||||
}
|
||||
sfree(selitems);
|
||||
|
317
windows/window.c
317
windows/window.c
@ -227,17 +227,87 @@ static UINT wm_mousewheel = WM_MOUSEWHEEL;
|
||||
(((wch) >= 0x180B && (wch) <= 0x180D) || /* MONGOLIAN FREE VARIATION SELECTOR */ \
|
||||
((wch) >= 0xFE00 && (wch) <= 0xFE0F)) /* VARIATION SELECTOR 1-16 */
|
||||
|
||||
static int wintw_setup_draw_ctx(TermWin *);
|
||||
static void wintw_draw_text(TermWin *, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attrs, int lattrs, truecolour tc);
|
||||
static void wintw_draw_cursor(TermWin *, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attrs, int lattrs, truecolour tc);
|
||||
static int wintw_char_width(TermWin *, int uc);
|
||||
static void wintw_free_draw_ctx(TermWin *);
|
||||
static void wintw_set_cursor_pos(TermWin *, int x, int y);
|
||||
static void wintw_set_raw_mouse_mode(TermWin *, int enable);
|
||||
static void wintw_set_scrollbar(TermWin *, int total, int start, int page);
|
||||
static void wintw_bell(TermWin *, int mode);
|
||||
static void wintw_clip_write(
|
||||
TermWin *, int clipboard, wchar_t *text, int *attrs,
|
||||
truecolour *colours, int len, int must_deselect);
|
||||
static void wintw_clip_request_paste(TermWin *, int clipboard);
|
||||
static void wintw_refresh(TermWin *);
|
||||
static void wintw_request_resize(TermWin *, int w, int h);
|
||||
static void wintw_set_title(TermWin *, const char *title);
|
||||
static void wintw_set_icon_title(TermWin *, const char *icontitle);
|
||||
static void wintw_set_minimised(TermWin *, int minimised);
|
||||
static int wintw_is_minimised(TermWin *);
|
||||
static void wintw_set_maximised(TermWin *, int maximised);
|
||||
static void wintw_move(TermWin *, int x, int y);
|
||||
static void wintw_set_zorder(TermWin *, int top);
|
||||
static int wintw_palette_get(TermWin *, int n, int *r, int *g, int *b);
|
||||
static void wintw_palette_set(TermWin *, int n, int r, int g, int b);
|
||||
static void wintw_palette_reset(TermWin *);
|
||||
static void wintw_get_pos(TermWin *, int *x, int *y);
|
||||
static void wintw_get_pixels(TermWin *, int *x, int *y);
|
||||
static const char *wintw_get_title(TermWin *, int icon);
|
||||
static int wintw_is_utf8(TermWin *);
|
||||
|
||||
static const TermWinVtable windows_termwin_vt = {
|
||||
wintw_setup_draw_ctx,
|
||||
wintw_draw_text,
|
||||
wintw_draw_cursor,
|
||||
wintw_char_width,
|
||||
wintw_free_draw_ctx,
|
||||
wintw_set_cursor_pos,
|
||||
wintw_set_raw_mouse_mode,
|
||||
wintw_set_scrollbar,
|
||||
wintw_bell,
|
||||
wintw_clip_write,
|
||||
wintw_clip_request_paste,
|
||||
wintw_refresh,
|
||||
wintw_request_resize,
|
||||
wintw_set_title,
|
||||
wintw_set_icon_title,
|
||||
wintw_set_minimised,
|
||||
wintw_is_minimised,
|
||||
wintw_set_maximised,
|
||||
wintw_move,
|
||||
wintw_set_zorder,
|
||||
wintw_palette_get,
|
||||
wintw_palette_set,
|
||||
wintw_palette_reset,
|
||||
wintw_get_pos,
|
||||
wintw_get_pixels,
|
||||
wintw_get_title,
|
||||
wintw_is_utf8,
|
||||
};
|
||||
|
||||
static TermWin wintw[1];
|
||||
static HDC wintw_hdc;
|
||||
|
||||
const int share_can_be_downstream = TRUE;
|
||||
const int share_can_be_upstream = TRUE;
|
||||
|
||||
int frontend_is_utf8(Frontend *frontend)
|
||||
static int is_utf8(void)
|
||||
{
|
||||
return ucsdata.line_codepage == CP_UTF8;
|
||||
}
|
||||
|
||||
static int wintw_is_utf8(TermWin *tw)
|
||||
{
|
||||
return is_utf8();
|
||||
}
|
||||
|
||||
static int win_seat_is_utf8(Seat *seat)
|
||||
{
|
||||
return frontend_is_utf8(NULL);
|
||||
return is_utf8();
|
||||
}
|
||||
|
||||
char *win_seat_get_ttymode(Seat *seat, const char *mode)
|
||||
@ -247,7 +317,7 @@ char *win_seat_get_ttymode(Seat *seat, const char *mode)
|
||||
|
||||
int win_seat_get_window_pixel_size(Seat *seat, int *x, int *y)
|
||||
{
|
||||
get_window_pixels(NULL, x, y);
|
||||
win_get_pixels(wintw, x, y);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -322,8 +392,8 @@ static void start_backend(void)
|
||||
title = msg;
|
||||
}
|
||||
sfree(realhost);
|
||||
set_title(NULL, title);
|
||||
set_icon(NULL, title);
|
||||
win_set_title(wintw, title);
|
||||
win_set_icon_title(wintw, title);
|
||||
|
||||
/*
|
||||
* Connect the terminal to the backend for resize purposes.
|
||||
@ -356,8 +426,8 @@ static void close_session(void *ignored_context)
|
||||
|
||||
session_closed = TRUE;
|
||||
sprintf(morestuff, "%.70s (inactive)", appname);
|
||||
set_icon(NULL, morestuff);
|
||||
set_title(NULL, morestuff);
|
||||
win_set_icon_title(wintw, morestuff);
|
||||
win_set_title(wintw, morestuff);
|
||||
|
||||
if (ldisc) {
|
||||
ldisc_free(ldisc);
|
||||
@ -667,7 +737,8 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
||||
* which will call schedule_timer(), which will in turn call
|
||||
* timer_change_notify() which will expect hwnd to exist.)
|
||||
*/
|
||||
term = term_init(conf, &ucsdata, NULL);
|
||||
wintw->vt = &windows_termwin_vt;
|
||||
term = term_init(conf, &ucsdata, wintw);
|
||||
setup_clipboards(term, conf);
|
||||
logctx = log_init(default_logpolicy, conf);
|
||||
term_provide_logctx(term, logctx);
|
||||
@ -1095,7 +1166,7 @@ static void win_seat_set_busy_status(Seat *seat, BusyStatus status)
|
||||
/*
|
||||
* set or clear the "raw mouse message" mode
|
||||
*/
|
||||
void set_raw_mouse_mode(Frontend *frontend, int activate)
|
||||
static void wintw_set_raw_mouse_mode(TermWin *tw, int activate)
|
||||
{
|
||||
activate = activate && !conf_get_int(conf, CONF_no_mouse_rep);
|
||||
send_raw_mouse = activate;
|
||||
@ -1651,7 +1722,7 @@ static void deinit_fonts(void)
|
||||
}
|
||||
}
|
||||
|
||||
void request_resize(Frontend *frontend, int w, int h)
|
||||
static void wintw_request_resize(TermWin *tw, int w, int h)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
@ -2046,6 +2117,28 @@ static void conf_cache_data(void)
|
||||
|
||||
static const int clips_system[] = { CLIP_SYSTEM };
|
||||
|
||||
static HDC make_hdc(void)
|
||||
{
|
||||
HDC hdc;
|
||||
|
||||
if (!hwnd)
|
||||
return NULL;
|
||||
|
||||
hdc = GetDC(hwnd);
|
||||
if (!hdc)
|
||||
return NULL;
|
||||
|
||||
SelectPalette(hdc, pal, FALSE);
|
||||
return hdc;
|
||||
}
|
||||
|
||||
static void free_hdc(HDC hdc)
|
||||
{
|
||||
assert(hwnd);
|
||||
SelectPalette(hdc, GetStockObject(DEFAULT_PALETTE), FALSE);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
@ -2348,7 +2441,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
init_lvl = 2;
|
||||
}
|
||||
|
||||
set_title(NULL, conf_get_str(conf, CONF_wintitle));
|
||||
win_set_title(wintw, conf_get_str(conf, CONF_wintitle));
|
||||
if (IsIconic(hwnd)) {
|
||||
SetWindowText(hwnd,
|
||||
conf_get_int(conf, CONF_win_name_always) ?
|
||||
@ -2671,12 +2764,15 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
* current terminal appearance so that WM_PAINT becomes
|
||||
* completely trivial. However, this should do for now.
|
||||
*/
|
||||
term_paint(term, hdc,
|
||||
assert(!wintw_hdc);
|
||||
wintw_hdc = hdc;
|
||||
term_paint(term,
|
||||
(p.rcPaint.left-offset_width)/font_width,
|
||||
(p.rcPaint.top-offset_height)/font_height,
|
||||
(p.rcPaint.right-offset_width-1)/font_width,
|
||||
(p.rcPaint.bottom-offset_height-1)/font_height,
|
||||
!term->window_update_pending);
|
||||
wintw_hdc = NULL;
|
||||
|
||||
if (p.fErase ||
|
||||
p.rcPaint.left < offset_width ||
|
||||
@ -3043,21 +3139,21 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
break;
|
||||
case WM_PALETTECHANGED:
|
||||
if ((HWND) wParam != hwnd && pal != NULL) {
|
||||
HDC hdc = get_ctx(NULL);
|
||||
HDC hdc = make_hdc();
|
||||
if (hdc) {
|
||||
if (RealizePalette(hdc) > 0)
|
||||
UpdateColors(hdc);
|
||||
free_ctx(hdc);
|
||||
free_hdc(hdc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_QUERYNEWPALETTE:
|
||||
if (pal != NULL) {
|
||||
HDC hdc = get_ctx(NULL);
|
||||
HDC hdc = make_hdc();
|
||||
if (hdc) {
|
||||
if (RealizePalette(hdc) > 0)
|
||||
UpdateColors(hdc);
|
||||
free_ctx(hdc);
|
||||
free_hdc(hdc);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -3308,7 +3404,7 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
* helper software tracks the system caret, so we should arrange to
|
||||
* have one.)
|
||||
*/
|
||||
void sys_cursor(Frontend *frontend, int x, int y)
|
||||
static void wintw_set_cursor_pos(TermWin *tw, int x, int y)
|
||||
{
|
||||
int cx, cy;
|
||||
|
||||
@ -3362,12 +3458,12 @@ static void sys_cursor_update(void)
|
||||
*
|
||||
* We are allowed to fiddle with the contents of `text'.
|
||||
*/
|
||||
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attr, int lattr, truecolour truecolour)
|
||||
static void do_text_internal(
|
||||
int x, int y, wchar_t *text, int len,
|
||||
unsigned long attr, int lattr, truecolour truecolour)
|
||||
{
|
||||
COLORREF fg, bg, t;
|
||||
int nfg, nbg, nfont;
|
||||
HDC hdc = ctx;
|
||||
RECT line_box;
|
||||
int force_manual_underline = 0;
|
||||
int fnt_width, char_width;
|
||||
@ -3513,13 +3609,13 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
GetBValue(fg) * 2 / 3);
|
||||
}
|
||||
|
||||
SelectObject(hdc, fonts[nfont]);
|
||||
SetTextColor(hdc, fg);
|
||||
SetBkColor(hdc, bg);
|
||||
SelectObject(wintw_hdc, fonts[nfont]);
|
||||
SetTextColor(wintw_hdc, fg);
|
||||
SetBkColor(wintw_hdc, bg);
|
||||
if (attr & TATTR_COMBINING)
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
SetBkMode(wintw_hdc, TRANSPARENT);
|
||||
else
|
||||
SetBkMode(hdc, OPAQUE);
|
||||
SetBkMode(wintw_hdc, OPAQUE);
|
||||
line_box.left = x;
|
||||
line_box.top = y;
|
||||
line_box.right = x + char_width * len;
|
||||
@ -3556,7 +3652,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
* generally reasonable results.
|
||||
*/
|
||||
xoffset = char_width / 2;
|
||||
SetTextAlign(hdc, TA_TOP | TA_CENTER | TA_NOUPDATECP);
|
||||
SetTextAlign(wintw_hdc, TA_TOP | TA_CENTER | TA_NOUPDATECP);
|
||||
lpDx_maybe = NULL;
|
||||
maxlen = 1;
|
||||
} else {
|
||||
@ -3565,7 +3661,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
* in the normal way.
|
||||
*/
|
||||
xoffset = 0;
|
||||
SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
|
||||
SetTextAlign(wintw_hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
|
||||
lpDx_maybe = lpDx;
|
||||
maxlen = len;
|
||||
}
|
||||
@ -3652,14 +3748,14 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
if (nlen <= 0)
|
||||
return; /* Eeek! */
|
||||
|
||||
ExtTextOutW(hdc, x + xoffset,
|
||||
ExtTextOutW(wintw_hdc, x + xoffset,
|
||||
y - font_height * (lattr == LATTR_BOT) + text_adjust,
|
||||
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
||||
&line_box, uni_buf, nlen,
|
||||
lpDx_maybe);
|
||||
if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
ExtTextOutW(hdc, x + xoffset - 1,
|
||||
SetBkMode(wintw_hdc, TRANSPARENT);
|
||||
ExtTextOutW(wintw_hdc, x + xoffset - 1,
|
||||
y - font_height * (lattr ==
|
||||
LATTR_BOT) + text_adjust,
|
||||
ETO_CLIPPED, &line_box, uni_buf, nlen, lpDx_maybe);
|
||||
@ -3678,12 +3774,12 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
for (i = 0; i < len; i++)
|
||||
directbuf[i] = text[i] & 0xFF;
|
||||
|
||||
ExtTextOut(hdc, x + xoffset,
|
||||
ExtTextOut(wintw_hdc, x + xoffset,
|
||||
y - font_height * (lattr == LATTR_BOT) + text_adjust,
|
||||
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
||||
&line_box, directbuf, len, lpDx_maybe);
|
||||
if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
SetBkMode(wintw_hdc, TRANSPARENT);
|
||||
|
||||
/* GRR: This draws the character outside its box and
|
||||
* can leave 'droppings' even with the clip box! I
|
||||
@ -3694,7 +3790,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
* or -1 for this shift depending on if the leftmost
|
||||
* column is blank...
|
||||
*/
|
||||
ExtTextOut(hdc, x + xoffset - 1,
|
||||
ExtTextOut(wintw_hdc, x + xoffset - 1,
|
||||
y - font_height * (lattr ==
|
||||
LATTR_BOT) + text_adjust,
|
||||
ETO_CLIPPED, &line_box, directbuf, len, lpDx_maybe);
|
||||
@ -3715,15 +3811,15 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
wbuf[i] = text[i];
|
||||
|
||||
/* print Glyphs as they are, without Windows' Shaping*/
|
||||
general_textout(hdc, x + xoffset,
|
||||
general_textout(wintw_hdc, x + xoffset,
|
||||
y - font_height * (lattr==LATTR_BOT) + text_adjust,
|
||||
&line_box, wbuf, len, lpDx,
|
||||
opaque && !(attr & TATTR_COMBINING));
|
||||
|
||||
/* And the shadow bold hack. */
|
||||
if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
ExtTextOutW(hdc, x + xoffset - 1,
|
||||
SetBkMode(wintw_hdc, TRANSPARENT);
|
||||
ExtTextOutW(wintw_hdc, x + xoffset - 1,
|
||||
y - font_height * (lattr ==
|
||||
LATTR_BOT) + text_adjust,
|
||||
ETO_CLIPPED, &line_box, wbuf, len, lpDx_maybe);
|
||||
@ -3734,7 +3830,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
* If we're looping round again, stop erasing the background
|
||||
* rectangle.
|
||||
*/
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
SetBkMode(wintw_hdc, TRANSPARENT);
|
||||
opaque = FALSE;
|
||||
}
|
||||
if (lattr != LATTR_TOP && (force_manual_underline ||
|
||||
@ -3745,10 +3841,10 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
if (lattr == LATTR_BOT)
|
||||
dec = dec * 2 - font_height;
|
||||
|
||||
oldpen = SelectObject(hdc, CreatePen(PS_SOLID, 0, fg));
|
||||
MoveToEx(hdc, line_box.left, line_box.top + dec, NULL);
|
||||
LineTo(hdc, line_box.right, line_box.top + dec);
|
||||
oldpen = SelectObject(hdc, oldpen);
|
||||
oldpen = SelectObject(wintw_hdc, CreatePen(PS_SOLID, 0, fg));
|
||||
MoveToEx(wintw_hdc, line_box.left, line_box.top + dec, NULL);
|
||||
LineTo(wintw_hdc, line_box.right, line_box.top + dec);
|
||||
oldpen = SelectObject(wintw_hdc, oldpen);
|
||||
DeleteObject(oldpen);
|
||||
}
|
||||
}
|
||||
@ -3756,8 +3852,9 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
/*
|
||||
* Wrapper that handles combining characters.
|
||||
*/
|
||||
void do_text(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attr, int lattr, truecolour truecolour)
|
||||
static void wintw_draw_text(
|
||||
TermWin *tw, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attr, int lattr, truecolour truecolour)
|
||||
{
|
||||
if (attr & TATTR_COMBINING) {
|
||||
unsigned long a = 0;
|
||||
@ -3767,13 +3864,13 @@ void do_text(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
len0 = 2;
|
||||
if (len-len0 >= 1 && IS_LOW_VARSEL(text[len0])) {
|
||||
attr &= ~TATTR_COMBINING;
|
||||
do_text_internal(ctx, x, y, text, len0+1, attr, lattr, truecolour);
|
||||
do_text_internal(x, y, text, len0+1, attr, lattr, truecolour);
|
||||
text += len0+1;
|
||||
len -= len0+1;
|
||||
a = TATTR_COMBINING;
|
||||
} else if (len-len0 >= 2 && IS_HIGH_VARSEL(text[len0], text[len0+1])) {
|
||||
attr &= ~TATTR_COMBINING;
|
||||
do_text_internal(ctx, x, y, text, len0+2, attr, lattr, truecolour);
|
||||
do_text_internal(x, y, text, len0+2, attr, lattr, truecolour);
|
||||
text += len0+2;
|
||||
len -= len0+2;
|
||||
a = TATTR_COMBINING;
|
||||
@ -3783,33 +3880,32 @@ void do_text(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
|
||||
while (len--) {
|
||||
if (len >= 1 && IS_SURROGATE_PAIR(text[0], text[1])) {
|
||||
do_text_internal(ctx, x, y, text, 2, attr | a, lattr, truecolour);
|
||||
do_text_internal(x, y, text, 2, attr | a, lattr, truecolour);
|
||||
len--;
|
||||
text++;
|
||||
} else
|
||||
do_text_internal(ctx, x, y, text, 1, attr | a, lattr, truecolour);
|
||||
do_text_internal(x, y, text, 1, attr | a, lattr, truecolour);
|
||||
|
||||
text++;
|
||||
a = TATTR_COMBINING;
|
||||
}
|
||||
} else
|
||||
do_text_internal(ctx, x, y, text, len, attr, lattr, truecolour);
|
||||
do_text_internal(x, y, text, len, attr, lattr, truecolour);
|
||||
}
|
||||
|
||||
void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attr, int lattr, truecolour truecolour)
|
||||
static void wintw_draw_cursor(
|
||||
TermWin *tw, int x, int y, wchar_t *text, int len,
|
||||
unsigned long attr, int lattr, truecolour truecolour)
|
||||
{
|
||||
|
||||
int fnt_width;
|
||||
int char_width;
|
||||
HDC hdc = ctx;
|
||||
int ctype = cursor_type;
|
||||
|
||||
lattr &= LATTR_MODE;
|
||||
|
||||
if ((attr & TATTR_ACTCURS) && (ctype == 0 || term->big_cursor)) {
|
||||
if (*text != UCSWIDE) {
|
||||
do_text(ctx, x, y, text, len, attr, lattr, truecolour);
|
||||
win_draw_text(tw, x, y, text, len, attr, lattr, truecolour);
|
||||
return;
|
||||
}
|
||||
ctype = 2;
|
||||
@ -3831,9 +3927,9 @@ void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
pts[2].x = pts[3].x = x + char_width - 1;
|
||||
pts[0].y = pts[3].y = pts[4].y = y;
|
||||
pts[1].y = pts[2].y = y + font_height - 1;
|
||||
oldpen = SelectObject(hdc, CreatePen(PS_SOLID, 0, colours[261]));
|
||||
Polyline(hdc, pts, 5);
|
||||
oldpen = SelectObject(hdc, oldpen);
|
||||
oldpen = SelectObject(wintw_hdc, CreatePen(PS_SOLID, 0, colours[261]));
|
||||
Polyline(wintw_hdc, pts, 5);
|
||||
oldpen = SelectObject(wintw_hdc, oldpen);
|
||||
DeleteObject(oldpen);
|
||||
} else if ((attr & (TATTR_ACTCURS | TATTR_PASCURS)) && ctype != 0) {
|
||||
int startx, starty, dx, dy, length, i;
|
||||
@ -3856,15 +3952,15 @@ void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
if (attr & TATTR_ACTCURS) {
|
||||
HPEN oldpen;
|
||||
oldpen =
|
||||
SelectObject(hdc, CreatePen(PS_SOLID, 0, colours[261]));
|
||||
MoveToEx(hdc, startx, starty, NULL);
|
||||
LineTo(hdc, startx + dx * length, starty + dy * length);
|
||||
oldpen = SelectObject(hdc, oldpen);
|
||||
SelectObject(wintw_hdc, CreatePen(PS_SOLID, 0, colours[261]));
|
||||
MoveToEx(wintw_hdc, startx, starty, NULL);
|
||||
LineTo(wintw_hdc, startx + dx * length, starty + dy * length);
|
||||
oldpen = SelectObject(wintw_hdc, oldpen);
|
||||
DeleteObject(oldpen);
|
||||
} else {
|
||||
for (i = 0; i < length; i++) {
|
||||
if (i % 2 == 0) {
|
||||
SetPixel(hdc, startx, starty, colours[261]);
|
||||
SetPixel(wintw_hdc, startx, starty, colours[261]);
|
||||
}
|
||||
startx += dx;
|
||||
starty += dy;
|
||||
@ -3875,8 +3971,8 @@ void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
|
||||
|
||||
/* This function gets the actual width of a character in the normal font.
|
||||
*/
|
||||
int char_width(Context ctx, int uc) {
|
||||
HDC hdc = ctx;
|
||||
static int wintw_char_width(TermWin *tw, int uc)
|
||||
{
|
||||
int ibuf = 0;
|
||||
|
||||
/* If the font max is the same as the font ave width then this
|
||||
@ -3903,26 +3999,28 @@ int char_width(Context ctx, int uc) {
|
||||
return 1;
|
||||
|
||||
if ( (uc & CSET_MASK) == CSET_ACP ) {
|
||||
SelectObject(hdc, fonts[FONT_NORMAL]);
|
||||
SelectObject(wintw_hdc, fonts[FONT_NORMAL]);
|
||||
} else if ( (uc & CSET_MASK) == CSET_OEMCP ) {
|
||||
another_font(FONT_OEM);
|
||||
if (!fonts[FONT_OEM]) return 0;
|
||||
|
||||
SelectObject(hdc, fonts[FONT_OEM]);
|
||||
SelectObject(wintw_hdc, fonts[FONT_OEM]);
|
||||
} else
|
||||
return 0;
|
||||
|
||||
if ( GetCharWidth32(hdc, uc&~CSET_MASK, uc&~CSET_MASK, &ibuf) != 1 &&
|
||||
GetCharWidth(hdc, uc&~CSET_MASK, uc&~CSET_MASK, &ibuf) != 1)
|
||||
if (GetCharWidth32(wintw_hdc, uc & ~CSET_MASK,
|
||||
uc & ~CSET_MASK, &ibuf) != 1 &&
|
||||
GetCharWidth(wintw_hdc, uc & ~CSET_MASK,
|
||||
uc & ~CSET_MASK, &ibuf) != 1)
|
||||
return 0;
|
||||
} else {
|
||||
/* Speedup, I know of no font where ascii is the wrong width */
|
||||
if (uc >= ' ' && uc <= '~') return 1;
|
||||
|
||||
SelectObject(hdc, fonts[FONT_NORMAL]);
|
||||
if ( GetCharWidth32W(hdc, uc, uc, &ibuf) == 1 )
|
||||
SelectObject(wintw_hdc, fonts[FONT_NORMAL]);
|
||||
if (GetCharWidth32W(wintw_hdc, uc, uc, &ibuf) == 1)
|
||||
/* Okay that one worked */ ;
|
||||
else if ( GetCharWidthW(hdc, uc, uc, &ibuf) == 1 )
|
||||
else if (GetCharWidthW(wintw_hdc, uc, uc, &ibuf) == 1)
|
||||
/* This should work on 9x too, but it's "less accurate" */ ;
|
||||
else
|
||||
return 0;
|
||||
@ -4844,7 +4942,7 @@ static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
||||
return -1;
|
||||
}
|
||||
|
||||
void set_title(Frontend *frontend, char *title)
|
||||
static void wintw_set_title(TermWin *tw, const char *title)
|
||||
{
|
||||
sfree(window_name);
|
||||
window_name = snewn(1 + strlen(title), char);
|
||||
@ -4853,7 +4951,7 @@ void set_title(Frontend *frontend, char *title)
|
||||
SetWindowText(hwnd, title);
|
||||
}
|
||||
|
||||
void set_icon(Frontend *frontend, char *title)
|
||||
static void wintw_set_icon_title(TermWin *tw, const char *title)
|
||||
{
|
||||
sfree(icon_name);
|
||||
icon_name = snewn(1 + strlen(title), char);
|
||||
@ -4862,7 +4960,7 @@ void set_icon(Frontend *frontend, char *title)
|
||||
SetWindowText(hwnd, title);
|
||||
}
|
||||
|
||||
void set_sbar(Frontend *frontend, int total, int start, int page)
|
||||
static void wintw_set_scrollbar(TermWin *tw, int total, int start, int page)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
|
||||
@ -4880,22 +4978,18 @@ void set_sbar(Frontend *frontend, int total, int start, int page)
|
||||
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
|
||||
}
|
||||
|
||||
Context get_ctx(Frontend *frontend)
|
||||
static int wintw_setup_draw_ctx(TermWin *tw)
|
||||
{
|
||||
HDC hdc;
|
||||
if (hwnd) {
|
||||
hdc = GetDC(hwnd);
|
||||
if (hdc && pal)
|
||||
SelectPalette(hdc, pal, FALSE);
|
||||
return hdc;
|
||||
} else
|
||||
return NULL;
|
||||
assert(!wintw_hdc);
|
||||
wintw_hdc = make_hdc();
|
||||
return wintw_hdc != NULL;
|
||||
}
|
||||
|
||||
void free_ctx(Context ctx)
|
||||
static void wintw_free_draw_ctx(TermWin *tw)
|
||||
{
|
||||
SelectPalette(ctx, GetStockObject(DEFAULT_PALETTE), FALSE);
|
||||
ReleaseDC(hwnd, ctx);
|
||||
assert(wintw_hdc);
|
||||
free_hdc(wintw_hdc);
|
||||
wintw_hdc = NULL;
|
||||
}
|
||||
|
||||
static void real_palette_set(int n, int r, int g, int b)
|
||||
@ -4910,7 +5004,7 @@ static void real_palette_set(int n, int r, int g, int b)
|
||||
}
|
||||
}
|
||||
|
||||
int palette_get(Frontend *frontend, int n, int *r, int *g, int *b)
|
||||
static int wintw_palette_get(TermWin *tw, int n, int *r, int *g, int *b)
|
||||
{
|
||||
if (n < 0 || n >= NALLCOLOURS)
|
||||
return FALSE;
|
||||
@ -4920,7 +5014,7 @@ int palette_get(Frontend *frontend, int n, int *r, int *g, int *b)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void palette_set(Frontend *frontend, int n, int r, int g, int b)
|
||||
static void wintw_palette_set(TermWin *tw, int n, int r, int g, int b)
|
||||
{
|
||||
if (n >= 16)
|
||||
n += 256 - 16;
|
||||
@ -4928,10 +5022,10 @@ void palette_set(Frontend *frontend, int n, int r, int g, int b)
|
||||
return;
|
||||
real_palette_set(n, r, g, b);
|
||||
if (pal) {
|
||||
HDC hdc = get_ctx(frontend);
|
||||
HDC hdc = make_hdc();
|
||||
UnrealizeObject(pal);
|
||||
RealizePalette(hdc);
|
||||
free_ctx(hdc);
|
||||
free_hdc(hdc);
|
||||
} else {
|
||||
if (n == (ATTR_DEFBG>>ATTR_BGSHIFT))
|
||||
/* If Default Background changes, we need to ensure any
|
||||
@ -4941,7 +5035,7 @@ void palette_set(Frontend *frontend, int n, int r, int g, int b)
|
||||
}
|
||||
}
|
||||
|
||||
void palette_reset(Frontend *frontend)
|
||||
static void wintw_palette_reset(TermWin *tw)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -4960,9 +5054,9 @@ void palette_reset(Frontend *frontend)
|
||||
if (pal) {
|
||||
HDC hdc;
|
||||
SetPaletteEntries(pal, 0, NALLCOLOURS, logpal->palPalEntry);
|
||||
hdc = get_ctx(frontend);
|
||||
hdc = make_hdc();
|
||||
RealizePalette(hdc);
|
||||
free_ctx(hdc);
|
||||
free_hdc(hdc);
|
||||
} else {
|
||||
/* Default Background may have changed. Ensure any space between
|
||||
* text area and window border is redrawn. */
|
||||
@ -4970,8 +5064,7 @@ void palette_reset(Frontend *frontend)
|
||||
}
|
||||
}
|
||||
|
||||
void write_aclip(Frontend *frontend, int clipboard,
|
||||
char *data, int len, int must_deselect)
|
||||
void write_aclip(int clipboard, char *data, int len, int must_deselect)
|
||||
{
|
||||
HGLOBAL clipdata;
|
||||
void *lock;
|
||||
@ -5018,9 +5111,9 @@ int cmpCOLORREF(void *va, void *vb)
|
||||
/*
|
||||
* Note: unlike write_aclip() this will not append a nul.
|
||||
*/
|
||||
void write_clip(Frontend *frontend, int clipboard,
|
||||
wchar_t *data, int *attr, truecolour *truecolour, int len,
|
||||
int must_deselect)
|
||||
static void wintw_clip_write(
|
||||
TermWin *tw, int clipboard, wchar_t *data, int *attr,
|
||||
truecolour *truecolour, int len, int must_deselect)
|
||||
{
|
||||
HGLOBAL clipdata, clipdata2, clipdata3;
|
||||
int len2;
|
||||
@ -5489,7 +5582,7 @@ static void process_clipdata(HGLOBAL clipdata, int unicode)
|
||||
sfree(clipboard_contents);
|
||||
}
|
||||
|
||||
void frontend_request_paste(Frontend *frontend, int clipboard)
|
||||
static void wintw_clip_request_paste(TermWin *tw, int clipboard)
|
||||
{
|
||||
assert(clipboard == CLIP_SYSTEM);
|
||||
|
||||
@ -5628,7 +5721,7 @@ static void flash_window(int mode)
|
||||
/*
|
||||
* Beep.
|
||||
*/
|
||||
void do_beep(Frontend *frontend, int mode)
|
||||
static void wintw_bell(TermWin *tw, int mode)
|
||||
{
|
||||
if (mode == BELL_DEFAULT) {
|
||||
/*
|
||||
@ -5690,13 +5783,13 @@ void do_beep(Frontend *frontend, int mode)
|
||||
* Minimise or restore the window in response to a server-side
|
||||
* request.
|
||||
*/
|
||||
void set_iconic(Frontend *frontend, int iconic)
|
||||
static void wintw_set_minimised(TermWin *tw, int minimised)
|
||||
{
|
||||
if (IsIconic(hwnd)) {
|
||||
if (!iconic)
|
||||
if (!minimised)
|
||||
ShowWindow(hwnd, SW_RESTORE);
|
||||
} else {
|
||||
if (iconic)
|
||||
if (minimised)
|
||||
ShowWindow(hwnd, SW_MINIMIZE);
|
||||
}
|
||||
}
|
||||
@ -5704,7 +5797,7 @@ void set_iconic(Frontend *frontend, int iconic)
|
||||
/*
|
||||
* Move the window in response to a server-side request.
|
||||
*/
|
||||
void move_window(Frontend *frontend, int x, int y)
|
||||
static void wintw_move(TermWin *tw, int x, int y)
|
||||
{
|
||||
int resize_action = conf_get_int(conf, CONF_resize_action);
|
||||
if (resize_action == RESIZE_DISABLED ||
|
||||
@ -5719,7 +5812,7 @@ void move_window(Frontend *frontend, int x, int y)
|
||||
* Move the window to the top or bottom of the z-order in response
|
||||
* to a server-side request.
|
||||
*/
|
||||
void set_zorder(Frontend *frontend, int top)
|
||||
static void wintw_set_zorder(TermWin *tw, int top)
|
||||
{
|
||||
if (conf_get_int(conf, CONF_alwaysontop))
|
||||
return; /* ignore */
|
||||
@ -5730,7 +5823,7 @@ void set_zorder(Frontend *frontend, int top)
|
||||
/*
|
||||
* Refresh the window in response to a server-side request.
|
||||
*/
|
||||
void refresh_window(Frontend *frontend)
|
||||
static void wintw_refresh(TermWin *tw)
|
||||
{
|
||||
InvalidateRect(hwnd, NULL, TRUE);
|
||||
}
|
||||
@ -5739,13 +5832,13 @@ void refresh_window(Frontend *frontend)
|
||||
* Maximise or restore the window in response to a server-side
|
||||
* request.
|
||||
*/
|
||||
void set_zoomed(Frontend *frontend, int zoomed)
|
||||
static void wintw_set_maximised(TermWin *tw, int maximised)
|
||||
{
|
||||
if (IsZoomed(hwnd)) {
|
||||
if (!zoomed)
|
||||
if (!maximised)
|
||||
ShowWindow(hwnd, SW_RESTORE);
|
||||
} else {
|
||||
if (zoomed)
|
||||
if (maximised)
|
||||
ShowWindow(hwnd, SW_MAXIMIZE);
|
||||
}
|
||||
}
|
||||
@ -5753,7 +5846,7 @@ void set_zoomed(Frontend *frontend, int zoomed)
|
||||
/*
|
||||
* Report whether the window is iconic, for terminal reports.
|
||||
*/
|
||||
int is_iconic(Frontend *frontend)
|
||||
static int wintw_is_minimised(TermWin *tw)
|
||||
{
|
||||
return IsIconic(hwnd);
|
||||
}
|
||||
@ -5761,7 +5854,7 @@ int is_iconic(Frontend *frontend)
|
||||
/*
|
||||
* Report the window's position, for terminal reports.
|
||||
*/
|
||||
void get_window_pos(Frontend *frontend, int *x, int *y)
|
||||
static void wintw_get_pos(TermWin *tw, int *x, int *y)
|
||||
{
|
||||
RECT r;
|
||||
GetWindowRect(hwnd, &r);
|
||||
@ -5772,7 +5865,7 @@ void get_window_pos(Frontend *frontend, int *x, int *y)
|
||||
/*
|
||||
* Report the window's pixel size, for terminal reports.
|
||||
*/
|
||||
void get_window_pixels(Frontend *frontend, int *x, int *y)
|
||||
static void wintw_get_pixels(TermWin *tw, int *x, int *y)
|
||||
{
|
||||
RECT r;
|
||||
GetWindowRect(hwnd, &r);
|
||||
@ -5783,7 +5876,7 @@ void get_window_pixels(Frontend *frontend, int *x, int *y)
|
||||
/*
|
||||
* Return the window or icon title.
|
||||
*/
|
||||
char *get_window_title(Frontend *frontend, int icon)
|
||||
static const char *wintw_get_title(TermWin *tw, int icon)
|
||||
{
|
||||
return icon ? icon_name : window_name;
|
||||
}
|
||||
|
@ -195,8 +195,6 @@ struct FontSpec *fontspec_new(const char *name,
|
||||
#define DEFAULT_CODEPAGE CP_ACP
|
||||
#define USES_VTLINE_HACK
|
||||
|
||||
typedef HDC Context;
|
||||
|
||||
#ifndef NO_GSSAPI
|
||||
/*
|
||||
* GSS-API stuff
|
||||
@ -261,7 +259,7 @@ int win_seat_confirm_weak_cached_hostkey(
|
||||
* which takes the data string in the system code page instead of
|
||||
* Unicode.
|
||||
*/
|
||||
void write_aclip(Frontend *frontend, int clipboard, char *, int, int);
|
||||
void write_aclip(int clipboard, char *, int, int);
|
||||
|
||||
#define WM_NETEVENT (WM_APP + 5)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user