int pasteout_data_len;
int font_width, font_height;
int ignore_sbar;
+ int mouseptr_visible;
+ guint term_paste_idle_id;
GdkAtom compound_text_atom;
char wintitle[sizeof(((Config *)0)->wintitle)];
};
gdk_window_set_cursor(inst->area->window, inst->currcursor);
else
gdk_window_set_cursor(inst->area->window, inst->blankcursor);
+ inst->mouseptr_visible = show;
}
gint configure_area(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
struct gui_data *inst = (struct gui_data *)data;
int w, h, need_size = 0;
+ /*
+ * Set up the colour map.
+ */
+ palette_reset();
+
w = (event->width - 2*cfg.window_border) / inst->font_width;
h = (event->height - 2*cfg.window_border) / inst->font_height;
term_size(h, w, cfg.savelines);
}
- /*
- * Set up the colour map.
- */
- palette_reset();
-
return TRUE;
}
/*
* NYI:
- * - nethack mode
* - alt+numpad
* - Compose key (!!! requires Unicode faff before even trying)
*/
return TRUE;
}
-gint idle_func(gpointer data)
-{
- /* struct gui_data *inst = (struct gui_data *)data; */
- term_paste();
- return TRUE;
-}
-
void pty_input_func(gpointer data, gint sourcefd, GdkInputCondition condition)
{
/* struct gui_data *inst = (struct gui_data *)data; */
inst->currcursor = inst->rawcursor;
else
inst->currcursor = inst->textcursor;
- show_mouseptr(1);
+ show_mouseptr(inst->mouseptr_visible);
}
void request_resize(int w, int h)
GDK_SELECTION_TYPE_STRING, GDK_CURRENT_TIME);
}
+gint idle_paste_func(gpointer data); /* forward ref */
+
void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
gpointer data)
{
inst->pastein_data, inst->pastein_data_len);
term_do_paste();
+
+ if (term_paste_pending())
+ inst->term_paste_idle_id = gtk_idle_add(idle_paste_func, inst);
+}
+
+gint idle_paste_func(gpointer data)
+{
+ struct gui_data *inst = (struct gui_data *)data;
+
+ if (term_paste_pending())
+ term_paste();
+ else
+ gtk_idle_remove(inst->term_paste_idle_id);
+
+ return TRUE;
}
+
void get_clip(wchar_t ** p, int *len)
{
if (p) {
/*
* NYI:
* - Unicode, code pages, and ATTR_WIDE for CJK support.
- * - LATTR_* (ESC # 4 double-width and double-height stuff)
* - cursor shapes other than block
* - shadow bolding
*/
nbg = NCOLOURS-1;
}
+ if (lattr != LATTR_NORM) {
+ x *= 2;
+ if (x >= cols)
+ return;
+ if (x + len*2 > cols)
+ len = (cols-x)/2; /* trim to LH half */
+ }
+
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 + uheight + cfg.window_border);
}
+ if (lattr != LATTR_NORM) {
+ /*
+ * I can't find any plausible StretchBlt equivalent in the
+ * X server, so I'm going to do this the slow and painful
+ * way. This will involve repeated calls to
+ * gdk_draw_pixmap() to stretch the text horizontally. It's
+ * O(N^2) in time and O(N) in network bandwidth, but you
+ * try thinking of a better way. :-(
+ */
+ int i;
+ for (i = 0; i < len * inst->font_width; i++) {
+ gdk_draw_pixmap(inst->pixmap, gc, inst->pixmap,
+ x*inst->font_width+cfg.window_border + 2*i,
+ y*inst->font_height+cfg.window_border,
+ x*inst->font_width+cfg.window_border + 2*i+1,
+ y*inst->font_height+cfg.window_border,
+ len * inst->font_width - i, inst->font_height);
+ }
+ len *= 2;
+ if (lattr != LATTR_WIDE) {
+ int dt, db;
+ /* Now stretch vertically, in the same way. */
+ if (lattr == LATTR_BOT)
+ dt = 0, db = 1;
+ else
+ dt = 1, db = 0;
+ for (i = 0; i < inst->font_height; i+=2) {
+ gdk_draw_pixmap(inst->pixmap, gc, inst->pixmap,
+ x*inst->font_width+cfg.window_border,
+ y*inst->font_height+cfg.window_border+dt*i+db,
+ x*inst->font_width+cfg.window_border,
+ y*inst->font_height+cfg.window_border+dt*(i+1),
+ len * inst->font_width, inst->font_height-i-1);
+ }
+ }
+ len *= 2;
+ }
+
gdk_draw_pixmap(inst->area->window, gc, inst->pixmap,
x*inst->font_width+cfg.window_border,
y*inst->font_height+cfg.window_border,
exit(1);
}
+char *get_x_display(void)
+{
+ return gdk_get_display();
+}
+
int main(int argc, char **argv)
{
extern int pty_master_fd; /* declared in pty.c */
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;
}
init_ucs();
- back = &pty_backend;
- back->init(NULL, 0, NULL, 0);
-
inst->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
if (cfg.wintitle[0])
GTK_SIGNAL_FUNC(selection_clear), inst);
gtk_signal_connect(GTK_OBJECT(inst->sbar_adjust), "value_changed",
GTK_SIGNAL_FUNC(scrollbar_moved), inst);
- gtk_idle_add(idle_func, inst);
gtk_timeout_add(20, timer_func, inst);
- gdk_input_add(pty_master_fd, GDK_INPUT_READ, pty_input_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 |
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(24, 80, 2000);