All pastes #955606 Raw Edit

FekketCantenel

public text v1 · immutable
#955606 ·published 2008-03-24 19:17 UTC
rendered paste body
;LineClip 1.0
;By FekketCantenel (FekketC@gmail.com)

;mIRC cuts off lines at 399 characters. Usually, when you paste/type a long paragraph, it gets cut-off. This script takes out the clipped text and puts it into a new line, so that nothing is lost.

;This is the event that will make it apply only to the user's input. It obviously isn't needed for input from other users, since the server takes care of that.
on *:INPUT:*:{
  ;It also isn't needed for /echo, since this displays fine at any length.
  if ($1 != /echo) {
    ;First, put the input into a variable and see if it's too long in the first place. This will cut out a lot of processing power that would otherwise be spent on _every single line_.
    var %lineclip.input $1-
    if ($len(%lineclip.input) > 399) {
      ;In a nutshell, this cuts the line off at 394 characters (399 minus the five for the '[...]' thing) and then pulls it back to the last space. This prevents words from being chopped in half.
      if ($mid(%lineclip.input,394,1) != $chr(32)) {
        var %lineclip.left.length $calc(394 - $len($gettok($left(%lineclip.input,394),-1,32)))
      }
      ;If the line has no spaces (in other words, if it's one long string of text, or a URL), this sets the variable to the default 394.
      if (!%lineclip.left.length) { var %lineclip.left.length 394 }
      ;Message the channel with the leftmost X characters. Note the -1 in the $calc, which also takes out that pesky space.
      var %lineclip.left $left(%lineclip.input,$calc(%lineclip.left.length - 1)) $+ [...]
      msg $chan %lineclip.left
      ;These two lines check to see if there's an odd number of underlines or bolds in the first part of the text. If there is, that means the second half is also bold/underlined, so it puts something into the variable.
      if ($len($calc($count(%lineclip.left, $chr(31)) / 2)) > 2) { var %lineclip.style $chr(31) }
      if ($len($calc($count(%lineclip.left, $chr(2)) / 2)) > 2) { var %lineclip.style %lineclip.style $+ $chr(2) }
      ;Message the channel with the remaining text.
      msg $chan %lineclip.style $+ [...] $+ $right(%lineclip.input,- $+ %lineclip.left.length)
      ;Halt so it doesn't show the pre-processed text.
      halt
    }
  }
}