Bug 234710 - experiment with text macro recording
Summary: experiment with text macro recording
Status: CLOSED DUPLICATE of bug 8519
Alias: None
Product: Incubator
Classification: Eclipse Project
Component: e4 (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: E4 Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 8519
Blocks: 80140
  Show dependency tree
 
Reported: 2008-05-29 15:36 EDT by Paul Webster CLA
Modified: 2017-11-06 12:39 EST (History)
10 users (show)

See Also:


Attachments
Macro project archive v01 (6.06 KB, application/octet-stream)
2008-05-29 15:37 EDT, Paul Webster CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Webster CLA 2008-05-29 15:36:10 EDT
Recording commands and text keystrokes might go a long way to providing macro recording.

This requires some investigation.
Comment 1 Paul Webster CLA 2008-05-29 15:37:27 EDT
Created attachment 102722 [details]
Macro project archive v01
Comment 2 Paul Webster CLA 2008-06-13 09:54:57 EDT
This experiment seems to have a lot in common with https://bugs.eclipse.org/bugs/show_bug.cgi?id=8519#c44

PW
Comment 3 Paul Webster CLA 2008-06-13 14:50:34 EDT
The latest version of the investigation is now in e4-incubator/ui/org.eclipse.e4.text.macro

It's not very predictable, although it should be.

PW
Comment 4 Paul Webster CLA 2008-09-16 11:17:54 EDT
(In reply to comment #3)
> The latest version of the investigation is now in
> e4-incubator/ui/org.eclipse.e4.text.macro
> 
> It's not very predictable, although it should be.

It turns out that bug 247069 was killing me on linux.

PW
Comment 5 Ernest Pasour CLA 2008-10-29 08:35:04 EDT
I can't seem to find the incubator website, so I apologize if the following is already taken into account.

I think it would be more useful to start with turning all actions into commands.  This can be used as a base for further macro support.  In my macro recording work, I started with the idea of capturing commands.  I turned any keystrokes that were entered into commands if possible.  So I:

1. created new commands that are currently missing from the system.  Ex. Move cursor up (i.e. up arrow).  There is no command for this, but the StyledText widget knows how to process the keystroke.  I added new commands for all of the ST command constants.
2. I translated character keystrokes into commands.  So if I decided they typed 'A', then I created an instance of command InsertString("A").

One problem that I didn't have a solution for was special modes.  I expect intellisense to generate commands for inserting a string, not necessarily to record the invocation of intellisense and moving the cursor in the hover tip and hitting return.  I think users are smart enough to know that you can't really record that.  

However, there are other modes (like matching quote mode) that could really benefit the command recording by issuing commands instead of doing operations directly on the document.  In my experimentation, in a Java document, typing '"' was handled by a VerifyKeyListener on the Editor.  That listener inserted the matching quote directly into the document; the StyledText object didn't even receive an event, you'd have to listen to the document listener.  This made it very difficult to figure out which events should be recorded from which listener.  I believe the solution is to encode those inserts as commands instead, channeling the changes through one interface.  So I would see something like:
InsertString("\"\"")     //inserting the quote and matching quote
Move Cursor Left          //putting the cursor back between the quotes
Move Cursor Right         //the user typed over the quote, leading to no document change

This requires that editor operation be made macro-enabled I think, since only they have semantic knowledge of the edits they are performing.  A playback should work the same way regardless of whether a user has "insert matching quotes" mode turned on or off.
Comment 6 Paul Webster CLA 2008-10-29 08:46:35 EDT
(In reply to comment #5)
> I can't seem to find the incubator website, so I apologize if the following is
> already taken into account.
> 
> I think it would be more useful to start with turning all actions into
> commands.  This can be used as a base for further macro support.  In my macro
> recording work, I started with the idea of capturing commands.

The direction of this experiment is to capture any commands that are issued or keystrokes that aren't filtered by the WorkbenchKeyboard.  The commands can be replayed through the IHandlerService, and the keystrokes by simply using org.eclipse.swt.widgets.Display.post(Event).

The "everything is a command" macro/scripting support has to be in there from the ground up, and will be looked at in e4.  However, simply being able to re-post commands and key strokes might go a long way to help in 3.x.

AFAICT this won't allow scripting of eclipse in the broad sense, but would allow text macros to be created within an editor and then executed.

PW
Comment 7 Ernest Pasour CLA 2008-10-29 08:54:11 EDT
Okay, that sounds reasonable.

I am not expecting that this would allow for general scripting of Eclipse.  I think that is a different problem with different requirements.

However, I did have one question.  I think in my experiments that mixing Display.post() with command execution gave me some issues with out of order execution.  It seemed to work if I posted the command executions as well, but I was still uncomfortable with it.
Comment 8 Paul Webster CLA 2008-10-29 09:09:19 EDT
(In reply to comment #3)
> The latest version of the investigation is now in
> e4-incubator/ui/org.eclipse.e4.text.macro

The CVS Repo for this path is :pserver:anonymous@dev.eclipse.org:/cvsroot/eclipse and then look in HEAD

PW
Comment 9 Paul Webster CLA 2008-10-29 15:29:24 EDT
(In reply to comment #7)
> However, I did have one question.  I think in my experiments that mixing
> Display.post() with command execution gave me some issues with out of order
> execution.  It seemed to work if I posted the command executions as well, but I
> was still uncomfortable with it.

I've updated the project to use WorkbenchKeyboard directly (the tweaklet patch must be applied to org.eclipse.ui.workbench, and is in /org.eclipse.e4.text.macro/org.eclipse.ui.workbench.txt)

This version will record one macro and can replay it.  It has the above mentioned problem that all the commands get executed while the posts start to trickle in because they're posted from another thread.  Also, it will only replay lower case :-)

Steve had mentioned that you didn't have to post the events from a different thread (although that's what at least one of their snippets does).

I'll investigate further.

PW
Comment 10 Fabio Zadrozny CLA 2017-11-06 12:39:27 EST
Closing this issue. I've submitted an initial implementation regarding text macro recording in Bug 8519 -- the artifacts from that can be already installed in Eclipse through the incubation snapshots -- https://wiki.eclipse.org/E4/Macros has more info (waiting for more feedback on Bug 8519).

*** This bug has been marked as a duplicate of bug 8519 ***