mIRC Home    About    Download    Register    News    Help

Print Thread
Highlighting a single word, not a line: possible? #241867 31/05/13 12:27 AM
Joined: May 2011
Posts: 53
S
sandygws Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: May 2011
Posts: 53
I'd like to highlight a single word - 'new' - in green and another single word - 'done' - in blue.

It seems the built in highlight function only permits a whole line/string to be highlighted.

Is there a way to highlight a single word - ideally in a specific channel, not across all channels?

Re: Highlighting a single word, not a line: possible? [Re: sandygws] #241894 01/06/13 05:43 AM
Joined: Oct 2012
Posts: 164
D
Deega Offline
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
Not with the Highlight feature, but you could do it with an on ^text script.
/help halting default text
/help on text

Re: Highlighting a single word, not a line: possible? [Re: Deega] #242327 05/07/13 04:00 AM
Joined: Jul 2013
Posts: 4
E
ERIC_ESOT Offline
Self-satisified door
Offline
Self-satisified door
E
Joined: Jul 2013
Posts: 4
PLEASE explain ur answer is all greek to a newb like me ty.

Re: Highlighting a single word, not a line: possible? [Re: ERIC_ESOT] #242328 05/07/13 04:18 AM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
You can use somthing like this. (Untested)
Code:
on ^*:text:*:#: {
 if (word iswmcs $1-) { haltdef | echo -mt This is a new text. }
 elseif (word2 iswmcs $1-) { haltdef | echo -mt This is a new text. }
}

You can look at the commands by type in mirc:

/help halting default text
/help on text


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: Highlighting a single word, not a line: possible? [Re: ERIC_ESOT] #242349 06/07/13 04:51 AM
Joined: Oct 2012
Posts: 164
D
Deega Offline
Vogon poet
Offline
Vogon poet
D
Joined: Oct 2012
Posts: 164
O.K. Feast your eyes on some more greek smile
Code:
on $&^*:text:/\b(new|done)\b/Si:*:{
  var %a = $regsubex($1-,/\b(new)\b/gi,3\t)
  var %a = $regsubex(%a,/\b(done)\b/gi,4\t)
  echo -mirctbfl normal $iif(#,#,$nick) $+(<,$nick,>) %a
  haltdef
}


This line checks for the words "new" or "done" in a message.
on $&^*:text:/\b(new|done)\b/Si:*:{

Replace all instances of "new" with (coloured) "new"
var %a = $regsubex($1-,/\b(new)\b/gi,3\t)

Replace the word(s) "done" with "done"
var %a = $regsubex(%a,/\b(done)\b/gi,12\t)

Display the line
echo -mirctbfl normal $iif(#,#,$nick) $+(<,$nick,>) %a

Halt the default output
haltdef

The end of the script
}

Re: Highlighting a single word, not a line: possible? [Re: Deega] #249035 11/11/14 11:45 PM
Joined: Nov 2014
Posts: 5
RonnyJ Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
Joined: Nov 2014
Posts: 5
Hi there,

I just found this script after searching for a script to highlight only single words in mIRC.

I am not sure if anyone follows this thread any longer, but I have two questions.

1: Is it possible to adjust the script to match for the proper capitalization of the word aswell, so it only matches New ?

2: I tried to add a word followed by colon, like New: but the script would not work. Is there a way to make the script do this ?

Thanks in advance

Re: Highlighting a single word, not a line: possible? [Re: RonnyJ] #249040 12/11/14 01:26 AM
Joined: Jan 2004
Posts: 1,322
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,322
Code:
on $&^*:text:/\b(New|Done)\x3A\b/S:*:{
  var %a = $regsubex($1-,/\b(New):\b/g,3\t)
  var %a = $regsubex(%a,/\b(Done):\b/g,4\t)
  echo -mirctbfl normal $iif(#,#,$nick) $+(<,$nick,>) %a
  haltdef
}


Remove the "i" modifier to force case sensitivity, ":" is meaningful in event headers, so escape it as \x3A

Re: Highlighting a single word, not a line: possible? [Re: Loki12583] #249044 12/11/14 04:41 AM
Joined: Nov 2014
Posts: 5
RonnyJ Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
Joined: Nov 2014
Posts: 5
I removed the i-modifier, and case sensitivity works now, thanks.

Although, the changes involving colon does not work. I just copy/pasted your code and New: and Done: are not colored.

Re: Highlighting a single word, not a line: possible? [Re: RonnyJ] #249045 12/11/14 05:14 AM
Joined: Jan 2004
Posts: 1,322
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,322
I see, it was the word boundaries. You can try either of these, the former will color the colon and the latter will not.

Code:
on $&^*:text:/\b(New|Done)\x3A/S:*:{
  var %a = $regsubex($1-,/\b(New:)/g,3\t)
  var %a = $regsubex(%a,/\b(Done:)/g,4\t)
  echo -mirctbfl normal $iif(#,#,$nick) $+(<,$nick,>) %a
  haltdef
}


Code:
on $&^*:text:/\b(New|Done)\x3A/S:*:{
  var %a = $regsubex($1-,/\b(New)(?=:)/g,3\t)
  var %a = $regsubex(%a,/\b(Done)(?=:)/g,4\t)
  echo -mirctbfl normal $iif(#,#,$nick) $+(<,$nick,>) %a
  haltdef
}

Re: Highlighting a single word, not a line: possible? [Re: Loki12583] #249046 12/11/14 05:24 AM
Joined: Nov 2014
Posts: 5
RonnyJ Offline
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
Joined: Nov 2014
Posts: 5
Works like a charm, thank you so much (=