Script editor suggestions

From Dragon Age Toolset Wiki
Jump to: navigation, search

Going Home

It would be nice if the Home key would to go to start of text on a line rather than start of line. Or as with the Visual Studio IDE could be used to toggle between the start of the line and the start of the text.

Drag And Drop

The implementation of drag and drop in the editor is pretty much unusable. I know that I've started using copy/cut and paste a lot more as a result.

  1. There are no visual cues for the drag and drop gesture:
    1. The cursor does not change to a beam so it is very difficult to gauge where the text will be inserted when you drop it (contrast with NWN toolset).
    2. Additionally it doesn't add a little + to indicate if you are moving or copying (so if you've forgotten to press Ctrl or pressed Shift by accident you are none the wiser).
    3. Finally it does not indicate invalid drop zones (which are normally indicated by a Ø cursor)
  2. If you drop text on an invalid drop zone (such as the column containing the line numbers) the text being dragged simply disappears rather aborting the drop (i.e. doing nothing/remaining in its original location)

The solution may be to be steal the drag and drop code from the NWN toolset since it didn't have these issues.

Tabbing A Line or Lines

If you select one or more entire lines (including the newline character) by dragging the cursor from the start of the first line in the block (directly down) to the start of the first line after the block and then hit Tab key the block is indented as expected, but so is the first line after the block. This is unexpected and different from, for example, the Visual Studio IDE where only the highlighted lines are indented.

A workaround is to select all or part of the first line but only part of the last line (i.e. you can select all of the visible text as long as you don't select the newline character). However this does not work for a single line. If you select some or all of the visible text (but not the newline character) on a single line and hit Tab key the text is replaced with a tab character. Consequently it is not possible to indent a single line using line selection and Tab key.

The solution would be to prevent the unselected line from being indented allowing for a consistent user experience.

Bad Indentions

In certain situations the auto-indent feature adds in an extra tab for no apparent reason. This normally occurs you are breaking a long line into two or more shorter lines or if you hit Return key again immediately after removing a newline. For some reason I also associate this with braces getting out of position but I've not been able to recreate an example so I might be remembering incorrectly. Probably not worth investigating but might be worth the programmer keeping in the back of his mind when reviewing the code.

For example, if you remove the newline character from between the second and third lines in the following return statement:

string v2s(vector v)
{
    return "(" + FloatToString(v.x, 0, 2)
        + ", " + FloatToString(v.y, 0, 2)
        + ", " + FloatToString(v.z, 0, 2)
        + ")";
}

And then hit Return key again you get the following instead of the original text:

string v2s(vector v)
{
    return "(" + FloatToString(v.x, 0, 2)
        + ", " + FloatToString(v.y, 0, 2)
            + ", " + FloatToString(v.z, 0, 2)
        + ")";
}

Note: even though the above are continuations of a single multi-line statement it can be replicated using multiple complete statements.

Scroll Lock vs. Overwrite

There is a Scroll Lock (SCRL) indicator in the editor's status bar but the editor does not support scroll locking.

Conversely is no Insert/Overwrite (INS/OVR) indicator in the editor's status bar but the editor does support the insert and overwrite modes.

Assuming you have no intention to support scroll lock (since it is essentially redundant) the Scroll Lock indictor should be replaced by an Insert/Overwrite indicator.

Replace All In Selection

Using Replace All on a selection clears the selection after it has completed that operation. This makes it annoying if you want to perform multiple Replace All operations on the same section of code as it requires the same block to be selected multiple times. Contrast this with Word.

Drowning In Inaccessible Variables

Both Auto Complete (F2 or Ctrl+Space) and the Functions/Variables/Constants/Templates (FVCT) Panel contains all variables visible to the current script file rather than the variables that are actually in scope for the current context (be it a script or a block within a block). This isn't too bad when working in an isolated script since on balance most of variables will accessible in the context in which you are trying to use them (i.e. in main or a block within main). Obviously it is slightly more of an issue when working on a function within your script as fewer variables will be in scope. However both features are rendered almost entirely useless for variables the moment you include a core script as they become flooded with hundreds of inaccessible, out of scope variables.

Ideally these two features would only ever present variables that were in scope for the current script or block but this is probably an unrealistic expectation. However, since Dragon Age does not supports script level variables (i.e. those declared at the same level as constants and functions) these two features, at the very least, should not include variables from anything other than the current script.

Devoid Of Accessible Parameters

Neither Auto Complete nor the FVCT Panel pick up parameters within a function and offer them as variables.

Ideally these two features would only ever present variables that were in scope for the current script or block but this is probably an unrealistic expectation. However, since Dragon Age does supports parameter variables these two features, at the very least, should include parameters from the current script (but not from any script further up the include chain).

Feature Rich FVCT Panel

Currently the FVCT panel has very limited functionality:

  1. single-clicking a function (and only a function) displays the appropriate comments in the Help Window
  2. double-clicking any symbol (or hitting the Return or Enter key a selected symbol) inserts the symbol at the current point

Single-clicking a function in the FVCT panel, does not guarantee that the Help Window will actually be visible. If like me you group the Help Window with other panels such as the Log Window, Resource History, Find/Replace and Bookmarks you have to manually select it to see the comments. In contrast to double-clicking on a function in the script always displays the Help Window. It would be helpful if the Help Window was automatically displayed when browsing symbols in the FVCT panel.

There is also scope for adding some basic but extremely useful features to the FVCT list:

  • Being able to copy a symbol to the clipboard so that it can be used repeatedly without having to mouse from the editor to the FVCT list and back again.
  • A Tooltip stating the source file containing the symbol in case we want to use that function or constant in another script with the minimum number of includes.
  • Being able to use Go to definition feature on functions and constants in the FVCT panel so that we don't have to artificially insert it into the current script or, if read only, find a script further up the include chain that uses it. The feature should also work for variables in the FVCT list however, as described above, variables should be limited to the current script.
  • Clicking on a Constant would show its definition in in the Help Window (as this would let us see both the type and literal value)
  • Clicking on a Template would show its contents in the Help Window

Constant Help

Double clicking on a constant in the editor should display the definition in the Help Window (as this would let us see both the type and literal value).

There And Back Again

After using the Go to definition feature there is no way to return to the originating location.

This isn't a huge issue if the symbols are in different scripts and you only have those scripts open as you can simply click the appropriate tab. However if you have a lot of tabs open it can be a bit of a pain (as you have to work out which script you came from and/or want to go back to) and if the symbol is in the same script it is a complete pain (as you have to manually scroll back or use find to return to the original location). Currently a partial workaround this is to bookmark the current position before using the Go to definition feature but that is almost as much trouble.

In contrast even very old versions of SlickEdit had a very nice feature where you can use the equivalent of Go to definition (Ctrl+.) repeatedly and then navigate back up the stack returning (Ctrl+,) to your original position.

Save As Template

Make it possible to select a section of script or an entire script in the editor; save it as a template and have it automatically added to the Templates list in the FVCT panel. It should be possible to overwrite an existing template (with appropriate confirmation). This would avoid having to manually create and update these in an external text editor and restart the Toolset to see these changes. It should encourage code reuse as you wouldn't have to stop what you were doing to make the template (which has been the problem up to now).

Unicode Friendly Filter

The text box used to filter the FVCT panel has some odd Unicode options and options which don't appear to do anything in its context menu. As these options don't appear in any other context menu I've seen I suspect they are not actually required. Since, for example, inserting a control character prevents any matches being made (without any visible cause) the filter's context menu properties should be reviewed to see if the options following the Select All options are actually required.