Darkenelf's Editor

This is the Darkeneditor, a device that makes editing a lot easier for people who can't run client programs. The editor works on a temporary copy of any register that you specify.

Category: Other

Instructions

Copy and paste the below code into a compatible MUSH or MUX.

MUSHCode for Darkenelf's Editor

@lock Darkenelf's Editor==me
@Desc Darkenelf's Editor=You see a small gizmo with a keypad and an LCD screen. This is the Darkeneditor, a device that makes editing a lot easier for people who can't run client programs. The editor works on a temporary copy of any register that you specify. A summary of commands is listed below:%r[u(ljust_fnc,edit obj/reg,15)] - This starts editing a temporary copy of the specified register.%r[u(ljust_fnc,edit/display,15)] - This displays the edited text. The cursor position is indicated at the start of the text by a number, and within the text by '[v(cursor)]'. The text is automatically displayed after all editing commands.%r[u(ljust_fnc,edit +num,15)] - Moves the cursor forward by num characters.%r[u(ljust_fnc,edit -num,15)] - Moves the cursor backward by num characters.%r[u(ljust_fnc,edit/find text,15)] - Places the cursor at the first occurence of <text>.%r[u(ljust_fnc,edit/ins text,15)] - Inserts <text> at the cursor position. WARNING! Special characters like \% and \[\] must be preceded by the escape character \\. Otherwise, these characters will be evaluated instead of being stored as text.%r[u(ljust_fnc,edit/delnum,15)] - Deletes <num> characters BACKWARDS from the cursor position.%r[u(ljust_fnc,edit/save,15)] - Saves the edited text back in the specified register and finishes editing.%r[u(ljust_fnc,edit/quit,15)] - Finishes editing without saving the edited text.%r%r
@set Darkenelf's Editor/Desc = no_command
&STATUS Darkenelf's Editor=editing
&LJUST_FNC Darkenelf's Editor=%0[space(sub(%1,strlen(%0)))]
&EDIT_DELETE Darkenelf's Editor=$edit/del *: @switch lt(sub(v(pos),%0),0)=1,{@pemit %#=Too many characters to delete.},{&edit_temp me=mid(v(edit_temp),0,sub(v(pos),%0))[mid(v(edit_temp),v(pos),strlen(v(edit_temp)))];&pos me=sub(v(pos),%0);@tr me/display=%#}
&EDIT_FIND Darkenelf's Editor=$edit/find *: &pos me=switch(pos(%0,v(edit_temp)),#-1,0,sub(pos(%0,v(edit_temp)),1));@tr me/display=%#
&EDIT_INSERT Darkenelf's Editor=$edit/ins *: &edit_temp me=mid(v(edit_temp),0,v(pos))[v(0)][mid(v(edit_temp),v(pos),strlen(v(edit_temp)))];&pos me=add(v(pos),strlen(%0));@tr me/display=%#
&POS Darkenelf's Editor=17
&EDIT_BACKWARD Darkenelf's Editor=$edit -*: &pos me=switch(lt(sub(v(pos),%0),0),1,0,sub(v(pos),%0));@tr me/display=%#
&EDIT_FORWARD Darkenelf's Editor=$edit +*: &pos me=switch(gt(add(v(pos),%0),strlen(v(edit_temp))),1,strlen(v(edit_temp)),add(v(pos),%0));@tr me/display=%#
&EDIT_DISP Darkenelf's Editor=$edit/display:@tr me/display=%#
&CURSOR Darkenelf's Editor=[]
&DISP_FUNC Darkenelf's Editor=[mid(%0,0,%1)][v(cursor)][mid(%0,%1,strlen(%0))]
&EDIT_ABORT Darkenelf's Editor=$edit/quit: @switch v(status)=editing,{@pemit %#=Aborting edit - [name(v(edit_object))]/[v(edit_reg)] not saved.;&[v(edit_reg)] [v(edit_object)]=v(edit_backup);&edit_object me=#-1;&edit_reg me=;&edit_temp me=;&edit_backup me=;&status me=},{@pemit #21746=You are not editing at the moment.}
&SAVE_REGS Darkenelf's Editor=&edit_temp me=get([v(edit_object)]/[v(edit_reg)]);&edit_backup me=get([v(edit_object)]/[v(edit_reg)])
&EDIT_DONE Darkenelf's Editor=$edit/save: @switch v(status)=editing,{@pemit %#=Saving [name(v(edit_object))]/[v(edit_reg)].%rDone.;&[v(edit_reg)] [v(edit_object)]=v(edit_temp);&edit_object me=#-1;&edit_reg me=;&edit_temp me=;&edit_backup me=;&status me=},{@pemit %#=You are not editing at the moment.}
&START_EDIT Darkenelf's Editor=$edit */*: @switch/first switch(owner(locate(%#,%0,*)),%#,1,0) [v(status)]=0 *,{@pemit %#=You don't own that.},1 editing,{@pemit %#=You are already editing [name(v(edit_object))]/[v(edit_reg)] - type ### to close.},{&edit_object me=locate(%#,%0,*);&edit_reg me=%1;&status me=editing;&pos me=0;@tr me/save_regs;@tr me/display=%#}
&DISPLAY Darkenelf's Editor=@pemit %0=switch(v(edit_object),#-1,Invalid edit object.,Cursor: [v(pos)]%r[U(disp_func,v(edit_temp),v(pos))])
&EDIT_OBJECT Darkenelf's Editor=#17163
&EDIT_TEMP Darkenelf's Editor=This is a TEST...
&EDIT_REG Darkenelf's Editor=feh
@set Darkenelf's Editor=INHERIT
@set Darkenelf's Editor=COMMANDS