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
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
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
+
// 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);
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
def (VIEW_CHANGE)
def (SCROLL_BACK)
def (TTY_ACTIVITY)
+ def (ADD_LINES)
def (OSC_SEQ)
def (REFRESH_BEGIN)
# 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 {
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
DT_INT,
DT_LONG,
DT_STRING,
+ DT_USTRING_LEN,
DT_XEVENT,
};
}
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)
{
return sv_bless (newRV ((SV *)hv), gv_stashpv (klass, 1));
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);
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
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
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)
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)
{
}
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:
STRLEN len;
if (nlines > 0)
{
nlines += screen.cur.row - screen.bscroll;
+
if (nlines > 0
&& screen.tscroll == 0
&& screen.bscroll == (nrow - 1))
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
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
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
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])
#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]])
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