mIRC Home    About    Download    Register    News    Help

Print Thread
#229295 29/01/11 05:08 AM
Joined: Jan 2011
Posts: 5
F
Fenton Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Jan 2011
Posts: 5
It would be really nice if there were an option to open URLs with one click rather than two. Perhaps even coloring them similar to how they are on websites.

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
in the mean time, both of these things can be scripted in a way that recreates mIRC's default behaviour to an extent that should be satisfactory for the majority of users.

you can detect single clicks on (whole) words using a HOTLINK event. validating a URL is trickier, and i've attempted to create a pattern that fits mIRC's own detection scheme as close as possible while staying relatively simple:

Code:
; Detects single clicks on URLs.
; Holding shift or ctrl will have them open in a new window, if your browser permits.
;
on ^*:hotlink:*:*:{
  if ($mouse.key & 1) && ($regex($1, $urlre)) {
    url -a $+ $iif($mouse.key & 6, n) $regml(1)
  }
  halt
}

; $urlre
; Returns a regular expression that matches URLs in a string and captures them in \1.
;
alias urlre {
  return /(*UTF8) (?:^|[\x20\x09]) [\Q '<([{" \E]* \K (                              $&
    (?: (?:irc|gopher|https?|ftps?|telnet):// 	| (?:www|ftp)\. )                    $& 
    [^\x20\x09]+\.[^\x20\x09]+? ) (?= [\Q ')]}>"., \E]* (?:[\x20\x09]|$) ) /giSx
}


various subtleties have been neglected either because they're difficult to account for (determining the character position of the mouse on the word in on HOTLINK) or because adding support would really inflate the code (such as replicating precisely mIRC's handling of brackets/quotes touching a URL - this cannot be done in a single regular expression).

as for the colouring, here's an example that uses the $urlre pattern included in the snippet above:

Code:
on &^*:text:*:*:{
  echo -mbflirt $iif(#, #, $nick) $+(<, $left($nick(#, $nick, a, r).pnick, 1), $nick, >) $urlcolour($1-)
  haltdef
}

; $urlcolour(text)
; Returns 'text' with URLs appropriately coloured and underlined.
;
alias urlcolour {
  return $regsubex($1, $urlre, $+($chr(31), $chr(3), 12\1, $chr(3), $chr(31)))
}

; American-friendly version!
;
alias urlcolor return $urlcolour($1)


with this, the loss of certain parts of mIRC's own behaviour might be more apparent, a topic about which one could certainly write a lot!


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Jan 2011
Posts: 5
F
Fenton Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Jan 2011
Posts: 5
Thanks, those work nicely, but is there a way to still have the address book color nicknames? Seems the url color script makes all nicknames black regardless of the address book settings.

Joined: Nov 2009
Posts: 295
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
It's a bit long but this colors the nick the same as mirc does.

Code:
$+(<,,$nick($chan,$nick).color,$iif($left($nick($chan,$nick).pnick,1) isin $prefix,$v1),$nick,>)


Just replace the "$+(<, $left($nick(#, $nick, a, r).pnick, 1), $nick, >)" part with that and you should be good

Last edited by pball; 29/01/11 04:18 PM.

http://scripting.pball.win
My personal site with some scripts I've released.
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Originally Posted By: pball
It's a bit long but this colors the nick the same as mirc does.
You're actually making it longer by using $chan lol But it doesn't make any difference really.

Joined: Nov 2009
Posts: 295
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
Using $chan over # is just a personal preference for me. I started using $chan so it seems normal and # I don't like since I always forget it's a special character.


http://scripting.pball.win
My personal site with some scripts I've released.
Joined: Jan 2011
Posts: 5
F
Fenton Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
F
Joined: Jan 2011
Posts: 5
Sorry to be a bother but when I replaced it all nicks are still black, they also have a 1 in front of them.

Joined: Oct 2003
Posts: 3,918
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
I'd suggest replacing the control codes with $chr(3) to be more easily copied.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I don't quite get the deal with isin $prefix when the whole thing can just be:
Code:
$+(<,$chr(3),$nick(#,$nick).color,$nick(#,$nick).pnick,$chr(3),>)

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
Originally Posted By: Tomao
I don't quite get the deal with isin $prefix when the whole thing can just be:
Code:
$+(<,$chr(3),$nick(#,$nick).color,$nick(#,$nick).pnick,$chr(3),>)


it serves a purpose. $nick().pnick returns the nick with the full set of associated prefixes. that means if Bob is both oped and voiced on #chan, $nick(#chan, Bob).pnick = @+Bob

the point of my $left() and pball's $iif() is to extract only the highest prefix (if one exists) and prepend it to $nick to yield the prefix+nick combination that mIRC shows by default.


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Dec 2002
Posts: 344
D
Pan-dimensional mouse
Offline
Pan-dimensional mouse
D
Joined: Dec 2002
Posts: 344
The script given in this thread was meant more as an example to demonstrate the way you might go about changing the way URLs appear via scripting, not really a feature complete implementation to be directly copied. (Even with the control codes fixed, it wouldn't handle query colors or your own text.)

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Thanks, jaytea. That explains it.


Link Copied to Clipboard