If the seperator is not \n, then we want to just split on the $split_length.
line_wrap itself works great, but I was never able/could be bothered to merge parse_output into it, and it became a little messy. Here are the procs:
Code: Select all
# [parse_output] : prepares output for sending to a channel/user, calls line_wrap
#
proc parse_output {input} {
set parsed_output [set parsed_current {}]
if {[string match "\n" $incith::layout::seperator] == 1} {
regsub {\n\s*$} $input "" input
foreach newline [split $input "\n"] {
foreach line [incith::layout::line_wrap $newline] {
lappend parsed_output $line
}
}
} else {
regsub "(?:${incith::layout::seperator}|\\|)\\s*$" $input {} input
foreach line [incith::layout::line_wrap $input] {
lappend parsed_output $line
}
}
return $parsed_output
}
# [line_wrap] : takes a long line in, and chops it before the specified length
# http://forum.egghelp.org/viewtopic.php?t=6690
#
proc line_wrap {str {splitChr { }}} {
set out [set cur {}]
set i 0
set len $incith::layout::split_length
foreach word [split [set str][set str ""] $splitChr] {
if {[incr i [string len $word]] > $len} {
lappend out [join $cur $splitChr]
set cur [list $word]
set i [string len $word]
} else {
lappend cur $word
}
incr i
}
lappend out [join $cur $splitChr]
}
Code: Select all
# [send_output] : sends $data appropriately out to $where
#
proc send_output {where data} {
if {${incith::layout::notices} >= 1 && ![string match {#*} $where]} {
foreach line [incith::layout::parse_output $data] {
putquick "NOTICE $where :${line}"
}
} else {
foreach line [incith::layout::parse_output $data] {
putquick "PRIVMSG $where :${line}"
}
}
}