int pasteout_data_len;
int font_width, font_height;
int ignore_sbar;
+ guint term_paste_idle_id;
GdkAtom compound_text_atom;
char wintitle[sizeof(((Config *)0)->wintitle)];
};
int askappend(char *filename)
{
/*
- * FIXME: for the moment we just wipe the log file. Since I
- * haven't yet enabled logging, this shouldn't matter yet!
+ * Logging in an xterm-alike is liable to be something you only
+ * do at serious diagnostic need. Hence, I'm going to take the
+ * easy option for now and assume we always want to overwrite
+ * log files. I can always make it properly configurable later.
*/
return 2;
}
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.
- */
- if (!inst->colmap) {
- static const int ww[] = {
- 6, 7, 8, 9, 10, 11, 12, 13,
- 14, 15, 16, 17, 18, 19, 20, 21,
- 0, 1, 2, 3, 4, 5
- };
- gboolean success[NCOLOURS];
- int i;
-
- inst->colmap = gdk_colormap_get_system();
-
- assert(lenof(ww) == NCOLOURS);
-
- for (i = 0; i < NCOLOURS; i++) {
- inst->cols[i].red = cfg.colours[ww[i]][0] * 0x0101;
- inst->cols[i].green = cfg.colours[ww[i]][1] * 0x0101;
- inst->cols[i].blue = cfg.colours[ww[i]][2] * 0x0101;
- }
-
- gdk_colormap_alloc_colors(inst->colmap, inst->cols, NCOLOURS,
- FALSE, FALSE, success);
- for (i = 0; i < NCOLOURS; i++) {
- if (!success[i])
- g_error("pterm: couldn't allocate colour %d (#%02x%02x%02x)\n",
- i, cfg.colours[i][0], cfg.colours[i][1], cfg.colours[i][2]);
- }
- }
-
return TRUE;
}
/* FIXME: currently ignored */
}
+void real_palette_set(int n, int r, int g, int b)
+{
+ gboolean success[1];
+
+ inst->cols[n].red = r * 0x0101;
+ inst->cols[n].green = g * 0x0101;
+ inst->cols[n].blue = b * 0x0101;
+
+ gdk_colormap_alloc_colors(inst->colmap, inst->cols + n, 1,
+ FALSE, FALSE, success);
+ if (!success[0])
+ g_error("pterm: couldn't allocate colour %d (#%02x%02x%02x)\n",
+ n, r, g, b);
+}
+
void palette_set(int n, int r, int g, int b)
{
- /* FIXME: currently ignored */
+ static const int first[21] = {
+ 0, 2, 4, 6, 8, 10, 12, 14,
+ 1, 3, 5, 7, 9, 11, 13, 15,
+ 16, 17, 18, 20, 22
+ };
+ real_palette_set(first[n], r, g, b);
+ if (first[n] >= 18)
+ real_palette_set(first[n] + 1, r, g, b);
}
+
void palette_reset(void)
{
- /* FIXME: currently ignored */
+ /* This maps colour indices in cfg to those used in inst->cols. */
+ static const int ww[] = {
+ 6, 7, 8, 9, 10, 11, 12, 13,
+ 14, 15, 16, 17, 18, 19, 20, 21,
+ 0, 1, 2, 3, 4, 5
+ };
+ gboolean success[NCOLOURS];
+ int i;
+
+ assert(lenof(ww) == NCOLOURS);
+
+ if (!inst->colmap) {
+ inst->colmap = gdk_colormap_get_system();
+ } else {
+ gdk_colormap_free_colors(inst->colmap, inst->cols, NCOLOURS);
+ }
+
+ for (i = 0; i < NCOLOURS; i++) {
+ inst->cols[i].red = cfg.colours[ww[i]][0] * 0x0101;
+ inst->cols[i].green = cfg.colours[ww[i]][1] * 0x0101;
+ inst->cols[i].blue = cfg.colours[ww[i]][2] * 0x0101;
+ }
+
+ gdk_colormap_alloc_colors(inst->colmap, inst->cols, NCOLOURS,
+ FALSE, FALSE, success);
+ for (i = 0; i < NCOLOURS; i++) {
+ if (!success[i])
+ g_error("pterm: couldn't allocate colour %d (#%02x%02x%02x)\n",
+ i, cfg.colours[i][0], cfg.colours[i][1], cfg.colours[i][2]);
+ }
}
void write_clip(wchar_t * data, int len, int must_deselect)
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) {
} 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;
}