int mouseptr_visible;
guint term_paste_idle_id;
GdkAtom compound_text_atom;
+ int alt_keycode;
char wintitle[sizeof(((Config *)0)->wintitle)];
char icontitle[sizeof(((Config *)0)->wintitle)];
};
char output[32];
int start, end;
+ /* By default, nothing is generated. */
+ end = start = 0;
+
+ /*
+ * If Alt is being released after typing an Alt+numberpad
+ * sequence, we should generate the code that was typed.
+ */
+ if (event->type == GDK_KEY_RELEASE &&
+ (event->keyval == GDK_Meta_L || event->keyval == GDK_Alt_L ||
+ event->keyval == GDK_Meta_R || event->keyval == GDK_Alt_R) &&
+ inst->alt_keycode >= 0) {
+#ifdef KEY_DEBUGGING
+ printf("Alt key up, keycode = %d\n", inst->alt_keycode);
+#endif
+ output[0] = inst->alt_keycode;
+ end = 1;
+ goto done;
+ }
+
if (event->type == GDK_KEY_PRESS) {
#ifdef KEY_DEBUGGING
{
#endif
/*
- * NYI:
- * - alt+numpad
- * - Compose key (!!! requires Unicode faff before even trying)
+ * NYI: Compose key (!!! requires Unicode faff before even trying)
+ */
+
+ /*
+ * If Alt has just been pressed, we start potentially
+ * accumulating an Alt+numberpad code. We do this by
+ * setting alt_keycode to -1 (nothing yet but plausible).
+ */
+ if ((event->keyval == GDK_Meta_L || event->keyval == GDK_Alt_L ||
+ event->keyval == GDK_Meta_R || event->keyval == GDK_Alt_R)) {
+ inst->alt_keycode = -1;
+ goto done; /* this generates nothing else */
+ }
+
+ /*
+ * If we're seeing a numberpad key press with Mod1 down,
+ * consider adding it to alt_keycode if that's sensible.
+ * Anything _else_ with Mod1 down cancels any possibility
+ * of an ALT keycode: we set alt_keycode to -2.
*/
+ if ((event->state & GDK_MOD1_MASK) && inst->alt_keycode != -2) {
+ int digit = -1;
+ switch (event->keyval) {
+ case GDK_KP_0: case GDK_KP_Insert: digit = 0; break;
+ case GDK_KP_1: case GDK_KP_End: digit = 1; break;
+ case GDK_KP_2: case GDK_KP_Down: digit = 2; break;
+ case GDK_KP_3: case GDK_KP_Page_Down: digit = 3; break;
+ case GDK_KP_4: case GDK_KP_Left: digit = 4; break;
+ case GDK_KP_5: case GDK_KP_Begin: digit = 5; break;
+ case GDK_KP_6: case GDK_KP_Right: digit = 6; break;
+ case GDK_KP_7: case GDK_KP_Home: digit = 7; break;
+ case GDK_KP_8: case GDK_KP_Up: digit = 8; break;
+ case GDK_KP_9: case GDK_KP_Page_Up: digit = 9; break;
+ }
+ if (digit < 0)
+ inst->alt_keycode = -2; /* it's invalid */
+ else {
+#ifdef KEY_DEBUGGING
+ printf("Adding digit %d to keycode %d", digit,
+ inst->alt_keycode);
+#endif
+ if (inst->alt_keycode == -1)
+ inst->alt_keycode = digit; /* one-digit code */
+ else
+ inst->alt_keycode = inst->alt_keycode * 10 + digit;
+#ifdef KEY_DEBUGGING
+ printf(" gives new code %d\n", inst->alt_keycode);
+#endif
+ /* Having used this digit, we now do nothing more with it. */
+ goto done;
+ }
+ }
/*
* Shift-PgUp and Shift-PgDn don't even generate keystrokes
goto done;
}
}
+ goto done;
+ }
- done:
+ done:
+ if (end-start > 0) {
#ifdef KEY_DEBUGGING
- {
- int i;
- printf("generating sequence:");
- for (i = start; i < end; i++)
- printf(" %02x", (unsigned char) output[i]);
- printf("\n");
- }
+ int i;
+ printf("generating sequence:");
+ for (i = start; i < end; i++)
+ printf(" %02x", (unsigned char) output[i]);
+ printf("\n");
#endif
- if (end-start > 0) {
- ldisc_send(output+start, end-start, 1);
- show_mouseptr(0);
- term_out();
- }
+
+ ldisc_send(output+start, end-start, 1);
+ show_mouseptr(0);
+ term_out();
}
return TRUE;
show_mouseptr(1);
+ if (event->button == 4 && event->type == GDK_BUTTON_PRESS) {
+ term_scroll(0, -5);
+ return TRUE;
+ }
+ if (event->button == 5 && event->type == GDK_BUTTON_PRESS) {
+ term_scroll(0, +5);
+ return TRUE;
+ }
+
shift = event->state & GDK_SHIFT_MASK;
ctrl = event->state & GDK_CONTROL_MASK;
alt = event->state & GDK_MOD1_MASK;
}
term_update();
+ term_blink(0);
return TRUE;
}
}
if (ret > 0)
from_backend(0, buf, ret);
+ term_blink(1);
term_out();
}
void request_resize(int w, int h)
{
- gtk_drawing_area_size(GTK_DRAWING_AREA(inst->area),
- inst->font_width * w + 2*cfg.window_border,
- inst->font_height * h + 2*cfg.window_border);
+ int large_x, large_y;
+ int offset_x, offset_y;
+ int area_x, area_y;
+ GtkRequisition inner, outer;
+
+ /*
+ * This is a heinous hack dreamed up by the gnome-terminal
+ * people to get around a limitation in gtk. The problem is
+ * that in order to set the size correctly we really need to be
+ * calling gtk_window_resize - but that needs to know the size
+ * of the _whole window_, not the drawing area. So what we do
+ * is to set an artificially huge size request on the drawing
+ * area, recompute the resulting size request on the window,
+ * and look at the difference between the two. That gives us
+ * the x and y offsets we need to translate drawing area size
+ * into window size for real, and then we call
+ * gtk_window_resize.
+ */
+
+ /*
+ * We start by retrieving the current size of the whole window.
+ * Adding a bit to _that_ will give us a value we can use as a
+ * bogus size request which guarantees to be bigger than the
+ * current size of the drawing area.
+ */
+ get_window_pixels(&large_x, &large_y);
+ large_x += 32;
+ large_y += 32;
+
+#if GTK_CHECK_VERSION(2,0,0)
+ gtk_widget_set_size_request(inst->area, large_x, large_y);
+#else
+ gtk_widget_set_usize(inst->area, large_x, large_y);
+#endif
+ gtk_widget_size_request(inst->area, &inner);
+ gtk_widget_size_request(inst->window, &outer);
+
+ offset_x = outer.width - inner.width;
+ offset_y = outer.height - inner.height;
+
+ area_x = inst->font_width * w + 2*cfg.window_border;
+ area_y = inst->font_height * h + 2*cfg.window_border;
+
+ /*
+ * Now we must set the size request on the drawing area back to
+ * something sensible before we commit the real resize. Best
+ * way to do this, I think, is to set it to what the size is
+ * really going to end up being.
+ */
+#if GTK_CHECK_VERSION(2,0,0)
+ gtk_widget_set_size_request(inst->area, area_x, area_y);
+#else
+ gtk_widget_set_usize(inst->area, area_x, area_y);
+#endif
+
+#if GTK_CHECK_VERSION(2,0,0)
+ gtk_window_resize(GTK_WINDOW(inst->window),
+ area_x + offset_x, area_y + offset_y);
+#else
+ gdk_window_resize(inst->window->window,
+ area_x + offset_x, area_y + offset_y);
+#endif
}
void real_palette_set(int n, int r, int g, int b)
inst->sbar = gtk_vscrollbar_new(inst->sbar_adjust);
}
inst->hbox = GTK_BOX(gtk_hbox_new(FALSE, 0));
+ if (cfg.scrollbar) {
+ if (cfg.scrollbar_on_left)
+ gtk_box_pack_start(inst->hbox, inst->sbar, FALSE, FALSE, 0);
+ else
+ gtk_box_pack_end(inst->hbox, inst->sbar, FALSE, FALSE, 0);
+ }
gtk_box_pack_start(inst->hbox, inst->area, TRUE, TRUE, 0);
- if (cfg.scrollbar)
- gtk_box_pack_start(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));
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), "key_release_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",