X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/putty/blobdiff_plain/12745e35f6aa5ba7b1a89afe6d5249d8ca46dd37..2916fa1404c5e3661440f174c3d3fa06c3482aad:/unix/gtkwin.c diff --git a/unix/gtkwin.c b/unix/gtkwin.c index 5397236c..ff08ec08 100644 --- a/unix/gtkwin.c +++ b/unix/gtkwin.c @@ -177,12 +177,34 @@ void ldisc_update(void *frontend, int echo, int edit) */ } +char *get_ttymode(void *frontend, const char *mode) +{ + struct gui_data *inst = (struct gui_data *)frontend; + return term_get_ttymode(inst->term, mode); +} + int from_backend(void *frontend, int is_stderr, const char *data, int len) { struct gui_data *inst = (struct gui_data *)frontend; return term_data(inst->term, is_stderr, data, len); } +int from_backend_untrusted(void *frontend, const char *data, int len) +{ + struct gui_data *inst = (struct gui_data *)frontend; + return term_data_untrusted(inst->term, data, len); +} + +int get_userpass_input(prompts_t *p, unsigned char *in, int inlen) +{ + struct gui_data *inst = (struct gui_data *)p->frontend; + int ret; + ret = cmdline_get_passwd_input(p, in, inlen); + if (ret == -1) + ret = term_get_userpass_input(inst->term, p, in, inlen); + return ret; +} + void logevent(void *frontend, const char *string) { struct gui_data *inst = (struct gui_data *)frontend; @@ -1346,7 +1368,7 @@ static void real_palette_set(struct gui_data *inst, int n, int r, int g, int b) gdk_colormap_free_colors(inst->colmap, inst->cols + n, 1); gdk_colormap_alloc_colors(inst->colmap, inst->cols + n, 1, - FALSE, FALSE, success); + FALSE, TRUE, success); if (!success[0]) g_error("%s: couldn't allocate colour %d (#%02x%02x%02x)\n", appname, n, r, g, b); @@ -1401,19 +1423,19 @@ void palette_reset(void *frontend) for (i = 0; i < NEXTCOLOURS; i++) { if (i < 216) { int r = i / 36, g = (i / 6) % 6, b = i % 6; - inst->cols[i+16].red = r * 0x3333; - inst->cols[i+16].green = g * 0x3333; - inst->cols[i+16].blue = b * 0x3333; + inst->cols[i+16].red = r ? r * 0x2828 + 0x3737 : 0; + inst->cols[i+16].green = g ? g * 0x2828 + 0x3737 : 0; + inst->cols[i+16].blue = b ? b + 0x2828 + 0x3737 : 0; } else { int shade = i - 216; - shade = (shade + 1) * 0xFFFF / (NEXTCOLOURS - 216 + 1); + shade = shade * 0x0a0a + 0x0808; inst->cols[i+16].red = inst->cols[i+16].green = inst->cols[i+16].blue = shade; } } gdk_colormap_alloc_colors(inst->colmap, inst->cols, NALLCOLOURS, - FALSE, FALSE, success); + FALSE, TRUE, success); for (i = 0; i < NALLCOLOURS; i++) { if (!success[i]) g_error("%s: couldn't allocate colour %d (#%02x%02x%02x)\n", @@ -1469,7 +1491,7 @@ char * retrieve_cutbuffer(int * nbytes) return ptr; } -void write_clip(void *frontend, wchar_t * data, int len, int must_deselect) +void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_deselect) { struct gui_data *inst = (struct gui_data *)frontend; if (inst->pasteout_data) @@ -1826,7 +1848,7 @@ void sys_cursor(void *frontend, int x, int y) * may want to perform additional actions on any kind of bell (for * example, taskbar flashing in Windows). */ -void beep(void *frontend, int mode) +void do_beep(void *frontend, int mode) { if (mode != BELL_VISUAL) gdk_beep(); @@ -1879,6 +1901,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, GdkGC *gc = dctx->gc; int ncombining, combining; int nfg, nbg, t, fontid, shadow, rlen, widefactor; + int monochrome = gtk_widget_get_visual(inst->area)->depth == 1; if (attr & TATTR_COMBINING) { ncombining = len; @@ -1886,9 +1909,9 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, } else ncombining = 1; - nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT); - nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT); - if (attr & ATTR_REVERSE) { + nfg = ((monochrome ? ATTR_DEFFG : (attr & ATTR_FGMASK)) >> ATTR_FGSHIFT); + nbg = ((monochrome ? ATTR_DEFBG : (attr & ATTR_BGMASK)) >> ATTR_BGSHIFT); + if (!!(attr & ATTR_REVERSE) ^ (monochrome && (attr & TATTR_ACTCURS))) { t = nfg; nfg = nbg; nbg = t; @@ -1901,7 +1924,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len, if (nbg < 16) nbg |= 8; else if (nbg >= 256) nbg |= 1; } - if (attr & TATTR_ACTCURS) { + if ((attr & TATTR_ACTCURS) && !monochrome) { nfg = 260; nbg = 261; } @@ -2835,7 +2858,7 @@ void clear_scrollback_menuitem(GtkMenuItem *item, gpointer data) void reset_terminal_menuitem(GtkMenuItem *item, gpointer data) { struct gui_data *inst = (struct gui_data *)data; - term_pwron(inst->term); + term_pwron(inst->term, TRUE); if (inst->ldisc) ldisc_send(inst->ldisc, NULL, 0, 0); } @@ -3206,6 +3229,7 @@ void restart_session_menuitem(GtkMenuItem *item, gpointer data) if (!inst->back) { logevent(inst, "----- Session restarted -----"); + term_pwron(inst->term, FALSE); start_backend(inst); inst->exited = FALSE; }