*** empty log message ***
authorroot <root>
Thu, 12 Jan 2006 03:32:56 +0000 (03:32 +0000)
committerroot <root>
Thu, 12 Jan 2006 03:32:56 +0000 (03:32 +0000)
src/command.C
src/perl/selection
src/screen.C
src/urxvt.pm

index 6854f6dfa8d1def2a03796ec2506305eb599b5fb..2f908821b6c85e5019cb19fb639c7a2c7e9a9c81 100644 (file)
@@ -1922,7 +1922,7 @@ rxvt_term::button_press (XButtonEvent &ev)
 #endif
 
                   /* allow shift+left click to extend selection */
-                  if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report))
+                  if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report))
                     {
                       if (MEvent.button == Button1 && clickintime)
                         selection_rotate (ev.x, ev.y);
index e653ec10b83417a05b4e75faa2e3d3df002ec99d..0c968d438cb79a123256fc3ece95dc307cfe7624 100644 (file)
@@ -11,11 +11,7 @@ sub on_keyboard_command {
 
 # "find interetsing things"-patterns
 my @mark_patterns = (
-   # urls, just a heuristic
-   qr{(
-      (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+
-      [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~]   # exclude some trailing characters (heuristic)
-   )}x,
+   qr{([[:alnum:]]+)},
 
    # common "parentheses"
    qr{(?:^|\s) ‘  ([^‘’]+?) ’ (?:\s|\)|$)}x,
@@ -23,6 +19,12 @@ my @mark_patterns = (
    qr{         \{ ([^{}]+?) \} }x,
    qr{         \[ ([^{}]+?) \] }x,
 
+   # urls, just a heuristic
+   qr{(
+      (?:https?|ftp|news|mailto|file)://[ab-zA-Z0-9\-\@;\/?:&=%\$_.+!*\x27(),~]+
+      [ab-zA-Z0-9\-\@;\/?:&=%\$_+!*\x27()~]   # exclude some trailing characters (heuristic)
+   )}x,
+
    # shell-like argument quoting, basically always matches
    qr{\G [\ \t|&;<>()] *(
       (?:
@@ -45,15 +47,21 @@ sub on_sel_extend {
 
    my ($row, $col) = $self->selection_mark;
    my $line = $self->line ($row);
-   my $offset = $line->offset_of ($row, $col);
    my $text = $line->t;
+   my $markofs = $line->offset_of ($row, $col);
+   my $curlen  = $line->offset_of ($self->selection_end)
+               - $line->offset_of ($self->selection_beg);
+
+   my @matches;
 
    for my $regex (@mark_patterns) {
       while ($text =~ /$regex/g) {
-         if ($-[1] <= $offset and $offset <= $+[1]) {
+         if ($-[1] <= $markofs and $markofs <= $+[1]) {
             my $ofs = $-[1];
             my $match = $1;
 
+            push @matches, [$ofs, length $match];
+
             for my $regex (@simplify_patterns) {
                if ($match =~ $regex) {
                   $match = $1;
@@ -61,12 +69,24 @@ sub on_sel_extend {
                }
             }
 
-            $self->selection_beg ($line->coord_of ($ofs));
-            $self->selection_end ($line->coord_of ($ofs + length $match));
-            return 1;
+            push @matches, [$ofs, length $match];
          }
       }
    }
 
-   ()
+   for (sort { $a->[1] <=> $b->[1] or $b->[0] <=> $a->[0] } @matches) {
+      my ($ofs, $len) = @$_;
+
+      next if $len <= $curlen;
+
+      $self->selection_beg ($line->coord_of ($ofs));
+      $self->selection_end ($line->coord_of ($ofs + $len));
+      return 1;
+   }
+
+   # whole line
+   $self->selection_beg ($line->beg, 0);
+   $self->selection_end ($line->end, $self->ncol);
+
+   return 1;
 }
index 6f10e9be5ddc7751b708aebd30df32cc2dac42d3..7e178f6008680c025f3eecc3d496a4aa27b171b9 100644 (file)
@@ -3047,6 +3047,13 @@ rxvt_term::selection_click (int clicks, int x, int y)
   clicks = ((clicks - 1) % 3) + 1;
   selection.clicks = clicks;       /* save clicks so extend will work */
 
+  if (clicks == 2 && !selection.rect
+      && HOOK_INVOKE ((this, HOOK_SEL_EXTEND, DT_END)))
+    {
+      MEvent.clicks = 1; // what a mess
+      return;
+    }
+
   selection_start_colrow (Pixel2Col (x), Pixel2Row (y));
 
   if (clicks == 2 || clicks == 3)
@@ -3351,11 +3358,8 @@ rxvt_term::selection_extend_colrow (int32_t col, int32_t row, int button3, int b
       if (ROWCOL_IS_AFTER (selection.end, selection.beg))
         selection.end.col--;
 
-      if (!HOOK_INVOKE ((this, HOOK_SEL_EXTEND, DT_END)))
-        {
-          selection_delimit_word (UP, &selection.beg, &selection.beg);
-          selection_delimit_word (DN, &selection.end, &selection.end);
-        }
+      selection_delimit_word (UP, &selection.beg, &selection.beg);
+      selection_delimit_word (DN, &selection.end, &selection.end);
     }
   else if (selection.clicks == 3)
     {
index 8b994530bf135d0ff66742f3d5a1fc1055b16765..2b852a63bab33bdc6e2cc7258a48093e9e8e6eea 100644 (file)
@@ -232,7 +232,9 @@ Returning a true value aborts selection grabbing. It will still be hilighted.
 Called whenever the user tries to extend the selection (e.g. with a double
 click) and is either supposed to return false (normal operation), or
 should extend the selection itelf and return true to suppress the built-in
-processing.
+processing. This can happen multiple times, as long as the callback
+returns true, it will be called on every further click by the user and is
+supposed to enlarge the selection more and more, if possible.
 
 See the F<selection> example extension.
 
@@ -597,6 +599,9 @@ sub invoke {
             warn $@;
          }
       }
+
+      verbose 11, "$HOOKNAME[$htype] returning <$retval>"
+         if $verbosity >= 11;
    }
 
    if ($htype == 1) { # DESTROY
@@ -1220,7 +1225,8 @@ Return the row number of the first/last row of the line, respectively.
 =item $offset = $line->offset_of ($row, $col)
 
 Returns the character offset of the given row|col pair within the logical
-line.
+line. Works for rows outside the line, too, and returns corresponding
+offsets outside the string.
 
 =item ($row, $col) = $line->coord_of ($offset)
 
@@ -1585,7 +1591,9 @@ numbers indicate more verbose output.
 
 =item >= 3 - script loading and management
 
-=item >=10 - all events received
+=item >=10 - all called hooks
+
+=item >=11 - hook reutrn values
 
 =back