codeset cs;
bool enc2b, encm;
- const char *get_property (XFontStruct *f, const char *property, const char *repl) const;
+ char *get_property (XFontStruct *f, const char *property, const char *repl) const;
bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth);
bool set_properties (rxvt_fontprop &p, XFontStruct *f);
bool set_properties (rxvt_fontprop &p, const char *name);
};
-const char *
+char *
rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const
{
unsigned long value;
if (XGetFontProperty (f, XInternAtom (DISPLAY, property, 0), &value))
return XGetAtomName (DISPLAY, value);
else
- return repl;
+ return rxvt_strdup (repl);
}
rxvt_fontprop
bool
rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f)
{
- const char *weight = get_property (f, "WEIGHT_NAME", "medium");
- const char *slant = get_property (f, "SLANT", "r");
-
unsigned long height;
if (!XGetFontProperty (f, XInternAtom (DISPLAY, "PIXEL_SIZE", 0), &height))
return false;
if (!XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth))
avgwidth = 0;
- return set_properties (p, height, weight, slant, avgwidth);
+ char *weight = get_property (f, "WEIGHT_NAME", "medium");
+ char *slant = get_property (f, "SLANT", "r");
+
+ set_properties (p, height, weight, slant, avgwidth);
+
+ free (weight);
+ free (slant);
+
+ return true;
}
bool
if (!f)
return false;
- const char *registry = get_property (f, "CHARSET_REGISTRY", 0);
- const char *encoding = get_property (f, "CHARSET_ENCODING", 0);
+ char *registry = get_property (f, "CHARSET_REGISTRY", 0);
+ char *encoding = get_property (f, "CHARSET_ENCODING", 0);
if (registry && encoding)
{
cs = codeset_from_name (charset);
}
+ free (registry);
+ free (encoding);
+
if (cs == CS_UNICODE)
cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font
# define __sun__
#endif
-
#ifndef HAVE_XPOINTER
typedef char *XPointer;
#endif
#define PrivMode_smoothScroll (1LU<<18)
#define PrivMode_vt52 (1LU<<19)
/* too annoying to implement X11 highlight tracking */
-/* #define PrivMode_MouseX11Track (1LU<<18) */
+/* #define PrivMode_MouseX11Track (1LU<<20) */
#define PrivMode_mouse_report (PrivMode_MouseX10|PrivMode_MouseX11)
#define PrivMode(test,bit) \
#define XCMAP display->cmap
#define XVISUAL display->visual
-#define IMBUFSIZ 128 /* input modifier buffer sizes */
-#ifndef BUFSIZ
-# define BUFSIZ 4096
-#endif
-#define KBUFSZ 512 /* size of keyboard mapping buffer */
+#define IMBUFSIZ 128 // input modifier buffer sizes
+#define KBUFSZ 512 // size of keyboard mapping buffer
+#define CBUFSIZ 4096 // size of command buffer
+#define UBUFSIZ 4096 // character buffer
/*
*****************************************************************************
# define D_X(x)
#endif
+extern class rxvt_failure_exception { } rxvt_failure_exception;
+
+typedef callback1<void, const char *> log_callback;
+
+extern void rxvt_vlog (const char *fmt, va_list arg_ptr);
+extern void rxvt_log (const char *fmt, ...);
+extern void rxvt_warn (const char *fmt, ...);
+extern void rxvt_fatal (const char *fmt, ...) __attribute__ ((noreturn));
+extern void rxvt_exit_failure () __attribute__ ((noreturn));
+
+#define SET_LOCALE(locale) rxvt_set_locale (locale)
+extern void rxvt_set_locale (const char *locale);
+
/*
*****************************************************************************
* VARIABLES
struct rxvt_term : rxvt_vars {
+ log_callback *log_hook;
+
struct mbstate mbstate;
unsigned char want_refresh:1,
hidden_pointer:1,
#endif
parsed_geometry:1,
- seen_input:1, /* wether any input has been seen so far */
- enc_utf8:1; /* wether terminal reads/writes utf-8 */
+// enc_utf8:1, /* wether terminal reads/writes utf-8 */
+ seen_input:1; /* wether any input has been seen so far */
unsigned char refresh_type,
#ifdef UTMP_SUPPORT
struct timeval lastmotion;
#endif
-/* these three don't need to be kept but do so to placate some mem checkers */
+ vector<void *> allocated; // free these memory blocks
+
char *env_windowid; /* environmental variable WINDOWID */
char *env_display; /* environmental variable DISPLAY */
char *env_term; /* environmental variable TERM */
char *env_colorfgbg;
char *locale;
+#if 0
char *codeset;
+#endif
char charsets[4];
unsigned char *v_buffer; /* pointer to physical buffer */
unsigned int v_buflen; /* size of area to write */
const unsigned char *Keysym_map[256];
#endif
const char *rs[NUM_RESOURCES];
-/* command input buffering */
+ /* command input buffering */
unsigned char *cmdbuf_ptr, *cmdbuf_endp;
- unsigned char cmdbuf_base[BUFSIZ];
+ unsigned char cmdbuf_base[CBUFSIZ];
rxvt_salloc *ralloc;
rxvt_salloc *talloc;
int pclose_printer (FILE *stream);
#endif
void process_print_pipe ();
- void process_nonprinting (unsigned char ch);
- void process_escape_vt52 (unsigned char ch);
+ void process_nonprinting (unicode_t ch);
+ void process_escape_vt52 (unicode_t ch);
void process_escape_seq ();
void process_csi_seq ();
void process_window_ops (const int *args, unsigned int nargs);
- unsigned char * get_to_st (unsigned char *ends_how);
+ unsigned char *get_to_st (unicode_t &ends_how);
void process_dcs_seq ();
void process_osc_seq ();
void xterm_seq (int op, const char *str, unsigned char resp __attribute__ ((unused)));
bool change_font (const char *fontname);
bool font_up_down (int n, int direction);
void set_title (const char *str);
- void set_iconName (const char *str);
+ void set_icon_name (const char *str);
void set_window_color (int idx, const char *color);
void set_colorfgbg ();
int rXParseAllocColor (rxvt_color * screen_in_out, const char *colour);
Pixmap set_bgPixmap (const char *file);
};
-#define SET_LOCALE(locale) rxvt_set_locale (locale)
-extern void rxvt_set_locale (const char *locale);
-
/*
*****************************************************************************
* PROTOTYPES
/*--------------------------------*-C-*---------------------------------*
* File: xdefaults.c
*----------------------------------------------------------------------*
- * $Id: xdefaults.C,v 1.17 2004-03-14 17:33:08 pcg Exp $
+ * $Id: xdefaults.C,v 1.19 2004-03-22 15:15:04 pcg Exp $
*
* All portions of code are copyright by their respective author/s.
* Copyright (c) 1994 Robert Nation <nation@rocket.sanders.lockheed.com>
static void
rxvt_usage (int type)
{
- unsigned int i, col;
+ unsigned int i, col;
- write (STDERR_FILENO, releasestring, sizeof (releasestring) - 1);
- write (STDERR_FILENO, optionsstring, sizeof (optionsstring) - 1);
- write (STDERR_FILENO, RESNAME, sizeof (RESNAME) - 1);
+ rxvt_log ("%s%s%s", releasestring, optionsstring, RESNAME);
switch (type)
{
case 0: /* brief listing */
- fprintf (stderr, " [-help] [--help]\n");
+ rxvt_log (" [-help] [--help]\n");
+
for (col = 1, i = 0; i < optList_size (); i++)
if (optList[i].desc != NULL)
{
col += len;
if (col > 79)
{ /* assume regular width */
- putc ('\n', stderr);
+ rxvt_log ("\n");
col = 1 + len;
}
- fprintf (stderr, " [-%s%s", (optList_isBool (i) ? "/+" : ""),
- optList[i].opt);
+
+ rxvt_log (" [-%s%s", (optList_isBool (i) ? "/+" : ""), optList[i].opt);
if (optList_strlen (i))
- fprintf (stderr, " %s]", optList[i].arg);
+ rxvt_log (" %s]", optList[i].arg);
else
- fprintf (stderr, "]");
+ rxvt_log ("]");
}
break;
case 1: /* full command-line listing */
- fprintf (stderr, " [options] [-e command args]\n\n"
- "where options include:\n");
+ rxvt_log (" [options] [-e command args]\n\nwhere options include:\n");
+
for (i = 0; i < optList_size (); i++)
if (optList[i].desc != NULL)
{
#ifdef DEBUG_STRICT
assert (optList[i].opt != NULL);
#endif
- fprintf (stderr, " %s%s %-*s%s%s\n",
- (optList_isBool (i) ? "-/+" : "-"), optList[i].opt,
- (INDENT - STRLEN (optList[i].opt)
- + (optList_isBool (i) ? 0 : 2)),
- (optList[i].arg ? optList[i].arg : ""),
- (optList_isBool (i) ? "turn on/off " : ""),
- optList[i].desc);
+ rxvt_log (" %s%s %-*s%s%s\n",
+ (optList_isBool (i) ? "-/+" : "-"), optList[i].opt,
+ (INDENT - STRLEN (optList[i].opt)
+ + (optList_isBool (i) ? 0 : 2)),
+ (optList[i].arg ? optList[i].arg : ""),
+ (optList_isBool (i) ? "turn on/off " : ""),
+ optList[i].desc);
}
- fprintf (stderr, "\n --help to list long-options");
+ rxvt_log ("\n --help to list long-options");
break;
case 2: /* full resource listing */
- fprintf (stderr,
- " [options] [-e command args]\n\n"
- "where resources (long-options) include:\n");
+ rxvt_log (" [options] [-e command args]\n\n"
+ "where resources (long-options) include:\n");
for (i = 0; i < optList_size (); i++)
if (optList[i].kw != NULL)
- fprintf (stderr, " %s: %*s%s\n",
+ rxvt_log (" %s: %*s%s\n",
optList[i].kw,
(INDENT - STRLEN (optList[i].kw)), "", /* XXX */
(optList_isBool (i) ? "boolean" : optList[i].arg));
#ifdef KEYSYM_RESOURCE
- fprintf (stderr, " " "keysym.sym" ": %*s%s\n",
+ rxvt_log (" " "keysym.sym" ": %*s%s\n",
(INDENT - sizeof ("keysym.sym") + 1), "", /* XXX */
"keysym");
#endif
- fprintf (stderr, "\n -help to list options");
+ rxvt_log ("\n -help to list options");
break;
}
- fprintf (stderr, "\n\n");
- exit (EXIT_FAILURE);
+
+ rxvt_log ("\n\n");
+ rxvt_exit_failure ();
/* NOTREACHED */
}
else
{
bad_option = 1;
- rxvt_print_error ("bad option \"%s\"", opt);
+ rxvt_warn ("\"%s\": malformed option.\n", opt);
continue;
}
/* if (!STRNCMP (opt, "keysym.", sizeof ("keysym.") - 1)) */
if (rxvt_Str_match (opt, "keysym."))
{
- const char *str = argv[++i];
+ const char *str = argv[++i];
if (str != NULL)
parse_keysym (opt + sizeof ("keysym.") - 1, str);
}
else
#endif
- bad_option = 1;
+ {
+ bad_option = 1;
+ rxvt_warn ("\"%s\": unknown or malformed option.\n", opt);
+ }
}
if (bad_option)
if (stream == NULL)
return;
+
len = STRLEN (name);
while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL)
{
# endif /* KEYSYM_RESOURCE */
for (entry = 0; entry < optList_size (); entry++)
{
- const char *kw = optList[entry].kw;
+ const char *kw = optList[entry].kw;
if (kw == NULL)
continue;
+
n = STRLEN (kw);
if (str[n] == ':' && rxvt_Str_match (str, kw))
{
}
rs[optList[entry].doff] = p;
+ allocated.push_back (p);
+
if (optList_isBool (entry))
{
s = STRCASECMP (str, "TRUE") == 0
|| STRCASECMP (str, "YES") == 0
|| STRCASECMP (str, "ON") == 0
|| STRCASECMP (str, "1") == 0;
+
if (optList_isReverse (entry))
s = !s;
+
if (s)
- Options |= (optList[entry].flag);
+ Options |= optList[entry].flag;
else
- Options &= ~ (optList[entry].flag);
+ Options &= ~optList[entry].flag;
}
}
+
break;
}
}
}
+
rewind (stream);
}
# if defined XAPPLOADDIR
# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
/* Compute the path of the possibly available localized Rxvt file */
- char *localepath = NULL;
+ char *localepath = NULL;
if (locale != NULL)
{ /* XXX: must limit length of string */
/*
* get resources using the X library function
*/
- int entry;
+ int entry;
# ifdef XrmEnumOneLevel
- int i;
- char *displayResource, *xe;
- XrmName name_prefix[3];
- XrmClass class_prefix[3];
- XrmDatabase database, rdb1;
- char fname[1024];
+ int i;
+ char *displayResource, *xe;
+ XrmName name_prefix[3];
+ XrmClass class_prefix[3];
+ XrmDatabase database, rdb1;
+ char fname[1024];
XrmInitialize ();
database = NULL;
{
sprintf (fname, "%-.*s/%s", sizeof (fname) - STRLEN (xnames[i]) - 2,
ptr, xnames[i]);
- if ((rdb1 = XrmGetFileDatabase (fname)) != NULL)
+ if ((rdb1 = XrmGetFileDatabase (fname)))
{
XrmMergeDatabases (rdb1, &database);
# ifndef HAVE_BOTH_XRESOURCE_FILES