*** empty log message ***
authorroot <root>
Thu, 5 Jan 2006 01:04:10 +0000 (01:04 +0000)
committerroot <root>
Thu, 5 Jan 2006 01:04:10 +0000 (01:04 +0000)
Changes
MANIFEST
src/command.C
src/hookinc.h
src/perl/mark-urls
src/perl/selection
src/rxvtperl.h
src/rxvtperl.xs
src/screen.C
src/urxvt.pm

diff --git a/Changes b/Changes
index 6cc6e89963cae9dba159a64e99e0390a679decc7..e1cdc0817ce8ff9fe8f7ccb0db047c8df17b141c 100644 (file)
--- a/Changes
+++ b/Changes
@@ -7,6 +7,7 @@ TODO: read property sequence is broken with respect to utf-8 etc.
 TODO: http://www120.pair.com/mccarthy/nextstep/intro.htmld/Workspace.html is the correct nextstep look.
 WISH: OnTheSpot editing, or maybe switch to miiiiiiif
 WISH: just for fun, do shade and tint with XRender.
+WISH: support tex fonts
 
 6.3  Wed Jan  4 22:37:10 CET 2006
         - SECURITY FIX: on systems using openpty, permissions were
index 9e74a0efc94ab03bbb8be14ca4887cecf0150ffa..cd37bf47f156719943034bdd0462f23fc67e9b63 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -121,15 +121,6 @@ src/version.h
 src/xdefaults.C
 src/xpm.C
 
-src/urxvt.pm
-src/typemap
-src/rxvtperl.h
-src/rxvtperl.xs
-
-src/perl/example-refresh-hooks
-src/perl/digital-clock
-src/perl/selection
-
 src/gentables
 src/gencompose
 src/genlinedraw
@@ -173,3 +164,14 @@ src/table/jis0208_1990_0.h
 src/table/jis0212_1990_0.h
 src/table/jis0213_1.h
 src/table/jis0213_2.h
+
+src/urxvt.pm
+src/typemap
+src/rxvtperl.h
+src/rxvtperl.xs
+
+src/perl/example-refresh-hooks
+src/perl/digital-clock
+src/perl/selection
+src/perl/mark-urls
+
index f3a40bce167719301e175f562031c4e5d93d6412..ecff4ec0e421d91b15f6af2394fa52a939c5e551 100644 (file)
@@ -2735,7 +2735,9 @@ rxvt_term::cmd_parse ()
                   // scr_add_lines only works for nlines <= nrow - 1.
                   if (nlines >= nrow - 1)
                     {
-                      scr_add_lines (buf, nlines, str - buf);
+                      if (!PERL_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END)))
+                        scr_add_lines (buf, nlines, str - buf);
+
                       nlines = 0;
                       str = buf;
                       eol = str + min (ncol, UBUFSIZ);
@@ -2758,7 +2760,8 @@ rxvt_term::cmd_parse ()
               ch = next_char ();
             }
 
