@verb #3:"tellColumns*_suspended" this none this rxdo #55 @program #3:"tellColumns*_suspended" this none this set_task_perms(caller_perms()) if (typeof(args[1]) == $INT) if (args[1] in {1, 2, 3}) justify = $string_utils:space(length(args[2]), "lcr"[args[1]]) args = listdelete(args, 1) else raise(E_INVARG, "Justify parameter must be 1,2,3 or a string") endif elseif (typeof(args[1]) == $STR) justify = args[1] args = listdelete(args, 1) else justify = $string_utils:space(length(args[1]), "l") endif {ratios, titles, @info} = args args = {titles, @info} out = {} if ($tcm && length(args) >= 16) underlines = {} args[2..1] = {$list_utils:make(length(ratios), "---")} for arg in (args) out = {@out, `$su:from_list(arg, $su.tab) ! E_TYPE => tostr(arg)'} $command_utils:suspend_if_needed() endfor else sep = `this.QuietColumnsSep ! E_PROPNF => " "' webber = this:isa($webber) cols = length(ratios) "Process && and determine max column widths." cwidths = $list_utils:make(cols) for i in [1..length(args)] for j in [1..length(args[i])] if (webber) a = $msg:process_notify($html_utils:detag(tostr(args[i][j])), "HTML") else a = tostr(args[i][j]) " a = $msg:process_notify(tostr(args[i][j]), `this.output_accent_mode ! E_PROPNF => \"STRIPPED\"');" endif "We're processing this now so that processed text isn't cut off by processed lengths." cwidths[j] = max(cwidths[j], $msg:string_length(a)) args[i][j] = a $command_utils:suspend_if_needed() endfor endfor "Use ratios to determine best column widths." ratio_tot = tofloat($math_utils:sum(@ratios)) for x in [1..cols] ratios[x] = tofloat(ratios[x]) / ratio_tot endfor freelen = `abs(this:linelength()) ! E_VERBNF => 79' - length(sep) * (cols - 1) new_ratio_tot = 0.0 unknownwidths = cwidths for x in [1..cols] "Look for columns that use less space than is allocated." if (cwidths[x] <= toint(ratios[x] * tofloat(freelen))) unknownwidths[x] = $maxint freelen = freelen - cwidths[x] else new_ratio_tot = new_ratio_tot + ratios[x] endif endfor while ((smallestunknown = min(@unknownwidths)) != $maxint) x = smallestunknown in unknownwidths cwidths[x] = min(cwidths[x], toint(ratios[x] / new_ratio_tot * tofloat(freelen))) unknownwidths[x] = $maxint freelen = freelen - cwidths[x] new_ratio_tot = 0.0 for x in [1..cols] "Recalculate ratios" if (unknownwidths[x] != $maxint) new_ratio_tot = new_ratio_tot + ratios[x] endif endfor endwhile "Display columns." underlines = {} if (titles) args[2..1] = {"underlines"} else args = listdelete(args, 1) endif linewidth = $math_utils:sum(@cwidths) + length(sep) * (length(cwidths) - 1) for arg in (args) line = "" if (arg == "underlines") for j in [1..length(cwidths)] line = line + $string_utils:space(cwidths[j], "-") if (`titles[j + 1] ! E_RANGE => 1') line = line + sep else line = line + $string_utils:space(length(sep), "-") endif endfor elseif (typeof(arg) == $STR) line = $su:space(min(linewidth + 2, this:linelength()), arg) else for j in [1..length(arg)] a = arg[j] " real_length = $msg:string_length(a);" " if (real_length >= cwidths[j])" "line = line + a[1..cwidths[j]];" " line = line + $su:slice_tagged(a, cwidths[j]);" " else" "Ok. It is obvious that a far more painful suspend is needed here. --Cecil" ticks_left() <= length(a) * 35 || seconds_left() <= 2 && suspend(0) line = line + this.output_rendering_object:({"left", "centre", "right"}[justify[j] in {"l", "c", "r"}] + "_render")(a, cwidths[j]) " endif" length(verb) > 11 && $command_utils:suspend_if_needed() "Additional change made by Cecil to cause it to make the justification be done by the renderer" line = line + (arg == args[1] && `!arg[j + 1] ! E_RANGE => 0' ? $su:space(length(sep)) | sep) $command_utils:suspend_if_needed() "Change made by Lao on previous line. Used to be 'line = line + sep;'. This change makes the 'ou' listing and other columns listings that use blank headers a little nicer when sep is something like \" | \". Change it back if you desire. :)" endfor endif out = {@out, $su:trimr(line[1..$ - length(sep)])} $command_utils:suspend_if_needed() endfor endif this:tell(out) "Commented and replaced with the code below by Cecil, to avoid Network buffer overflows." "$code_utils:semaphore_enter(\"tellcolumns\");" "try" " while (out)" " \"First 60 lines are free. Every 30 after that require suspends\";" " icount = min(`icount ! E_VARNF' ? 30 | 60, length(out));" " text = out[1..icount];" " out = `out[icount + 1..$] ! E_RANGE';" " this:tell(text);" " if (out)" " suspend(1);" " endif" " endwhile" "finally" " $code_utils:semaphore_exit(\"tellcolumns\");" "endtry" "Last modified by Dax (#789) on Tue May 3 13:43:06 2005 MDT." .