wh me=Beginning installation of lib-unparseobj... @prog lib-unparseobj 1 10000 d i ( lib-unparseobj: $Revision: 1.17 $ $Date: 2007/04/20 22:08:42 $ ) ( Author: Feaelin Moilar AKA Iain E. Davis ) ( Purpose: Provides more sophisticated unparseobj with color and flagging. ) ( Contributors: Syvel ) ( Dependencies: lib-case ) ( Dependents: lib-look, cmd-find, look-show-exits ) ( --------------------------------------------------------------------------- ) ( Inspired By Syvel's glow-color-unparseobj ) ( Dedicated to Syvel...Syvel contributed extensively to the FB/Glow ) ( community. If you ever see her, give her the appreciation she deserves. ) ( Thank you, Syvel! ) ( --------------------------------------------------------------------------- ) ( This library provides four publicly accessible routines: ) ( ) ( UPO-special-unparseobj: d formatstr -- s ) ( Takes format string formstr and generates a formatted string: see format ) ( specifiers below. ) ( ) ( UPO-color-unparseobj: d -- s ) ( Generates a colorized unparseobj either using the default format string, ) ( or the nearest format string in the environment ) ( ) ( UPO-color-query: s1 s2 -- s ) ( Takes string 's1' looks up color 's2' and prepends the appropiate color ) ( code ) ( ) ( UPO-color-query-d: s1 s2 -- s d ) ( Takes string 's1' looks up color 's2', prepends s1 with the color code. ) ( Returns database reference of database item the code was found on. ) ( ) ( UPO-color-setting: startref prefprop -- dbref-color-found-on color ) ( Takes dbref 'startref' and looks up color preference 'prefprop' and ) ( searches up the environment to find where that color preference is set ) ( and what it is set to. ) ( ) ( Format Specifiers: ) ( %N %n Name of Object. 'One' ) ( %P Name of Object 'One' [No upper or lower adjustment] ) ( %D %d DBref of Object. '#1' ) ( %T %t Type Flag. 'P' [also %o for back-compatibility] ) ( %F %f General Flags 'CT' ) ( %B %b Builder Flag 'B' ) ( %L %l Mucker/Wizard 'W4' ) ( Level Flag ) ( %M %m Meeper Flag 'M' ) ( %/ Conditional Slash '/' or '' if nothing after. ) ( %Q %q %P[%D%T%/%F%/%B%M%L] 'One[#1P/CI/BMW4] ) ( Except the brackets are actually parentheses, ) ( but I can't include parentheses in a comment. ) ( ** THIS IS THE DEFAULT ) ( %X %x %T%/%F%/%B%M%L 'P/CI/BMW4' ) ( %Y %y %F%/%B%M%L 'CI/BMW4' ) ( %Z %z %/%B%M%L '/BMW4' ) ( ) ( Syvel's version prepended forward slashes using %b instead of %B. I prefer ) ( to use the pronoun substitution model, which means %B would produce 'B' if ) ( the Builder flag is set, while %b produces 'b'. To insert a slash ) ( intelligently, just use %/. ) ( ) ( lib-unparseobj will attempt to use the FENI-name library call if there is ) ( $lib/feni library and will call the FENI-name word in place of a normal ) ( call to 'name'. It calls FENI-name with two dbrefs on the stack ) ( [me @ database-item-dbref], which it expects the word to destroy. ) ( ) ( This lib supports the following props: ) ( _prefs/unparse/format: Format for full unparseobj ) ( _prefs/unparse/nocolor?: 'yes' to disable smart colorization. ) ( _prefs/unparse/colors/: ) ( By setting to you can customize the color of a given ) ( item's color. The carets are not required for the color codes, but ) ( can be included if you desire. The props are searched through the ) ( entire environment, which means a muck can change the muck wide ) ( defaults by setting these on a top level parent, or even customize by ) ( area/region be setting them on lower-level parents. ) ( ) ( The preferences and their defaults are: ) ( builder:^GREEN^ -- The color of the "builder" flag. ) ( dbref:^FOREST^ -- The color of the dbref#. ) ( exit:^BLUE^ -- The color of the name of an exit & the type flag. ) ( flag:^AQUA^ -- The color the miscellaneous flags. ) ( guest:^GLOOM^ -- The color of the "guest" flag. ) ( meeper:^CYAN^ -- The color of the "meeper" flag. ) ( mucker:^RED^ -- The color of the "mucker" flags. ) ( paren:^GREY^ -- The color of the parentheses. ) ( player:^GREEN^ -- The color of the player name and type flag. ) ( feni:^GREEN^ -- The color of the player's feni-name. ) ( sleeper:^FOREST^ -- The color of the sleeper name and type flag. ) ( program:^RED^ -- The color of the program name and type flag. ) ( room:^CYAN^ -- The color of the room name and type flag. ) ( slash:^GREY^ -- The color of the slash. ) ( thing:^PURPLE^ -- The color of the thing name and type flag. ) ( unknown:^GLOOM^ -- The color of garbage obj and type flag ) ( wizard:^PURPLE^ -- The color of the "wizard" flags. ) ( --------------------------------------------------------------------------- ) ( $Log: lib-unparseobj,v $ Revision 1.17 2007/04/20 22:08:42 feaelin Added support for FENI and added the UPO-color-setting word which searches environment for color code settings. Revision 1.16 2005/09/25 23:10:37 feaelin Revised documentation. Revision 1.15 2005/04/07 21:20:00 feaelin Added Library Symbols Revision 1.14 2005/04/05 21:23:13 feaelin It is kindof annoying to have to make another commit for a single character typo in the documentation...unfortunately, it was a critical one. Revision 1.13 2005/04/05 21:18:32 feaelin Brought library calls in line with the new standard. Tidied documentation Revision 1.12 2005/04/04 23:04:18 feaelin Removed extraneous include of lib-glow-standard. Updated documentation Revision 1.11 2005/03/21 01:31:43 feaelin General maintenance and documentation updates Revision 1.10 2004/04/23 02:38:44 feaelin Installer now flags the program link_ok Revision 1.9 2004/04/22 01:41:27 feaelin Added support for lib-feni, if it exists on the muck that lib-unparseobj is on. Revision 1.8 2004/04/12 15:47:57 feaelin Documentation cleanup. Revision 1.7 2004/04/10 15:54:10 feaelin Fixed bugs related to the builder, guest, and meeper flags Revision 1.6 2004/04/10 15:19:21 feaelin Fixed bug in public library call of UPOspecial-unparseobj Fixed bug in formatting that caused names with parentheses in them be colorized to the paren color. Revision 1.5 2004/04/10 15:12:29 feaelin Streamlined the color-query code. Made the word public for handy use in other programs, e.g., @detail. Made the documentation clearer and more detailed. Revision 1.4 2004/04/08 03:01:20 feaelin database item names are now different colors Revision 1.3 2004/04/07 03:48:43 feaelin Added %/ and fixed the // error. Revision 1.2 2004/04/07 00:08:07 feaelin Minor fixes ) ( -------------------------------------------------------------------------- ) $include $lib/case $def NOCOLORPROP "_prefs/unparse/nocolor?" $def COLORPROPDIR "_prefs/unparse/colors/" $def FORMATPROP "/_prefs/unparse/format" $def DEFAULTFORMAT "%P(%D%T%/%F%Z)" ( color selection handling ) : color-query (s s -- s ) ( string-to-color prefprop -- resultstring ) me @ NOCOLORPROP envpropstr swap pop "y" instring if pop "" else me @ COLORPROPDIR 3 pick strcat envpropstr swap pop dup "" strcmp not if pop prog "_colors/" rot strcat getpropstr else swap pop then "" "^" subst "^" swap strcat "^" strcat then swap strcat ; PUBLIC color-query : color-setting (d s -- d s ) ( startref prefprop -- dbref-color-found-on color ) over NOCOLORPROP envpropstr "y" instring if swap pop swap pop "Color Disabled" exit else pop swap over COLORPROPDIR swap strcat envpropstr dup "" strcmp not if pop pop prog "_colors/" rot strcat getpropstr prog swap exit else rot pop then then ; PUBLIC color-setting : format-setting ( d -- d s ) ( startref -- dbref-format-found-on formatstr ) FORMATPROP envpropstr dup "" strcmp not if pop pop prog DEFAULTFORMAT exit then ; PUBLIC format-setting : color-allowed-setting ( d -- d s ) ( startref -- dbref-found-on yes/no-str ) NOCOLORPROP envpropstr dup "" strcmp not if pop pop prog "Yes" exit else dup "y" instring if pop "Yes" exit else pop "No" exit then then ; PUBLIC color-allowed-setting : name-color ( s d -- s ) case exit? when "" "exit" color-query end program? when "" "program" color-query end dup player? if awake? when "" "player" color-query end then dup player? if awake? not when "" "sleeper" color-query end then room? when "" "room" color-query end thing? when "" "thing" color-query end default "" "unknown" color-query end endcase swap strcat ; : feni-name ( d -- s ) ( We should check depth and use checkargs? ) "$lib/feni" match program? if me @ swap "$lib/feni" match "FENI-Name" call "feni" color-query else name then ; ( Builder, Guest, Meeper flags we put next to the M1/W3 flag ) : b-flag ( d -- s ) dup "b" flag? swap player? and if "B" "builder" color-query else "" then ; : g-flag ( d -- s ) dup "guest" flag? if "G" "guest" color-query else "" then ; : m-flag ( s d -- s ) dup "meeper" flag? swap player? and if "M" "meeper" color-query else "" then ; : parse_mlevel ( d -- s ) mlevel case 0 = when "" end 1 = when "M1" "mucker" color-query end 2 = when "M2" "mucker" color-query end 3 = when "M3" "mucker" color-query end 4 = when "W1" "wizard" color-query end 5 = when "W2" "wizard" color-query end 6 = when "W3" "wizard" color-query end 7 = when "W4" "wizard" color-query end 8 = when "W5" "wizard" color-query end endcase ; : parse_type ( d -- s ) case exit? when "E" "exit" color-query end program? when "F" "program" color-query end player? when "P" "player" color-query end room? when "R" "room" color-query end thing? when "T" "thing" color-query end default "?" "unknown" color-query end endcase ; : parse_flags ( d -- s ) "" over "a" flag? if "A" strcat then over "b" flag? if over player? not if "B" strcat then then over "c" flag? if "C" strcat then over "d" flag? if "D" strcat then over "guest" flag? if "G" "guest" color-query strcat then over "h" flag? if "H" strcat then over "idle" flag? if "I" strcat then over "j" flag? if "J" strcat then over "k" flag? if "K" strcat then over "l" flag? if "L" strcat then over "meeper" flag? if over player? not if "M" strcat then then over "q" flag? if "Q" strcat then over "s" flag? if "S" strcat then over "tinkerproof" flag? if "T" strcat then over "v" flag? if "V" strcat then over "x" flag? if "X" strcat then over "z" flag? if "Z" strcat then swap pop "flag" color-query ; : do-slashes dup "%/" instr dup if 1 + strcut dup "%/" instr if do-slashes then dup ansi_strip dup "" strcmp not swap dup ")" rinstr 1 = swap "/" rinstr 1 = or or if swap dup strlen 2 - strcut pop swap strcat else swap dup strlen 2 - strcut pop "/" strcat swap strcat then else pop then ; : special-unparseobj ( d s -- s ) "%T" "%O" subst "%t" "%o" subst "%P(%D%T%/%F%/%B%M%L)" "%Q" subst "%p(%d%t%/%f%/%b%m%l)" "%q" subst "(" "paren" color-query "(" subst ")" "paren" color-query ")" subst "%T%/%F%/%B%M%L" "%X" subst "%t%/%f%/%b%m%l" "%x" subst "%F%/%B%M%L" "%Y" subst "%f%/%b%m%l" "%y" subst "%/%B%M%L" "%Z" subst "%/%b%m%l" "%z" subst swap dup feni-name dup 4 pick swap 4 pick name-color "%P" subst 3 put 1 strcut swap dup toupper 3 pick strcat 4 pick name-color -3 rotate tolower swap strcat 3 pick name-color 4 rotate swap "%n" subst swap "%N" subst "#" "dbref" color-query 3 pick int intostr strcat dup rot swap "%D" subst swap "%d" subst over parse_type dup tolower -3 rotate toupper "%T" subst swap "%t" subst over parse_flags dup tolower -3 rotate toupper "%F" subst swap "%f" subst over b-flag dup tolower -3 rotate toupper "%B" subst swap "%b" subst over m-flag dup tolower -3 rotate toupper "%M" subst swap "%m" subst over parse_mlevel dup tolower -3 rotate toupper "%L" subst swap "%l" subst "%/" "slash" color-query "%/" subst do-slashes swap pop ; PUBLIC special-unparseobj : color-unparseobj ( d -- s ) dup "/_prefs/unparse/format" envpropstr swap pop dup "" strcmp not if pop DEFAULTFORMAT then special-unparseobj ; PUBLIC color-unparseobj . c q @reg lib-unparseobj=lib/unparseobj @set $lib/unparseobj=L @set $lib/unparseobj=/_defs/UPO-NOCOLORPROP:"_prefs/unparse/nocolor?" @set $lib/unparseobj=/_defs/UPO-FORMATPROP:"/_prefs/unparse/format" @set $lib/unparseobj=/_defs/UPO-COLORPROPDIR:"_prefs/unparse/colors/" @set $lib/unparseobj=/_defs/UPO-color-allowed-setting:"$lib/unparseobj" match "color-allowed-setting" call @set $lib/unparseobj=/_defs/UPO-color-query:"$lib/unparseobj" match "color-query" call @set $lib/unparseobj=/_defs/UPO-color-setting:"$lib/unparseobj" match "color-setting" call @set $lib/unparseobj=/_defs/UPO-color-unparseobj:"$lib/unparseobj" match "color-unparseobj" call @set $lib/unparseobj=/_defs/UPO-format-setting:"$lib/unparseobj" match "format-setting" call @set $lib/unparseobj=/_defs/UPO-special-unparseobj:"$lib/unparseobj" match "special-unparseobj" call @set $lib/unparseobj=/_defs/UPOcolor-query:"$lib/unparseobj" match "color-query" call @set $lib/unparseobj=/_defs/UPOcolor-unparseobj:"$lib/unparseobj" match "color-unparseobj" call @set $lib/unparseobj=/_defs/UPOspecial-unparseobj:"$lib/unparseobj" match "special-unparseobj" call @set $lib/unparseobj=/_defs/color-query:"$lib/unparseobj" match "color-query" call @set $lib/unparseobj=/_defs/color-unparseobj:"$lib/unparseobj" match "color-unparseobj" call @set $lib/unparseobj=/_defs/special-unparseobj:"$lib/unparseobj" match "special-unparseobj" call @set $lib/unparseobj=/_colors/builder:^GREEN^ @set $lib/unparseobj=/_colors/dbref:^FOREST^ @set $lib/unparseobj=/_colors/exit:^BLUE^ @set $lib/unparseobj=/_colors/flag:^AQUA^ @set $lib/unparseobj=/_colors/guest:^GLOOM^ @set $lib/unparseobj=/_colors/meeper:^CYAN^ @set $lib/unparseobj=/_colors/mucker:^RED^ @set $lib/unparseobj=/_colors/paren:^GREY^ @set $lib/unparseobj=/_colors/player:^GREEN^ @set $lib/unparseobj=/_colors/feni:^GREEN^ @set $lib/unparseobj=/_colors/sleeper:^FOREST^ @set $lib/unparseobj=/_colors/program:^RED^ @set $lib/unparseobj=/_colors/room:^CYAN^ @set $lib/unparseobj=/_colors/slash:^GREY^ @set $lib/unparseobj=/_colors/thing:^PURPLE^ @set $lib/unparseobj=/_colors/unknown:^GLOOM^ @set $lib/unparseobj=/_colors/wizard:^PURPLE^ @set $lib/unparseobj=/_lib-version:FM$Revision: 1.17 $ @set $lib/unparseobj=/_/de:Use @list $lib/unparseobj=1-94 for documentation. @set $lib/unparseobj=/_docs:@list $lib/unparseobj=1-94 @set $lib/unparseobj=/_lib-symbol:UPO wh me=Installation Complete.