#1 2016-05-02 19:49

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

[Suggestion] Change script insertion behavior

I wrote a lengthy script and clicked the Scripts button to display the menu so I could save it. Unfortunately my finger slipped on the trackpad and I clicked on an existing script's name by mistake. This completely replaced my new script with the existing one, and even Ctrl+Z couldn't undo this mistake so I lost all my hard work.

I have a very simple solution for this. Whenever we select an existing script, instead of overwriting whatever is in the code window, it should be inserted instead at the current cursor location. This will have multiple benefits:

  1. No possible loss of existing code.

  2. If the existing code is to be discarded we can easily use Ctrl+A and Del prior to script insertion.

  3. This will allow code snippets to be inserted easily. For example, if I have a section of code I reuse frequently, I can simply save just that bit in a .PAS file, then insert it whenever and wherever I want inside (not in place of) a new script I am writing.
     
    Currently it is tedious to do this because I need to browse to the directory, open the snippet file in a text editor, copy the code and paste it into the code window. Why should all this be required when we can simply click on the snippet script's name in the menu and have it inserted directly into the code window?

Offline

#2 2016-05-04 20:56

kunkel321
Member
From: Washington State
Registered: 2012-09-01
Posts: 38

Re: [Suggestion] Change script insertion behavior

It makes sense to me (but then you can see my level of Pascal knowledge from a couple of other posts! wink )
Question:  Would you want the commented first lines {name of script} to be truncated so they don't fill up your script with snippet titles?
Also, I image some people would soon have more scripts than could fit in a single popup list without scrolling, but that's okay.  smile

EDIT:  In the popup script list there is a "Save Script" command.  I suppose if folks were doing snippets, then you'd want the option to select only a portion of the script in the window, and save that (rather than the entire script).  Or maybe that's already possible, I don't know.

Last edited by kunkel321 (2016-05-04 20:59)

Offline

#3 2016-05-05 15:09

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,379

Re: [Suggestion] Change script insertion behavior

Andrew wrote:

I wrote a lengthy script and clicked the Scripts button to display the menu so I could save it. Unfortunately my finger slipped on the trackpad and I clicked on an existing script's name by mistake. This completely replaced my new script with the existing one, and even Ctrl+Z couldn't undo this mistake so I lost all my hard work.

This can be addressed by enabling undo operation when loading external scripts which overwrite the current script. This will get implemented in the next version.

Andrew wrote:

I have a very simple solution for this. Whenever we select an existing script, instead of overwriting whatever is in the code window, it should be inserted instead at the current cursor location.

I don't like using insertion mode as a default, it seems counter-intuitive. Maybe using modifier keys to differentiate between script opening modes would be more elegant.

For example:
A) By default, loading a new script overwrites the current script, with ability to undo.
B) If SHIFT key is down when the new script is loaded, then the new script is inserted into the current script, replacing the current selection (if any), with ability to undo.

Offline

#4 2016-05-05 16:28

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: [Suggestion] Change script insertion behavior

kunkel321 wrote:

Question:  Would you want the commented first lines {name of script} to be truncated so they don't fill up your script with snippet titles?

Well, I was mainly thinking about short code-only snippets saved with descriptive file names, but you do bring up an interesting point. I suppose if there are any comments at the top of a snippet then it'll do no harm to include them as well.

kunkel321 wrote:

Also, I image some people would soon have more scripts than could fit in a single popup list without scrolling, but that's okay.  smile

That can already happen though, so it's not a new issue.

kunkel321 wrote:

EDIT:  In the popup script list there is a "Save Script" command.  I suppose if folks were doing snippets, then you'd want the option to select only a portion of the script in the window, and save that (rather than the entire script).  Or maybe that's already possible, I don't know.

No, I don't think that's possible, and although I didn't think of it I don't believe it is all that necessary. It'll be up to users to remove all non-essential code and save just the required bit if they want a snippet rather than a full script. They should probably also name the files accordingly so they'll know what's what.

den4b wrote:

This can be addressed by enabling undo operation when loading external scripts which overwrite the current script. This will get implemented in the next version.

Not quite what I was looking for Denis, but I'll take it. smile

den4b wrote:

I don't like using insertion mode as a default, it seems counter-intuitive. Maybe using modifier keys to differentiate between script opening modes would be more elegant.

For example:
A) By default, loading a new script overwrites the current script, with ability to undo.
B) If SHIFT key is down when the new script is loaded, then the new script is inserted into the current script, replacing the current selection (if any), with ability to undo.

Insertion by default doesn't seem counter-intuitive to me, however using the Shift modifier is also a good idea. The only minor issue with this I feel is that it's pretty non-discoverable. How would a user ever know about this feature unless they happen to read about it? Perhaps you can come up with something to address this, if you too feel it could be an issue?

Offline

#5 2016-05-09 09:47

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,379

Re: [Suggestion] Change script insertion behavior

den4b wrote:

A) By default, loading a new script overwrites the current script, with ability to undo.
B) If SHIFT key is down when the new script is loaded, then the new script is inserted into the current script, replacing the current selection (if any), with ability to undo.

These two ideas can now be tested in v6.4.0.3 Beta.

Andrew wrote:

The only minor issue with this I feel is that it's pretty non-discoverable. How would a user ever know about this feature unless they happen to read about it? Perhaps you can come up with something to address this, if you too feel it could be an issue?

I agree, it is pretty non-discoverable. At the very least, it is documented on the wiki.

Last edited by den4b (2016-05-09 09:51)

Offline

#6 2016-05-11 18:35

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: [Suggestion] Change script insertion behavior

Works well Denis, not that I expected any less. smile

I was wondering... is it possible to display a tooltip when the mouse hovers over menu items? Perhaps then an appropriate message can be displayed to the user about this feature.

Last edited by Andrew (2016-05-11 18:36)

Offline

#7 2016-05-12 22:00

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,379

Re: [Suggestion] Change script insertion behavior

Andrew wrote:

I was wondering... is it possible to display a tooltip when the mouse hovers over menu items? Perhaps then an appropriate message can be displayed to the user about this feature.

How about a hint-comment in the code template?

begin
  // Add your code here
  // Press Ctrl+Space for code completion
  // Hold Shift when loading a script to insert it inline
end.

Offline

#8 2016-05-13 15:24

Andrew
Senior Member
Registered: 2008-05-22
Posts: 542

Re: [Suggestion] Change script insertion behavior

den4b wrote:

How about a hint-comment in the code template?

That's a great solution, Denis. Thumbs_Up.gif

Offline

Board footer

Powered by FluxBB