Diff

Differences From Artifact [3cdc2c8f33]:

To Artifact [a12ebdd4b1]:


20
21
22
23
24
25
26

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41




42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

#define PUTTY_DO_GLOBALS	       /* actually _define_ globals */

#include "putty.h"
#include "terminal.h"

#define CAT2(x,y) x ## y
#define CAT(x,y) CAT2(x,y)
#define ASSERT(x) enum {CAT(assertion_,__LINE__) = 1 / (x)}

#define NCOLOURS (lenof(((Config *)0)->colours))

struct gui_data {
    GtkWidget *window, *area, *sbar;
    GtkBox *hbox;
    GtkAdjustment *sbar_adjust;
    GdkPixmap *pixmap;
    GdkFont *fonts[2];                 /* normal and bold (for now!) */




    GdkCursor *rawcursor, *textcursor, *blankcursor, *currcursor;
    GdkColor cols[NCOLOURS];
    GdkColormap *colmap;
    wchar_t *pastein_data;
    int pastein_data_len;
    char *pasteout_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;
    int alt_keycode;
    int alt_digits;
    char wintitle[sizeof(((Config *)0)->wintitle)];
    char icontitle[sizeof(((Config *)0)->wintitle)];
    int master_fd, master_func_id, exited;
    void *ldisc;
    Backend *back;







>















>
>
>
>





|
|




|







20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

#define PUTTY_DO_GLOBALS	       /* actually _define_ globals */

#include "putty.h"
#include "terminal.h"

#define CAT2(x,y) x ## y
#define CAT(x,y) CAT2(x,y)
#define ASSERT(x) enum {CAT(assertion_,__LINE__) = 1 / (x)}

#define NCOLOURS (lenof(((Config *)0)->colours))

struct gui_data {
    GtkWidget *window, *area, *sbar;
    GtkBox *hbox;
    GtkAdjustment *sbar_adjust;
    GdkPixmap *pixmap;
    GdkFont *fonts[2];                 /* normal and bold (for now!) */
    struct {
	int charset;
	int is_wide;
    } fontinfo[2];
    GdkCursor *rawcursor, *textcursor, *blankcursor, *currcursor;
    GdkColor cols[NCOLOURS];
    GdkColormap *colmap;
    wchar_t *pastein_data;
    int pastein_data_len;
    char *pasteout_data, *pasteout_data_utf8;
    int pasteout_data_len, pasteout_data_utf8_len;
    int font_width, font_height;
    int ignore_sbar;
    int mouseptr_visible;
    guint term_paste_idle_id;
    GdkAtom compound_text_atom, utf8_string_atom;
    int alt_keycode;
    int alt_digits;
    char wintitle[sizeof(((Config *)0)->wintitle)];
    char icontitle[sizeof(((Config *)0)->wintitle)];
    int master_fd, master_func_id, exited;
    void *ldisc;
    Backend *back;
827
828
829
830
831
832
833











834

835
836
837
838
839
840
841
	int i;
	printf("generating sequence:");
	for (i = start; i < end; i++)
	    printf(" %02x", (unsigned char) output[i]);
	printf("\n");
#endif












	ldisc_send(inst->ldisc, output+start, end-start, 1);

	show_mouseptr(inst, 0);
	term_seen_key_event(inst->term);
	term_out(inst->term);
    }

    return TRUE;
}







>
>
>
>
>
>
>
>
>
>
>
|
>







832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
	int i;
	printf("generating sequence:");
	for (i = start; i < end; i++)
	    printf(" %02x", (unsigned char) output[i]);
	printf("\n");
#endif

	/*
	 * The stuff we've just generated is assumed to be
	 * ISO-8859-1! This sounds insane, but `man XLookupString'
	 * agrees: strings of this type returned from the X server
	 * are hardcoded to 8859-1. Strictly speaking we should be
	 * doing this using some sort of GtkIMContext, which (if
	 * we're lucky) would give us our data directly in Unicode;
	 * but that's not supported in GTK 1.2 as far as I can
	 * tell, and it's poorly documented even in 2.0, so it'll
	 * have to wait.
	 */
	lpage_send(inst->ldisc, CS_ISO8859_1, output+start, end-start, 1);

	show_mouseptr(inst, 0);
	term_seen_key_event(inst->term);
	term_out(inst->term);
    }

    return TRUE;
}
1194
1195
1196
1197
1198
1199
1200
















1201
1202

