Vogon poet
Joined: Dec 2015
Posts: 147 |
Well, the second one is technically a button so you could make it look at the topic and open link(s) when you click it.
on *:start:tbtopic
alias tbtopic {
unset %tb.*
if ($toolbar(tb.topic)) {
window -c @tb.topic
toolbar -d tb.topic
.timertb.topic off
}
else {
window -hfp @tb.topic -1 -1 256 16
set -e %tb.pos 0
set -eu2 %tb.pause 1
toolbar -a tb.topic "Channel topic" @tb.topic 0 0 256 16 /topiclinks
.timertb.topic -iom 0 20 tupdate
}
}
alias -l tupdate {
if (%tb.active != $active) { set -e %tb.active $v2 | set -e %tb.pos 0 | set -eu2 %tb.pause 1 }
var %t = $iif(%tb.active ischan,$iif($chan($active).topic,$v1,No topic.),$v1)
drawrect -fn @tb.topic $color(background) 1 0 0 256 16
if ($width(%t,Tahoma,-9,0,1) > 256) {
if (%tb.pos >= $calc(48+$v1)) { set -e %tb.pos 0 | set -eu2 %tb.pause 1 }
drawtext -np @tb.topic $color(topic) Tahoma -9 - $+ %tb.pos 0 %t $str($chr(160),10) %t
if (!%tb.pause) inc -e %tb.pos
}
else drawtext -np @tb.topic $color(topic) Tahoma -9 - $+ %tb.pos 0 %t
toolbar -p tb.topic @tb.topic 0 0 256 16
}
alias -l topiclinks {
var %x = 1,%t $replacex($strip($chan($active).topic),$chr(28),$chr(32),$chr(29),$chr(32),[,$chr(32),],$chr(32),<,$chr(32),>,$chr(32),$chr(123),$chr(32),$chr(124),$chr(32),$chr(125),$chr(32),$chr(44),$chr(32))
while ($wildtok(%t,*?.?*,%x,32)) {
tokenize 1 $v1
if ($wildtok($1,http://?*.??*,1,32)) || ($wildtok($1,https://?*.??*,1,32)) || ($wildtok($1,www.?*.??*,1,32)) url -a $v1
inc %x
}
}
It will open all of the links it detects in the topic. Getting a whole new bar for it should be possible with possibly dcx.dll, but it would require more work. And while I was typing this I got a new idea, and decided to play around:
alias topicbar {
var %x = 1,%m $window(-3).dw $calc($window(-3).dh -25),%a $active
while ($window(*,%x)) {
window -r $qt($v1) 0 25 %m
inc %x
}
window -a $qt(%a)
window -pw0 +d @topicbar 0 0 $window(-3).dw 25
set %topicbar.tx 4
.timertopicbar -iom 0 500 topicbar.refresh
topicbar.refresh
}
alias -l topicbar.refresh {
var %a = $iif($active == @topicbar,$lactive,$active)
if (%a != %topicbar.lw) set -e %topicbar.tx 4
drawrect -fn @topicbar $color(background) 1 0 0 $window(@topicbar).dw $window(@topicbar).dh
drawtext -np @topicbar $color(topic) Tahoma -11 %topicbar.tx 1 $iif(%a ischan,$iif($chan(%a).topic,$v1,No topic.),$v1)
drawdot @topicbar
}
menu @topicbar {
mouse: {
if (%topicbar.mx) {
tokenize 32 %topicbar.mx $mouse.x
%topicbar.tx = $calc($2 -$1)
%topicbar.lw = $iif($active == @topicbar,$lactive,$active)
topicbar.refresh
}
}
sclick:set %topicbar.mx $mouse.x
uclick:unset %topicbar.mx | window -a $qt($lactive)
$submenu($topicbar.links($1))
-
Reset topic position:set %topicbar.tx 4 | topicbar.refresh
Reset window positions:topicbar
-
Close:window -c @topicbar | .timertopicbar off | unset %topicbar.*
}
alias topicbar.links {
if ($1 == begin) { set -eu1 %topicbar.x 1 | set -eu1 %topicbar.topic $replacex($strip($chan($iif($active == @topicbar,$lactive,$active)).topic),$chr(28),$chr(32),$chr(29),$chr(32),[,$chr(32),],$chr(32),<,$chr(32),>,$chr(32),$chr(123),$chr(32),$chr(124),$chr(32),$chr(125),$chr(32),$chr(44),$chr(32)) }
elseif ($wildtok(%topicbar.topic,*?.?*,%topicbar.x,32)) {
tokenize 1 $v1
inc %topicbar.x
if ($wildtok($1,http://?*.??*,1,32)) || ($wildtok($1,https://?*.??*,1,32)) || ($wildtok($1,www.?*.??*,1,32)) return $replacex($v1,:,;) :url -a $v1
}
elseif ($1 == end) unset %topicbar.x %topicbar.topic
}
It probably needs quite a bit of tweaking, but it's kind of what you wanted. You can start it by typing /TOPICBAR. If you right click the window it'll open a menu that has the links listed in the topic (also a few other options). If you left click it, hold the button down and move your mouse, it'll move the topic around. That way you'll be able to see the whole topic.
|