SMM++ Manual Version 5.0

12 Scriptfile Editor

12.1 Why Scriptfiles and not fancy Inputs?

I want to point out this matter, as I chose this implementation after thinking well about it. I hope you understand my arguments and dont miss "modern days" inputs. It would have been much easier to provide "fancy" alias/action/etc. inputs and indeed I wanted to do so, until I recognized that those "fancy" inputs arent powerful! As soon as I tried to make them more powerful, they got very unhandy in usage or become naturally an editor.

There is an easy explanation for this: In really powerful configurations aliases, variables, action, userinterface, etc. go hand in hand! e.g.:

Example:
::variable bag
::variable stuff

::set bag   backpack
::set stuff torch

# wear the bag
::proc wb {} {::variable bag ; wear $bag}
# remove the bag
::proc rb {} {::variable bag ; remove $bag}
# look at some stuff and remember at what you have looked
::proc l  {what} {
  ::variable stuff  
  ::set stuff $what 
  ::tomud "look at $stuff"
}
# easily put the "stuff" into the bag
::proc pb {} {
  ::variable bag
  ::variable stuff
  ::tomud "put $stuff in $bag"
}

# during mudding you find a sword, examine it,
#  find it interessting and take it with you
l sword
pb

This is only a very basic example, but it well points out the matter. You dont want to have the aliases and variables scattered around in different user interfaces.

12.2 Three Flavors of Scriptfiles

There are three different types of scriptfiles:
  • SMM++ scriptfiles,
  • session scriptfiles and
  • user scriptfiles.
SMM++ scriptfiles
are distributed with the SMM++ package. You cannot edit, save or delete them. They are intended to be examples of how SMM++ can be used. You are encouraged ot send in your scripts to be included into the distribution. Just export your script to a file and send it to the author. So others can profit from your work too! (You can load these scriptfiles into your session with the command '::smm::file syseval', please refer to the commands section of the documentation.)
Session scriptfiles
are loaded at start of a session. Here you can store your configuration on per session basis. Of course they are saveable, but (of course) not deletable. If you dont want a configuration leave the file empty. If you delete a session, all session configuration (including its scriptfile) is deleted.
User scriptfiles
close the gap between the SMM++- and session script files. Here you can store your more global configurations and load them into all session scriptfiles, which need these configurations. I.e. this means that many sessions can share the same scriptfiles. It is natural that you can create and delete all these scriptfiles as you want to. E.g. general aliases like '::proc ga {} {get all}' are best kept here,.. (You can load these scriptfiles into your session with the command '::smm::file usereval', please refer to the commands section of the documentation.)

12.3 Start the Scriptfile Editor

From the Configuration menu choose Scriptfile Editor. The editor will show up and you can enter your input. At any time, you can save your text or close the editor with cancel.

You can launch or close the editor at any time. It doesnt interfere with any other actions. If you start a session it will load whatever is saved on disk. If you close the editor and launch it later again, you can continue exactly where you stoped your work.

12.4 Use the Scriptfile Editor

When designing the editor I had always emacs in mind; so most concepts are taken from there (though emacs is of course much better than the SMM scriptfile editor,.. If you miss some needed functionality please notify me. Thanks!).

Unlike emacs you can only view one buffer at a time: the actual buffer.

12.4.1 Buffers

One of the concepts is the buffer concept. Each buffer has a corresponding file and vice versa. If you load a file, its corresponding buffer is created containing what is in the file. If you save a buffer, its content is written to the file.

The buffermanager keeps track of all the seperate buffers loaded.

12.4.2 Editor Menubar

Here follows a description of the menubar entries. Most actions can be invoked via key sequences; they are denoted beneath the entry.

  • File
    Buffers
    Invokes the buffermanager. You can switch to another buffer by clicking on it. The buffers are separated in three classes which correspond to the three flavors of scriptfiles.
    SMM++ scriptfile
    A chooser will pop up, in which you can choose a SMM++ scriptfile or cancel this action.
    If a file is choosen it will be loaded into its buffer. If the buffer is already loaded it will not be reloaded, but becomes the actual buffer. You cannot edit this buffer, but have a look at it or copy parts of code, if you want to.
    user scriptfile
    A chooser will pop up, in which you can choose a user scriptfile or cancel this action.
    You can also choose to create a new file: Enter a file name in the entrybox and press the 'new'-button. The filename must begin with a lower case character (a-z) and continue with lower case (a-z) or numeric (0-9) characters.
    If the buffer is already loaded it will not be reloaded, but becomes the actual buffer.
    session scriptfile
    A chooser will pop up, in which you can choose a session scriptfile or cancel this action.
    If a file is choosen it will be loaded into its buffer. If the buffer is already loaded it will not be reloaded, but becomes the actual buffer.
    Session scriptfiles are those, which will be executed, if a session is started ('load' or 'connect' from the session manager).
    Save
    Saves the actual buffer.
    Kill
    Removes the actual buffer from memory (and buffermanager). The file itself stays untouched! It is a "save" action, if you dont want your changes (since the last save) to take effect.
    Delete
    Removes the actual buffer from memory and removes the file too! This of course only works for user scriptfiles. This action may be desasterous,..
    Import
    You need a editable buffer as the actual buffer. A filechoose will pop up and you can choose a file. The contents of this file will be inserted at the text cursor position. You can use this function to import scriptfiles of others into your SMM scriptfiles.
    Export
    A filechooser will pop up and you have to choose a file, into which the actual buffer will be saved. After saving you can e.g. send this file to your friends or to SMM++ to be included into the distribution. If accepted, it will become a SMM++ scriptfile. You are strongly encouraged to contribute! Thanks a lot in advance!
    Close
    Closes the editor window (it doesn't delete it!). This is a save action. If you restart the editor, you continue your work, where you have stopped. If SMM++ had been stopped meanwhile, you loose of course all your unsaved changes.
  • Edit
    Remark:
    1. You can select pieces of text by clicking into the text, keeping the mouse button pressed and drag the mouse to some other point.
    2. The editor has its own clipboard.
    Undo
    Undoes your last action(s). The undo buffer has a length of 50. The implementation of Undo may not be 100% save yet! So dont depend too much on it. If you find bugs, please notify me! Thanks!
    Redo
    Redoes undoes,..
    Cut
    Cuts the selected text into the clipboard.
    Copy
    Copies the selected text into the clipboard.
    Paste
    Inserts the text in the clipboard at the text cursor position.
    Sys.-Paste
    Inserts the text in the system-clipboard at the text cursor position.
    Clear
    Deletes all selected text.
    Select all
    Unselect all
  • Option
    Quite obvious,.. if not, then I guessed wrong and then please! tell me, so I can write some docu.
  • Find
    Find button
    You enter a find expression into the find entry, choose find options and press the 'Find' button. The found text piece(s) is (are) marked.
    Clear button
    The 'Clear' button removes all find marks and clears the 'Find' and 'Replace with' entries.
    Replace button
    If you press the 'Replace' button all found marked text pieces are replace with whatever is in the 'Replace with' entry. If you leave it empty you will remove all found marked text. After replacement took place another find is initiated.
Selim Issever
<SMM++ Configuration|Contents|Scripting in SMM++>