inst->sbar_adjust = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 0, 0, 0)); inst->sbar = gtk_vscrollbar_new(inst->sbar_adjust);
if (cfg.scrollbar) { inst->sbar_adjust = GTK_ADJUSTMENT(gtk_adjustment_new(0,0,0,0,0,0)); inst->sbar = gtk_vscrollbar_new(inst->sbar_adjust); }
int main(int argc, char **argv){    extern int pty_master_fd;	       /* declared in pty.c */    extern char **pty_argv;	       /* declared in pty.c */    int err = 0;    gtk_init(&argc, &argv);    do_defaults(NULL, &cfg);    while (--argc > 0) {	char *p = *++argv;	if (!strcmp(p, "-fn")) {	    if (--argc > 0) {		strncpy(cfg.font, *++argv, sizeof(cfg.font));		cfg.font[sizeof(cfg.font)-1] = '\0';	    } else		err = 1, fprintf(stderr, "pterm: -fn expects an argument\n");	}	if (!strcmp(p, "-e")) {	    if (--argc > 0) {		int i;		pty_argv = smalloc((argc+1) * sizeof(char *));		++argv;		for (i = 0; i < argc; i++)		    pty_argv[i] = argv[i];		pty_argv[argc] = NULL;		break;		       /* finished command-line processing */	    } else		err = 1, fprintf(stderr, "pterm: -e expects an argument\n");	}	if (!strcmp(p, "-T")) {	    if (--argc > 0) {		strncpy(cfg.wintitle, *++argv, sizeof(cfg.wintitle));		cfg.wintitle[sizeof(cfg.wintitle)-1] = '\0';	    } else		err = 1, fprintf(stderr, "pterm: -T expects an argument\n");	}	if (!strcmp(p, "-log")) {	    if (--argc > 0) {		strncpy(cfg.logfilename, *++argv, sizeof(cfg.logfilename));		cfg.logfilename[sizeof(cfg.logfilename)-1] = '\0';		cfg.logtype = LGTYP_DEBUG;	    } else		err = 1, fprintf(stderr, "pterm: -log expects an argument\n");	}	if (!strcmp(p, "-hide")) {	    cfg.hide_mouseptr = 1;	}	if (!strcmp(p, "-ut-")) {	    cfg.stamp_utmp = 0;	}	if (!strcmp(p, "-ls-")) {	    cfg.login_shell = 0;	}	if (!strcmp(p, "-nethack")) {	    cfg.nethack_keypad = 1;	}    }    inst->fonts[0] = gdk_font_load(cfg.font);    inst->fonts[1] = NULL;             /* FIXME: what about bold font? */    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(cfg.wintitle);    else	set_title("pterm");    /*     * Set up the colour map.     */    palette_reset();    inst->area = gtk_drawing_area_new();    gtk_drawing_area_size(GTK_DRAWING_AREA(inst->area),			  inst->font_width * cfg.width + 2*cfg.window_border,			  inst->font_height * cfg.height + 2*cfg.window_border);    inst->sbar_adjust = GTK_ADJUSTMENT(gtk_adjustment_new(0, 0, 0, 0, 0, 0));    inst->sbar = gtk_vscrollbar_new(inst->sbar_adjust);    inst->hbox = GTK_BOX(gtk_hbox_new(FALSE, 0));    gtk_box_pack_start(inst->hbox, inst->area, TRUE, TRUE, 0);    gtk_box_pack_end(inst->hbox, inst->sbar, FALSE, FALSE, 0);    gtk_window_set_policy(GTK_WINDOW(inst->window), FALSE, TRUE, TRUE);    gtk_container_add(GTK_CONTAINER(inst->window), GTK_WIDGET(inst->hbox));    {	GdkGeometry geom;	geom.min_width = inst->font_width + 2*cfg.window_border;	geom.min_height = inst->font_height + 2*cfg.window_border;	geom.max_width = geom.max_height = -1;	geom.base_width = 2*cfg.window_border;	geom.base_height = 2*cfg.window_border;	geom.width_inc = inst->font_width;	geom.height_inc = inst->font_height;	geom.min_aspect = geom.max_aspect = 0;	gtk_window_set_geometry_hints(GTK_WINDOW(inst->window), inst->area, &geom,				      GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE |				      GDK_HINT_RESIZE_INC);    }    gtk_signal_connect(GTK_OBJECT(inst->window), "destroy",		       GTK_SIGNAL_FUNC(destroy), inst);    gtk_signal_connect(GTK_OBJECT(inst->window), "delete_event",		       GTK_SIGNAL_FUNC(delete_window), inst);    gtk_signal_connect(GTK_OBJECT(inst->window), "key_press_event",		       GTK_SIGNAL_FUNC(key_event), inst);    gtk_signal_connect(GTK_OBJECT(inst->window), "focus_in_event",		       GTK_SIGNAL_FUNC(focus_event), inst);    gtk_signal_connect(GTK_OBJECT(inst->window), "focus_out_event",		       GTK_SIGNAL_FUNC(focus_event), inst);    gtk_signal_connect(GTK_OBJECT(inst->area), "configure_event",		       GTK_SIGNAL_FUNC(configure_area), inst);    gtk_signal_connect(GTK_OBJECT(inst->area), "expose_event",		       GTK_SIGNAL_FUNC(expose_area), inst);    gtk_signal_connect(GTK_OBJECT(inst->area), "button_press_event",		       GTK_SIGNAL_FUNC(button_event), inst);    gtk_signal_connect(GTK_OBJECT(inst->area), "button_release_event",		       GTK_SIGNAL_FUNC(button_event), inst);    gtk_signal_connect(GTK_OBJECT(inst->area), "motion_notify_event",		       GTK_SIGNAL_FUNC(motion_event), inst);    gtk_signal_connect(GTK_OBJECT(inst->area), "selection_received",		       GTK_SIGNAL_FUNC(selection_received), inst);    gtk_signal_connect(GTK_OBJECT(inst->area), "selection_get",		       GTK_SIGNAL_FUNC(selection_get), inst);    gtk_signal_connect(GTK_OBJECT(inst->area), "selection_clear_event",		       GTK_SIGNAL_FUNC(selection_clear), inst);    gtk_signal_connect(GTK_OBJECT(inst->sbar_adjust), "value_changed",		       GTK_SIGNAL_FUNC(scrollbar_moved), inst);    gtk_timeout_add(20, timer_func, inst);    gtk_widget_add_events(GTK_WIDGET(inst->area),			  GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |			  GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |			  GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK);    gtk_widget_show(inst->area);    gtk_widget_show(inst->sbar);    gtk_widget_show(GTK_WIDGET(inst->hbox));    gtk_widget_show(inst->window);    inst->textcursor = make_mouse_ptr(GDK_XTERM);    inst->rawcursor = make_mouse_ptr(GDK_LEFT_PTR);    inst->blankcursor = make_mouse_ptr(-1);    make_mouse_ptr(-2);		       /* clean up cursor font */    inst->currcursor = inst->textcursor;    show_mouseptr(1);    back = &pty_backend;    back->init(NULL, 0, NULL, 0);    gdk_input_add(pty_master_fd, GDK_INPUT_READ, pty_input_func, inst);    term_init();    term_size(cfg.height, cfg.width, cfg.savelines);    gtk_main();    return 0;}