mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2010
Posts: 1
A
avah Offline OP
Mostly harmless
OP Offline
Mostly harmless
A
Joined: Oct 2010
Posts: 1
Hello All

I tried to find information about this feature from these forums and google, but my searches turned up nothing that matches my needs.

I would like to have URL's that appear in a chat window to be highlighted with a selectable color and character style (e.g. underline). Not the whole line, but only the URL part. I'm aware of the URL catcher, address book's highlight features and color schemes, but these don't match my needs. I don't want to open links blindly from the catcher window, instead I would like to see the context these addresses appear in and highlighting would make it much easier. On the other hand, highlighting the whole line would be both overkill and confusing. Finally, color schemes doesn't seem have dedicated color for clickable links at all?

I couldn't find any third party script for this, and despite my relatively long experience with PC's and IRC, I'm not much of a scripter my self. I would very much appreciate if this kind of feature could be implemented in mIRC.


Thank you!

-A-

Joined: Jun 2007
Posts: 933
5
Hoopy frood
Offline
Hoopy frood
5
Joined: Jun 2007
Posts: 933
You can achieve this also by using the on HOTLINK event and then echoing the line and halting the default text.
You probably want to use a regex match for catching URLs.

That said, this could be a desirable default function.

Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
to add a little to this, the largest hump would be color codes AFTER the URL; getting it use the codes that were active before it to still be active after highlighting


I am SReject
My Stuff
Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
Originally Posted By: FroggieDaFrog
to add a little to this, the largest hump would be color codes AFTER the URL; getting it use the codes that were active before it to still be active after highlighting


It's actually really easy to do this...


Beware of MeStinkBAD! He knows more than he actually does!
Joined: Nov 2009
Posts: 295
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
if that's really easy could you please post an example. I made something similar and highlighting just a word and leaving the other color/control codes intact was quite hard.


http://scripting.pball.win
My personal site with some scripts I've released.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I know very little about regex, but here's an example to handle the colors. I'm sure a similar method (and better set up regex) can just as easily do the rest of the control codes.

Code:
alias test {
  var %pos1 = $pos($1-,http), %pos2 = $pos($right($1-,- $+ %pos1),$chr(32))
  var %a = $left($1-,$calc(%pos1 - 1))
  var %b = 11 $+ $mid($1-,%pos1,%pos2) $+ 
  if ($regex(%a,/([0-9]{1,2})/g)) { var %color = $regml($regml(0)) }
  var %c = %color $+ $right($1-,$calc($len($1-) - %pos1 - %pos2))
  echo -a %a %b %c
}


Test case:
/test this is a 04colored 03link http://www.mirc.com/ to get help

Now, as I said, I don't really know regex... this is really my first time coming up with anything that actually works with regex. wink So, this definitely can be cleaned up ... a LOT. And I also didn't work too hard at making any of the rest look nice either. I was mainly just trying to get a working example of the regex part set up and just threw together the rest to show how it would work.

Also, this doesn't take into account certain situations (such as the use of Ctrl-O or multiple links) that may affect the output. However, it should show that obtaining the previous color shouldn't be too difficult. I'm looking forward to seeing a regex pro's example to see how far or close I am. laugh

A final note -- You'd want to use a regex to match the URL instead of using "http". I just used that for a quick example.


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
Don't use REGEX... use $pos($1-,$chr(3))... then search offset of that for...
if +1 == NUM then
if +2 == NUM then
if +3 == , then
if +4 == NUM then
if +5 == NUM

etc...

I've written color parsers for mIRC and Ircle... both using a scripting langauge and ANSI C. Real simple...

I wish I could find the code... lol...

Last edited by MeStinkBAD; 01/11/10 07:12 PM.

Beware of MeStinkBAD! He knows more than he actually does!
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
First problem I can see using $pos($1-,$chr(3)) is that it returns the first position, so if there's more than one $chr(3) you might not get the correct colour codes. Additionally, this doesn't take into account bold, underlining, or reverse character codes.


Link Copied to Clipboard