1203
1204
1205
1206
1207
1208
1209
1210
1211


1212
1213
1214
1215
1216
1217
1218

1219




1220
1221
1222
1223
1224
1225
1226
1227
1228
1229


1230
1231


1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242








1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253













1254
1255

1256
1257
1258
1259
1260
1261
1262



1263
1264
1265
1266
1267
1268
1269
1270
1271
}

void write_clip(void *frontend, wchar_t * data, int len, int must_deselect)
{
    struct gui_data *inst = (struct gui_data *)frontend;
    if (inst->pasteout_data)
	sfree(inst->pasteout_data);
















    inst->pasteout_data = smalloc(len);
    inst->pasteout_data_len = len;

    wc_to_mb(0, 0, data, len, inst->pasteout_data, inst->pasteout_data_len,
	     NULL, NULL);

    if (gtk_selection_owner_set(inst->area, GDK_SELECTION_PRIMARY,
				GDK_CURRENT_TIME)) {
	gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
				 GDK_SELECTION_TYPE_STRING, 1);
	gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
				 inst->compound_text_atom, 1);


    }
}

void selection_get(GtkWidget *widget, GtkSelectionData *seldata,
		   guint info, guint time_stamp, gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;

    gtk_selection_data_set(seldata, GDK_SELECTION_TYPE_STRING, 8,




			   inst->pasteout_data, inst->pasteout_data_len);
}

gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
		     gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;
    term_deselect(inst->term);
    if (inst->pasteout_data)
	sfree(inst->pasteout_data);


    inst->pasteout_data = NULL;
    inst->pasteout_data_len = 0;


    return TRUE;
}

void request_paste(void *frontend)
{
    struct gui_data *inst = (struct gui_data *)frontend;
    /*
     * In Unix, pasting is asynchronous: all we can do at the
     * moment is to call gtk_selection_convert(), and when the data
     * comes back _then_ we can call term_do_paste().
     */








    gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
			  GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME);
}

gint idle_paste_func(gpointer data);   /* forward ref */

void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
			guint time, gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;














    if (seldata->length <= 0 ||
	seldata->type != GDK_SELECTION_TYPE_STRING)

	return;			       /* Nothing happens. */

    if (inst->pastein_data)
	sfree(inst->pastein_data);

    inst->pastein_data = smalloc(seldata->length * sizeof(wchar_t));
    inst->pastein_data_len = seldata->length;



    mb_to_wc(0, 0, seldata->data, seldata->length,
	     inst->pastein_data, inst->pastein_data_len);

    term_do_paste(inst->term);

    if (term_paste_pending(inst->term))
	inst->term_paste_idle_id = gtk_idle_add(idle_paste_func, inst);
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


>
|








>
>







>
|
>
>
>
>
|









>
>


>
>











>
>
>
>
>
>
>
>

|









>
>
>
>
>
>
>
>
>
>
>
>
>

|
>







>
>
>
|
|







1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
}

void write_clip(void *frontend, wchar_t * data, int len, int must_deselect)
{
    struct gui_data *inst = (struct gui_data *)frontend;
    if (inst->pasteout_data)
	sfree(inst->pasteout_data);
    if (inst->pasteout_data_utf8)
	sfree(inst->pasteout_data_utf8);

    inst->pasteout_data_utf8 = smalloc(len*6);
    inst->pasteout_data_utf8_len = len*6;
    {
	wchar_t *tmp = data;
	int tmplen = len;
	inst->pasteout_data_utf8_len =
	    charset_from_unicode(&tmp, &tmplen, inst->pasteout_data_utf8,
				 inst->pasteout_data_utf8_len,
				 CS_UTF8, NULL, NULL, 0);
	inst->pasteout_data_utf8 =
	    srealloc(inst->pasteout_data_utf8, inst->pasteout_data_utf8_len);
    }

    inst->pasteout_data = smalloc(len);
    inst->pasteout_data_len = len;
    wc_to_mb(line_codepage, 0, data, len,
	     inst->pasteout_data, inst->pasteout_data_len,
	     NULL, NULL);

    if (gtk_selection_owner_set(inst->area, GDK_SELECTION_PRIMARY,
				GDK_CURRENT_TIME)) {
	gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
				 GDK_SELECTION_TYPE_STRING, 1);
	gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
				 inst->compound_text_atom, 1);
	gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
				 inst->utf8_string_atom, 1);
    }
}

