mIRC Home    About    Download    Register    News    Help

Print Thread
#189836 12/11/07 04:21 AM
Joined: Nov 2003
Posts: 50
X
x64 Offline OP
Babel fish
OP Offline
Babel fish
X
Joined: Nov 2003
Posts: 50
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.

Last edited by x64; 12/11/07 04:21 AM.
x64 #189847 12/11/07 01:48 PM
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
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



"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
jaytea #189849 12/11/07 02:49 PM
Joined: Oct 2007
Posts: 51
T
Babel fish
Offline
Babel fish
T
Joined: Oct 2007
Posts: 51
So it doesn't even need to be added, all you gotta do is findtext.

Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
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.

Bekar #189876 12/11/07 08:17 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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

Horstl #189880 12/11/07 08:41 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
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-)

Horstl #189882 12/11/07 08:53 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
qwerty #189883 12/11/07 08:57 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
The tremendous sound of Horstls hand clapping on his forehead sounds through these forums smirk
thx

qwerty #189884 12/11/07 09:01 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Thing is highlight entries can be set for 'message', 'nick' or 'both' so you should include $nick making $lf un-needed wink

deegee #189886 12/11/07 09:08 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.

Last edited by qwerty; 12/11/07 09:17 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
qwerty #189888 12/11/07 09:20 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
hum, so $ishighlight remains (maybe) a valid suggestion laugh

qwerty #189889 12/11/07 09:28 PM
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Actually such an entry triggers with "$1- $+ $lf" but not with "$nick $1-"


Last edited by deegee; 12/11/07 09:30 PM.
deegee #189899 12/11/07 10:27 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Horstl #196009 07/03/08 07:44 PM
Joined: Nov 2004
Posts: 22
G
Ameglian cow
Offline
Ameglian cow
G
Joined: Nov 2004
Posts: 22
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: https://forums.mirc.com/ubbthreads.php?ubb=showflat&Number=196007&page=0#Post196007


Link Copied to Clipboard