X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/0f33f9d1535a1384f97c0a4948c95447aa1e400a..e2277a0a3912e6c4fea605d269c94609b0a7dfc4:/unix/pterm.c diff --git a/unix/pterm.c b/unix/pterm.c index 94b732de..714bef1a 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1352,7 +1353,7 @@ void beep(void *frontend, int mode) gdk_beep(); } -int CharWidth(Context ctx, int uc) +int char_width(Context ctx, int uc) { /* * Under X, any fixed-width font really _is_ fixed-width. @@ -1398,7 +1399,7 @@ void do_text_internal(Context ctx, int x, int y, char *text, int len, struct gui_data *inst = dctx->inst; GdkGC *gc = dctx->gc; - int nfg, nbg, t, fontid, shadow; + int nfg, nbg, t, fontid, shadow, rlen; /* * NYI: @@ -1435,13 +1436,25 @@ void do_text_internal(Context ctx, int x, int y, char *text, int len, return; if (x + len*2 > inst->term->cols) len = (inst->term->cols-x)/2; /* trim to LH half */ + rlen = len * 2; + } else + rlen = len; + + { + GdkRectangle r; + + r.x = x*inst->font_width+cfg.window_border; + r.y = y*inst->font_height+cfg.window_border; + r.width = rlen*inst->font_width; + r.height = inst->font_height; + gdk_gc_set_clip_rectangle(gc, &r); } gdk_gc_set_foreground(gc, &inst->cols[nbg]); gdk_draw_rectangle(inst->pixmap, gc, 1, x*inst->font_width+cfg.window_border, y*inst->font_height+cfg.window_border, - len*inst->font_width, inst->font_height); + rlen*inst->font_width, inst->font_height); gdk_gc_set_foreground(gc, &inst->cols[nfg]); gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc, @@ -1767,18 +1780,22 @@ int do_cmdline(int argc, char **argv, int do_everything) extern char **pty_argv; /* declared in pty.c */ /* - * Macros to make argument handling easier. + * Macros to make argument handling easier. Note that because + * they need to call `continue', they cannot be contained in + * the usual do {...} while (0) wrapper to make them + * syntactically single statements; hence it is not legal to + * use one of these macros as an unbraced statement between + * `if' and `else'. */ -#define EXPECTS_ARG do { \ +#define EXPECTS_ARG { \ if (--argc <= 0) { \ err = 1; \ fprintf(stderr, "pterm: %s expects an argument\n", p); \ + continue; \ } else \ val = *++argv; \ -} while (0) -#define SECOND_PASS_ONLY do { \ - if (!do_everything) continue; \ -} while (0) +} +#define SECOND_PASS_ONLY { if (!do_everything) continue; } /* * TODO: @@ -2085,7 +2102,7 @@ int main(int argc, char **argv) inst->currcursor = inst->textcursor; show_mouseptr(inst, 1); - inst->term = term_init(inst); + inst->term = term_init(&cfg, inst); inst->logctx = log_init(inst); term_provide_logctx(inst->term, inst->logctx); @@ -2097,7 +2114,8 @@ int main(int argc, char **argv) term_size(inst->term, cfg.height, cfg.width, cfg.savelines); - inst->ldisc = ldisc_create(inst->term, inst->back, inst->backhandle, inst); + inst->ldisc = + ldisc_create(&cfg, inst->term, inst->back, inst->backhandle, inst); ldisc_send(inst->ldisc, NULL, 0, 0);/* cause ldisc to notice changes */ inst->master_fd = pty_master_fd;