TODO: resources! resources! resources!
TODO: better environment handling in rxvt/xim etc. and urxvt::term->new
+TODO: selection-extending with rmb does not work?
- added sections for DISTRIBUTION MAINTAINERS and about
SETUID/SETGID to the FAQ.
- selection, searchable-scrollback, selection-popup and
- applied minor cleanups by Ladislav Michnovic.
- applied better configure support for openpty by Emanuele Giaquinta.
- mark-urls launch-on-click by jepler.
+ - removed "small" resource parsing function, as it wasn't really
+ compatible, and not really small either.
+ - removed PATH_ENV and PATH file search support.
+ - removed support for locale-specific app-defaults file.
6.3 Wed Jan 4 22:37:10 CET 2006
- SECURITY FIX: on systems using openpty, permissions were
/* Define if you don't want any resources read */
#undef NO_RESOURCES
-/* Define if you want to use XGetDefault instead of our internal version */
-#undef USE_XGETDEFAULT
-
/* Fallback resource class */
#undef RESFALLBACK
AC_DEFINE(NO_RESOURCES, 1, Define if you don't want any resources read)
fi])
-AC_ARG_ENABLE(xgetdefault,
- [ --enable-xgetdefault enable resources via X instead of our small version],
- [if test x$enableval = xyes; then
- AC_DEFINE(USE_XGETDEFAULT, 1, Define if you want to use XGetDefault instead of our internal version)
- fi])
-
AC_ARG_ENABLE(8bitctrls,
[ --enable-8bitctrls enable 8 bit control sequences (not recommended)],
[if test x$enableval = xyes -o x$enableval = xno; then
--disable-backspace-key disable handling of the backspace key
--disable-delete-key disable handling of the delete key
--disable-resources disable all resource checking
- --enable-xgetdefault enable resources via X instead of our small version
--enable-8bitctrls enable 8 bit control sequences (not recommended)
--enable-fallback(=CLASS) fall back on CLASS resources in addition to URxvt ones (default: Rxvt)
--enable-strings enable some replacement system functions
fi
fi;
-# Check whether --enable-xgetdefault or --disable-xgetdefault was given.
-if test "${enable_xgetdefault+set}" = set; then
- enableval="$enable_xgetdefault"
- if test x$enableval = xyes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define USE_XGETDEFAULT 1
-_ACEOF
-
- fi
-fi;
-
# Check whether --enable-8bitctrls or --disable-8bitctrls was given.
if test "${enable_8bitctrls+set}" = set; then
enableval="$enable_8bitctrls"
</dt>
<dd>
Rxvt-unicodes special way of encoding text, where one ``unicode'' character
-always represents one screen cell. See <em>row_t</em> for a discussion of this format.
+always represents one screen cell. See <a href="#item_row_t">ROW_t</a> for a discussion of this format.
</dd>
<p></p>
<dt><strong><a name="item__24string">$string</a></strong><br />
The current terminal. This variable stores the current <code>urxvt::term</code>
object, whenever a callback/hook is executing.
</dd>
-<p></p>
-<dt></dt>
-</dl>
+<p></p></dl>
<p>
</p>
<h2><a name="functions_in_the_urxvt_package">Functions in the <code>urxvt</code> Package</a></h2>
<dl>
-<dt><strong><a name="item__24term__3d_new_urxvt__5barg_2e_2e_2e_5d">$term = new urxvt [arg...]</a></strong><br />
-</dt>
-<dd>
-Creates a new terminal, very similar as if you had started it with
-<code>system $binfile, arg...</code>. Croaks (and probably outputs an error message)
-if the new instance couldn't be created. Returns <code>undef</code> if the new
-instance didn't initialise perl, and the terminal object otherwise. The
-<code>init</code> and <a href="#item_start"><code>start</code></a> hooks will be called during the call.
-</dd>
-<p></p>
<dt><strong><a name="item_urxvt_3a_3afatal__24errormessage">urxvt::fatal $errormessage</a></strong><br />
</dt>
<dd>
<p>Using this function has the advantage that its output ends up in the
correct place, e.g. on stderr of the connecting urxvtc client.</p>
</dd>
+<dd>
+<p>Messages have a size limit of 1023 bytes currently.</p>
+</dd>
<p></p>
<dt><strong><a name="item__24is_safe__3d_urxvt_3a_3asafe">$is_safe = urxvt::safe</a></strong><br />
</dt>
</p>
<h2><a name="the_urxvt__term_class">The <code>urxvt::term</code> Class</a></h2>
<dl>
+<dt><strong><a name="item__24term__3d_new_urxvt_3a_3aterm__24envhashref_2c__">$term = new urxvt::term $envhashref, $rxvtname, [arg...]</a></strong><br />
+</dt>
+<dd>
+Creates a new terminal, very similar as if you had started it with system
+<code>$rxvtname, arg...</code>. <code>$envhashref</code> must be a reference to a <code>%ENV</code>-like
+hash which defines the environment of the new terminal.
+</dd>
+<dd>
+<p>Croaks (and probably outputs an error message) if the new instance
+couldn't be created. Returns <code>undef</code> if the new instance didn't
+initialise perl, and the terminal object otherwise. The <code>init</code> and
+<a href="#item_start"><code>start</code></a> hooks will be called during this call.</p>
+</dd>
+<p></p>
<dt><strong><a name="item_destroy">$term->destroy</a></strong><br />
</dt>
<dd>
Return various integers describing terminal characteristics.
</dd>
<p></p>
+<dt><strong><a name="item_display_id">$x_display = $term->display_id</a></strong><br />
+</dt>
+<dd>
+Return the DISPLAY used by rxvt-unicode.
+</dd>
+<p></p>
<dt><strong><a name="item_locale">$lc_ctype = $term->locale</a></strong><br />
</dt>
<dd>
Returns the LC_CTYPE category string used by this rxvt-unicode.
</dd>
<p></p>
-<dt><strong><a name="item_display_id">$x_display = $term->display_id</a></strong><br />
+<dt><strong><a name="item_env">$env = $term->env</a></strong><br />
</dt>
<dd>
-Return the DISPLAY used by rxvt-unicode.
+Returns a copy of the environment in effect for the terminal as a hashref
+similar to <code>\%ENV</code>.
</dd>
<p></p>
<dt><strong><a name="item_modlevel3mask">$modifiermask = $term->ModLevel3Mask</a></strong><br />
.\" ========================================================================
.\"
.IX Title "rxvt 3"
-.TH rxvt 3 "2006-01-10" "6.3" "RXVT-UNICODE"
+.TH rxvt 3 "2006-01-11" "6.3" "RXVT-UNICODE"
.SH "NAME"
@@RXVT_NAME@@perl \- rxvt\-unicode's embedded perl interpreter
.SH "SYNOPSIS"
.IP "$text" 4
.IX Item "$text"
Rxvt-unicodes special way of encoding text, where one \*(L"unicode\*(R" character
-always represents one screen cell. See row_t for a discussion of this format.
+always represents one screen cell. See ROW_t for a discussion of this format.
.IP "$string" 4
.IX Item "$string"
A perl text string, with an emphasis on \fItext\fR. It can store all unicode
.IX Item "$urxvt::TERM"
The current terminal. This variable stores the current \f(CW\*(C`urxvt::term\*(C'\fR
object, whenever a callback/hook is executing.
-.IP "*" 4
.ie n .Sh "Functions in the ""urxvt"" Package"
.el .Sh "Functions in the \f(CWurxvt\fP Package"
.IX Subsection "Functions in the urxvt Package"
-.PD 0
-.IP "$term = new urxvt [arg...]" 4
-.IX Item "$term = new urxvt [arg...]"
-.PD
-Creates a new terminal, very similar as if you had started it with
-\&\f(CW\*(C`system $binfile, arg...\*(C'\fR. Croaks (and probably outputs an error message)
-if the new instance couldn't be created. Returns \f(CW\*(C`undef\*(C'\fR if the new
-instance didn't initialise perl, and the terminal object otherwise. The
-\&\f(CW\*(C`init\*(C'\fR and \f(CW\*(C`start\*(C'\fR hooks will be called during the call.
.ie n .IP "urxvt::fatal $errormessage" 4
.el .IP "urxvt::fatal \f(CW$errormessage\fR" 4
.IX Item "urxvt::fatal $errormessage"
.Sp
Using this function has the advantage that its output ends up in the
correct place, e.g. on stderr of the connecting urxvtc client.
+.Sp
+Messages have a size limit of 1023 bytes currently.
.IP "$is_safe = urxvt::safe" 4
.IX Item "$is_safe = urxvt::safe"
Returns true when it is safe to do potentially unsafe things, such as
.ie n .Sh "The ""urxvt::term"" Class"
.el .Sh "The \f(CWurxvt::term\fP Class"
.IX Subsection "The urxvt::term Class"
+.ie n .IP "$term = new urxvt::term $envhashref\fR, \f(CW$rxvtname, [arg...]" 4
+.el .IP "$term = new urxvt::term \f(CW$envhashref\fR, \f(CW$rxvtname\fR, [arg...]" 4
+.IX Item "$term = new urxvt::term $envhashref, $rxvtname, [arg...]"
+Creates a new terminal, very similar as if you had started it with system
+\&\f(CW\*(C`$rxvtname, arg...\*(C'\fR. \f(CW$envhashref\fR must be a reference to a \f(CW%ENV\fR\-like
+hash which defines the environment of the new terminal.
+.Sp
+Croaks (and probably outputs an error message) if the new instance
+couldn't be created. Returns \f(CW\*(C`undef\*(C'\fR if the new instance didn't
+initialise perl, and the terminal object otherwise. The \f(CW\*(C`init\*(C'\fR and
+\&\f(CW\*(C`start\*(C'\fR hooks will be called during this call.
.IP "$term\->destroy" 4
.IX Item "$term->destroy"
Destroy the terminal object (close the window, free resources
.IX Item "$lines_in_scrollback = $term->nsaved"
.PD
Return various integers describing terminal characteristics.
-.ie n .IP "$lc_ctype = $term\->locale" 4
-.el .IP "$lc_ctype = \f(CW$term\fR\->locale" 4
-.IX Item "$lc_ctype = $term->locale"
-Returns the \s-1LC_CTYPE\s0 category string used by this rxvt\-unicode.
.ie n .IP "$x_display = $term\->display_id" 4
.el .IP "$x_display = \f(CW$term\fR\->display_id" 4
.IX Item "$x_display = $term->display_id"
Return the \s-1DISPLAY\s0 used by rxvt\-unicode.
+.ie n .IP "$lc_ctype = $term\->locale" 4
+.el .IP "$lc_ctype = \f(CW$term\fR\->locale" 4
+.IX Item "$lc_ctype = $term->locale"
+Returns the \s-1LC_CTYPE\s0 category string used by this rxvt\-unicode.
+.ie n .IP "$env = $term\->env" 4
+.el .IP "$env = \f(CW$term\fR\->env" 4
+.IX Item "$env = $term->env"
+Returns a copy of the environment in effect for the terminal as a hashref
+similar to \f(CW\*(C`\e%ENV\*(C'\fR.
.ie n .IP "$modifiermask = $term\->ModLevel3Mask" 4
.el .IP "$modifiermask = \f(CW$term\fR\->ModLevel3Mask" 4
.IX Item "$modifiermask = $term->ModLevel3Mask"
.IX Subsection "The urxvt::timer Class"
This class implements timer watchers/events. Time is represented as a
fractional number of seconds since the epoch. Example:
-.Sp
+.PP
.Vb 8
\& $term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0);
\& $term->{timer} = urxvt::timer
\& sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]);
\& });
.Ve
-.RS 4
.IP "$timer = new urxvt::timer" 4
.IX Item "$timer = new urxvt::timer"
Create a new timer object in started state. It is scheduled to fire
.el .IP "$timer = \f(CW$timer\fR\->stop" 4
.IX Item "$timer = $timer->stop"
Stop the timer.
-.RE
-.RS 4
.ie n .Sh "The ""urxvt::iow"" Class"
.el .Sh "The \f(CWurxvt::iow\fP Class"
.IX Subsection "The urxvt::iow Class"
This class implements io watchers/events. Example:
-.Sp
+.PP
.Vb 12
\& $term->{socket} = ...
\& $term->{iow} = urxvt::iow
.el .IP "$iow = \f(CW$iow\fR\->stop" 4
.IX Item "$iow = $iow->stop"
Stop watching for events on the given filehandle.
-.RE
-.RS 4
.SH "ENVIRONMENT"
.IX Header "ENVIRONMENT"
.Sh "\s-1URXVT_PERL_VERBOSITY\s0"
.IX Item ">= 3 - script loading and management"
.IP ">=10 \- all events received" 4
.IX Item ">=10 - all events received"
-.RE
-.RS 4
.PD
.SH "AUTHOR"
.IX Header "AUTHOR"
$text
Rxvt-unicodes special way of encoding text, where one "unicode"
- character always represents one screen cell. See row_t for a
+ character always represents one screen cell. See ROW_t for a
discussion of this format.
$string
The current terminal. This variable stores the current "urxvt::term"
object, whenever a callback/hook is executing.
- *
-
Functions in the "urxvt" Package
- $term = new urxvt [arg...]
- Creates a new terminal, very similar as if you had started it with
- "system $binfile, arg...". Croaks (and probably outputs an error
- message) if the new instance couldn't be created. Returns "undef" if
- the new instance didn't initialise perl, and the terminal object
- otherwise. The "init" and "start" hooks will be called during the
- call.
-
urxvt::fatal $errormessage
Fatally aborts execution with the given error message. Avoid at all
costs! The only time this is acceptable is when the terminal process
Using this function has the advantage that its output ends up in the
correct place, e.g. on stderr of the connecting urxvtc client.
+ Messages have a size limit of 1023 bytes currently.
+
$is_safe = urxvt::safe
Returns true when it is safe to do potentially unsafe things, such
as evaluating perl code specified by the user. This is true when
should work.
The "urxvt::term" Class
+ $term = new urxvt::term $envhashref, $rxvtname, [arg...]
+ Creates a new terminal, very similar as if you had started it with
+ system "$rxvtname, arg...". $envhashref must be a reference to a
+ %ENV-like hash which defines the environment of the new terminal.
+
+ Croaks (and probably outputs an error message) if the new instance
+ couldn't be created. Returns "undef" if the new instance didn't
+ initialise perl, and the terminal object otherwise. The "init" and
+ "start" hooks will be called during this call.
+
$term->destroy
Destroy the terminal object (close the window, free resources etc.).
Please note that rxvt will not exit as long as any event watchers
$lines_in_scrollback = $term->nsaved
Return various integers describing terminal characteristics.
+ $x_display = $term->display_id
+ Return the DISPLAY used by rxvt-unicode.
+
$lc_ctype = $term->locale
Returns the LC_CTYPE category string used by this rxvt-unicode.
- $x_display = $term->display_id
- Return the DISPLAY used by rxvt-unicode.
+ $env = $term->env
+ Returns a copy of the environment in effect for the terminal as a
+ hashref similar to "\%ENV".
$modifiermask = $term->ModLevel3Mask
$modifiermask = $term->ModMetaMask
Displays the popup (which is initially hidden).
The "urxvt::timer" Class
- This class implements timer watchers/events. Time is represented as
- a fractional number of seconds since the epoch. Example:
+ This class implements timer watchers/events. Time is represented as a
+ fractional number of seconds since the epoch. Example:
- $term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0);
- $term->{timer} = urxvt::timer
- ->new
- ->interval (1)
- ->cb (sub {
- $term->{overlay}->set (0, 0,
- sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]);
- });
+ $term->{overlay} = $term->overlay (-1, 0, 8, 1, urxvt::OVERLAY_RSTYLE, 0);
+ $term->{timer} = urxvt::timer
+ ->new
+ ->interval (1)
+ ->cb (sub {
+ $term->{overlay}->set (0, 0,
+ sprintf "%2d:%02d:%02d", (localtime urxvt::NOW)[2,1,0]);
+ });
- $timer = new urxvt::timer
- Create a new timer object in started state. It is scheduled to
- fire immediately.
+ $timer = new urxvt::timer
+ Create a new timer object in started state. It is scheduled to fire
+ immediately.
- $timer = $timer->cb (sub { my ($timer) = @_; ... })
- Set the callback to be called when the timer triggers.
+ $timer = $timer->cb (sub { my ($timer) = @_; ... })
+ Set the callback to be called when the timer triggers.
- $tstamp = $timer->at
- Return the time this watcher will fire next.
+ $tstamp = $timer->at
+ Return the time this watcher will fire next.
- $timer = $timer->set ($tstamp)
- Set the time the event is generated to $tstamp.
+ $timer = $timer->set ($tstamp)
+ Set the time the event is generated to $tstamp.
- $timer = $timer->interval ($interval)
- Normally (and when $interval is 0), the timer will automatically
- stop after it has fired once. If $interval is non-zero, then the
- timer is automatically rescheduled at the given intervals.
+ $timer = $timer->interval ($interval)
+ Normally (and when $interval is 0), the timer will automatically
+ stop after it has fired once. If $interval is non-zero, then the
+ timer is automatically rescheduled at the given intervals.
- $timer = $timer->start
- Start the timer.
+ $timer = $timer->start
+ Start the timer.
- $timer = $timer->start ($tstamp)
- Set the event trigger time to $tstamp and start the timer.
+ $timer = $timer->start ($tstamp)
+ Set the event trigger time to $tstamp and start the timer.
- $timer = $timer->stop
- Stop the timer.
+ $timer = $timer->stop
+ Stop the timer.
The "urxvt::iow" Class
- This class implements io watchers/events. Example:
-
- $term->{socket} = ...
- $term->{iow} = urxvt::iow
- ->new
- ->fd (fileno $term->{socket})
- ->events (urxvt::EVENT_READ)
- ->start
- ->cb (sub {
- my ($iow, $revents) = @_;
- # $revents must be 1 here, no need to check
- sysread $term->{socket}, my $buf, 8192
- or end-of-file;
- });
-
- $iow = new urxvt::iow
- Create a new io watcher object in stopped state.
-
- $iow = $iow->cb (sub { my ($iow, $reventmask) = @_; ... })
- Set the callback to be called when io events are triggered.
- $reventmask is a bitset as described in the "events" method.
-
- $iow = $iow->fd ($fd)
- Set the filedescriptor (not handle) to watch.
-
- $iow = $iow->events ($eventmask)
- Set the event mask to watch. The only allowed values are
- "urxvt::EVENT_READ" and "urxvt::EVENT_WRITE", which might be
- ORed together, or "urxvt::EVENT_NONE".
-
- $iow = $iow->start
- Start watching for requested events on the given handle.
-
- $iow = $iow->stop
- Stop watching for events on the given filehandle.
+ This class implements io watchers/events. Example:
+
+ $term->{socket} = ...
+ $term->{iow} = urxvt::iow
+ ->new
+ ->fd (fileno $term->{socket})
+ ->events (urxvt::EVENT_READ)
+ ->start
+ ->cb (sub {
+ my ($iow, $revents) = @_;
+ # $revents must be 1 here, no need to check
+ sysread $term->{socket}, my $buf, 8192
+ or end-of-file;
+ });
+
+ $iow = new urxvt::iow
+ Create a new io watcher object in stopped state.
+
+ $iow = $iow->cb (sub { my ($iow, $reventmask) = @_; ... })
+ Set the callback to be called when io events are triggered.
+ $reventmask is a bitset as described in the "events" method.
+
+ $iow = $iow->fd ($fd)
+ Set the filedescriptor (not handle) to watch.
+
+ $iow = $iow->events ($eventmask)
+ Set the event mask to watch. The only allowed values are
+ "urxvt::EVENT_READ" and "urxvt::EVENT_WRITE", which might be ORed
+ together, or "urxvt::EVENT_NONE".
+
+ $iow = $iow->start
+ Start watching for requested events on the given handle.
+
+ $iow = $iow->stop
+ Stop watching for events on the given filehandle.
ENVIRONMENT
URXVT_PERL_VERBOSITY
- This variable controls the verbosity level of the perl extension.
- Higher numbers indicate more verbose output.
+ This variable controls the verbosity level of the perl extension. Higher
+ numbers indicate more verbose output.
- == 0 - fatal messages
- >= 3 - script loading and management
- >=10 - all events received
+ == 0 - fatal messages
+ >= 3 - script loading and management
+ >=10 - all events received
AUTHOR
- Marc Lehmann <pcg@goof.com>
- http://software.schmorp.de/pkg/rxvt-unicode
+ Marc Lehmann <pcg@goof.com>
+ http://software.schmorp.de/pkg/rxvt-unicode
* report bugs, too!), but don't _expect_ them to work.
*/
-/*
- * Define the name of the environment variable to be used in
- * addition to the "PATH" environment and the `path' resource.
- * Usually it should point to where you keep your background pixmaps and/or
- * your menu files
- */
-#define PATH_ENV "RXVTPATH"
-
/*
* Avoid enabling the colour cursor (-cr, cursorColor, cursorColor2)
*/
*/
/* #define ALLOW_132_MODE */
-/*------------------------------RESOURCES-------------------------------*/
-/*
- * Define to find installed application defaults for rxvt
- * Only if USE_XGETDEFAULT is not defined.
- */
-#define USE_XAPPLOADDIR
-
/*
* Add support for the Offix DND (Drag 'n' Drop) protocol
*/
* with various KeySyms (0xFF00 - 0xFFFF).
* Required by perl.
*/
-#if (!NO_RESOURCES && ENABLE_FRILLS) || ENABLE_PERL
+#if ENABLE_FRILLS || ENABLE_PERL
# define KEYSYM_RESOURCE
#endif
def (MOTION_NOTIFY)
def (MAP_NOTIFY)
def (UNMAP_NOTIFY)
+ def (ON_CUSTOM_REND) // hovering over custom rendition, generate enter/leave maybe?
/*
* Open display, get options/resources and create the window
*/
- if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL)
- rs[Rs_display_name] = ":0";
+ {
+ TEMP_ENV;
+
+ if ((rs[Rs_display_name] = getenv ("DISPLAY")) == NULL)
+ rs[Rs_display_name] = ":0";
- get_options (r_argc, r_argv);
+ get_options (r_argc, r_argv);
- if (!(display = displays.get (rs[Rs_display_name])))
- rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
+ if (!(display = displays.get (rs[Rs_display_name])))
+ rxvt_fatal ("can't open display %s, aborting.\n", rs[Rs_display_name]);
+ }
extract_resources ();
free (r_argv);
void
rxvt_term::set_locale (const char *locale)
{
+ TEMP_ENV;
+
#if HAVE_XSETLOCALE || HAVE_SETLOCALE
free (this->locale);
this->locale = setlocale (LC_CTYPE, locale);
{
if (*locale)
{
- rxvt_warn ("unable to set locale \"%s\", using default locale instead.\n", locale);
- setlocale (LC_CTYPE, "");
+ rxvt_warn ("unable to set locale \"%s\", using C locale instead.\n", locale);
+ setlocale (LC_CTYPE, "C");
}
else
rxvt_warn ("default locale unavailable, check LC_* and LANG variables. Continuing.\n");
- this->locale = "";
+ this->locale = "C";
}
void
rxvt_term::init_xlocale ()
{
+ TEMP_ENV;
+
#ifdef USE_XIM
if (!locale)
rxvt_warn ("setting locale failed, working without locale support.\n");
{
char *login;
+ TEMP_ENV; // not very temporary...
+
SET_TTYMODE (STDIN_FILENO, &tio); /* init terminal attributes */
if (OPTION (Opt_console))
}
else
{
- const char *argv0, *shell;
+ const char *argv0, *shell;
if ((shell = getenv ("SHELL")) == NULL || *shell == '\0')
shell = "/bin/sh";
strcpy (&login[1], argv0);
argv0 = login;
}
+
execlp (shell, argv0, NULL);
/* no error message: STDERR is closed! */
}
#if OFF_FOCUS_FADING
delete pix_colors_unfocused;
#endif
-#if USE_XGETDEFAULT
- XrmDestroyDatabase (xrmdatabase);
-#endif
displays.put (display);
// TODO: handle this with exceptions and tolerate the memory loss
XSetIOErrorHandler (rxvt_xioerror_handler);
-#ifdef USE_XGETDEFAULT
XrmInitialize ();
-#endif
}
/* ------------------------------------------------------------------------- *
if (file == NULL || *file == '\0')
return NULL;
- /* search environment variables here too */
- if ((f = rxvt_File_search_path (path, file, ext)) == NULL)
-#ifdef PATH_ENV
- if ((f = rxvt_File_search_path (getenv (PATH_ENV), file, ext)) == NULL)
-#endif
- f = rxvt_File_search_path (getenv ("PATH"), file, ext);
+ f = rxvt_File_search_path (path, file, ext);
#ifdef DEBUG_SEARCH_PATH
if (f)
# define NO_MOUSE_REPORT_SCROLLBAR 1
#endif
-#ifdef NO_RESOURCES
-# undef USE_XGETDEFAULT
-#endif
-
#if defined (ISO_14755) || defined (ENABLE_PERL)
# define ENABLE_OVERLAY 1
#endif
#define Width2Pixel(n) ((int32_t)(n) * (int32_t)fwidth)
#define Height2Pixel(n) ((int32_t)(n) * (int32_t)fheight)
-#define OPTION(opt) (options & (opt))
-#define DEFAULT_OPTIONS (Opt_scrollBar | Opt_scrollTtyOutput \
- | Opt_jumpScroll | Opt_secondaryScreen \
- | Opt_pastableTabs | Opt_intensityStyles)
+#define TEMP_ENV temp_environ temp_environ (envv)
+
+#define OPTION(opt) (options & (opt))
+#define DEFAULT_OPTIONS (Opt_scrollBar | Opt_scrollTtyOutput \
+ | Opt_jumpScroll | Opt_secondaryScreen \
+ | Opt_pastableTabs | Opt_intensityStyles)
// for m >= -n, ensure remainder lies between 0..n-1
#define MOD(m,n) (((m) + (n)) % (n))
struct rxvt_term : zero_initialized, rxvt_vars {
log_callback *log_hook; // log error messages through this hook, if != 0
getfd_callback *getfd_hook; // convert remote to local fd, if != 0
-
#if ENABLE_PERL
rxvt_perl_term perl;
#endif
-#if USE_XGETDEFAULT
- XrmDatabase xrmdatabase;
-#endif
-
struct mbstate mbstate; // current input multibyte state
unsigned char want_refresh:1,
envv->push_back (0);
{
- char **old_environ = environ;
- environ = envv->begin ();
-
rxvt_term *term = new rxvt_term;
term->log_hook = &log_cb;
term->log_hook = 0;
- environ = old_environ;
chdir ("/");
if (!success)
{
uint8_t s[2];
+ if (len > 65535)
+ len = 65535;
+
s[0] = len >> 8; s[1] = len;
write (fd, s, 2);
return false;
l = (s[0] << 8) + s[1];
- if (l > 4096)
+ if (l > 65535)
return false;
if (len)
export_const_iv (EVENT_WRITE);
}
-SV *
-new (...)
- CODE:
-{
- stringvec *argv = new stringvec;
- bool success;
-
- for (int i = 0; i < items ;i++)
- argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
-
- rxvt_term *term = new rxvt_term;
-
- term->argv = argv;
-
- try
- {
- if (!term->init (argv->size (), argv->begin ()))
- term = 0;
- }
- catch (const class rxvt_failure_exception &e)
- {
- term->destroy ();
- croak ("exception caught while initializing new terminal instance");
- }
-
- RETVAL = term && term->perl.self ? newSVterm (term) : &PL_sv_undef;
-}
- OUTPUT:
- RETVAL
-
void
set_should_invoke (int htype, int value)
CODE:
MODULE = urxvt PACKAGE = urxvt::term
+SV *
+_new (...)
+ CODE:
+{
+ if (items < 1 || !SvROK (ST (0)) || SvTYPE (SvRV (ST (0))) != SVt_PVAV)
+ croak ("first argument to urxvt::term->_new must be arrayref");
+
+ rxvt_term *term = new rxvt_term;
+
+ term->argv = new stringvec;
+ term->envv = new stringvec;
+
+ for (int i = 1; i < items; i++)
+ term->argv->push_back (strdup (SvPVbyte_nolen (ST (i))));
+
+ AV *envv = (AV *)SvRV (ST (0));
+ for (int i = av_len (envv) + 1; i--; )
+ term->envv->push_back (strdup (SvPVbyte_nolen (*av_fetch (envv, i, 1))));
+
+ term->envv->push_back (0);
+
+ bool success;
+
+ try
+ {
+ success = term->init (term->argv->size (), term->argv->begin ());
+ }
+ catch (const class rxvt_failure_exception &e)
+ {
+ success = false;
+ }
+
+ if (!success)
+ {
+ term->destroy ();
+ croak ("error while initializing new terminal instance");
+ }
+
+ RETVAL = term && term->perl.self
+ ? newSVterm (term) : &PL_sv_undef;
+}
+ OUTPUT:
+ RETVAL
+
void
rxvt_term::destroy ()
OUTPUT:
RETVAL
+SV *
+rxvt_term::_env ()
+ CODE:
+{
+ if (THIS->envv)
+ {
+ AV *av = newAV ();
+
+ for (char **i = THIS->envv->begin (); i != THIS->envv->end (); ++i)
+ if (*i)
+ av_push (av, newSVpv (*i, 0));
+
+ RETVAL = newRV_noinc ((SV *)av);
+ }
+ else
+ RETVAL = &PL_sv_undef;
+}
+ OUTPUT:
+ RETVAL
+
int
rxvt_term::pty_ev_events (int events = EVENT_UNDEF)
CODE:
#include <unistd.h>
#include <fcntl.h>
+#include <sys/utsname.h>
+
#ifndef NO_SLOW_LINK_SUPPORT
# include <sys/socket.h>
# include <sys/un.h>
{
if (!strcmp (id, (*i)->id))
{
- (*i)->referenced++;
+ ++(*i)->referenced;
+ (*i)->ref_next ();
return *i;
}
}
T *obj = new T (id);
- obj->referenced = 1;
-
- if (obj && obj->init ())
+ if (obj && obj->ref_init ())
{
+ obj->referenced = 1;
this->push_back (obj);
return obj;
}
display->im_change_cb ();
}
-bool rxvt_xim::init ()
+bool
+rxvt_xim::ref_init ()
{
display = GET_R->display; //HACK: TODO
{
}
-bool rxvt_display::init ()
+XrmDatabase
+rxvt_display::get_resources ()
+{
+ char *homedir = (char *)getenv ("HOME");
+ char fname[1024];
+
+ /*
+ * get resources using the X library function
+ */
+ char *displayResource, *xe;
+ XrmDatabase database, rdb1;
+
+ database = NULL;
+
+ // for ordering, see for example http://www.faqs.org/faqs/Xt-FAQ/ Subject: 20
+
+ // 6. System wide per application default file.
+
+ /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */
+ if ((xe = (char *)getenv ("XAPPLRESDIR")))
+ {
+ snprintf (fname, sizeof (fname), "%s/%s", xe, RESCLASS);
+
+ if ((rdb1 = XrmGetFileDatabase (fname)))
+ XrmMergeDatabases (rdb1, &database);
+ }
+
+ // 5. User's per application default file.
+ // none
+
+ // 4. User's defaults file.
+ /* Get any Xserver defaults */
+ displayResource = XResourceManagerString (display);
+
+ if (displayResource != NULL)
+ {
+ if ((rdb1 = XrmGetStringDatabase (displayResource)))
+ XrmMergeDatabases (rdb1, &database);
+ }
+ else if (homedir)
+ {
+ snprintf (fname, sizeof (fname), "%s/.Xdefaults", homedir);
+
+ if ((rdb1 = XrmGetFileDatabase (fname)))
+ XrmMergeDatabases (rdb1, &database);
+ }
+
+ /* Get screen specific resources */
+ displayResource = XScreenResourceString (ScreenOfDisplay (display, screen));
+
+ if (displayResource != NULL)
+ {
+ if ((rdb1 = XrmGetStringDatabase (displayResource)))
+ /* Merge with screen-independent resources */
+ XrmMergeDatabases (rdb1, &database);
+
+ XFree (displayResource);
+ }
+
+ // 3. User's per host defaults file
+ /* Add in XENVIRONMENT file */
+ if ((xe = (char *)getenv ("XENVIRONMENT"))
+ && (rdb1 = XrmGetFileDatabase (xe)))
+ XrmMergeDatabases (rdb1, &database);
+ else if (homedir)
+ {
+ struct utsname un;
+
+ if (!uname (&un))
+ {
+ snprintf (fname, sizeof (fname), "%s/.Xdefaults-%s", homedir, un.nodename);
+
+ if ((rdb1 = XrmGetFileDatabase (fname)))
+ XrmMergeDatabases (rdb1, &database);
+ }
+ }
+
+ return database;
+}
+
+bool rxvt_display::ref_init ()
{
#ifdef LOCAL_X_IS_UNIX
if (id[0] == ':')
cmap = DefaultColormap (display, screen);
depth = DefaultDepth (display, screen);
- int fd = XConnectionNumber (display);
-
-#ifndef NO_SLOW_LINK_SUPPORT
- // try to detect wether we have a local connection.
- // assume unix domains socket == local, everything else not
- // TODO: might want to check for inet/127.0.0.1
- is_local = 0;
- sockaddr_un sa;
- socklen_t sl = sizeof (sa);
-
- if (!getsockname (fd, (sockaddr *)&sa, &sl))
- is_local = sa.sun_family == AF_LOCAL;
-#endif
+ XrmSetDatabase (display, get_resources ());
#ifdef POINTER_BLANK
XColor blackcolour;
}
#endif
+ int fd = XConnectionNumber (display);
+
+#ifndef NO_SLOW_LINK_SUPPORT
+ // try to detect wether we have a local connection.
+ // assume unix domains socket == local, everything else not
+ // TODO: might want to check for inet/127.0.0.1
+ is_local = 0;
+ sockaddr_un sa;
+ socklen_t sl = sizeof (sa);
+
+ if (!getsockname (fd, (sockaddr *)&sa, &sl))
+ is_local = sa.sun_family == AF_LOCAL;
+#endif
+
x_ev.start (fd, EVENT_READ);
fcntl (fd, F_SETFD, FD_CLOEXEC);
return true;
}
+void
+rxvt_display::ref_next ()
+{
+ // TODO: somehow check wether the database files/resources changed
+ // before re-loading/parsing
+ XrmDestroyDatabase (XrmGetDatabase (display));
+ XrmSetDatabase (display, get_resources ());
+}
+
rxvt_display::~rxvt_display ()
{
if (!display)
char *id;
refcounted (const char *id);
- bool init () { return false; }
+ bool ref_init () { return false; }
+ void ref_next () { }
~refcounted ();
};
XIM xim;
rxvt_xim (const char *id) : refcounted (id) { }
- bool init ();
+ bool ref_init ();
~rxvt_xim ();
};
#endif
#endif
rxvt_display (const char *id);
- bool init ();
+ XrmDatabase get_resources ();
+ bool ref_init ();
+ void ref_next ();
~rxvt_display ();
operator Display *() const { return display; }
static bool vax () { return e == 0x44332211; };
} byteorder;
+// various utility functions
template<typename T, typename U> static inline T min (T a, U b) { return a < (T)b ? a : (T)b; }
template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; }
template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; }
#define IN_RANGE_EXC(val,beg,end) \
((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg))
+// makes dynamically allocated objects zero-initialised
struct zero_initialized {
void *operator new (size_t s);
void operator delete (void *p, size_t s);
}
};
+// temporarily replace the process environment
+extern char **environ;
+
+struct temp_environ
+{
+ char **prev;
+
+ temp_environ (const stringvec *envv)
+ : prev (environ)
+ {
+ if (envv)
+ environ = (char **)envv->begin ();
+ }
+
+ ~temp_environ ()
+ {
+ environ = prev;
+ }
+};
+
#endif
=item $text
Rxvt-unicodes special way of encoding text, where one "unicode" character
-always represents one screen cell. See L<row_t> for a discussion of this format.
+always represents one screen cell. See L<ROW_t> for a discussion of this format.
=item $string
=back
+=cut
+
+package urxvt;
+
+use utf8;
+use strict;
+use Carp ();
+use Scalar::Util ();
+use List::Util ();
+
+our $VERSION = 1;
+our $TERM;
+our @HOOKNAME;
+our %HOOKTYPE = map +($HOOKNAME[$_] => $_), 0..$#HOOKNAME;
+our %OPTION;
+
+our $LIBDIR;
+our $RESNAME;
+our $RESCLASS;
+our $RXVTNAME;
+
=head2 Variables in the C<urxvt> Package
=over 4
The current terminal. This variable stores the current C<urxvt::term>
object, whenever a callback/hook is executing.
-=item
-
=back
=head2 Functions in the C<urxvt> Package
=over 4
-=item $term = new urxvt [arg...]
-
-Creates a new terminal, very similar as if you had started it with
-C<system $binfile, arg...>. Croaks (and probably outputs an error message)
-if the new instance couldn't be created. Returns C<undef> if the new
-instance didn't initialise perl, and the terminal object otherwise. The
-C<init> and C<start> hooks will be called during the call.
-
=item urxvt::fatal $errormessage
Fatally aborts execution with the given error message. Avoid at all
Using this function has the advantage that its output ends up in the
correct place, e.g. on stderr of the connecting urxvtc client.
+Messages have a size limit of 1023 bytes currently.
+
=item $is_safe = urxvt::safe
Returns true when it is safe to do potentially unsafe things, such as
=cut
-package urxvt;
-
-use utf8;
-use strict;
-use Carp ();
-use Scalar::Util ();
-use List::Util ();
-
-our $VERSION = 1;
-our $TERM;
-our @HOOKNAME;
-our %HOOKTYPE = map +($HOOKNAME[$_] => $_), 0..$#HOOKNAME;
-our %OPTION;
-
-our $LIBDIR;
-our $RESNAME;
-our $RESCLASS;
-our $RXVTNAME;
-
BEGIN {
urxvt->bootstrap;
}
}
+=item $term = new urxvt::term $envhashref, $rxvtname, [arg...]
+
+Creates a new terminal, very similar as if you had started it with system
+C<$rxvtname, arg...>. C<$envhashref> must be a reference to a C<%ENV>-like
+hash which defines the environment of the new terminal.
+
+Croaks (and probably outputs an error message) if the new instance
+couldn't be created. Returns C<undef> if the new instance didn't
+initialise perl, and the terminal object otherwise. The C<init> and
+C<start> hooks will be called during this call.
+
+=cut
+
+sub new {
+ my ($class, $env, @args) = @_;
+
+ _new ([ map "$_=$env->{$_}", keys %$env ], @args);
+}
+
=item $term->destroy
Destroy the terminal object (close the window, free resources
Return various integers describing terminal characteristics.
+=item $x_display = $term->display_id
+
+Return the DISPLAY used by rxvt-unicode.
+
=item $lc_ctype = $term->locale
Returns the LC_CTYPE category string used by this rxvt-unicode.
-=item $x_display = $term->display_id
+=item $env = $term->env
-Return the DISPLAY used by rxvt-unicode.
+Returns a copy of the environment in effect for the terminal as a hashref
+similar to C<\%ENV>.
+
+=cut
+
+sub env {
+ if (my $env = $_[0]->_env) {
+ +{ map /^([^=]+)(?:=(.*))?$/s && ($1 => $2), @$env }
+ } else {
+ +{ %ENV }
+ }
+}
=item $modifiermask = $term->ModLevel3Mask
local $urxvt::popup::self = $self;
- local $ENV{LC_ALL} = $self->{term}->locale;
+ my $env = $self->{term}->env;
+ # we can't hope to reproduce the locale algorithm, so nuke LC_ALL and set LC_CTYPE.
+ delete $env->{LC_ALL};
+ $env->{LC_CTYPE} = $self->{term}->locale;
- urxvt->new ("--perl-lib" => "", "--perl-ext-common" => "", "-pty-fd" => -1, "-sl" => 0, "-b" => 0,
- "--transient-for" => $self->{term}->parent,
- "-display" => $self->{term}->display_id,
- "-pe" => "urxvt-popup")
+ urxvt::term->new ($env, $self->{term}->resource ("name"),
+ "--perl-lib" => "", "--perl-ext-common" => "", "-pty-fd" => -1, "-sl" => 0, "-b" => 0,
+ "--transient-for" => $self->{term}->parent,
+ "-display" => $self->{term}->display_id,
+ "-pe" => "urxvt-popup")
or die "unable to create popup window\n";
}
$self->{term}->ungrab;
}
+=back
+
=head2 The C<urxvt::timer> Class
This class implements timer watchers/events. Time is represented as a
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------*/
-/*----------------------------------------------------------------------*
- * get resources from ~/.Xdefaults or ~/.Xresources with the memory-saving
- * default or with XGetDefault() (#define USE_XGETDEFAULT)
- *----------------------------------------------------------------------*/
#include "../config.h" /* NECESSARY */
#include "rxvt.h" /* NECESSARY */
#include "version.h"
-#include <sys/utsname.h>
-
#ifdef KEYSYM_RESOURCE
#include "keyboard.h"
#endif
RSTRG (Rs_perl_ext_1, "perl-ext-common", "string"), //, "colon-separated list of perl extensions to enable"),TODO
STRG (Rs_perl_ext_2, "perl-ext", "pe", "string", "colon-separated list of perl extensions to enable for this instance"),
#endif
-#if 0 && TODO
-#if !defined(NO_RESOURCES) && defined(USE_XGETDEFAULT)
+#ifndef NO_RESOURCES
INFO ("xrm", "string", "X resource"),
-#endif
#endif
INFO ("e", "command arg ...", "command to execute")
};
static const char releasestring[] = "rxvt-unicode (" RXVTNAME ") v" VERSION " - released: " DATE "\n";
static const char optionsstring[] = "options: "
+#if ENABLE_PERL
+ "perl,"
+#endif
#if XFT
"xft,"
#endif
#endif
#if defined(NO_RESOURCES)
"NoResources"
-#else
-# if defined(USE_XGETDEFAULT)
- "XGetDefault"
-# else
- ".Xdefaults"
-# endif
#endif
"\nUsage: "; /* Usage */
}
# endif /* KEYSYM_RESOURCE */
-
-# ifndef USE_XGETDEFAULT
-/*{{{ rxvt_get_xdefaults () */
-/*
- * the matching algorithm used for memory-save fake resources
- */
-void
-rxvt_term::get_xdefaults (FILE *stream, const char *name)
-{
- unsigned int len;
- char *str, buffer[256];
-
- if (stream == NULL)
- return;
-
- len = strlen (name);
- while ((str = fgets (buffer, sizeof (buffer), stream)) != NULL)
- {
- unsigned int entry, n;
-
- while (*str && isspace (*str))
- str++; /* leading whitespace */
-
- if ((str[len] != '*' && str[len] != '.')
- || (len && strncmp (str, name, len)))
- continue;
- str += (len + 1); /* skip `name*' or `name.' */
-
-# ifdef KEYSYM_RESOURCE
- if (!parse_keysym (str, NULL))
-# endif /* KEYSYM_RESOURCE */
- for (entry = 0; entry < optList_size; entry++)
- {
- const char *kw = optList[entry].kw;
-
- if (kw == NULL)
- continue;
-
- n = strlen (kw);
- if (str[n] == ':' && rxvt_Str_match (str, kw))
- {
- /* skip `keyword:' */
- str += n + 1;
- rxvt_Str_trim (str);
- n = strlen (str);
-
- if (n && rs[optList[entry].doff] == NULL)
- {
- /* not already set */
- int s;
- char *p = 0;
-
- for (int o = 0;;)
- {
- p = (char *)rxvt_realloc (p, o + n + 1);
- memcpy (p + o, str, n);
- o += n;
- p[o] = 0;
-
- if (o == 0 || p[o - 1] != '\\') // continuation line
- break;
-
- o--; // eat "\"
-
- if ((str = fgets (buffer, sizeof (buffer), stream)) == NULL)
- break;
-
- rxvt_Str_trim (str);
- n = strlen (str);
- }
-
- 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
- || strcmp (str, "1") == 0;
-
- if (optList_isReverse (entry))
- s = !s;
-
- set_option (optList[entry].flag & Optflag_mask, s);
- }
- }
-
- break;
- }
- }
- }
-
- rewind (stream);
-}
-
-/*}}} */
-# endif /* ! USE_XGETDEFAULT */
#endif /* NO_RESOURCES */
-#ifdef USE_XGETDEFAULT
char *get_res (XrmDatabase database, const char *program, const char *option)
{
char resource[512];
return result.addr;
}
-#endif
/*{{{ read the resources files */
/*
dDisp;
#ifndef NO_RESOURCES
-
- char *homedir = (char *)getenv ("HOME");
- char fname[1024];
-
-# if defined XAPPLOADDIR
-# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
- /* Compute the path of the possibly available localized Rxvt file */
- char localepath[1024];
-
- if (locale)
- snprintf (localepath, sizeof (localepath), XAPPLOADDIRLOCALE "/" RESCLASS, locale);
- else
- localepath[0] = 0;
-# endif
-# endif
-
-# ifdef USE_XGETDEFAULT
- /*
- * get resources using the X library function
- */
- int entry;
-
- char *displayResource, *xe;
- XrmName name_prefix[3];
- XrmClass class_prefix[3];
- XrmDatabase database, rdb1;
-
- database = NULL;
-
- // for ordering, see for example http://www.faqs.org/faqs/Xt-FAQ/ Subject: 20
-
- // 6. System wide per application default file.
- /* Add in Rxvt file */
-# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
- if (*localepath
- && ((rdb1 = XrmGetFileDatabase (localepath))
- || (rdb1 = XrmGetFileDatabase (XAPPLOADDIR "/" RESCLASS))))
-# endif
- XrmMergeDatabases (rdb1, &database);
-
- /* Add in $XAPPLRESDIR/Rxvt only; not bothering with XUSERFILESEARCHPATH */
- if ((xe = (char *)getenv ("XAPPLRESDIR")))
- {
- snprintf (fname, sizeof (fname), "%s/%s", xe, RESCLASS);
-
- if ((rdb1 = XrmGetFileDatabase (fname)))
- XrmMergeDatabases (rdb1, &database);
- }
-
- // 5. User's per application default file.
- // none
-
- // 4. User's defaults file.
- /* Get any Xserver defaults */
- displayResource = XResourceManagerString (disp);
- if (displayResource != NULL)
- {
- if ((rdb1 = XrmGetStringDatabase (displayResource)))
- XrmMergeDatabases (rdb1, &database);
- }
- else if (homedir)
- {
- snprintf (fname, sizeof (fname), "%s/.Xdefaults", homedir);
-
- if ((rdb1 = XrmGetFileDatabase (fname)))
- XrmMergeDatabases (rdb1, &database);
- }
-
- /* Get screen specific resources */
- displayResource = XScreenResourceString (ScreenOfDisplay (disp, display->screen));
- if (displayResource != NULL)
- {
- if ((rdb1 = XrmGetStringDatabase (displayResource)))
- /* Merge with screen-independent resources */
- XrmMergeDatabases (rdb1, &database);
-
- XFree (displayResource);
- }
-
- // 3. User's per host defaults file
- /* Add in XENVIRONMENT file */
- if ((xe = (char *)getenv ("XENVIRONMENT"))
- && (rdb1 = XrmGetFileDatabase (xe)))
- XrmMergeDatabases (rdb1, &database);
- else if (homedir)
- {
- struct utsname un;
-
- if (!uname (&un))
- {
- snprintf (fname, sizeof (fname), "%s/.Xdefaults-%s", homedir, un.nodename);
-
- if ((rdb1 = XrmGetFileDatabase (fname)))
- XrmMergeDatabases (rdb1, &database);
- }
- }
-
- xrmdatabase = database;
+ XrmDatabase database = XrmGetDatabase (display->display);
/*
* Query resources for options that affect us
*/
- for (entry = 0; entry < optList_size; entry++)
+ for (int entry = 0; entry < optList_size; entry++)
{
int s;
char *p, *p0;
const char *kw = optList[entry].kw;
if (kw == NULL || rs[optList[entry].doff] != NULL)
- continue; /* previously set */
+ continue; // previously set
p = get_res (database, rs[Rs_name], kw);
p0 = get_res (database, "!INVALIDPROGRAMMENAMEDONTMATCH!", kw);
if (p)
{
+ p = strdup (p);
+ allocated.push_back (p);
rs[optList[entry].doff] = p;
if (optList_isBool (entry))
* [R5 or later]: enumerate the resource database
*/
# ifdef KEYSYM_RESOURCE
+ XrmName name_prefix[3];
+ XrmClass class_prefix[3];
+
name_prefix[0] = XrmStringToName (rs[Rs_name]);
name_prefix[1] = XrmStringToName ("keysym");
name_prefix[2] = NULLQUARK;
# endif
# endif
-# else /* USE_XGETDEFAULT */
- /* get resources the hard way, but save lots of memory */
- FILE *fd = NULL;
-
- if (homedir)
- {
- static const char *const xnames[2] = { ".Xdefaults", ".Xresources" };
-
- for (int i = 0; i < (sizeof (xnames) / sizeof (xnames [0])); i++)
- {
- snprintf (fname, sizeof (fname), "%s/%s", homedir, xnames [i]);
-
- if ((fd = fopen (fname, "r")) != NULL)
- break;
- }
- }
- /*
- * The normal order to match resources is the following:
- * @ global resources (partial match, ~/.Xdefaults)
- * @ application file resources (XAPPLOADDIR/Rxvt)
- * @ class resources (~/.Xdefaults)
- * @ private resources (~/.Xdefaults)
- *
- * However, for the hand-rolled resources, the matching algorithm
- * checks if a resource string value has already been allocated
- * and won't overwrite it with (in this case) a less specific
- * resource value.
- *
- * This avoids multiple allocation. Also, when we've called this
- * routine command-line string options have already been applied so we
- * needn't to allocate for those resources.
- *
- * So, search in resources from most to least specific.
- *
- * Also, use a special sub-class so that we can use either or both of
- * "XTerm" and "Rxvt" as class names.
- */
-
- get_xdefaults (fd, rs[Rs_name]);
- get_xdefaults (fd, RESCLASS);
-# ifdef RESFALLBACK
- get_xdefaults (fd, RESFALLBACK);
-# endif
-
-# if defined(XAPPLOADDIR) && defined(USE_XAPPLOADDIR)
- {
- FILE *ad = NULL;
-
-# if defined(HAVE_XSETLOCALE) || defined(HAVE_SETLOCALE)
- if (!*localepath || (ad = fopen (localepath, "r")) == NULL)
-# endif
- ad = fopen (XAPPLOADDIR "/" RESCLASS, "r");
- if (ad != NULL)
- {
- get_xdefaults (ad, RESCLASS);
- get_xdefaults (ad, "");
- fclose (ad);
- }
- }
-# endif /* XAPPLOADDIR */
-
- get_xdefaults (fd, ""); /* partial match */
- if (fd != NULL)
- fclose (fd);
-# endif /* USE_XGETDEFAULT */
-
#endif /* NO_RESOURCES */
}