### gMOO Tcl configuration script
#

### Register macros:
#
register.macro e       macro_do_e      {Invoke the verb editor}
register.macro ne      macro_do_ne     {Invoke the string and list editor}
register.macro de      macro_do_de     {Describe an object}
register.macro me      macro_do_me     {Describe yourself}
register.macro he      macro_do_he     {Describe your location}
register.macro verb    macro_do_verb   {Show the verb name on an object}
register.macro prop    macro_do_prop   {Show the propertie names on an object}
register.macro macros  macro_do_macros {Show a listing of the registered macros}

### Implement macros
#
proc macro_do_e    args { send "@edit [lindex $args 0]" }
proc macro_do_ne   args { send "@notedit [lindex $args 0]" }
proc macro_do_de   args { send "@notedit [lindex $args 0].description" }
proc macro_do_me   args { send "@notedit me.description" }
proc macro_do_he   args { send "@notedit here.description" }
proc macro_do_verb args { send "@d [lindex $args 0]:" }
proc macro_do_prop args { send "@d [lindex $args 0]." }

proc macro_do_macros args {
	tell "\033\[32mClient macros:"
	tell [format "%-13s %-50s %s" {Macro name} Description {Tcl Command}]
	set list [registered.macros -client]
	set len [llength $list]
	for {set i 0} {$i < $len} {incr i 3} {
		if {[expr $i + 3] == $len} {set s "`"} {set s "|"}
		tell [format "$s- %-10s %-50s %s" \
			[lindex $list $i] \
			[lindex $list [expr $i + 2]] \
			[lindex $list [expr $i + 1]] \
		     ]
	}
	tell "\nWorld macros:"
	tell [format "%-13s %-50s %s" {Macro name} Description {Tcl Command}]
	set list [registered.macros -world]
	set len [llength $list]
	for {set i 0} {$i < $len} {incr i 3} {
		if {[expr $i + 3] == $len} {set s "`"} {set s "|"}
		tell [format "$s- %-10s %-50s %s" \
			[lindex $list $i] \
			[lindex $list [expr $i + 2]] \
			[lindex $list [expr $i + 1]] \
		     ]
	}
	tell -n "\033\[0m"
}
