Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Here's a scripted method of preserving spaces in incoming IRC channel messages without
- adding or modifying any characters in the original string. It uses the fact that /loadbuf
- preserves excess spaces, which you can extend to being able to add text with excess spaces
- to any window where you would normally use /echo.
- */
- ; Using this regex as matchtext fills $regml(1) with the original line as sent by the
- ; user as opposed to $1- which returns it with excess spaces stripped
- on &$^*:text:/(.*)/:#:{
- ; Prepare an auxiliary hidden window
- if ($window(@ $+ #)) clear @ $+ #
- window -h @ $+ #
- ; Add the line to the hidden window so that the result of there being
- ; various /echo switches can take effect (not extensively tested)
- ; $crlf added so we know where the text starts from later
- echo -mbflrt @ $+ # $+(<,$left($remove($nick(#,$nick).pnick,$nick),1),$nick,>) $crlf $1-
- ; Save the window to a file then load it into a binvar for some handling
- btrunc tmp 0
- savebuf @ $+ # tmp
- bread tmp 0 $file(tmp) &tmp
- ; Find the $crlf we added earlier and start creating the full message from that point
- var %i = $bfind(&tmp, 1, 13 10), %x = 1
- ; Since binvars function bytewise, we need $utfencode() to modify $regml(1) so that
- ; $mid( ,,1) returns individual ASCII characters
- while ($asc($mid($utfencode($regml(1)), %x, 1))) {
- bset -c &tmp %i $v1
- inc %i
- inc %x
- }
- ; Save the binvar, which now holds the message as sent by the user as well as timestamp
- ; and nick prefixes, to a file
- btrunc tmp 0
- bwrite tmp -1 -1 &tmp
- ; Highlight the switchbar button if the hidden window's is highlighted
- window -g $+ $iif($window(@ $+ #).sbcolor == highlight, 2, 1) #
- ; Add the line to the window
- loadbuf -pinc $+ $iif($v1 == highlight, $highlight($1-).color, $color(normal)) # tmp
- ; Clean up and stop the default text from showing
- window -c @ $+ #
- btrunc tmp 0
- haltdef
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement