*** empty log message ***
authorroot <root>
Wed, 11 Jan 2006 00:59:57 +0000 (00:59 +0000)
committerroot <root>
Wed, 11 Jan 2006 00:59:57 +0000 (00:59 +0000)
21 files changed:
Changes
autoconf/config.h.in
autoconf/configure.in
configure
doc/rxvtperl.3.html
doc/rxvtperl.3.man.in
doc/rxvtperl.3.txt
src/feature.h
src/hookinc.h
src/init.C
src/main.C
src/misc.C
src/rxvt.h
src/rxvtd.C
src/rxvtdaemon.C
src/rxvtperl.xs
src/rxvttoolkit.C
src/rxvttoolkit.h
src/rxvtutil.h
src/urxvt.pm
src/xdefaults.C

diff --git a/Changes b/Changes
index c2500173779544a95a0fef07944ea817813dedde..512a59250e6470dbcfd26c4b9bf2a24e6d26dc7b 100644 (file)
--- a/Changes
+++ b/Changes
@@ -11,6 +11,7 @@ WISH: support tex fonts
 
 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
@@ -32,6 +33,10 @@ TODO: better environment handling in rxvt/xim etc. and urxvt::term->new
         - 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
index dcab8034524c0223927f068e1f985ecfc826f08e..70c2cd81f93718c495d351f0c3e0c15d83c89998 100644 (file)
 /* 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
 
index 12c525be580d46b1bb8ebb7b19bd35f67048def1..99b9afeb3dce5e36759bca46d74cd470fac14252 100644 (file)
@@ -350,12 +350,6 @@ AC_ARG_ENABLE(resources,
     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
index b9dade0ffcd0f787d6d194fc6388fb79c7e4e868..6fc2b594cb3a6b8d20e2c2e3596d5414f56138ab 100755 (executable)
--- a/configure
+++ b/configure
@@ -891,7 +891,6 @@ Optional Features:
   --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
@@ -4641,18 +4640,6 @@ _ACEOF
   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"
index 624de21d8c3075833d906756a869ddbc5628d7b1..4fb3dff4b90f70dbe37ef5e0a836c09d2154a82b 100644 (file)
@@ -185,7 +185,7 @@ hints on what they mean:</p>
 </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 />
@@ -478,23 +478,11 @@ The basename of the installed binaries, usually <code>urxvt</code>.
 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>
@@ -514,6 +502,9 @@ that calls this function.
 <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>
@@ -614,6 +605,20 @@ work.</p>
 </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-&gt;destroy</a></strong><br />
 </dt>
 <dd>
@@ -908,16 +913,23 @@ Return the window id of the terminal window.
 Return various integers describing terminal characteristics.
 </dd>
 <p></p>
+<dt><strong><a name="item_display_id">$x_display = $term-&gt;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-&gt;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-&gt;display_id</a></strong><br />
+<dt><strong><a name="item_env">$env = $term-&gt;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-&gt;ModLevel3Mask</a></strong><br />
index d5c939cad0dc3c1c994bd68b16f037f5090b937b..e6cc2beb3a0bdfe47f0190ee8f35fe867798cb93 100644 (file)
 .\" ========================================================================
 .\"
 .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"
@@ -246,7 +246,7 @@ hints on what they mean:
 .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
@@ -477,19 +477,9 @@ The basename of the installed binaries, usually \f(CW\*(C`urxvt\*(C'\fR.
 .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"
@@ -505,6 +495,8 @@ that calls this function.
 .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
@@ -582,6 +574,17 @@ work.
 .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
@@ -824,14 +827,19 @@ Return the window id of the terminal window.
 .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"
@@ -1010,7 +1018,7 @@ Displays the popup (which is initially hidden).
 .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
@@ -1021,7 +1029,6 @@ fractional number of seconds since the epoch. Example:
 \&                          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
@@ -1056,13 +1063,11 @@ Set the event trigger time to \f(CW$tstamp\fR and start the timer.
 .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
@@ -1103,8 +1108,6 @@ Start watching for requested events on the given handle.
 .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"
@@ -1118,8 +1121,6 @@ numbers indicate more verbose output.
 .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"
index 713d8fb56143aa339944220d2feee0141dd2f187..9b8b83bceb49787c69b7065dff483c823f7992a0 100644 (file)
@@ -100,7 +100,7 @@ API DOCUMENTATION
 
     $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
@@ -301,17 +301,7 @@ API DOCUMENTATION
         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
@@ -325,6 +315,8 @@ API DOCUMENTATION
         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
@@ -387,6 +379,16 @@ API DOCUMENTATION
     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
@@ -579,11 +581,15 @@ API DOCUMENTATION
     $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
@@ -729,92 +735,92 @@ API DOCUMENTATION
         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
 
index 4f373a68b79c672895fc7b2cd1a8e2cc58b086fd..acb8097e64cc470c7aae66a49510749f9c377d21 100644 (file)
  * 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
 
index 50b4e0964868401d10e1ae47f39709e690a9a1fd..c158c71ba0dcde1dcb3ab93bcc2917478f9f3592 100644 (file)
@@ -33,3 +33,4 @@
   def (MOTION_NOTIFY)
   def (MAP_NOTIFY)
   def (UNMAP_NOTIFY)
+  def (ON_CUSTOM_REND) // hovering over custom rendition, generate enter/leave maybe?
index b4bf4dbc6ca506a112c9d62de355e03a0c07cd8b..8537a303e095e88aeb1985615830b73166dff03c 100644 (file)
@@ -341,13 +341,17 @@ rxvt_term::init_resources (int argc, const char *const *argv)
   /*
    * 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);
@@ -578,6 +582,8 @@ rxvt_term::init_env ()
 void
 rxvt_term::set_locale (const char *locale)
 {
+  TEMP_ENV;
+
 #if HAVE_XSETLOCALE || HAVE_SETLOCALE
   free (this->locale);
   this->locale = setlocale (LC_CTYPE, locale);
@@ -586,13 +592,13 @@ rxvt_term::set_locale (const char *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";
     }
 
 
@@ -617,6 +623,8 @@ rxvt_term::set_locale (const char *locale)
 void
 rxvt_term::init_xlocale ()
 {
+  TEMP_ENV;
+
 #ifdef USE_XIM
   if (!locale)
     rxvt_warn ("setting locale failed, working without locale support.\n");
@@ -1527,6 +1535,8 @@ rxvt_term::run_child (const char *const *argv)
 {
   char *login;
 
+  TEMP_ENV; // not very temporary...
+
   SET_TTYMODE (STDIN_FILENO, &tio);       /* init terminal attributes */
 
   if (OPTION (Opt_console))
@@ -1582,7 +1592,7 @@ rxvt_term::run_child (const char *const *argv)
     }
   else
     {
-      const char     *argv0, *shell;
+      const char *argv0, *shell;
 
       if ((shell = getenv ("SHELL")) == NULL || *shell == '\0')
         shell = "/bin/sh";
@@ -1597,6 +1607,7 @@ rxvt_term::run_child (const char *const *argv)
           strcpy (&login[1], argv0);
           argv0 = login;
         }
+
       execlp (shell, argv0, NULL);
       /* no error message: STDERR is closed! */
     }
index 1646a80fbf0b1ab257137921751b8d71c7aac361..e148576c2df1da78ba2a10e706ce0f5a695bc2fa 100644 (file)
@@ -291,9 +291,6 @@ rxvt_term::~rxvt_term ()
 #if OFF_FOCUS_FADING
   delete pix_colors_unfocused;
 #endif
-#if USE_XGETDEFAULT
-  XrmDestroyDatabase (xrmdatabase);
-#endif
 
   displays.put (display);
 
@@ -647,9 +644,7 @@ rxvt_init ()
   // TODO: handle this with exceptions and tolerate the memory loss
   XSetIOErrorHandler (rxvt_xioerror_handler);
 
-#ifdef USE_XGETDEFAULT
   XrmInitialize ();
