Advertisement
Guest User

jaytea

a guest
Jul 4th, 2010
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. /*
  2.  
  3. Here's a scripted method of preserving spaces in incoming IRC channel messages without
  4. adding or modifying any characters in the original string. It uses the fact that /loadbuf
  5. preserves excess spaces, which you can extend to being able to add text with excess spaces
  6. to any window where you would normally use /echo.
  7.  
  8. */
  9.  
  10. ; Using this regex as matchtext fills $regml(1) with the original line as sent by the
  11. ; user as opposed to $1- which returns it with excess spaces stripped
  12. on &$^*:text:/(.*)/:#:{
  13.  
  14. ; Prepare an auxiliary hidden window
  15. if ($window(@ $+ #)) clear @ $+ #
  16. window -h @ $+ #
  17.  
  18. ; Add the line to the hidden window so that the result of there being
  19. ; various /echo switches can take effect (not extensively tested)
  20. ; $crlf added so we know where the text starts from later
  21.  
  22. echo -mbflrt @ $+ # $+(<,$left($remove($nick(#,$nick).pnick,$nick),1),$nick,>) $crlf $1-
  23.  
  24. ; Save the window to a file then load it into a binvar for some handling
  25. btrunc tmp 0
  26. savebuf @ $+ # tmp
  27. bread tmp 0 $file(tmp) &tmp
  28.  
  29. ; Find the $crlf we added earlier and start creating the full message from that point
  30. var %i = $bfind(&tmp, 1, 13 10), %x = 1
  31.  
  32. ; Since binvars function bytewise, we need $utfencode() to modify $regml(1) so that
  33. ; $mid( ,,1) returns individual ASCII characters
  34. while ($asc($mid($utfencode($regml(1)), %x, 1))) {
  35. bset -c &tmp %i $v1
  36. inc %i
  37. inc %x
  38. }
  39.  
  40. ; Save the binvar, which now holds the message as sent by the user as well as timestamp
  41. ; and nick prefixes, to a file
  42. btrunc tmp 0
  43. bwrite tmp -1 -1 &tmp
  44.  
  45. ; Highlight the switchbar button if the hidden window's is highlighted
  46. window -g $+ $iif($window(@ $+ #).sbcolor == highlight, 2, 1) #
  47.  
  48. ; Add the line to the window
  49. loadbuf -pinc $+ $iif($v1 == highlight, $highlight($1-).color, $color(normal)) # tmp
  50.  
  51. ; Clean up and stop the default text from showing
  52. window -c @ $+ #
  53. btrunc tmp 0
  54. haltdef
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement