... | ... |
@@ -30,6 +30,7 @@ set curselection "" |
30 | 30 |
|
31 | 31 |
set lastseconds 0 |
32 | 32 |
set nstolen 0 |
33 |
+set lastfile "" |
|
33 | 34 |
|
34 | 35 |
proc selectionlost {} { |
35 | 36 |
global curselection |
... | ... |
@@ -47,9 +48,11 @@ proc selectionlost {} { |
47 | 48 |
set nstolen 0 |
48 | 49 |
} |
49 | 50 |
# process the selection |
50 |
- set curselection [selection get -selection PRIMARY] |
|
51 |
- puts $curselection |
|
52 |
- checkselection $curselection |
|
51 |
+ catch { |
|
52 |
+ set curselection [selection get -selection PRIMARY] |
|
53 |
+ puts $curselection |
|
54 |
+ checkselection $curselection |
|
55 |
+ } |
|
53 | 56 |
selection own -selection PRIMARY -command selectionlost "." |
54 | 57 |
} |
55 | 58 |
|
... | ... |
@@ -59,12 +62,10 @@ proc selectionrequest { offset maxchars } { |
59 | 62 |
} |
60 | 63 |
|
61 | 64 |
proc checkselection { curselection } { |
62 |
- global env |
|
65 |
+ global env lastfile |
|
63 | 66 |
set socketsdir /tmp/.re_$env(USER) |
64 |
- set filenames [list] |
|
65 |
- catch { |
|
66 |
- set filenames [glob -tails -directory $socketsdir ) *] |
|
67 |
- } |
|
67 |
+ set filenames [glob -tails -directory $socketsdir ) *] |
|
68 |
+ # search for occurrences of <filename>:<line>[:<col>] |
|
68 | 69 |
foreach f $filenames { |
69 | 70 |
set index -1 |
70 | 71 |
set flen [string length $f] |
... | ... |
@@ -82,9 +83,14 @@ proc checkselection { curselection } { |
82 | 83 |
} |
83 | 84 |
set newpos [string range $curselection $startindex $index-1] |
84 | 85 |
remotecontrol $socketsdir $f "goto $newpos" |
86 |
+ set lastfile $f |
|
85 | 87 |
} |
86 | 88 |
} |
87 | 89 |
} |
90 |
+ # if it is just <line>, set last used file to that line (useful for gdb) |
|
91 |
+ if { [string length $lastfile]>0 && [string is ascii $curselection] && [string is digit $curselection] } { |
|
92 |
+ remotecontrol $socketsdir $lastfile "goto $curselection" |
|
93 |
+ } |
|
88 | 94 |
} |
89 | 95 |
|
90 | 96 |
proc remotecontrol { socketsdir filename command } { |