mIRC Homepage

Jump to hilight

Posted By: x64

Jump to hilight - 12/11/07 04:21 AM

When i get back to my computer, i often have several channels flashing in hilighted state, but i usually have to scroll up looking for the hilighted text, since there doesn't seem to be any way (except perhaps iterating through every line in a window progmatically looking for hilighted lines) to jump right to the last hilighted line. Correct me if i'm wrong, but i can't find any "jump to highlight" command anywhere.
Posted By: jaytea

Re: Jump to hilight - 12/11/07 01:48 PM

i find myself needing this quite often too :P i just make do with /findtext jaytea (which searches for 'jaytea' upwards and seeks to the first matching line). of course, this is enough for me because i just have one highlight entry.. but i can understand the need for such an inbuilt feature if your highlight list is long and complicated

one could try to make a snippet that uses /findtext with $highlight, $fline, etc. but it wouldn't be very functional due to certain mIRCscript inadequacies.. you can't return the current scrollbar position of a channel window, you can't seek to a specific line (without /findtext), you can't (immediately) find a line of a certain color

here's a couple of simple aliases i just added, inspired by this suggestion ;D

Code:
alias f2 findtext -n jaytea
alias f3 findtext jaytea


f2 searches downwards, f3 searches upwards

Posted By: Trashlord_

Re: Jump to hilight - 12/11/07 02:49 PM

So it doesn't even need to be added, all you gotta do is findtext.
Posted By: Bekar

Re: Jump to hilight - 12/11/07 08:01 PM

Using $fline() and $line() coupled with $highlight(), you can pull out all the highlighted lines and do something with them..

Not quite as useful as a jump-to-highlight, but something that can be done now.
Posted By: Horstl

Re: Jump to hilight - 12/11/07 08:17 PM

I think there's no easy AND accurate way to detect highlighting with scripted means, which I want to demonstrate below.

The $highlight identifier allows cycling through all highlight entries:
Code:
alias listhighlight {
  var %nr = 1
  while ($highlight(%nr)) {
    echo -na HIGHLIGHT nr. %nr is $v1 
    echo -na SETTINGS: match regex: $iif($highlight(%nr).regex,yes,no) $&
       match nicks: $iif($highlight(%nr).nicks,yes,no) $&
       message: $iif($highlight(%nr).message,$v1,none) $&
       flash: $iif($highlight(%nr).flash,$v1 times,no) $&
       tip: $iif($highlight(%nr).tip,$v1 seconds,no) $&
       sound: $iif($highlight(%nr).sound,$v1,none)  colour: $iif($highlight(%nr).colour,$v1,none) 
    inc %nr
  }
}
Side Note: $highlight().regex and $highlight().tip are not officially documentated, and I did not find the property for case seinsitive by guessing so far...

One can return if highlight is enabled or not as well.. $highlight (without property).

But the trouble begins when trying to catch all highlights correctly. For example:
Code:
on *:text:*:*: {
  if ($highlight($1-)) { echo -anc highlight Highlight triggers (matching: $highlight($1-).text $+ ) }
}
This works apparently well. But $highlight uses the syntax $highlight(N/text). Now, if text == N? That is: if someone sends the message "1"? confused

Therefore, one needs to go the other way round (evaluate all highlight entries against the given text).
Pseudocode:
Code:
event or text to loop {
  while $highlight(N) {
    if (the highlight is a regex) { check for (regex(text,highlight) }
    elseif (the highlight contains wildcards) { check for (highlight iswm text) }
    else { check for (istok(highlight,text,32)) }
  }
}
And this does not even take the "case sensitive" switch into account.... to me, that seems quite intricately. frown

Thus, I am looking forward for (I'm aware of the fact that this has been requested before)

- an ishighlight operator:
if (<text> ishl) { }
... allowing easy loops through blocks of text

and / or (more important):

- an $ishighlight identifier returning $true/$false for on text/on action events:
if ($ishiglight) { }
... allowing easy event-related highlight scripting


PS: In addition, a switch ignore -h(ighlight) would be most welcome. S

Sorry for the lengthy post smile
Posted By: deegee

Re: Jump to hilight - 12/11/07 08:41 PM

Originally Posted By: Horstl

But the trouble begins when trying to catch all highlights correctly. For example:
Code:
on *:text:*:*: {
  if ($highlight($1-)) { echo -anc highlight Highlight triggers (matching: $highlight($1-).text $+ ) }
}
This works apparently well. But $highlight uses the syntax $highlight(N/text). Now, if text == N? That is: if someone sends the message "1"? confused

Well, the simple (and proper) way is to check $highlight($nick $1-)
Posted By: qwerty

Re: Jump to hilight - 12/11/07 08:53 PM

Quote:
But $highlight uses the syntax $highlight(N/text). Now, if text == N? That is: if someone sends the message "1"?
A way around that is $highlight($1- $+ $lf). A line feed cannot be part of an IRC message or entered in Highlight, so it's a safe choice of padding, although not very pretty.
Posted By: Horstl

Re: Jump to hilight - 12/11/07 08:57 PM

The tremendous sound of Horstls hand clapping on his forehead sounds through these forums smirk
thx
Posted By: deegee

Re: Jump to hilight - 12/11/07 09:01 PM

Thing is highlight entries can be set for 'message', 'nick' or 'both' so you should include $nick making $lf un-needed wink
Posted By: qwerty

Re: Jump to hilight - 12/11/07 09:08 PM

True, although now that regex is supported, this could break too, eg if you set the entry /^deegee$/ to "Nick only" and use $highlight($nick $1-). Also, both $highlight($1- $+ $lf) and $highlight($nick $1-) would break (regardless of the regex setting) if somebody else said "hello deegee" (it would make $highlight return $true). A complete solution would have to take into account $highlight().nicks too, at least.
Posted By: Horstl

Re: Jump to hilight - 12/11/07 09:20 PM

hum, so $ishighlight remains (maybe) a valid suggestion laugh
Posted By: deegee

Re: Jump to hilight - 12/11/07 09:28 PM

Actually such an entry triggers with "$1- $+ $lf" but not with "$nick $1-"

Posted By: qwerty

Re: Jump to hilight - 12/11/07 10:27 PM

If you specify /^deegee$/ as "Nick only" in Highlight and then type "//msg $me blah", the line will be highlighted (because your nick is deegee) but $highlight($nick $1-) will return $null, so will $highlight($1- $+ $lf) of course (false negative).

On the other hand, if you specify "deegee" (no regex) as "Nick only" and somebody that's not deegee says "deegee", both versions will return $true (false positive).

What I'm saying is that just including $nick in $highlight (whether you suffix $1- with $lf or not) is not going to solve the nick/message/both problem.
Posted By: gencha

Re: Jump to hilight - 07/03/08 07:44 PM

I was directed to this thread because of another, similar issue i had in another thread. I implemented a function to determine whether a given text matches a highlight.
To avoid duplication, here is a link to the according post: http://forums.mirc.com/ubbthreads.php?ubb=showflat&Number=196007&page=0#Post196007
© 2021 mIRC Discussion Forums