Diff

Differences From Artifact [fc6b234790]:

To Artifact [1dd2ecb1bc]:


27
28
29
30
31
32
33

34
35
36
37
38
39
40
    GtkWidget *area;
    GdkPixmap *pixmap;
    GdkFont *fonts[2];                 /* normal and bold (for now!) */
    GdkCursor *rawcursor, *textcursor;
    GdkColor cols[NCOLOURS];
    GdkColormap *colmap;
    GdkGC *black_gc, *white_gc;

};

static struct gui_data the_inst;
static struct gui_data *inst = &the_inst;   /* so we always write `inst->' */
static int send_raw_mouse;

void ldisc_update(int echo, int edit)







>







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
    GtkWidget *area;
    GdkPixmap *pixmap;
    GdkFont *fonts[2];                 /* normal and bold (for now!) */
    GdkCursor *rawcursor, *textcursor;
    GdkColor cols[NCOLOURS];
    GdkColormap *colmap;
    GdkGC *black_gc, *white_gc;
    int font_width, font_height;
};

static struct gui_data the_inst;
static struct gui_data *inst = &the_inst;   /* so we always write `inst->' */
static int send_raw_mouse;

void ldisc_update(int echo, int edit)
169
170
171
172
173
174
175
176


177
178
179
180
181
182
183
184
185
186
gint configure_area(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;

    if (inst->pixmap)
	gdk_pixmap_unref(inst->pixmap);

    inst->pixmap = gdk_pixmap_new(widget->window, 9*80, 15*24, -1);



    inst->fonts[0] = gdk_font_load("9x15t");   /* XXCONFIG */
    inst->fonts[1] = NULL;             /* XXCONFIG */
    inst->black_gc = widget->style->black_gc;
    inst->white_gc = widget->style->white_gc;

    /*
     * Set up the colour map.
     */
    inst->colmap = gdk_colormap_get_system();







|
>
>

<
<







170
171
172
173
174
175
176
177
178
179
180


181
182
183
184
185
186
187
gint configure_area(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
{
    struct gui_data *inst = (struct gui_data *)data;

    if (inst->pixmap)
	gdk_pixmap_unref(inst->pixmap);

    inst->pixmap = gdk_pixmap_new(widget->window,
				  cfg.width * inst->font_width,
				  cfg.height * inst->font_height, -1);



    inst->black_gc = widget->style->black_gc;
    inst->white_gc = widget->style->white_gc;

    /*
     * Set up the colour map.
     */
    inst->colmap = gdk_colormap_get_system();
218
219
220
221
222
223
224
225

226
227
228
229
230
231
232
233
234
    /* struct gui_data *inst = (struct gui_data *)data; */

    /*
     * Pass the exposed rectangle to terminal.c, which will call us
     * back to do the actual painting.
     */
    term_paint(NULL, 
	       event->area.x / 9, event->area.y / 15,

	       (event->area.x + event->area.width - 1) / 9,
	       (event->area.y + event->area.height - 1) / 15);
    return TRUE;
}

#define KEY_PRESSED(k) \
    (inst->keystate[(k) / 32] & (1 << ((k) % 32)))

gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)







|
>
|
|







219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
    /* struct gui_data *inst = (struct gui_data *)data; */

    /*
     * Pass the exposed rectangle to terminal.c, which will call us
     * back to do the actual painting.
     */
    term_paint(NULL, 
	       event->area.x / inst->font_width,
	       event->area.y / inst->font_height,
	       (event->area.x + event->area.width - 1) / inst->font_width,
	       (event->area.y + event->area.height - 1) / inst->font_height);
    return TRUE;
}

#define KEY_PRESSED(k) \
    (inst->keystate[(k) / 32] & (1 << ((k) % 32)))

gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
763
764
765
766
767
768
769
770


771
772
773
774
775
776
777
778
779
780
781

782
783
784
785


786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805


806
807


808
809
810
811
812
813
814
	nbg++;
    if (attr & TATTR_ACTCURS) {
	nfg = NCOLOURS-2;
	nbg = NCOLOURS-1;
    }

    gdk_gc_set_foreground(gc, &inst->cols[nbg]);
    gdk_draw_rectangle(inst->pixmap, gc, 1, x*9, y*15, len*9, 15);


    
    gdk_gc_set_foreground(gc, &inst->cols[nfg]);
    gdk_draw_text(inst->pixmap, inst->fonts[0], gc,
		  x*9, y*15 + inst->fonts[0]->ascent, text, len);

    if (attr & ATTR_UNDER) {
	int uheight = inst->fonts[0]->ascent + 1;
	if (uheight >= 15)
	    uheight = 14;
	gdk_draw_line(inst->pixmap, gc, x*9, y*15 + uheight,
		      (x+len)*9-1, y*15+uheight);

    }

    gdk_draw_pixmap(inst->area->window, gc, inst->pixmap,
		    x*9, y*15, x*9, y*15, len*9, 15);


}

