X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/4c0901edb98a3987acf3ba17e7205f1275ed760c..614bb468761f5cc8fd243f0f0083e9df95bdaa6a:/unix/pterm.c?ds=inline diff --git a/unix/pterm.c b/unix/pterm.c index 77743edf..58f9846e 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -38,6 +38,8 @@ struct gui_data { int pasteout_data_len; int font_width, font_height; int ignore_sbar; + int mouseptr_visible; + guint term_paste_idle_id; GdkAtom compound_text_atom; char wintitle[sizeof(((Config *)0)->wintitle)]; }; @@ -188,6 +190,7 @@ void show_mouseptr(int show) gdk_window_set_cursor(inst->area->window, inst->currcursor); else gdk_window_set_cursor(inst->area->window, inst->blankcursor); + inst->mouseptr_visible = show; } gint configure_area(GtkWidget *widget, GdkEventConfigure *event, gpointer data) @@ -195,6 +198,11 @@ gint configure_area(GtkWidget *widget, GdkEventConfigure *event, gpointer data) struct gui_data *inst = (struct gui_data *)data; int w, h, need_size = 0; + /* + * Set up the colour map. + */ + palette_reset(); + w = (event->width - 2*cfg.window_border) / inst->font_width; h = (event->height - 2*cfg.window_border) / inst->font_height; @@ -228,11 +236,6 @@ gint configure_area(GtkWidget *widget, GdkEventConfigure *event, gpointer data) term_size(h, w, cfg.savelines); } - /* - * Set up the colour map. - */ - palette_reset(); - return TRUE; } @@ -278,7 +281,6 @@ gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data) /* * NYI: - * - nethack mode * - alt+numpad * - Compose key (!!! requires Unicode faff before even trying) */ @@ -750,13 +752,6 @@ gint timer_func(gpointer data) return TRUE; } -gint idle_func(gpointer data) -{ - /* struct gui_data *inst = (struct gui_data *)data; */ - term_paste(); - return TRUE; -} - void pty_input_func(gpointer data, gint sourcefd, GdkInputCondition condition) { /* struct gui_data *inst = (struct gui_data *)data; */ @@ -808,7 +803,7 @@ void set_raw_mouse_mode(int activate) inst->currcursor = inst->rawcursor; else inst->currcursor = inst->textcursor; - show_mouseptr(1); + show_mouseptr(inst->mouseptr_visible); } void request_resize(int w, int h) @@ -924,6 +919,8 @@ void request_paste(void) GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME); } +gint idle_paste_func(gpointer data); /* forward ref */ + void selection_received(GtkWidget *widget, GtkSelectionData *seldata, gpointer data) { @@ -940,8 +937,24 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata, inst->pastein_data, inst->pastein_data_len); term_do_paste(); + + if (term_paste_pending()) + inst->term_paste_idle_id = gtk_idle_add(idle_paste_func, inst); } +gint idle_paste_func(gpointer data) +{ + struct gui_data *inst = (struct gui_data *)data; + + if (term_paste_pending()) + term_paste(); + else + gtk_idle_remove(inst->term_paste_idle_id); + + return TRUE; +} + + void get_clip(wchar_t ** p, int *len) { if (p) { @@ -1033,7 +1046,6 @@ void do_text(Context ctx, int x, int y, char *text, int len, /* * NYI: * - Unicode, code pages, and ATTR_WIDE for CJK support. - * - LATTR_* (ESC # 4 double-width and double-height stuff) * - cursor shapes other than block * - shadow bolding */ @@ -1054,6 +1066,14 @@ void do_text(Context ctx, int x, int y, char *text, int len, nbg = NCOLOURS-1; } + if (lattr != LATTR_NORM) { + x *= 2; + if (x >= cols) + return; + if (x + len*2 > cols) + len = (cols-x)/2; /* trim to LH half */ + } + gdk_gc_set_foreground(gc, &inst->cols[nbg]); gdk_draw_rectangle(inst->pixmap, gc, 1, x*inst->font_width+cfg.window_border, @@ -1076,6 +1096,44 @@ void do_text(Context ctx, int x, int y, char *text, int len, y*inst->font_height + uheight + cfg.window_border); } + if (lattr != LATTR_NORM) { + /* + * I can't find any plausible StretchBlt equivalent in the + * X server, so I'm going to do this the slow and painful + * way. This will involve repeated calls to + * gdk_draw_pixmap() to stretch the text horizontally. It's + * O(N^2) in time and O(N) in network bandwidth, but you + * try thinking of a better way. :-( + */ + int i; + for (i = 0; i < len * inst->font_width; i++) { + gdk_draw_pixmap(inst->pixmap, gc, inst->pixmap, + x*inst->font_width+cfg.window_border + 2*i, + y*inst->font_height+cfg.window_border, + x*inst->font_width+cfg.window_border + 2*i+1, + y*inst->font_height+cfg.window_border, + len * inst->font_width - i, inst->font_height); + } + len *= 2; + if (lattr != LATTR_WIDE) { + int dt, db; + /* Now stretch vertically, in the same way. */ + if (lattr == LATTR_BOT) + dt = 0, db = 1; + else + dt = 1, db = 0; + for (i = 0; i < inst->font_height; i+=2) { + gdk_draw_pixmap(inst->pixmap, gc, inst->pixmap, + x*inst->font_width+cfg.window_border, + y*inst->font_height+cfg.window_border+dt*i+db, + x*inst->font_width+cfg.window_border, + y*inst->font_height+cfg.window_border+dt*(i+1), + len * inst->font_width, inst->font_height-i-1); + } + } + len *= 2; + } + gdk_draw_pixmap(inst->area->window, gc, inst->pixmap, x*inst->font_width+cfg.window_border, y*inst->font_height+cfg.window_border, @@ -1345,7 +1403,6 @@ int main(int argc, char **argv) GTK_SIGNAL_FUNC(selection_clear), inst); gtk_signal_connect(GTK_OBJECT(inst->sbar_adjust), "value_changed", GTK_SIGNAL_FUNC(scrollbar_moved), inst); - gtk_idle_add(idle_func, inst); gtk_timeout_add(20, timer_func, inst); gdk_input_add(pty_master_fd, GDK_INPUT_READ, pty_input_func, inst); gtk_widget_add_events(GTK_WIDGET(inst->area),