void selection_get(GtkWidget *widget, GtkSelectionData *seldata,
		   guint info, guint time_stamp, gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;
    if (seldata->target == inst->utf8_string_atom)
	gtk_selection_data_set(seldata, seldata->target, 8,
			       inst->pasteout_data_utf8,
			       inst->pasteout_data_utf8_len);
    else
	gtk_selection_data_set(seldata, seldata->target, 8,
			       inst->pasteout_data, inst->pasteout_data_len);
}

gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
		     gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;
    term_deselect(inst->term);
    if (inst->pasteout_data)
	sfree(inst->pasteout_data);
    if (inst->pasteout_data_utf8)
	sfree(inst->pasteout_data_utf8);
    inst->pasteout_data = NULL;
    inst->pasteout_data_len = 0;
    inst->pasteout_data_utf8 = NULL;
    inst->pasteout_data_utf8_len = 0;
    return TRUE;
}

void request_paste(void *frontend)
{
    struct gui_data *inst = (struct gui_data *)frontend;
    /*
     * In Unix, pasting is asynchronous: all we can do at the
     * moment is to call gtk_selection_convert(), and when the data
     * comes back _then_ we can call term_do_paste().
     */

    /*
     * First we attempt to retrieve the selection as a UTF-8 string
     * (which we will convert to the correct code page before
     * sending to the session, of course). If that fails,
     * selection_received() will be informed and will fall back to
     * an ordinary string.
     */
    gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
			  inst->utf8_string_atom, GDK_CURRENT_TIME);
}

gint idle_paste_func(gpointer data);   /* forward ref */

void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
			guint time, gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;

    if (seldata->target == inst->utf8_string_atom && seldata->length <= 0) {
	/*
	 * Failed to get a UTF-8 selection string. Try an ordinary
	 * string.
	 */
	gtk_selection_convert(inst->area, GDK_SELECTION_PRIMARY,
			      GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME);
	return;
    }

    /*
     * Any other failure should just go foom.
     */
    if (seldata->length <= 0 ||
	(seldata->type != GDK_SELECTION_TYPE_STRING &&
	 seldata->type != inst->utf8_string_atom))
	return;			       /* Nothing happens. */

    if (inst->pastein_data)
	sfree(inst->pastein_data);

    inst->pastein_data = smalloc(seldata->length * sizeof(wchar_t));
    inst->pastein_data_len = seldata->length;
    inst->pastein_data_len =
	mb_to_wc((seldata->type == inst->utf8_string_atom ?
		  CS_UTF8 : line_codepage),
		 0, seldata->data, seldata->length,
		 inst->pastein_data, inst->pastein_data_len);

    term_do_paste(inst->term);

    if (term_paste_pending(inst->term))
	inst->term_paste_idle_id = gtk_idle_add(idle_paste_func, inst);
}

1453
1454
1455
1456
1457
1458
1459































1460
1461
1462
1463




1464
1465
1466
1467
1468
1469
1470
    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,
		       rlen*inst->font_width, inst->font_height);

    gdk_gc_set_foreground(gc, &inst->cols[nfg]);































    gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
		  x*inst->font_width+cfg.window_border,
		  y*inst->font_height+cfg.window_border+inst->fonts[0]->ascent,
		  text, len);





    if (shadow) {
	gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
		      x*inst->font_width+cfg.window_border + cfg.shadowboldoffset,
		      y*inst->font_height+cfg.window_border+inst->fonts[0]->ascent,
		      text, len);
    }







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
>
>
>
>