-          scr_add_lines (buf, nlines, str - buf);
+          if (!PERL_INVOKE ((this, HOOK_ADD_LINES, DT_USTRING_LEN, buf, str - buf, DT_END)))
+            scr_add_lines (buf, nlines, str - buf);
 
           /*
            * If there have been a lot of new lines, then update the screen
index 84526d281158cd0a72957dde29960063b2f0d43a..96769cc617d7ce25385dc30141c990e54908ae2c 100644 (file)
@@ -18,6 +18,7 @@
   def (VIEW_CHANGE)
   def (SCROLL_BACK)
   def (TTY_ACTIVITY)
+  def (ADD_LINES)
   def (OSC_SEQ)
 
   def (REFRESH_BEGIN)
index 6bd16c2519cfb70d50a1b38d8bc2228a0ca64877..ce19f2bc36f4d801b640acb5926f08af3a1d5611 100644 (file)
@@ -3,8 +3,8 @@
 # same url as used in "selection"
 my $url =
    qr{(
-      (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),]+
-      [^.]   # do not include a trailing dot, its wrong too often
+      (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+
+      [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~]   # do not include a trailing dot, its wrong too often
    )}x;
 
 sub on_add_lines {
index 7ca4e4d66380fe11ab9c53ec9cf3aa90ce809cd5..e28594c3fb8c3de9ac6610e3edc44308c756c7b3 100644 (file)
@@ -12,8 +12,8 @@ sub on_keyboard_command {
 my @patterns = (
    # urls, just a heuristic
    qr{(
-      (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),]+
-      [^.]   # do not include a trailing dot, its wrong too often
+      (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+
+      [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27(),~]   # do not include a trailing dot, its wrong too often
    )}x,
 
    # shell-like argument quoting
index d59ba368fcd3e057854d98b5afd6bcfe85bfcbea..13692262427cdf32747bffb1d574f8498283cdef 100644 (file)
@@ -16,6 +16,7 @@ enum data_type {
   DT_INT,
   DT_LONG,
   DT_STRING,
+  DT_USTRING_LEN,
   DT_XEVENT,
 };
 
index 904ea1bcefa98e83e7d9c50d4f4d3a3dd0f8a302..810d4adc569b76076d7a48c1e1b50d3dd02a3083 100644 (file)
@@ -52,6 +52,18 @@ sv2wcs (SV *sv)
   return rxvt_utf8towcs (str, len);
 }
 
+static SV *
+wcs2sv (wchar_t *wstr, int len = -1)
+{
+  char *str = rxvt_wcstoutf8 (wstr, len);
+
+  SV *sv = newSVpv (str, 0);
+  SvUTF8_on (sv);
+  free (str);
+
+  return sv;
+}
+
 static SV *
 new_ref (HV *hv, const char *klass)
 {
@@ -459,6 +471,20 @@ rxvt_perl_interp::invoke (rxvt_term *term, hook_type htype, ...)
           XPUSHs (sv_2mortal (newSVpv (va_arg (ap, char *), 0)));
           break;
 
+        case DT_USTRING_LEN:
+          {
+            unicode_t *ustr = va_arg (ap, unicode_t *);
+            int ulen = va_arg (ap, int);
+            wchar_t *wstr = new wchar_t [ulen];
+
+            for (int i = ulen; i--; )
+              wstr [i] = ustr [i];
+
+            XPUSHs (sv_2mortal (wcs2sv (wstr, ulen)));
+
+            delete [] wstr;
+          }
+
         case DT_END:
           {
             va_end (ap);
@@ -636,12 +662,8 @@ rxvt_term::locale_decode (SV *octets)
         wchar_t *wstr = rxvt_mbstowcs (data, len);
         rxvt_pop_locale ();
 
-        char *str = rxvt_wcstoutf8 (wstr);
+        RETVAL = wcs2sv (wstr);
         free (wstr);
-
-        RETVAL = newSVpv (str, 0);
-        SvUTF8_on (RETVAL);
-        free (str);
 }
        OUTPUT:
         RETVAL
@@ -683,11 +705,11 @@ rxvt_term::width ()
         RETVAL
 
 U32
-rxvt_term::screen_rstyle (U32 new_rstyle = THIS->screen.s_rstyle)
+rxvt_term::rstyle (U32 new_rstyle = THIS->rstyle)
        CODE:
 {
-        RETVAL = THIS->screen.s_rstyle;
-        THIS->screen.s_rstyle = new_rstyle;
+        RETVAL = THIS->rstyle;
+        THIS->rstyle = new_rstyle;
 }
         OUTPUT:
        RETVAL
@@ -728,13 +750,9 @@ rxvt_term::ROW_t (int row_number, SV *new_text = 0, int start_col = 0)
             for (int col = 0; col <THIS->ncol; col++)
               wstr [col] = l.t [col];
 
-            char *str = rxvt_wcstoutf8 (wstr, THIS->ncol);
-            free (wstr);
+            XPUSHs (sv_2mortal (wcs2sv (wstr)));
 
-            SV *sv = newSVpv (str, 0);
-            SvUTF8_on (sv);
-            XPUSHs (sv_2mortal (sv));
-            free (str);
+            delete [] wstr;
           }
 
         if (new_text)
@@ -918,13 +936,7 @@ rxvt_term::selection (SV *newtext = 0)
         PPCODE:
 {
         if (GIMME_V != G_VOID)
-          {
-            char *sel = rxvt_wcstoutf8 (THIS->selection.text, THIS->selection.len);
-            SV *sv = newSVpv (sel, 0);
-            SvUTF8_on (sv);
-            free (sel);
-            XPUSHs (sv_2mortal (sv));
-          }
+          XPUSHs (sv_2mortal (wcs2sv (THIS->selection.text, THIS->selection.len)));
 
         if (newtext)
           {
@@ -935,6 +947,27 @@ rxvt_term::selection (SV *newtext = 0)
           }
 }
 
+void
+rxvt_term::scr_add_lines (SV *string)
+       CODE:
+{
+        wchar_t *wstr = sv2wcs (string);
+        int wlen = wcslen (wstr);
+        unicode_t *ustr = new unicode_t [wlen];
+        int nlines = 0;
+
+        for (int i = wlen; i--; )
+          {
+            ustr [i] = wstr [i];
+            nlines += ustr [i] == '\012';
+          }
+
+        THIS->scr_add_lines (ustr, nlines, wlen);
+
+        free (wstr);
+        delete [] ustr;
+}
+
 void
 rxvt_term::tt_write (SV *octets)
         INIT:
index 93d27d3db598c773babf9e95cc98d4ca4678aa28..d3f88c3d2312034d74036ac9a9e57382a1ab993e 100644 (file)
@@ -724,6 +724,7 @@ rxvt_term::scr_add_lines (const unicode_t *str, int nlines, int len)
   if (nlines > 0)
     {
       nlines += screen.cur.row - screen.bscroll;
+
       if (nlines > 0
           && screen.tscroll == 0
           && screen.bscroll == (nrow - 1))
index 10e1878f9f209cabad7084ff3eb857f955566256..9b416b1a28b3e151d6b673bcfbdc1bffb7d586ba 100644 (file)
@@ -68,6 +68,13 @@ Displays a very simple digital clock in the upper right corner of the
 window. Illustrates overwriting the refresh callbacks to create your own
 overlays or changes.
 
+=item mark-urls
+
+A not very useful example of filtering all text output to the terminal, by
+underlining all urls that matches a certain regex (i.e. some urls :). It
+is not very useful because urls that are output in multiple steps (e.g.
+when typing them) do not get marked.
+
 =back
 
 =head2 General API Considerations
@@ -83,6 +90,29 @@ emptied, so its best to store related objects such as time watchers and
 the like inside the terminal object so they get destroyed as soon as the
 terminal is destroyed.
 
+Argument names also often indicate the type of a parameter. Here are some
+hints on what they mean:
+
+=over 4
+
+=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.
+
+=item $string
+
+A perl text string, with an emphasis on I<text>. It can store all unicode
+characters and is to be distinguished with text encoded in a specific
+encoding (often locale-specific) and binary data.
+
+=item $octets
+
+Either binary data or - more common - a text string encoded in a
+locale-specific way.
+
+=back
+
 =head2 Hooks
 
 The following subroutines can be declared in loaded scripts, and will be
@@ -187,6 +217,14 @@ Be careful not ever to trust (in a security sense) the data you receive,
 as its source can not easily be controleld (e-mail content, messages from
 other users on the same system etc.).
 
+=item on_add_lines $term, $string
+
+Called whenever text is about to be output, with the text as argument. You
+can filter/change and output the text yourself by returning a true value
+and calling C<< $term->scr_add_lines >> yourself. Please note that this
+might be very slow, however, as your hook is called for B<all> text being
+output.
+
 =item on_refresh_begin $term
 
 Called just before the screen gets redrawn. Can be used for overlay
@@ -489,10 +527,10 @@ sub urxvt::term::resource($$;$) {
    goto &urxvt::term::_resource;
 }
 
-=item $rend = $term->screen_rstyle ([$new_rstyle])
+=item $rend = $term->rstyle ([$new_rstyle])
 
-Return and optionally change the current rendition. Text thta is output by
-the temrianl application will use this style.
+Return and optionally change the current rendition. Text that is output by
+the terminal application will use this style.
 
 =item ($row, $col) = $term->screen_cur ([$row, $col])
 
@@ -522,21 +560,20 @@ Return the current selection text and optionally replace it by C<$newtext>.
 #Create a simple multi-line overlay box. See the next method for details.
 #
 #=cut
-
-sub urxvt::term::scr_overlay {
-die;
-   my ($self, $x, $y, $text) = @_;
-
-   my @lines = split /\n/, $text;
-
-   my $w = 0;
-   for (map $self->strwidth ($_), @lines) {
-      $w = $_ if $w < $_;
-   }
-
-   $self->scr_overlay_new ($x, $y, $w, scalar @lines);
-   $self->scr_overlay_set (0, $_, $lines[$_]) for 0.. $#lines;
-}
+#
+#sub urxvt::term::scr_overlay {
+#   my ($self, $x, $y, $text) = @_;
+#
+#   my @lines = split /\n/, $text;
+#
+#   my $w = 0;
+#   for (map $self->strwidth ($_), @lines) {
+#      $w = $_ if $w < $_;
+#   }
+#
+#   $self->scr_overlay_new ($x, $y, $w, scalar @lines);
+#   $self->scr_overlay_set (0, $_, $lines[$_]) for 0.. $#lines;
+#}
 
 =item $term->overlay ($x, $y, $width, $height[, $rstyle[, $border]])
 
@@ -586,6 +623,17 @@ Convert the given text string into the corresponding locale encoding.
 
 Convert the given locale-encoded octets into a perl string.
 
+=item $term->scr_add_lines ($string)
+
+Write the given text string to the screen, as if output by the application
+running inside the terminal. It may not contain command sequences (escape
+codes), but is free to use line feeds, carriage returns and tabs. The
+string is a normal text string, not in locale-dependent encoding.
+
+Normally its not a good idea to use this function, as programs might be
+confused by changes in cursor position or scrolling. Its useful inside a
+C<on_add_lines> hook, though.
+
 =item $term->tt_write ($octets)
 
 Write the octets given in C<$data> to the tty (i.e. as program input). To