def edit_parser(args)
case args
when nil
sendto("What??")
when /^\.h/
sendto "@edit help (commands on blank line):\n.r /old/new/ - replace a substring\n.h - get help (this info)\n.s - show string so far\n.ww [width] - word wrap string (width optional)\n defaults to 76\n.c - clear string so far\n.ld <num> - delete line <num>\n.li <num> <txt> - insert <txt> before line <num>\n.lr <num> <txt> - replace line <num> with <txt>\n@ - end string\n"
when /^\.c/
@editstr = ""
when /^\.s/
sendto(edit_display(@editstr))
when /^\.r\s+\/(.+)?\/(.+)?\//
@editstr.gsub!($1, '\2')
when /^\.ww\s+(\d+)/, /^\.ww/
@editstr = word_wrap(@editstr, $1 && $1.to_i > 2 ? $1.to_i : 76 )
when /^\.ld\s+(\d+)/
idx = $1.to_i
return if idx < 1
idx -= 1
lines = @editstr.split("\n")
lines.delete_at(idx)
@editstr = lines.join("\n")
when /^\.li\s+(\d+)\s+(.*)?$/
idx = $1.to_i
return if idx < 1
idx -= 1
nl = $2
lines = @editstr.split("\n")
lines.insert(idx, nl + "\n")
@editstr = lines.join("\n")
when /^\.lr\s+(\d+)\s+(.*)?$/
idx = $1.to_i
return if idx < 1
idx -= 1
nl = $2
lines = @editstr.split("\n")
lines[idx] = nl + "\n"
@editstr = lines.compact.join("\n")
when /^@/
@mode = nil
if @editobj.object_id == world.msgs.object_id
@editobj.send("[]=", @editfield, @editstr)
else
@editobj.send(@editfield+"=", @editstr)
end
when /^\./
sendto "Invalid command."
else
@editstr << args << "\n"
end
end