1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
    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,
		       rlen*inst->font_width, inst->font_height);

    gdk_gc_set_foreground(gc, &inst->cols[nfg]);
    {
	GdkWChar *gwcs;
	gchar *gcs;
	wchar_t *wcs;
	int i;

	wcs = smalloc(sizeof(wchar_t) * (len+1));
	for (i = 0; i < len; i++) {
	    wcs[i] = (wchar_t) ((attr & CSET_MASK) + (text[i] & CHAR_MASK));
	}

	if (inst->fontinfo[fontid].is_wide) {
	    gwcs = smalloc(sizeof(GdkWChar) * (len+1));
	    /*
	     * FIXME: when we have a wide-char equivalent of
	     * from_unicode, use it instead of this.
	     */
	    for (i = 0; i <= len; i++)
		gwcs[i] = wcs[i];
	    gdk_draw_text_wc(inst->pixmap, inst->fonts[fontid], gc,
			     x*inst->font_width+cfg.window_border,
			     y*inst->font_height+cfg.window_border+inst->fonts[0]->ascent,
			     gwcs, len*2);
	    sfree(gwcs);
	} else {
	    wchar_t *wcstmp = wcs;
	    int lentmp = len;
	    gcs = smalloc(sizeof(GdkWChar) * (len+1));
	    charset_from_unicode(&wcstmp, &lentmp, gcs, len,
				 inst->fontinfo[fontid].charset,
				 NULL, ".", 1);
	    gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
			  x*inst->font_width+cfg.window_border,
			  y*inst->font_height+cfg.window_border+inst->fonts[0]->ascent,
			  gcs, len);
	    sfree(gcs);
	}
	sfree(wcs);
    }

    if (shadow) {
	gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
		      x*inst->font_width+cfg.window_border + cfg.shadowboldoffset,
		      y*inst->font_height+cfg.window_border+inst->fonts[0]->ascent,
		      text, len);
    }
1814
1815
1816
1817
1818
1819
1820






1821
1822
1823
1824
1825
1826
1827

	} else if (!strcmp(p, "-fb")) {
	    EXPECTS_ARG;
	    SECOND_PASS_ONLY;
	    strncpy(cfg.boldfont, val, sizeof(cfg.boldfont));
	    cfg.boldfont[sizeof(cfg.boldfont)-1] = '\0';







	} else if (!strcmp(p, "-geometry")) {
	    int flags, x, y, w, h;
	    EXPECTS_ARG;
	    SECOND_PASS_ONLY;

	    flags = XParseGeometry(val, &x, &y, &w, &h);
	    if (flags & WidthValue)







>
>
>
>
>
>







1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938

	} else if (!strcmp(p, "-fb")) {
	    EXPECTS_ARG;
	    SECOND_PASS_ONLY;
	    strncpy(cfg.boldfont, val, sizeof(cfg.boldfont));
	    cfg.boldfont[sizeof(cfg.boldfont)-1] = '\0';

	} else if (!strcmp(p, "-cs")) {
	    EXPECTS_ARG;
	    SECOND_PASS_ONLY;
	    strncpy(cfg.line_codepage, val, sizeof(cfg.line_codepage));
	    cfg.line_codepage[sizeof(cfg.line_codepage)-1] = '\0';

	} else if (!strcmp(p, "-geometry")) {
	    int flags, x, y, w, h;
	    EXPECTS_ARG;
	    SECOND_PASS_ONLY;

	    flags = XParseGeometry(val, &x, &y, &w, &h);
	    if (flags & WidthValue)
1950
1951
1952
1953
1954
1955
1956






























































1957
1958
1959
1960
1961
1962
1963
  sigemptyset(&ss);
  sigaddset(&ss, sig);
  if(sigprocmask(block_it ? SIG_BLOCK : SIG_UNBLOCK, &ss, 0) < 0) {
    perror("sigprocmask");
    exit(1);
  }
}































































int main(int argc, char **argv)
{
    extern int pty_master_fd;	       /* declared in pty.c */
    extern void pty_pre_init(void);    /* declared in pty.c */
    struct gui_data *inst;








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
  sigemptyset(&ss);
  sigaddset(&ss, sig);
  if(sigprocmask(block_it ? SIG_BLOCK : SIG_UNBLOCK, &ss, 0) < 0) {
    perror("sigprocmask");
    exit(1);
  }
}