void do_cursor(Context ctx, int x, int y, char *text, int len,
	       unsigned long attr, int lattr)
{
    int passive;
    GdkGC *gc = (GdkGC *)ctx;

    /*
     * NYI: cursor shapes other than block
     */
    if (attr & TATTR_PASCURS) {
	attr &= ~TATTR_PASCURS;
	passive = 1;
    } else
	passive = 0;
    do_text(ctx, x, y, text, len, attr, lattr);
    if (passive) {
	gdk_gc_set_foreground(gc, &inst->cols[NCOLOURS-1]);
	gdk_draw_rectangle(inst->pixmap, gc, 0, x*9, y*15, len*9-1, 15-1);


	gdk_draw_pixmap(inst->area->window, gc, inst->pixmap,
			x*9, y*15, x*9, y*15, len*9, 15);


    }
}

void modalfatalbox(char *p, ...)
{
    va_list ap;
    fprintf(stderr, "FATAL ERROR: ");







|
>
>


|
|



|
|
|
|
>



|
>
>



















|
>
>

|
>
>







765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
	nbg++;
    if (attr & TATTR_ACTCURS) {
	nfg = NCOLOURS-2;
	nbg = NCOLOURS-1;
    }

    gdk_gc_set_foreground(gc, &inst->cols[nbg]);
    gdk_draw_rectangle(inst->pixmap, gc, 1,
		       x*inst->font_width, y*inst->font_height,
		       len*inst->font_width, inst->font_height);
    
    gdk_gc_set_foreground(gc, &inst->cols[nfg]);
    gdk_draw_text(inst->pixmap, inst->fonts[0], gc, x*inst->font_width,
		  y*inst->font_height + inst->fonts[0]->ascent, text, len);

    if (attr & ATTR_UNDER) {
	int uheight = inst->fonts[0]->ascent + 1;
	if (uheight >= inst->font_height)
	    uheight = inst->font_height - 1;
	gdk_draw_line(inst->pixmap, gc, x*inst->font_width,
		      y*inst->font_height + uheight,
		      (x+len)*inst->font_width-1, y*inst->font_height+uheight);
    }

    gdk_draw_pixmap(inst->area->window, gc, inst->pixmap,
		    x*inst->font_width, y*inst->font_height,
		    x*inst->font_width, y*inst->font_height,
		    len*inst->font_width, inst->font_height);
}

void do_cursor(Context ctx, int x, int y, char *text, int len,
	       unsigned long attr, int lattr)
{
    int passive;
    GdkGC *gc = (GdkGC *)ctx;

    /*
     * NYI: cursor shapes other than block
     */
    if (attr & TATTR_PASCURS) {
	attr &= ~TATTR_PASCURS;
	passive = 1;
    } else
	passive = 0;
    do_text(ctx, x, y, text, len, attr, lattr);
    if (passive) {
	gdk_gc_set_foreground(gc, &inst->cols[NCOLOURS-1]);
	gdk_draw_rectangle(inst->pixmap, gc, 0,
			   x*inst->font_width, y*inst->font_height,
			   len*inst->font_width-1, inst->font_height-1);
	gdk_draw_pixmap(inst->area->window, gc, inst->pixmap,
			x*inst->font_width, y*inst->font_height,
			x*inst->font_width, y*inst->font_height,
			len*inst->font_width, inst->font_height);
    }
}

void modalfatalbox(char *p, ...)
{
    va_list ap;
    fprintf(stderr, "FATAL ERROR: ");
824
825
826
827
828
829
830





831
832
833
834
835
836
837
838
839

840
841
842
843
844
845
846
    GtkWidget *window;
    extern int pty_master_fd;	       /* declared in pty.c */

    gtk_init(&argc, &argv);

    do_defaults(NULL, &cfg);






    init_ucs();

    back = &pty_backend;
    back->init(NULL, 0, NULL, 0);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    inst->area = gtk_drawing_area_new();
    gtk_drawing_area_size(GTK_DRAWING_AREA(inst->area),
			  9*80, 15*24);/* FIXME: proper resizing stuff */


    gtk_container_add(GTK_CONTAINER(window), inst->area);

    gtk_signal_connect(GTK_OBJECT(window), "destroy",
		       GTK_SIGNAL_FUNC(destroy), inst);
    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
		       GTK_SIGNAL_FUNC(delete_window), inst);







>
>
>
>
>








|
>







835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
    GtkWidget *window;
    extern int pty_master_fd;	       /* declared in pty.c */

    gtk_init(&argc, &argv);

    do_defaults(NULL, &cfg);

    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;

    init_ucs();

    back = &pty_backend;
    back->init(NULL, 0, NULL, 0);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    inst->area = gtk_drawing_area_new();
    gtk_drawing_area_size(GTK_DRAWING_AREA(inst->area),
			  inst->font_width * cfg.width,
			  inst->font_height * cfg.height);

    gtk_container_add(GTK_CONTAINER(window), inst->area);

    gtk_signal_connect(GTK_OBJECT(window), "destroy",
		       GTK_SIGNAL_FUNC(destroy), inst);
    gtk_signal_connect(GTK_OBJECT(window), "delete_event",
		       GTK_SIGNAL_FUNC(delete_window), inst);