ANSI Utilities #32
Aliases: ANSI Utilities, au
37 verbs · 67 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
length | this none this | rxd | #32 | 1 |
index rindex | this none this | rxd | #32 | 3 |
contains_codes | this none this | rx | #32 | 2 |
delete | this none this | rxd | #32 | 9 |
update_all | this none this | rx | #32 | 45 |
get_code | this none this | rx | #32 | 1 |
cutoff*_suspended | this none this | rx | #32 | 8 |
add_group | this none this | rxd | #32 | 22 |
add_code | this none this | rxd | #32 | 30 |
show_who_listing | this none this | rx | #32 | 121 |
notify | this none this | rx | #32 | 30 |
add_noansi | this none this | rxd | #32 | 10 |
remove_noansi | this none this | rxd | #32 | 3 |
tell | this none this | rxd | #32 | 1 |
self_diagnostic | this none this | rx | #32 | 14 |
trusts | this none this | rxd | #32 | 2 |
cutoff_locs | this none this | rx | #32 | 40 |
cleanup_noansi | this none this | rxd | #32 | 6 |
test_benchmark | this none this | rxd | #32 | 37 |
cutoff_assign | this none this | rxd | #32 | 15 |
setadd | this none this | rxd | #32 | 14 |
setremove | this none this | rxd | #32 | 16 |
ansi_status | this none this | rxd | #32 | 8 |
terminate_normal | this none this | rxd | #32 | 11 |
left | this none this | rxd | #32 | 6 |
right | this none this | rxd | #32 | 6 |
centre center | this none this | rxd | #32 | 6 |
columnize columnise | this none this | rxd | #32 | 19 |
space | this none this | rxd | #32 | 18 |
ansi_title | this none this | rx | #32 | 12 |
strip_black | this none this | rxd | #32 | 17 |
quote_ansi | this none this | rxd | #32 | 5 |
update_player_codes | this none this | rxd | #32 | 14 |
fill_string | this none this | rxd | #32 | 54 |
@ansi-setup | this none none | rx | #32 | 196 |
get_html_code | this none this | rx | #32 | 6 |
player_wrap_off | this none this | rx | #32 | 3 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
escape | #32 | | #36 | "\u001b" |
code_red | #32 | r | #36 | "e[31m" |
code_green | #32 | r | #36 | "e[32m" |
code_yellow | #32 | r | #36 | "e[33m" |
code_blue | #32 | r | #36 | "e[34m" |
code_purple | #32 | r | #36 | "e[35m" |
code_cyan | #32 | r | #36 | "e[36m" |
code_normal | #32 | r | #36 | "e[0m" |
code_inverse | #32 | r | #36 | "e[7m" |
code_underline | #32 | r | #36 | "e[4m" |
code_bold | #32 | r | #36 | "e[1m" |
beep | #32 | | #36 | "\u0007" |
code_bright | #32 | r | #36 | "e[1m" |
group_colors | #32 | r | #36 | list of 10{"red", "green", "yellow", "blue", "purple", "cyan", "gray", "grey", "magenta", "white"} |
group_bold | #32 | r | #36 | {"bold", "unbold", "bright", "unbright"} |
code_unbold | #32 | r | #36 | "e[22m" |
group_misc | #32 | r | #36 | {"underline", "inverse"} |
code_blink | #32 | r | #36 | "e[5m" |
code_unblink | #32 | r | #36 | "e[25m" |
group_blinking | #32 | r | #36 | {"blink", "unblink"} |
code_magenta | #32 | r | #36 | "e[35m" |
code_unbright | #32 | r | #36 | "e[22m" |
groups | #32 | r | #36 | {"bold", "colors", "misc", "blinking", "extra"} |
code_white | #32 | r | #36 | "e[37m" |
noansi_task | #32 | r | #36 | 300036584 |
all | #32 | r | #36 | {} |
all_regexp | #32 | r | #36 | "%[%(random%|normal%|null%|bold%|unbold%|bright%|unbright%|red%|green%|yellow%|blue%|purple%|cyan%|gray%|grey%|magenta%|white%|underline%|inverse%|blink%|unblink%|beep%)%]" |
group_colors_regexp | #32 | r | #36 | "%[%(red%|green%|yellow%|blue%|purple%|cyan%|gray%|grey%|magenta%|white%)%]" |
group_bold_regexp | #32 | r | #36 | "%[%(bold%|unbold%|bright%|unbright%)%]" |
group_misc_regexp | #32 | r | #36 | "%[%(underline%|inverse%)%]" |
group_blinking_regexp | #32 | r | #36 | "%[%(blink%|unblink%)%]" |
version | #32 | r | #36 | "2.1r" |
code_gray | #32 | r | #36 | "e[1;30m" |
code_grey | #32 | r | #36 | "e[1;30m" |
test_screen | #32 | r | #36 | {} |
extra_codes | #32 | r | #36 | {"random", "normal", "null"} |
active | #32 | r | #36 | 1 |
random_colors | #32 | r | #36 | {"red", "green", "yellow", "blue", "purple", "cyan", "gray", "white"} |
ansi_log | #32 | r | #36 | list of 14{{"2.1", 820519200, "[cyan]D[gray]ark_[unbold][cyan]O[gray]wl[normal]", {"Updated all the documentation. Fixed up $ansi_pc:@ansi-setup. Fixed up $ansi_utils:notify to be a *much* faster. Changed the format of $ansi_utils.ansi_log and made $ansi_help:ansi_log do the formatting itself. Added $ansi_utils:tell, $ansi_pc:title, $ansi_utils:ansi_title, help ansi-cutoff, $ansi_pc:confunc, $ansi_utils:quote_ansi, $ansi_utils.status_message, $ansi_pc:@ansi-status, help @ansi-status, $ansi_utils:trusts, $ansi_utils.trusted, $ansi_utils:setadd, $ansi_utils:setremove, $ansi_utils:terminate_normal, $ansi_utils:self_diagnostic, and a benchmark test. Fixed a bug in $ansi_utils:replace_group where it was ignoring @ansi-o escape. Removed $ansi_utils:maybe_restart_noansi and replaced it with the less server intensive :cleanup_noansi. Moved the main part of $ansi_utils:cutoff into an internal verb, :cutoff_locs, and made a :cutoff_assign verb that also uses it. Removed $ansi_utils:replace_group and :reset_string and moved it to :notify. Got rid of $ansi_utils.su_<whatever> and moved them to regular verbs on $ansi_utils. Fixed up $ansi_pc:linesplit to use $ansi_utils:cutoff_locs. Renamed $ansi_utils:update_regexp to update_all and made it update all the caches. Moved @ansi-setup to $ansi_utils.", "NOTE: $ansi_utils:notify doesn't terminate all strings with a [[null]normal] code anymore, you will have to run the string through $ansi_utils:terminate_normal before calling it.", "The home of the ANSI system is now NestMOO, instead of EnigMOO."}}, {"2.0", 817840800, "[red]D[gray]ark_[unbold][red]O[gray]wl[normal]", "Updated all the documentation, removed $ansi_utils.test_title, added $ansi_pc:set_aliases, added $ansi_pc:@more to fix the one on $player, fixed up @ansi-setup a lot. I'm fairly confident that the ANSI system is now safe and secure."}, {"1.6", 817840800, "[blue]D[gray]ark_[unbold][blue]O[gray]wl[normal]", "Made $ansi_utils:notify, moved all the replacing stuff there, and hacked $ansi_pc:notify to call it instead of notify(). Moved the .noansi_queue, :add_noansi, and :remove_noansi from $ansi_pc to $ansi_utils. I also updated 'help ansi-bugs' now that I tracked down a couple of them."}, {"1.5", 815248800, "[green]Grant[normal]", "Fixed some security problems that allowed players to get a copy of the escape character and use it for malicious purposes. To do that, I got rid of $ansi_pc:replace_ansi and put the code straight in :notify, which is able to pass() now. Also made an @ansi-setup verb for convenient porting, along with some core verb code on $ansi_utils. Fixed randoms to substitute faster by adding .random_colors. Added $ansi_utils:show_who_listing and changed @who to use it."}, {"1.4", 815248800, "[green]Grant[normal]", "In Dark_Owl's absence, I fixed up a lot of code to make it take less ticks, due to the recent lag problems on EnigMOO, which we suspect were called by color codes (most noticeably s). Average :notify call with colors takes around 200 less ticks. Also updated much of the documentation, since I know DO doesn't like to do it ;) Copied the part of $player:set_name that checked whether people had color codes in their name or not to the ANSI PC."}, {"1.3", 812570400, "[green]D[gray]ark_[unbold][green]O[gray]wl[normal]", "Fixed up 'help ansi-programming' a little more. Fixed $string_utils:columnize, for some reason it worked fine here but got screwed up on ForestMOO. Added 'help ansi-porting'."}, {"1.2", 812570400, "[purple]D[gray]ark_[unbold][purple]O[gray]wl[normal]", "$ansi_utils:replace_group now uses substitute(). Added 'help ansi-programming' and 'help ansi-bugs'. Added @ansi-test and 'help @ansi-test'. Cleaned up a lot of other stuff. Added $ansi_utils.active."}, {"1.1", 812570400, "[green]D[gray]ark_[unbold][green]O[gray]wl[normal]", "Fixed up $ansi_pc:notify a little but unfortunately now it requires wizperms and overrides the ones on it's ancestors. Fixed the line wrapping. Added this log, along with $ansi_utils.version. Hacked $ansi_utils:replace_group and $ansi_utils:cutoff to use regexps."}, {"1.0", 809978400, "[cyan]D[gray]ark_[unbold][cyan]O[gray]wl[normal]", "$emu disappears and is replaced with $ansi_utils. $ansi_pc, $ansi_help, $ansi_options, are created and everything on $player is moved to $ansi_pc. @ansi is replaced by @ansi-o."}, {"0.9", 807300000, "[white]D[gray]ark_[unbold][white]O[gray]wl[normal]", "EnigMOO opens resulting in a lot of bug fixes and more core hacks."}, {"0.6", 799351200, "[cyan]D[gray]ark_[unbold][cyan]O[gray]wl[normal]", "Fixed up @ansi some more, fixed a lot more core stuff including $generic_editor, and made it possible to ignore ANSI codes."}, {"0.4", 788983200, "[yellow]D[gray]ark_[unbold][yellow]O[gray]wl[normal]", "Fixed up @ansi a little and hacked some core stuff, mostly on $string_utils to fix columnizing. $emu:replace is hacked to use strsub() as opposed to going through letter by letter, ick."}, {"0.2", 781034400, "[purple]D[gray]ark_[unbold][purple]O[gray]wl[normal]", "Added an .ansi_on property on $player and a primitive @ansi command to turn it on and off."}, {"0.1", 778442400, "[white]D[gray]ark_[unbold][white]O[gray]wl[normal]", "First version, added $emu and hacked $player:notify to call it."}} |
noansi_queue | #32 | r | #36 | list of 16{265944150, 726511868, 359817630, 1040368788, 804677874, 1973909103, 77135325, 9396761, 1275762763, 1073186343, 1145656802, 1509376017, 685586529, 544900665, 1323020615, 93235527} |
need_wizperms | #32 | r | #36 | {{"ansi_pc", "@more"}, {"ansi_pc", "notify"}, {"ansi_utils", "notify"}, {"ansi_utils", "@ansi-setup"}} |
code_beep | #32 | r | #36 | "b" |
status_message | #32 | r | #36 | "" |
trusted | #32 | r | #36 | {} |
diagnostic_tests | #32 | r | #36 | {"benchmark"} |
redirect_su_names | #32 | r | #36 | {"left", "right", "center centre", "columnize columnise", "space"} |
redirect_su_code | #32 | r | #36 | list of 7{"\"...redirects verbs to $ansi_utils...\";", "if (verb == \"redirect_ansi\")", "elseif (valid(au = $ansi_utils))", " return au:(verb)(@args);", "else", " return this:(verb + \"(noansi)\")(@args);", "endif"} |
default_codes | #32 | r | #36 | {"white", "unbold", "unblink", "null"} |
code_null | #32 | r | #36 | "" |
code_random | #32 | r | #36 | "" |
group_extra | #32 | r | #36 | {"beep"} |
group_extra_regexp | #32 | r | #36 | "%[%(beep%)%]" |
terminate_regexp | #32 | r | #36 | "%[%(random%|normal%|bold%|unbold%|bright%|unbright%|white%|red%|green%|yellow%|blue%|purple%|cyan%|gray%|grey%|magenta%|underline%|inverse%|blink%)%]" |
replace_code_pointers | #32 | r | #36 | {} |
notify_regexp | #32 | r | #36 | "%[%(random%|normal%|bold%|unbold%|bright%|unbright%|red%|green%|yellow%|blue%|purple%|cyan%|gray%|grey%|magenta%|white%|underline%|inverse%|blink%|unblink%|beep%)%]" |
reset_guest_props | #32 | r | #36 | {"ansi_options", "replace_codes"} |
ge_fill_string | #32 | r | #36 | list of 5{"if (valid(au = $ansi_utils) && au.active)", " return au:(verb)(@args);", "else", " return this:(verb + \"(noansi)\")(@args);", "endif"} |
plr_db_insert | #32 | r | #36 | list of 3{"typeof(args[1]) == NUM && typeof(args[2]) == STR && (args[2] = $ansi_utils:delete(args[2]));", "typeof(args[1]) == STR && (args[1] = $ansi_utils:delete(args[1]));", "return pass(@args);"} |
html_start | #32 | rc | #36 | "<CENTER><TABLE><TR><TD height=62 bgcolor=\"black\">" |
html_end | #32 | rc | #36 | "</TD></TR></TABLE></CENTER>" |
filter_subs | #32 | r | #36 | list of 9{{"<", "< "}, {"< font ", "<font "}, {"< img ", "<img "}, {"< a ", "<a "}, {"< table", "<table"}, {"< tr", "<tr"}, {"< td", "<td"}, {"< center", "<center"}, {"< /", "</"}} |
help_msg | #79 | rc | #36 | {"A utility package for controlling ANSI sequences from within the MOO. See 'help ansi-intro' for more info."} |
key | #1 | c | #36 | 0 |
aliases | #1 | rc | #36 | {"ANSI Utilities", "au"} |
description | #1 | rc | #36 | "{A utility for controlling ANSI sequences from within the MOO. See 'help ansi-intro' for more info.}" |
object_size | #1 | r | #36 | {55246, -1090650497} |
html | #1 | rc | #36 | <clear> |
Ancestry
Ancestors (nearest first): #79 Generic Utilities Package → #1 Root Class
Children: none
Call graph
Showing 48 of 65 verbs; 17 not shown.
Source
length
Referenced by
- #32:show_who_listing line 85:
this:length - #32:left line 6:
this:length - #32:right line 6:
this:length - #32:centre line 6:
this:length - #32:columnize line 17:
this:length - #32:space line 3:
this:length - #32:space line 13:
this:length - #32:space line 18:
this:length - #32:fill_string line 14:
this:length - #91:tell_contents line 14:
au:length - #95:at_item line 7:
$ansi_utils:length - #95:at_item line 15:
$ansi_utils:length - #95:at_item line 15:
$ansi_utils:length - #104:look_self line 5:
$ansi_utils:length - #107:tell_contents line 14:
au:length
Source
1return length(index(a = args[1], "[") ? this:delete(a) | a);
index rindex
Referenced by
- #32:fill_string line 19:
this:rindex - #32:fill_string line 21:
this:index - #32:fill_string line 40:
this:rindex - #32:fill_string line 42:
this:index - #95:linesplit line 9:
au:rindex
Source
1":[r]index (STR string, STR character, NUM case_matters)"; 2"like index() and rindex() but ignores ANSI codes"; 3return (verb == "index") ? index(this:delete(args[1]), @listdelete(args, 1)) | rindex(this:delete(args[1]), @listdelete(args, 1));
contains_codes
Referenced by
- #32:setadd line 6:
this:contains_codes - #32:setremove line 6:
this:contains_codes - #95:@ansi-title line 45:
$ansi_utils:contains_codes
Source
1":contains_codes(STR string) => True if <string> contains any ANSI codes"; 2return !(!match(args[1], this.all_regexp));
delete
Referenced by
- #10:notify line 2:
$ansi_utils:delete - #32:length line 1:
this:delete - #32:index line 3:
this:delete - #32:index line 3:
this:delete - #32:setadd line 7:
this:delete - #32:setadd line 9:
this:delete - #32:setremove line 9:
this:delete - #32:setremove line 12:
this:delete - #39:insert line 1:
$ansi_utils:delete - #39:insert line 2:
$ansi_utils:delete - #95:set_name line 7:
$ansi_utils:delete - #95:set_aliases line 9:
$ansi_utils:delete - #95:set_ansi_title line 16:
au:delete - #95:set_ansi_title line 22:
au:delete
Source
1":delete (STR string) => STR <string> with ANSI codes stripped out"; 2line = args[1]; 3if (this.active) 4while (index = match(line, this.notify_regexp)) 5line[index[1]..index[2]] = ""; 6endwhile 7line = strsub(line, "[null]", ""); 8endif 9return line;
update_all
Referenced by
- #32:add_code line 28:
this:update_all - #95:@ansi-s*tatus line 82:
au:update_all
Source
1if (!this:trusts(caller_perms())) 2return E_PERM; 3endif 4codes = this.extra_codes; 5"...we really don't need group regexps anymore, but I'm going to keep them around for a while just in case..."; 6for x in (this.groups) 7this.(tostr("group_", x, "_regexp")) = tostr("%[%(", $string_utils:from_list(g = this.("group_" + x), "%|"), "%)%]"); 8codes = {@codes, @g}; 9endfor 10this.all = codes; 11this.all_regexp = tostr("%[%(", $string_utils:from_list(codes, "%|"), "%)%]"); 12this.terminate_regexp = tostr("%[%(", $string_utils:from_list($set_utils:difference(codes, {@this.default_codes, @this.group_extra}), "%|"), "%)%]"); 13this.notify_regexp = tostr("%[%(", $string_utils:from_list(setremove(codes, "null"), "%|"), "%)%]"); 14colors = {}; 15ccs = {}; 16for x in (this.group_colors) 17if (!((a = this:get_code(x, "ESC")) in ccs)) 18colors = setadd(colors, x); 19ccs = setadd(ccs, a); 20endif 21endfor 22this.random_colors = colors; 23this.replace_code_pointers = {}; 24index = 0; 25leaves = $object_utils:leaves_suspended($ansi_pc); 26data = {}; 27ll = length(leaves); 28"...this will probably have to suspend on most large MOOs but you'll have to rewrite it so it can.."; 29while (index <= ll) 30index = index + 1; 31if (!is_player(leaves[index])) 32elseif (typeof(x = this:update_player_codes(leaves[index])) != LIST) 33elseif (!(i = $list_utils:iassoc(x, data, 2))) 34data = listappend(data, {1, x}); 35elseif ((((data[i][1] + 1) * length(x)) / ll) >= 6) 36"Must be at least 25% of people for 25 element long lists..."; 37" 50% 12..."; 38" 12% 50... etc"; 39this.replace_code_pointers = listappend(this.replace_code_pointers, x); 40index = 0; 41data = {}; 42else 43data[i][1] = data[i][1] + 1; 44endif 45endwhile
get_code
Referenced by
- #32:update_all line 17:
this:get_code - #32:notify line 16:
this:get_code
Source
1return (caller == this) ? strsub(strsub(this.("code_" + args[1]), "e", args[2] || this.escape, 1), "b", this.beep) | E_PERM;
cutoff*_suspended
Referenced by
none
Source
1":cutoff[_suspended] (STR string, NUM start, NUM end) => STR"; 2"Acts like: string[start..end] but ignores ANSI codes."; 3args = {@args, 0}[1..4]; 4if (typeof(info = this:cutoff_locs(@args, verb == "cutoff_suspended")) == LIST) 5return args[1][info[1]..info[2]]; 6else 7return info; 8endif
add_group
Referenced by
none
Source
1":add_group (STR group)"; 2"Adds <group> to the groups and makes a property for it."; 3if (!this:trusts(caller_perms())) 4return E_PERM; 5elseif (!((args && args[1]) && (typeof(args[1]) == STR))) 6return E_INVARG; 7elseif (args[1] in this.groups) 8return 0; 9else 10this.groups = setadd(this.groups, args[1]); 11arg1 = {this, "group_" + args[1], {}, {$code_utils:verb_perms(), "r"}}; 12arg2 = {this, tostr("group_", args[1], "_regexp"), "", arg1[4]}; 13if ($object_utils:has_callable_verb(#0, "add_property")) 14$add_property(@arg1); 15$add_property(@arg2); 16else 17add_property(@arg1); 18add_property(@arg2); 19endif 20$ansi_options:add_name(args[1]); 21return 1; 22endif
add_code
Referenced by
none
Source
1":add_code (STR code, NUM/STR sequence, STR group)"; 2"Adds a new code, <code> and adds it to group <group>."; 3"If <sequence> is a string, it is used as the ANSI sequence, otherwise"; 4"it uses 'e[<sequence>m'. 'e' is replaced with the escape character, and"; 5"'b' is replaced with the beep character in <sequence>"; 6if (!this:trusts(caller_perms())) 7return E_PERM; 8elseif (length(args) < 3) 9return E_ARGS; 10elseif (!(((args[1] && (typeof(args[1]) == STR)) && (!$object_utils:has_property(this, cn = tostr("code_", args[1])))) && ((group = args[3]) in {@this.groups, E_NONE}))) 11return E_INVARG; 12else 13code = args[2]; 14if (typeof(code) == NUM) 15code = tostr("e[", n, "m"); 16endif 17arg = {this, cn, code, {$code_utils:verb_perms(), "r"}}; 18if ($object_utils:has_verb(#0, "add_property")) 19$add_property(@arg); 20else 21add_property(@arg); 22endif 23if (args[3] == E_NONE) 24this.extra_codes = setadd(this.extra_codes, args[1]); 25else 26this.("group_" + args[3]) = setadd(this.("group_" + args[3]), args[1]); 27endif 28this:update_all(); 29return 1; 30endif
show_who_listing
Referenced by
Source
1":show_who_listing(players[,more_players])"; 2" prints a listing of the indicated players."; 3" For players in the first list, idle/connected times are shown if the player is logged in, otherwise the last_disconnect_time is shown. For players in the second list, last_disconnect_time is shown, no matter whether the player is logged in."; 4idles = itimes = offs = otimes = listing = {}; 5for p in (args[2]) 6if (!valid(p)) 7listing = {@listing, tostr(p, " <invalid>")}; 8elseif (typeof(t = p.last_disconnect_time) == NUM) 9(p in offs) || ((offs = {@offs, p}) && (otimes = {@otimes, {-t, -t, p}})); 10elseif (is_player(p)) 11listing = {@listing, tostr(p.name, " (", p, ") ", (t == E_PROPNF) ? "is not a $player." | "has a garbled .last_disconnect_time.")}; 12else 13listing = {@listing, tostr(p.name, " (", p, ") is not a player.")}; 14endif 15endfor 16for p in (args[1]) 17if (p in offs) 18elseif (!valid(p)) 19listing = {@listing, tostr(p, " <invalid>")}; 20elseif ((typeof(i = idle_seconds(p)) != ERR) && (p in connected_players())) 21(p in idles) || ((idles = {@idles, p}) && (itimes = {@itimes, {i, connected_seconds(p), p}})); 22elseif (typeof(t = p.last_disconnect_time) == NUM) 23(offs = {@offs, p}) && (otimes = {@otimes, {-t, -t, p}}); 24elseif (is_player(p)) 25listing = {@listing, tostr(p.name, " (", p, ") not logged in.", (t == E_PROPNF) ? " Not a $player." | " Garbled .last_disconnect_time.")}; 26else 27listing = {@listing, tostr(p.name, " (", p, ") is not a player.")}; 28endif 29endfor 30if (!(idles || offs)) 31return 0; 32endif 33idles = $list_utils:sort_alist(itimes); 34offs = $list_utils:sort_alist(otimes); 35headers = {"Player name", @idles ? {"Connected", "Idle time"} | {"Last disconnect time", ""}, "Location"}; 36total_width = caller:linelen() || 79; 37max_name = total_width / 4; 38name_width = length(headers[1]); 39names = locations = {}; 40for lst in ({@idles, @offs}) 41((ticks_left() < 2000) || (seconds_left() < 2)) && suspend(0); 42p = lst[3]; 43"p.name and this:ansi_title(p) should be the same length, saves a call to this:length"; 44namestr = tostr(this:cutoff(this:ansi_title(p), 1, min(max_name, z = length(p.name)), 1), " (", p, ")"); 45name_width = max((z + 3) + length(tostr(p)), name_width); 46names = {@names, namestr}; 47(typeof(wlm = p.location:who_location_msg(p)) == STR) || (wlm = valid(p.location) ? p.location.name | tostr("** Nowhere ** (", p.location, ")")); 48locations = {@locations, wlm}; 49endfor 50time_width = offs ? 15 | 13; 51before = {0, w1 = 3 + name_width, w2 = w1 + time_width, w2 + time_width}; 52su = $string_utils; 53tell1 = headers[1]; 54tell2 = su:space(tell1, "-"); 55for j in [2..4] 56tell1 = su:left(tell1, before[j]) + headers[j]; 57tell2 = su:left(tell2, before[j]) + su:space(headers[j], "-"); 58endfor 59listing = {@listing, tell1[1..min(length(tell1), total_width)]}; 60listing = {@listing, tell2[1..min(length(tell2), total_width)]}; 61"..."; 62"...print lines..."; 63"..."; 64active = 0; 65for i in [1..total = (ilen = length(idles)) + length(offs)] 66if (i <= ilen) 67lst = idles[i]; 68if (lst[1] < (5 * 60)) 69active = active + 1; 70endif 71l = {names[i], su:from_seconds(lst[2]), su:from_seconds(lst[1]), locations[i]}; 72else 73lct = offs[i - ilen][3].last_connect_time; 74ldt = offs[i - ilen][3].last_disconnect_time; 75ctime = caller:ctime(ldt) || ctime(ldt); 76l = {names[i], (lct <= time()) ? ctime | "Never", "", locations[i]}; 77if ((i == (ilen + 1)) && idles) 78listing = {@listing, su:space(before[2]) + "------- Disconnected -------"}; 79endif 80endif 81tell1 = l[1]; 82for j in [2..4] 83tell1 = su:left(tell1, before[j]) + l[j]; 84endfor 85listing = {@listing, this:cutoff(tell1, 1, min(this:length(tell1), total_width))}; 86if ($command_utils:running_out_of_time()) 87if ($login:is_lagging()) 88"Check lag two ways---global lag, but we might still fail due to individual lag of the queue this runs in, so check again later."; 89listing = {@listing, tostr("Plus ", total - i, " other players (", total, " total; out of time and lag is high).")}; 90return; 91endif 92now = time(); 93suspend(0); 94if ((time() - now) > 10) 95listing = {@listing, tostr("Plus ", total - i, " other players (", total, " total; out of time and lag is high).")}; 96return; 97endif 98endif 99endfor 100"..."; 101"...epilogue..."; 102listing = {@listing, ""}; 103if (total == 1) 104active_str = ", who has" + ((active == 1) ? "" | " not"); 105else 106if (active == total) 107active_str = (active == 2) ? "s, both" | "s, all"; 108elseif (active == 0) 109active_str = "s, none"; 110else 111active_str = tostr("s, ", active); 112endif 113active_str = tostr(active_str, " of whom ha", (active == 1) ? "s" | "ve"); 114endif 115listing = {@listing, tostr("Total: ", total, " player", active_str, " been active recently.")}; 116vrb = ((caller == $login) || $perm_utils:controls($code_utils:verb_perms(), caller)) ? "notify" | "tell"; 117for line in (listing) 118caller:(vrb)(line); 119((seconds_left() < 2) || (ticks_left() < 4000)) && suspend(0); 120endfor 121return total;
notify
Referenced by
- #32:test_benchmark line 13:
$ansi_utils:notify - #32:test_benchmark line 23:
$ansi_utils:notify - #32:test_benchmark line 26:
$ansi_utils:notify - #32:test_benchmark line 30:
$ansi_utils:notify
Source
1":notify (OBJ player, STR line[, extra parameters for notify])"; 2set_task_perms(caller_perms()); 3plr = args[1]; 4line = args[2]; 5"...use property_info() instead of $object_utils:isa to save ticks..."; 6if (((((index(line, "[") && valid(plr)) && property_info(plr, "ansi_options")) && this.active) && (!(task_id() in this.noansi_queue))) && (!plr:ansi_option("ignore"))) 7codes = (typeof(z = plr.replace_codes) == NUM) ? this.replace_code_pointers[z] | z; 8esc = plr:ansi_option("escape"); 9while (m = match(line, this.notify_regexp)) 10z = line[m[1] + 1..m[2] - 1]; 11(z == "random") && (z = this.random_colors[random(length(this.random_colors))]); 12"*****HTML CODE*****"; 13if (plr:ansi_option("html")) 14line[m[1]..m[2]] = (z in codes) ? this:get_html_code(z) | ""; 15else 16line[m[1]..m[2]] = (z in codes) ? this:get_code(z, esc) | ""; 17endif 18"*****END HTML*****"; 19endwhile 20line = strsub(line, "[null]", ""); 21if (plr:ansi_option("html")) 22line = strsub(line, "\"><font", "\""); 23endif 24endif 25if (plr:ansi_option("filter_tags")) 26for pair in (this.filter_subs) 27line = strsub(line, pair[1], pair[2]); 28endfor 29endif 30return notify(plr, line, @args[3..length(args)]);
add_noansi
Referenced by
- #32:test_benchmark line 28:
this:add_noansi - #50:list_line line 1:
$ansi_utils:add_noansi - #58:@list*# line 107:
$ansi_utils:add_noansi
Source
1":add_noansi()"; 2"Called by tasks to tell players to ignore any ANSI codes from them."; 3"Can be undone with a call to :remove_noansi"; 4if ((length(this.noansi_queue) > 30) && (!$code_utils:task_valid(this.noansi_task))) 5fork tid (0) 6this:cleanup_noansi(); 7endfork 8this.noansi_task = tid; 9endif 10this.noansi_queue = setadd(this.noansi_queue, task_id());
remove_noansi
Referenced by
- #32:test_benchmark line 32:
this:remove_noansi - #50:list_line line 6:
$ansi_utils:remove_noansi
Source
1":remove_noansi()"; 2"Start translating the ANSI codes from the current task again"; 3this.noansi_queue = setremove(this.noansi_queue, task_id());
tell
Referenced by
none
Source
1return;
self_diagnostic
Referenced by
- #95:@ansi-s*tatus line 78:
au:self_diagnostic
Source
1":self_diagnostic ([NUM fix[, OBJ plyr]]) => NUM errors fixed"; 2"Reports all errors found to <plyr> or the current player."; 3"Fixes any errors it can if <fix> is specified and true."; 4"<errors fixed> is the errors that could have been fixed if <fix> is false."; 5if (!this:trusts(caller_perms())) 6return E_PERM; 7else 8count = 0; 9for x in (this.diagnostic_tests) 10player:tell("Running test \"", x, "\"..."); 11count = count + (!(!this:("test_" + x)(@args))); 12endfor 13return count; 14endif
trusts
Referenced by
- #32:update_all line 1:
this:trusts - #32:add_group line 3:
this:trusts - #32:add_code line 6:
this:trusts - #32:self_diagnostic line 5:
this:trusts - #32:update_player_codes line 3:
this:trusts - #95:@ansi-s*tatus line 26:
au:trusts
Source
1":trusts (OBJ player) => true of <player> is trusted by the ANSI system."; 2return (args[1].wizard || (args[1] == this.owner)) || (args[1] in this.trusted);
cutoff_locs
Referenced by
- #32:cutoff*_suspended line 4:
this:cutoff_locs - #32:cutoff_assign line 10:
this:cutoff_locs - #95:linesplit line 14:
au:cutoff_locs
Source
1":cutoff_locs (STR string,NUM start,NUM end[,NUM extra][, NUM suspendok])"; 2" => {nstart, nend}"; 3"Takes <start> and <end>, fixes them to compensate for the ANSI codes, and"; 4"returns them. If <extra> is provided and true, <nend> will include the"; 5"codes after the ending letter."; 6start = args[2]; 7end = args[3]; 8if (typeof(string = args[1]) != STR) 9return E_INVARG; 10elseif (!(index(string, "[") && this.active)) 11return {start, (end == "$") ? length(string) | end}; 12elseif (start > end) 13return args[2..3]; 14endif 15i = begin = 0; 16x = 1; 17extra = {@args, 0}[4]; 18reg = this.all_regexp; 19l = length(string); 20suspendok = {@args, 0}[5]; 21while (x <= l) 22((suspendok && ((ticks_left() < 1000) || (seconds_left() < 2))) && player:tell("suspending...")) && suspend(0); 23if (m = match(string, reg)) 24i = i + (m[1] - 1); 25if ((!begin) && ((i + 1) >= start)) 26begin = (((x + m[1]) - i) + start) - 2; 27if (end == "$") 28return {begin, l}; 29endif 30endif 31if (begin && ((i - extra) >= end)) 32return {begin, (((x + m[1]) - i) + end) - 2}; 33endif 34x = x + m[2]; 35string[1..m[2]] = ""; 36else 37return {begin || (((x - i) + start) - 1), (end == "$") ? l | (((x - i) + end) - 1)}; 38endif 39endwhile 40return ((end == i) && begin) ? {begin, l} | E_RANGE;
cleanup_noansi
Referenced by
- #32:add_noansi line 6:
this:cleanup_noansi
Source
1while (this.noansi_queue && (!$command_utils:running_out_of_time())) 2x = this.noansi_queue[1]; 3if (!$code_utils:task_valid(x)) 4this.noansi_queue = setremove(this.noansi_queue, x); 5endif 6endwhile
test_benchmark
Referenced by
none
Source
1if (caller != this) 2return E_PERM; 3else 4new = $recycler:_create($ansi_pc); 5if (typeof(new) != OBJ) 6return player:tell("Unable to create Benchmark test player: ", new); 7endif 8new:set_name("Benchmark_test_player"); 9suspend(0); 10ticks = ticks_left(); 11seconds = seconds_left(); 12for x in [1..3] 13$ansi_utils:notify(new, "[blue]B[bold]e[unbold]n[bold]c[unbold]h[bold]m[unbold]a[bold]r[unbold]k [red]T[bold]e[unbold]s[bold]t [random].[random].[random].[random].[random]."); 14endfor 15ticks = ticks - ticks_left(); 16seconds = seconds - seconds_left(); 17new:set_ansi_option("colors", 1); 18new:set_ansi_option("escape", "~"); 19new:set_ansi_option("misc", 1); 20ticks = ticks + ticks_left(); 21seconds = seconds + seconds_left(); 22for x in [1..3] 23$ansi_utils:notify(new, "[blue]B[bold]e[unbold]n[bold]c[unbold]h[bold]m[unbold]a[bold]r[unbold]k [red]T[bold]e[unbold]s[bold]t [random].[random].[random].[random].[random]."); 24endfor 25for x in [1..3] 26$ansi_utils:notify(new, "Testing..."); 27endfor 28this:add_noansi(); 29for x in [1..3] 30$ansi_utils:notify(new, "[blue]B[bold]e[unbold]n[bold]c[unbold]h[bold]m[unbold]a[bold]r[unbold]k [red]T[bold]e[unbold]s[bold]t [random].[random].[random].[random].[random]."); 31endfor 32this:remove_noansi(); 33ticks = ticks - ticks_left(); 34seconds = seconds - seconds_left(); 35$recycler:_recycle(new); 36player:tell("12 notifies: ", ticks, " tick", (ticks == 1) ? "" | "s", ", ", seconds, " second", (seconds == 1) ? "" | "s", "."); 37endif
cutoff_assign
Referenced by
- #32:fill_string line 33:
this:cutoff_assign
Source
1":cutoff_assign (STR string, NUM start, NUM end, STR replacement[, NUM extra])"; 2" => STR"; 3"Example:"; 4" string[2..3] = \"test\";"; 5"Is the same as:"; 6" string = $ansi_utils:cutoff_assign(string, 2, 3, \"test\");"; 7"Except that it ignores the ANSI codes in <string> when finding <start> and"; 8"<end>. If <extra> is specified and true, any codes after <end> but before"; 9"the next character will also be overwritten."; 10if (typeof(a = this:cutoff_locs(@listdelete(args, 4))) == LIST) 11args[1][a[1]..a[2]] = args[4]; 12return args[1]; 13else 14return a; 15endif
setadd
Referenced by
none
Source
1":setadd (LIST l, value) => LIST"; 2"Does the same thing as the built-in setadd(), but if <value> is a string,"; 3"it won't be added to <l> if <value> with it's ANSI codes stripped out equals"; 4"any of <l>'s elements with their ANSI codes stripped out."; 5l = args[1]; 6if ((typeof(value = args[2]) == STR) && this:contains_codes(value)) 7nvalue = this:delete(value); 8for x in (l) 9if ((typeof(x) == STR) && (this:delete(x) == nvalue)) 10return l; 11endif 12endfor 13endif 14return setadd(l, value);
setremove
Referenced by
none
Source
1":setremove (LIST l, value) => LIST"; 2"Does the same thing as the built-in setremove(), but if <value> is a"; 3"string, it will remove any string in <l> that, when it's ANSI codes are"; 4"stripped out, is equal to <value> with it's ANSI codes stripped out."; 5l = args[1]; 6if ((typeof(value = args[2]) != STR) || (!this:contains_codes(value))) 7return setremove(l, value); 8endif 9nvalue = this:delete(value); 10for x in [-length(l)..-1] 11x = -x; 12if ((typeof(l[x]) == STR) && (this:delete(l[x]) == nvalue)) 13l = listdelete(l, x); 14endif 15endfor 16return l;
ansi_status
Referenced by
- #95:@ansi-s*tatus line 31:
$ansi_utils:ansi_status
Source
1mess = {}; 2mess = {@mess, tostr("ANSI Version ", this.version, ":")}; 3a = 0; 4for x in (this.groups) 5a = a + length(this.("group_" + x)); 6endfor 7mess = {@mess, tostr("It is ", this.active ? "currently" | "not", " active. There are ", $string_utils:english_number(a), " codes defined in ", $string_utils:english_number(length(this.groups)), " groups. There ", (length(this.noansi_queue) == 1) ? "is" | "are", " ", $string_utils:english_number(length(this.noansi_queue)), " tasks in the ignore ANSI task queue, and the cleanup task is ", $code_utils:task_valid(this.noansi_queue) ? "currently" | "not", " running.")}; 8return mess;
terminate_normal
Referenced by
- #32:left line 6:
this:terminate_normal - #32:right line 6:
this:terminate_normal - #32:centre line 6:
this:terminate_normal - #32:columnize line 15:
this:terminate_normal - #32:columnize line 17:
this:terminate_normal - #91:say line 4:
$ansi_utils:terminate_normal - #95:say line 8:
au:terminate_normal - #95:@ansi-title line 13:
$ansi_utils:terminate_normal - #95:set_ansi_title line 19:
au:terminate_normal - #95:set_ansi_title line 25:
au:terminate_normal - #116:say line 2:
$ansi_utils:terminate_normal
Source
1":terminate_normal (STR string) => STR <string> with a [[null]normal] code"; 2"tacked onto the end if there wasn't one"; 3if (!index(string = args[1], "[")) 4return string; 5endif 6m = rmatch(string, this.terminate_regexp); 7while ((string && m) && (m[2] == length(string))) 8string = string[1..m[1] - 1]; 9m = rmatch(string, this.terminate_regexp); 10endwhile 11return string && (string + ((m && (string[m[1]..m[2]] != "[normal]")) ? "[normal]" | ""));
left
Referenced by
- #32:columnize line 15:
this:left
Source
1"$ansi_utils:left(string,width[,filler])"; 2""; 3"Assures that <string> is at least <width> characters wide. Returns <string> if it is at least that long, or else <string> followed by enough filler to make it that wide. If <width> is negative and the length of <string> is greater than the absolute value of <width>, then the <string> is cut off at <width>."; 4""; 5"The <filler> is optional and defaults to \" \"; it controls what is used to fill the resulting string when it is too short. The <filler> is replicated as many times as is necessary to fill the space in question."; 6return this:terminate_normal(z = ((l = this:length(out = tostr(args[1]))) < (len = abs(args[2]))) ? out + this:space(l - len, ((length(args) >= 3) && args[3]) || " ") | ((args[2] > 0) ? out | this:cutoff(out, 1, len)));
right
Referenced by
none
Source
1"$ansi_utils:right(string,width[,filler])"; 2""; 3"Assures that <string> is at least <width> characters wide. Returns <string> if it is at least that long, or else <string> preceded by enough filler to make it that wide. If <width> is negative and the length of <string> is greater than the absolute value of <width>, then <string> is cut off at <width>."; 4""; 5"The <filler> is optional and defaults to \" \"; it controls what is used to fill the resulting string when it is too short. The <filler> is replicated as many times as is necessary to fill the space in question."; 6return this:terminate_normal(((l = this:length(out = tostr(args[1]))) < (len = abs(args[2]))) ? this:space(len - l, ((length(args) >= 3) && args[3]) || " ") + out | ((args[2] > 0) ? out | this:cutoff(out, 1, len)));
centre center
Referenced by
- #104:look_self line 4:
$ansi_utils:center
Source
1"$ansi_utils:center(string,width[,lfiller[,rfiller]])"; 2""; 3"Assures that <string> is at least <width> characters wide. Returns <string> if it is at least that long, or else <string> preceded and followed by enough filler to make it that wide. If <width> is negative and the length of <string> is greater than the absolute value of <width>, then the <string> is cut off at <width>."; 4""; 5"The <lfiller> is optional and defaults to \" \"; it controls what is used to fill the left part of the resulting string when it is too short. The <rfiller> is optional and defaults to the value of <lfiller>; it controls what is used to fill the right part of the resulting string when it is too short. In both cases, the filler is replicated as many times as is necessary to fill the space in question."; 6return this:terminate_normal(((l = this:length(out = tostr(args[1]))) < (len = abs(args[2]))) ? tostr(this:space((len - l) / 2, lfill = ((length(args) >= 3) && args[3]) || " "), out, this:space(((len - l) + 1) / -2, (length(args) >= 4) ? args[4] | lfill)) | ((args[2] > 0) ? out | this:cutoff(out, 1, len)));
columnize columnise
Referenced by
none
Source
1"columnize (items, n [, width]) - Turn a one-column list of items into an n-column list. 'width' is the last character position that may be occupied; it defaults to a standard screen width. Example: To tell the player a list of numbers in three columns, do 'player:tell_lines ($string_utils:columnize ({1, 2, 3, 4, 5, 6, 7}, 3));'."; 2items = args[1]; 3n = args[2]; 4width = {@args, 79}[3]; 5height = ((length(items) + n) - 1) / n; 6items = {@items, @$list_utils:make((height * n) - length(items), "")}; 7colwidths = {}; 8for col in [1..n - 1] 9colwidths = listappend(colwidths, 1 - (((width + 1) * col) / n)); 10endfor 11result = {}; 12for row in [1..height] 13line = tostr(items[row]); 14for col in [1..n - 1] 15line = tostr(this:terminate_normal(this:left(line, colwidths[col])), " ", items[row + (col * height)]); 16endfor 17result = listappend(result, this:terminate_normal(this:cutoff(line, 1, min(this:length(line), width)))); 18endfor 19return result;
space
Referenced by
- #32:left line 6:
this:space - #32:right line 6:
this:space - #32:centre line 6:
this:space - #32:centre line 6:
this:space
Source
1"space(len,fill) returns a string of length abs(len) consisting of copies of fill. If len is negative, fill is anchored on the right instead of the left."; 2n = args[1]; 3(typeof(n) == STR) && (n = this:length(n)); 4if (" " != (fill = {@args, " "}[2])) 5fill = fill + fill; 6fill = fill + fill; 7fill = fill + fill; 8elseif ((n = abs(n)) < 70) 9return " "[1..n]; 10else 11fill = " "; 12endif 13m = (n - 1) / this:length(fill); 14while (m) 15fill = fill + fill; 16m = m / 2; 17endwhile 18return (n > 0) ? this:cutoff(fill, 1, n) | this:cutoff(fill, ((f = this:length(fill)) + 1) + n, f);
ansi_title
Referenced by
- #32:show_who_listing line 44:
this:ansi_title - #95:say line 10:
au:ansi_title - #95:@ansi-title line 35:
$ansi_utils:ansi_title - #95:emote line 10:
$ansi_utils:ansi_title
Source
1":ansi_title (OBJ player[, STR name]) => STR <player>'s title"; 2"If <name> is specified, it will be used instead of <player>.name"; 3name = {@args, args[1].name}[2]; 4for x in (args[1].ansi_title) 5if (typeof(x[2]) == LIST) 6nn = x[2][random(length(x[2]))]; 7else 8nn = x[2]; 9endif 10nn && (name = strsub(name, x[1], nn)); 11endfor 12return name;
strip_black
Referenced by
none
Source
1gray = 0; 2x = 1; 3string = args[1]; 4l = length(string); 5while ((x <= l) && (m = match(string[x..l], this.all_regexp))) 6code = string[x + m[1]..(x + m[2]) - 2]; 7if (code in {"gray", "grey"}) 8gray = 1; 9elseif (code in this.group_colors) 10gray = 0; 11elseif (gray && (code == "unbold")) 12string[x + m[2]..(x + m[2]) - 1] = "[white]"; 13x = x + 7; 14endif 15x = x + m[2]; 16endwhile 17return string;
quote_ansi
Referenced by
none
Source
1":quote_ansi (STR string) => STR new_string"; 2"Puts a [[null]null] code in the middle of all of the other codes in <string>"; 3"so they won't be replaced."; 4return strsub(args[1], "[", "[[null]"); 5"...should probably only fix real codes, but this works for now...";
update_player_codes
Referenced by
- #32:update_all line 32:
this:update_player_codes - #95:set_ansi_option line 15:
$ansi_utils:update_player_codes
Source
1":update_player_codes (OBJ player)"; 2"Updates <player>'s .replace_codes property"; 3if (!this:trusts(caller_perms())) 4return E_PERM; 5elseif ($object_utils:isa(plr = args[1], $ansi_pc)) 6codes = {}; 7for x in (this.groups) 8if (plr:ansi_option(x)) 9codes = {@codes, @this.("group_" + x)}; 10(x == "extra") || (codes = setadd(codes, "normal")); 11endif 12endfor 13return plr.replace_codes = (codes in this.replace_code_pointers) || codes; 14endif
fill_string
Referenced by
none
Source
1"fill(string,width[,prefix])"; 2"tries to cut <string> into substrings of length < <width> along word boundaries. Prefix, if supplied, will be prefixed to the 2nd..last substrings."; 3if (length(args) < 2) 4width = 2 + player:linelen(); 5prefix = ""; 6else 7width = args[2] + 1; 8prefix = {@args, ""}[3]; 9endif 10if (width < (3 + length(prefix))) 11return E_INVARG; 12endif 13string = ("$" + args[1]) + " $"; 14len = this:length(string); 15if (len <= width) 16last = len - 1; 17next = len; 18else 19last = this:rindex(this:cutoff(string, 1, width), " "); 20if (last < ((width + 1) / 2)) 21last = width + this:index(this:cutoff(string, width + 1, "$", 1), " "); 22endif 23next = last; 24while (string[next = next + 1] == " ") 25endwhile 26endif 27while (string[last = last - 1] == " ") 28endwhile 29ret = {this:cutoff(string, 2, last)}; 30width = width - length(prefix); 31minlast = (width + 1) / 2; 32while (next < len) 33string = this:cutoff_assign(string, 1, next - 1, "$"); 34"string = \"$\" + string[next..len];"; 35len = (len - next) + 2; 36if (len <= width) 37last = len - 1; 38next = len; 39else 40last = this:rindex(this:cutoff(string, 1, width), " "); 41if (last < minlast) 42last = width + this:index(this:cutoff(string, width + 1, "$", 1), " "); 43endif 44next = last; 45while (string[next = next + 1] == " ") 46endwhile 47endif 48while (string[last = last - 1] == " ") 49endwhile 50if (last > 1) 51ret = {@ret, prefix + this:cutoff(string, 2, last)}; 52endif 53endwhile 54return ret;
@ansi-setup
Referenced by
none
Source
1"Usage: @ansi-setup <this>"; 2"Used to fix various core utilities to work with ANSI. This verb can only be used by a wizard, and needs wizperms to run."; 3"Ugh, this verb is getting out of control, this stuff should all be moved to diagnostic tests."; 4if (!player.wizard) 5player:tell("This verb was intended to fix up the rest of a MOO's core so it can function properly with the ANSI PC. If something's wrong, ask a wizard to set this up for you."); 6elseif (!$code_utils:verb_perms().wizard) 7player:tell("This verb needs to be wizpermed before it can work."); 8elseif (!$command_utils:yes_or_no("This will change various verbs in the core so they can be used with the ANSI PC, overwriting the previous verbs. Are you sure you want to do this?")) 9player:notify("Well, okay then."); 10else 11set_task_perms(valid(cp = caller_perms()) ? cp | player); 12spiffy = 1; 13"----== Corify Objects ==----"; 14for x in ({"help", "pc", "utils", "options"}) 15prop = "ansi_" + x; 16if (!$object_utils:has_property($sysobj, prop)) 17add_property($sysobj, prop, #-1, {player, "r"}); 18player:notify(tostr("Creating a $", prop, " property.")); 19endif 20if (valid($sysobj.(prop))) 21elseif (x == "utils") 22player:notify(tostr("Setting $", prop, " to ", $string_utils:nn(this), ".")); 23$sysobj.(prop) = this; 24else 25objects = {}; 26for o in ({@player.owned_objects || {}, @player.public_identity.owned_objects || {}, @player.contents || {}, @player.location.contents || {}}) 27if (index(o.name, "ANSI") && index(o.name, strsub(x, "s", ""))) 28objects = setadd(objects, o); 29endif 30endfor 31if (!objects) 32return player:notify(tostr("Unable to find $", prop, ", please port this object and set #0.", prop, " to it's object number.")); 33elseif (length(objects) == 1) 34player:notify(tostr("Setting $", prop, " to ", $string_utils:nn(objects[1]), ".")); 35$sysobj.(prop) = objects[1]; 36else 37return player:notify(tostr("Found ", length(objects), " objects that could be $", prop, ", please set #0.", prop, " to the object number of the correct one: ", $string_utils:nn_list(objects))); 38endif 39endif 40endfor 41"----== Wizperm everything that should be ==----"; 42for x in (this.need_wizperms) 43if (!(info = verb_info(y = $sysobj.(x[1]), x[2]))[1].wizard) 44player:notify(tostr("Wizperming $", x[1], ":", x[2], "...")); 45set_verb_info(y, x[2], listset(info, player, 1)); 46endif 47endfor 48if (!($ansi_help in ((typeof(ah = $ansi_pc.help) == LIST) ? ah | {ah}))) 49player:notify("Setting $ansi_pc.help..."); 50$ansi_pc.help = $ansi_help; 51endif 52"----== Various core hacks ==----"; 53su = $string_utils; 54if (!$object_utils:has_callable_verb(su, "redirect_ansi")) 55player:notify("Adding $string_utils:redirect_ansi..."); 56add_verb(su, {$hacker, "rx", "redirect_ansi"}, {"this", "none", "this"}); 57set_verb_code(su, "redirect_ansi", this.redirect_su_code); 58endif 59for x in (this.redirect_su_names) 60if ((info = verb_info(su, x)) && (!index(info[3], "redirect_ansi"))) 61nn = ""; 62for y in ($string_utils:explode(info[3], " ")) 63nn = tostr(nn, " ", y, "(noansi)"); 64endfor 65set_verb_info(su, x, listset(info, $string_utils:triml(nn), 3)); 66player:notify(tostr("Renaming $string_utils:\"", info[3], "\" to \"", nn, "\"...")); 67endif 68endfor 69redirect = $string_utils:from_list({"redirect_ansi", @this.redirect_su_names}, " "); 70if ((info = verb_info(su, "redirect_ansi"))[3] != redirect) 71player:notify(tostr("Renaming $string_utils:redirect_ansi to \"", redirect, "\".")); 72set_verb_info(su, "redirect_ansi", listset(info, redirect, 3)); 73endif 74$command_utils:suspend_if_needed(0); 75((!((length(vc = verb_code($login, "notify")) == 2) && index(vc[2], "$ansi_utils:delete"))) && $command_utils:yes_or_no("Update $login:notify?")) ? set_verb_code($login, "notify", {"(caller!=$ansi_utils)&&set_task_perms(caller_perms());notify(player,$ansi_utils:delete(args[1]));"}) || $player:notify("$login:notify changed.") | ((spiffy = 0) || player:notify("$login:notify left alone.")); 76thatline = "line[1..min(width, length(line))]"; 77newline = "$ansi_utils:cutoff(line,1,min(width,$ansi_utils:length(line)))"; 78for x in ({"mail_agent", "big_mail_recipient"}) 79vc = $string_utils:print(verb_code(y = $sysobj.(x), vn = "display_seq_headers")); 80player:notify(tostr("$", x, ":", vn, " ", ((index(vc, thatline) && $command_utils:yes_or_no(tostr("Replace \"", thatline, "\" in $", x, ":", vn, " with \"", newline, "\"?"))) && (set_verb_code(y, vn, $string_utils:to_value(strsub(vc, thatline, newline))[2]) == {})) ? "changed." | ((spiffy = 0) || "left alone."))); 81endfor 82code = {}; 83for x in (verb_code($login, "@who")) 84code = {@code, strsub(x, "$code_utils:show_who_listing", "$ansi_utils:show_who_listing")}; 85endfor 86if (code != verb_code($login, "@who")) 87player:notify("Setting $login:@who..."); 88set_verb_code($login, "@who", code); 89endif 90$command_utils:suspend_if_needed(0); 91code = {}; 92for x in (verb_code($guest, "do_reset", 0, 0)) 93if ((m = match(x, "^for x in (%(%{.+%}%))$")) && (info = $string_utils:to_value(substitute("%1", m)))[1]) 94x = tostr("for x in (", $string_utils:print($set_utils:union(info[2], $ansi_utils.reset_guest_props)), ")"); 95endif 96code = {@code, x}; 97$command_utils:suspend_if_needed(0); 98endfor 99if (code != verb_code($guest, "do_reset", 0, 0)) 100player:notify("Setting $guest:do_reset..."); 101set_verb_code($guest, "do_reset", code); 102endif 103code = {}; 104for x in (verb_code($prog, "@list", 0, 0)) 105if (code == 0) 106elseif (index(x, "$ansi_utils:add_noansi(")) 107code = 0; 108elseif (index(x, "player:notify(tostr(what, \":\", fullname, \"") == 1) 109code = {@code, "$ansi_utils:add_noansi();", x}; 110else 111code = {@code, x}; 112endif 113$command_utils:suspend_if_needed(0); 114endfor 115if (code && (code != verb_code($prog, "@list", 0, 0))) 116player:notify("Setting $prog:@list..."); 117set_verb_code($prog, "@list", code); 118endif 119code = {}; 120a = {0, 0}; 121for x in (verb_code($generic_editor, "list_line")) 122a[1] = a[1] || index(x, "$ansi_utils:add_noansi("); 123a[2] = a[2] || index(x, "$ansi_utils:remove_noansi("); 124code = {@code, x}; 125$command_utils:suspend_if_needed(0); 126endfor 127a[1] || (code = {"$ansi_utils:add_noansi();", @code}); 128a[2] || (code = {@code, "$ansi_utils:remove_noansi();"}); 129if (code != verb_code($generic_editor, "list_line")) 130player:notify("Setting $generic_editor:list_line..."); 131set_verb_code($generic_editor, "list_line", code); 132endif 133$command_utils:suspend_if_needed(0); 134if (!$object_utils:defines_verb($player_db, "insert")) 135player:notify("Adding $player_db:insert..."); 136add_verb($player_db, {player, "rxd", "insert"}, {"this", "none", "this"}); 137set_verb_code($player_db, "insert", this.plr_db_insert); 138elseif (verb_code($player_db, "insert") != this.plr_db_insert) 139player:notify("$player_db:insert already exists, you will have to edit it manually for the ANSI, see $ansi_utils.plr_db_insert for sample code."); 140endif 141if (verb_code($generic_editor, "fill_string") != this.ge_fill_string) 142a = ""; 143while ($object_utils:has_verb($generic_editor, vname = tostr("fill_string(noansi", a, ")"))) 144a = call_function("tonum", a) + 1; 145endwhile 146set_verb_info($generic_editor, "fill_string", listset(verb_info($generic_editor, "fill_string"), vname, 3)); 147add_verb($generic_editor, {player, "rx", "fill_string"}, {"this", "none", "this"}) || player:notify("Adding new $generic_editor:fill_string..."); 148set_verb_code($generic_editor, "fill_string", this.ge_fill_string); 149endif 150"...ugh, I want to put $prog:@dump in here but the one I put on NestMOO is too big to search..."; 151"----== Set the non-printable characters ==----"; 152try 153$command_utils:suspend_if_needed(0); 154for x in ({{"escape", 27, "033"}, {"beep", 7, "007"}}) 155chr = x[1]; 156code = x[2]; 157octal = x[3]; 158if ((typeof(this.(chr)) != STR) || (length(this.(chr)) != 1)) 159if (eval(";return chr(64);")[1]) 160player:notify(tostr("Setting $ansi_utils.", chr, " with chr()...")); 161eval(tostr(";$ansi_utils.(\"", chr, "\")=chr(", code, ");")); 162elseif ((eval = eval(";return filelist(\"\", \"\");"))[1]) 163if ((chr + ".chr") in eval[2][1]) 164player:notify(tostr("Setting $ansi_utils.", chr, " with FUP from file ", chr, ".chr...")); 165eval(tostr(";$ansi_utils.(\"", chr, "\")=fileread(\"\", \"", chr, ".chr\")[1];")); 166else 167player:notify(tostr("FUP detected, please create a file named \"", chr, ".chr\" in the FUP directory and put an ASCII character ", code, " in it. This can be done on most systems with the command: echo -e '\\", octal, "' > ", chr, ".chr from the FUP directory.")); 168spiffy = 0; 169endif 170else 171z = this.(chr) = tostr("<----- ", $string_utils:uppercase(chr), " ----->"); 172player:notify(tostr("I can't find any way to set $ansi_utils.", chr, ", please either install the FUP or chr() server patches and rerun this verb, or shut down the MOO, load the DB into an editor, and replace \"", z, "\" with an ASCII character ", code, ".")); 173spiffy = 0; 174endif 175endif 176endfor 177except v (ANY) 178player:notify("I could not set 'beep' and 'escape' properties on $ansi_utils. They may already be set to the proper characters."); 179if ($command_utils:yes_or_no("I can put <beep> and <esc> where their characters are supposed to be in the database. You can change them with a text editor later. Do you want me to do this?")) 180$ansi_utils.escape = "<esc>"; 181$ansi_utils.beep = "<beep>"; 182endif 183endtry 184if (this.active) 185player:notify("@ansi-setup finished."); 186elseif (!spiffy) 187player:notify("@ansi-setup can not verify that everything has been set up correctly, you will probably have to rerun this verb. If you're sure everything is correct, you can type: ;;$ansi_utils.active=1; to activate it."); 188elseif ($command_utils:yes_or_no("Everything seems to be set up correctly, activate the ANSI system?")) 189this.active = 1; 190"...raw notify() the first message in case it breaks, we're wizpermed anyway..."; 191notify(player, "The ANSI system is now active, it can be deactivated by typing: ;;$ansi_utils.active = 0;"); 192player:notify(tostr("Welcome to ANSI version ", this.version, ".")); 193else 194player:notify("Not activating the ANSI system, you can do this manually by typing: ;;$ansi_utils.active = 1; when you're sure everything's set up correctly."); 195endif 196endif
get_html_code
Referenced by
- #32:notify line 14:
this:get_html_code
Source
1if (args[1] == "normal") 2return "</font>"; 3endif 4tags = {@this.group_bold, @this.group_colors}; 5codes = {"size=\"+1\"", "", "size=\"+1\"", "", "color=\"red\"", "color=\"green\"", "color=\"yellow\"", "color=\"#2222FF\"", "color=\"blue\"", "color=\"#00DDDD\"", "color=\"#666666\"", "color=\"#666666\"", "color=\"#DD00DD\"", "color=\"white\""}; 6return tostr("<font ", codes[(args[1] in tags) || 2], ">");
player_wrap_off
Referenced by
- #95:@ansi-o*ptions line 9:
$ansi_utils:player_wrap_off
Source
1if (caller == player) 2force_input(player, "@wrap off"); 3endif