static void set_font_info(struct gui_data *inst, int fontid)
{
    GdkFont *font = inst->fonts[fontid];
    XFontStruct *xfs = GDK_FONT_XFONT(font);
    Display *disp = GDK_FONT_XDISPLAY(font);
    Atom charset_registry, charset_encoding;
    unsigned long registry_ret, encoding_ret;
    charset_registry = XInternAtom(disp, "CHARSET_REGISTRY", False);
    charset_encoding = XInternAtom(disp, "CHARSET_ENCODING", False);
    inst->fontinfo[fontid].charset = CS_NONE;
    inst->fontinfo[fontid].is_wide = 0;
    if (XGetFontProperty(xfs, charset_registry, &registry_ret) &&
	XGetFontProperty(xfs, charset_encoding, &encoding_ret)) {
	char *reg, *enc;
	reg = XGetAtomName(disp, (Atom)registry_ret);
	enc = XGetAtomName(disp, (Atom)encoding_ret);
	if (reg && enc) {
	    char *encoding = dupcat(reg, "-", enc, NULL);
	    inst->fontinfo[fontid].charset = charset_from_xenc(encoding);
	    /* FIXME: when libcharset supports wide encodings fix this. */
	    if (!strcasecmp(encoding, "iso10646-1"))
		inst->fontinfo[fontid].is_wide = 1;

	    /*
	     * Hack for X line-drawing characters: if the primary
	     * font is encoded as ISO-8859-anything, and has valid
	     * glyphs in the first 32 char positions, it is assumed
	     * that those glyphs are the VT100 line-drawing
	     * character set.
	     * 
	     * Actually, we'll hack even harder by only checking
	     * position 0x19 (vertical line, VT100 linedrawing
	     * `x'). Then we can check it easily by seeing if the
	     * ascent and descent differ.
	     */
	    if (inst->fontinfo[fontid].charset == CS_ISO8859_1) {
		int lb, rb, wid, asc, desc;
		gchar text[2];

		text[1] = '\0';
		text[0] = '\x12';
		gdk_string_extents(inst->fonts[fontid], text,
				   &lb, &rb, &wid, &asc, &desc);
		if (asc != desc)
		    inst->fontinfo[fontid].charset = CS_ISO8859_1_X11;
	    }

	    /*
	     * FIXME: this is a hack. Currently fonts with
	     * incomprehensible encodings are dealt with by
	     * pretending they're 8859-1. It's ugly, but it's good
	     * enough to stop things crashing. Should do something
	     * better here.
	     */
	    if (inst->fontinfo[fontid].charset == CS_NONE)
		inst->fontinfo[fontid].charset = CS_ISO8859_1;

	    sfree(encoding);
	}
    }
}

int main(int argc, char **argv)
{
    extern int pty_master_fd;	       /* declared in pty.c */
    extern void pty_pre_init(void);    /* declared in pty.c */
    struct gui_data *inst;

1983
1984
1985
1986
1987
1988
1989

1990
1991
1992
1993
1994
1995
1996

1997
1998
1999
2000
2001
2002
2003

2004
2005
2006
2007
2008
2009
2010
    inst->alt_keycode = -1;            /* this one needs _not_ to be zero */

    inst->fonts[0] = gdk_font_load(cfg.font);
    if (!inst->fonts[0]) {
	fprintf(stderr, "pterm: unable to load font \"%s\"\n", cfg.font);
	exit(1);
    }

    if (cfg.boldfont[0]) {
	inst->fonts[1] = gdk_font_load(cfg.boldfont);
	if (!inst->fonts[1]) {
	    fprintf(stderr, "pterm: unable to load bold font \"%s\"\n",
		    cfg.boldfont);
	    exit(1);
	}

    } else
	inst->fonts[1] = NULL;

    inst->font_width = gdk_char_width(inst->fonts[0], ' ');
    inst->font_height = inst->fonts[0]->ascent + inst->fonts[0]->descent;

    inst->compound_text_atom = gdk_atom_intern("COMPOUND_TEXT", FALSE);


    init_ucs();

    inst->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    if (cfg.wintitle[0])
	set_title(inst, cfg.wintitle);







>







>







>







2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
    inst->alt_keycode = -1;            /* this one needs _not_ to be zero */

    inst->fonts[0] = gdk_font_load(cfg.font);
    if (!inst->fonts[0]) {
	fprintf(stderr, "pterm: unable to load font \"%s\"\n", cfg.font);
	exit(1);
    }
    set_font_info(inst, 0);
    if (cfg.boldfont[0]) {
	inst->fonts[1] = gdk_font_load(cfg.boldfont);
	if (!inst->fonts[1]) {
	    fprintf(stderr, "pterm: unable to load bold font \"%s\"\n",
		    cfg.boldfont);
	    exit(1);
	}
	set_font_info(inst, 1);
    } else
	inst->fonts[1] = NULL;

    inst->font_width = gdk_char_width(inst->fonts[0], ' ');
    inst->font_height = inst->fonts[0]->ascent + inst->fonts[0]->descent;

    inst->compound_text_atom = gdk_atom_intern("COMPOUND_TEXT", FALSE);
    inst->utf8_string_atom = gdk_atom_intern("UTF8_STRING", FALSE);

    init_ucs();

    inst->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    if (cfg.wintitle[0])
	set_title(inst, cfg.wintitle);