From: root Date: Thu, 5 Jan 2006 01:04:10 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=7601b50db7877e7e9d815baf93203eb728ec4d95;p=dana%2Furxvt.git *** empty log message *** --- diff --git a/Changes b/Changes index 6cc6e899..e1cdc081 100644 --- 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 diff --git a/MANIFEST b/MANIFEST index 9e74a0ef..cd37bf47 100644 --- 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 + diff --git a/src/command.C b/src/command.C index f3a40bce..ecff4ec0 100644 --- a/src/command.C +++ b/src/command.C @@ -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 diff --git a/src/hookinc.h b/src/hookinc.h index 84526d28..96769cc6 100644 --- a/src/hookinc.h +++ b/src/hookinc.h @@ -18,6 +18,7 @@ def (VIEW_CHANGE) def (SCROLL_BACK) def (TTY_ACTIVITY) + def (ADD_LINES) def (OSC_SEQ) def (REFRESH_BEGIN) diff --git a/src/perl/mark-urls b/src/perl/mark-urls index 6bd16c25..ce19f2bc 100644 --- a/src/perl/mark-urls +++ b/src/perl/mark-urls @@ -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 { diff --git a/src/perl/selection b/src/perl/selection index 7ca4e4d6..e28594c3 100644 --- a/src/perl/selection +++ b/src/perl/selection @@ -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 diff --git a/src/rxvtperl.h b/src/rxvtperl.h index d59ba368..13692262 100644 --- a/src/rxvtperl.h +++ b/src/rxvtperl.h @@ -16,6 +16,7 @@ enum data_type { DT_INT, DT_LONG, DT_STRING, + DT_USTRING_LEN, DT_XEVENT, }; diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs index 904ea1bc..810d4adc 100644 --- a/src/rxvtperl.xs +++ b/src/rxvtperl.xs @@ -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 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: diff --git a/src/screen.C b/src/screen.C index 93d27d3d..d3f88c3d 100644 --- a/src/screen.C +++ b/src/screen.C @@ -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)) diff --git a/src/urxvt.pm b/src/urxvt.pm index 10e1878f..9b416b1a 100644 --- a/src/urxvt.pm +++ b/src/urxvt.pm @@ -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 for a discussion of this format. + +=item $string + +A perl text string, with an emphasis on I. 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 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 hook, though. + =item $term->tt_write ($octets) Write the octets given in C<$data> to the tty (i.e. as program input). To