mIRC Home    About    Download    Register    News    Help

Print Thread
N
NorxMAL
NorxMAL
N
This is the code I wrote
Code:
on *:TABCOMP:#: {
  if ( $nick($chan,$1) != $null ) || ( $nick($chan,$left($1,$calc($len($1)-1))) != $null ) { 
    if ( $right($1,1) == $chr(44) ) { 
      /editbox -a left($1,1)
    }
    else {
      /editbox -ap $1 $+ $chr(44)
    }
    haltdef
  }
}


Problem is that I can't retrieve what was typed before TAB was pressed in the ON TABCOMP, and to cycle nicks one need to double tap TAB for the next one to show.

Joined: Oct 2003
Posts: 3,641
A
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,641
FYI this belongs in "Scripts & Popups"

Originally Posted By: NorxMAL
Problem is that I can't retrieve what was typed before TAB


Sure you can, just use $editbox().selstart to get the position of the caret in the $editbox() line.

N
NorxMAL
NorxMAL
N
I ask a moderator to move it now smile

Thanks for the tip smile

N
NorxMAL
NorxMAL
N
I fixed it with this code smile
Code:
on *:TABCOMP:#: {
  if  ( $2 == $null ) {
    if ( %tabn != $left($1,$len(%tabn)) ) {  
      unset %tabm
      unset %tabn
    }
    if ( %tabm == $null ) { set %tabn $left($1,$calc($editbox($active).selstart -1)) }
    var %tabv 0
    :tab
    inc %tabv 1
    if ( %tabn == $left($nick($chan,%tabv),$len(%tabn)) ) { set %tabm $addtok(%tabm,$nick($chan,%tabv),58) }
    if ( $nick($chan,0) >= %tabv ) { goto tab }
    if ( %tabac >= $gettok(%tabm,0,58) ) { set %tabac 0 }
    inc %tabac 1
    /editbox -ap $gettok(%tabm,%tabac,58) $+ $chr(44)
    haltdef
  }
}


Edit : haltdef in the wrong place

Last edited by NorxMAL; 07/07/12 08:56 PM.
N
NorxMAL
NorxMAL
N
Improvement on the script
Code:
on *:TABCOMP:#: {
  if  ( $2 == $null ) {
    if ( %tabn != $left($1,$len(%tabn)) ) {
      unset %tabm
      unset %tabn
    }
    set %tabedit $left($1,$calc($editbox($active).selstart -1))
    var %tablen $len($remove($left($1,$calc($editbox($active).selstart -1)),$chr(44)))
    if ( %tabedit != $left(%tabm,%tablen) ) && ( $right(%tabedit,1) != $chr(44) ) {
      unset %tabm
    }
    if ( %tabm == $null ) { set %tabn $left($1,$calc($editbox($active).selstart -1)) }
    var %tabv 0
    :tab
    inc %tabv 1
    if ( %tabn == $left($nick($chan,%tabv),$len(%tabn)) ) { set %tabm $addtok(%tabm,$nick($chan,%tabv),58) }
    if ( $nick($chan,0) >= %tabv ) { goto tab }
    if ( %tabac >= $gettok(%tabm,0,58) ) { set %tabac 0 }
    if ( %tabm == $null ) { halt }
    inc %tabac 1
    /editbox -ap $gettok(%tabm,%tabac,58) $+ $chr(44)
    haltdef
  }
}


edit : did a /set to /var instead
edit 2 : Further improvement

Last edited by NorxMAL; 08/07/12 12:08 PM.
T
Tomao
Tomao
T
You can improve it a tad further by using:
Code:
unset %tabm %tabn
Or to remove all of the variables starting with %tab:
Code:
unset %tab*
Your overall snippet can be shortened even more, but good job on that nevertheless.

R
r0ot
r0ot
R
This is an awesome script. Thank you.

I know I can make <nick> bold when it's first, but can't seem to figure out how I can do the same when <nick> is after or in the middle of a sentence.

Thanks!

Last edited by r0ot; 14/04/14 09:53 PM.
B
blessing
blessing
B
Good snippet. Well done.

It can be improved not only for channel window. Also coloring, bold, etc. I will try if i have time.

R
r0ot
r0ot
R
Thanks you blessing. Looking forward to it smile

B
blessing
blessing
B
This is what i have.

The script works on channel and chat window.
The nick can be customized and not only work on first word in editbox, but also anywhere after that.
You can put color, bold, underline on nick, or give some style to it like *nick* [~*<nick>*~] etc.

var %f1 is nick on first word in editbox
var %f2 is nick anywhere after %f1
You can edit it as you wish.

i hope it works as expected.

Code:
on *:tabcomp:*:{
  var %f1 nick:
  var %f2 *nick*
  
  var %t $target, %eb $1-, %nt $numtok(%eb,32), %f $iif(%nt > 1,%f2,%f1), %a 1
  while %a < $len(%f) {
    if $mid(%f,%a,4) == nick { dec %a | break }
    inc %a
  }
  var %aa $iif(%a,$mid(%f,1,%a)), %bb $mid(%f,$calc(%a + 5))
  var %et $gettok(%eb,1 - $calc(%nt - 1),32), %e $gettok(%eb,-1,32)
  var %ee $iif($remove(%e,%aa,%bb) == %nc.nick,%nc.nick,%e)
  var %p $iif($remove(%e,%aa,%bb) == %nc.nick,%nc.pos,$calc($editbox(%t).selstart - 1 - $iif(%nt > 1,$calc($len(%et) + 1),0))) 
  var %i $calc($nick(%t,%ee) + $iif($left(%nc.nick,%p) == $left(%ee,%p) && %nc.pos == %p,1,0))
  if %t ischan {
    var %n $nick(%t,$nc(%t,%i,%p,%ee))
    if !%n { var %n $nick(%t,$nc(%t,1,%p,%ee)) }
  }
  else { var %n $iif($+($mid(%ee,1,%p),*) iswm %t,%t) }
  if %n {
    haltdef
    var %lt $+(%aa,%n,%bb), %text $iif(%nt > 1,$+(%et,$chr(32),%lt),%lt)
    editbox -ap %text
    set -e %nc.pos %p
    set -e %nc.nick %n
  }    
}

alias -l nc {
  var %t $1, %i $2, %p $3, %ee $4, %b 1
  while $nick(%t,%i) {
    var %n $v1 
    if $+($mid(%ee,1,%p),*) iswm %n { var %b 0 | break }
    inc %i
  }
  return $calc(%i + %b) 
}

R
r0ot
r0ot
R
Dude...its beautiful!


Link Copied to Clipboard