On tabcomp

From Scriptwiki
Jump to: navigation, search

The on TABCOMP event triggers when you press the <tab> key in an editbox and mIRC is about to perform tab completion.

on <level>:TABCOMP:<*#?=!@>:<commands>

When the event is triggered $1- is populated with what mIRC would by default fill the editbox with, not with what you actually typed.

To get what is actually currently in the editbox you need to use the $editbox identifer. Once you have the text you need to find what posistion the cursor was when tab was pressed.

By default mIRC tries to auto complete the word that $editbox($active).selstart is associated to. If that character is a space it will attempt to auto complete the word that would be starting at posistion $editbox($active).selstart unless that character is also a space, in which case it halts and does not evaluate anything.

If you want to stop mirc from populating the editbox with what it believes should be in there, you must use haltdef or halt to stop mIRC's default action.

Example

on *:TABCOMP:*: {
  ;Get everything up to the cursor.
  var %complete = $left($editbox($active),$editbox($active).selstart)
  ;Find how many spaces are before the cursor and add one. This should leave us with the word we tabbed at.
  var %complete = $count(%complete,$chr(32)) + 1
  ;Set varible to the n'th word.
  var %complete = $gettok($editbox($active),%complete,32)

  echo -ag The word to auto-complete is %complete 

  haltdef
}

The above is just an example of how you could start off a tab auto-complete, you would need some way to check if %complete starts with a character in $chantypes if it is then, complete the channel name. If it doesn't start with what looks as if it's a channel, you then need to check to see if its a %varible or an $identifier, it needs to be evaluated. Other wise, if it only contains 0-9a-z\[]^_`{|}- characters then try and auto complete the nickname.

By default mIRC will try and auto-complete a nickname if you try and use something like Da?? this could evaluate to Dana or Dart or Dark.

See Also

  • Nick Reference to check for valid nickname characters.