-#endif
 }
 
 /* ------------------------------------------------------------------------- *
index ff96ed3c459af9a8ab41e9c20f490b018d00c93b..51bcb81ebbe44fd045a6703a0a2c8f258b6f3f2a 100644 (file)
@@ -527,12 +527,7 @@ rxvt_File_find (const char *file, const char *ext, const char *path)
   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)
index 82d45ad5db385eb287c5413031b6d7b0126a1c2d..82c47db858d39bf723148d3cff1edd0fb602d845 100644 (file)
@@ -213,10 +213,6 @@ typedef struct _mwmhints {
 # 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
@@ -701,10 +697,12 @@ enum {
 #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))
@@ -975,14 +973,9 @@ extern class rxvt_composite_vec rxvt_composite;
 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,
index 4a714e1b66c72a1725298cf204e4de4adf43af90..ddc7b76ff4b1a20f6964baf04ec4c792a240ef4c 100644 (file)
@@ -188,9 +188,6 @@ void server::read_cb (io_watcher &w, short revents)
           envv->push_back (0);
 
           {
-            char **old_environ = environ;
-            environ = envv->begin ();
-
             rxvt_term *term = new rxvt_term;
             
             term->log_hook = &log_cb;
@@ -211,7 +208,6 @@ void server::read_cb (io_watcher &w, short revents)
 
             term->log_hook = 0;
 
-            environ = old_environ;
             chdir ("/");
 
             if (!success)
index c20446c040e5935473f1561239f644546fdd436b..779ff94b4ee466d44aee99cb62df601c3253facb 100644 (file)
@@ -58,6 +58,9 @@ void rxvt_connection::send (const char *data, int len)
 {
   uint8_t s[2];
 
+  if (len > 65535)
+    len = 65535;
+
   s[0] = len >> 8; s[1] = len;
 
   write (fd, s, 2);
@@ -78,7 +81,7 @@ bool rxvt_connection::recv (auto_str &data, int *len)
     return false;
 
   l = (s[0] << 8) + s[1];
-  if (l > 4096)
+  if (l > 65535)
     return false;
 
   if (len)
index e315398e70c3270fb78d4f93052c1d73f86d47bb..69a62de9eff252379a2f546d2e3ab42d263a3cdb 100644 (file)
@@ -677,36 +677,6 @@ BOOT:
   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:
@@ -794,6 +764,50 @@ SET_CUSTOM (int rend, int new_value)
 
 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 ()
 
@@ -961,6 +975,26 @@ rxvt_term::display_id ()
         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:
index 46dead6da1ad5579d273f28cc08e7e172b511739..3e79ad42b4e907254b3413fc7c90e1b638f451c2 100644 (file)
@@ -27,6 +27,8 @@
 #include <unistd.h>
 #include <fcntl.h>
 
+#include <sys/utsname.h>
+
 #ifndef NO_SLOW_LINK_SUPPORT
 # include <sys/socket.h>
 # include <sys/un.h>
@@ -49,17 +51,17 @@ T *refcache<T>::get (const char *id)
     {
       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;
     }
@@ -109,7 +111,8 @@ im_destroy_cb (XIM unused1, XPointer client_data, XPointer unused3)
   display->im_change_cb ();
 }
 
-bool rxvt_xim::init ()
+bool
+rxvt_xim::ref_init ()
 {
   display = GET_R->display; //HACK: TODO
 
@@ -143,7 +146,87 @@ rxvt_display::rxvt_display (const char *id)
 {
 }
 
-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] == ':')
@@ -170,19 +253,7 @@ bool rxvt_display::init ()
   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;
@@ -214,6 +285,20 @@ bool rxvt_display::init ()
     }
 #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);
 
@@ -227,6 +312,15 @@ bool rxvt_display::init ()
   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)
index 90b47f370ee1619470604893b300bf0a8c2c37e9..4d6eb581e68fe7a784d7bfc5dc838c53e355b846 100644 (file)
@@ -28,7 +28,8 @@ struct refcounted {
   char *id;
 
   refcounted (const char *id);
-  bool init () { return false; }
+  bool ref_init () { return false; }
+  void ref_next () { }
   ~refcounted ();
 };
 
@@ -55,7 +56,7 @@ struct rxvt_xim : refcounted {
   XIM xim;
 
   rxvt_xim (const char *id) : refcounted (id) { }
-  bool init ();
+  bool ref_init ();
   ~rxvt_xim ();
 };
 #endif
@@ -91,7 +92,9 @@ struct rxvt_display : refcounted {
 #endif
 
   rxvt_display (const char *id);
-  bool init ();
+  XrmDatabase get_resources ();
+  bool ref_init ();
+  void ref_next ();
   ~rxvt_display ();
 
   operator Display *() const { return display; }
index cdab0090aedb75009c5f1e102aa80df35c17f900..2e9164cf27492a95eaa0007960d393d1aafe5218 100644 (file)
@@ -19,6 +19,7 @@ public:
   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; }
@@ -37,6 +38,7 @@ template<typename T, typename U> static inline void swap (T& a, U& b) { T t=a; a
 #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);
@@ -395,5 +397,25 @@ struct stringvec : simplevec<char *>
   }
 };
 
+// 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
 
index c943bd83fd560a8565d0ec02523e3913ea956ca1..44c7611c45613fabb07745971ca7f9491b1bcb4f 100644 (file)
@@ -125,7 +125,7 @@ hints on what they mean:
 =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
 
@@ -345,6 +345,27 @@ subwindow.
 
 =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
@@ -367,22 +388,12 @@ The basename of the installed binaries, usually C<urxvt>.
 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
@@ -398,6 +409,8 @@ that calls this function.
 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
@@ -472,25 +485,6 @@ Change the custom value.
 
 =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;
 
@@ -785,6 +779,25 @@ sub register_package {
    }
 }
 
+=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
@@ -1057,13 +1070,28 @@ Return the window id of the terminal window.
 
 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
 
@@ -1394,12 +1422,16 @@ sub show {
 
    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";
 }
 
@@ -1410,6 +1442,8 @@ sub DESTROY {
    $self->{term}->ungrab;
 }
 
+=back
+
 =head2 The C<urxvt::timer> Class
 
 This class implements timer watchers/events. Time is represented as a
index 90a62aba8395496702f8f43d8a60e485e2249990..d83b008f61e24cfadae75c8e5af7e1ac507137ea 100644 (file)
  * 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
@@ -266,10 +260,8 @@ optList[] = {
               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")
             };
@@ -283,6 +275,9 @@ optList[] = {
 
 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
@@ -404,12 +399,6 @@ static const char optionsstring[] = "options: "
 #endif
 #if defined(NO_RESOURCES)
                                     "NoResources"
-#else
-# if defined(USE_XGETDEFAULT)
-                                    "XGetDefault"
-# else
-                                    ".Xdefaults"
-# endif
 #endif
                                     "\nUsage: ";               /* Usage */
 
@@ -782,107 +771,8 @@ rxvt_term::parse_keysym (const char *str, const char *arg)
 }
 
 # 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];
@@ -894,7 +784,6 @@ char *get_res (XrmDatabase database, const char *program, const char *option)
 
   return result.addr;
 }
-#endif
 
 /*{{{ read the resources files */
 /*
@@ -907,116 +796,19 @@ rxvt_term::extract_resources ()
   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);
@@ -1034,6 +826,8 @@ rxvt_term::extract_resources ()
 
       if (p)
         {
+          p = strdup (p);
+          allocated.push_back (p);
           rs[optList[entry].doff] = p;
 
           if (optList_isBool (entry))
@@ -1055,6 +849,9 @@ rxvt_term::extract_resources ()
    * [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;
@@ -1075,72 +872,6 @@ rxvt_term::extract_resources ()
 #   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 */
 }