Idea collecting thread: Scripting / Macro

Started by Stefan, April 21, 2009, 09:15:26 PM

Previous topic - Next topic

Stefan

Quote from: alex on September 27, 2009, 02:35:28 PM
And if macro does not change cursor position or how to find out that it is now over bookmark?
And then to describe user why my macro which moves mouse or opens files does not work till end of file? or how can I get it working?
I just do not want to have such unclear options which are not fitting to all scenarios.
And execute n time fit to all. You can open file or move mouse n times.

Sorry Alex, i didn't understand. I see this only from an user POV, and see it implemented in other editor. BUT...
QuoteLet do simple Single and n Times execute and then discuss based on existing functionality.
... OK ;D
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

Yes, I found Run till End of File in notepad ++.
For me looks strange. Tried with one installed macro: trim trailing space and save (by the way could not found how to edit macro).

So, let us discuss this later. And thanks for scripts. I would check them when implementing object model for scripting.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

1.) FYI, an another example of an simple macro style to easy create an macro "by hand" in text editor

Quotetrim(" \t")
setlineformat(1)
setblanks(0,1,2)
replace("<","&lt;")
replace(">","&gt;")
beginline("<p>")
endline("</p>")
insert("<html>",1)
insert("<head>",2)
insert("<meta name=\qauthor\q content=\qSomebody\q>",3)
insert("<title>Something</title>",4)
insert("</head>",5)
insert("<body>",6)
add("</body>")
add("</html>")

---
2.)
How did you though about quoting?
Would HE remove to outer quotes?
Like from:  tmp="C:\Doc and Set\user\loc\temp"


Since quoting could be hell, maybe you want to add an quote(str) function
and/or an special sign like \q to insert an "-sign, like in the example above.

Explanation:
quote (example="one" str=""string"")  => "example="one" str=""string"""
str="This is what \qi\q mean:"  => "This is what "i" mean:"
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

but I think, here is and object to which all this insert and add missing :)
About function for removing adding quotes. Do not know. My idea was to deliver some set of helper includes in vb and js for example with functions like this, which can be reused later on in user scripts.
But maybe be some of such functions could be integrated into the host.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Stefan

>object missing
Leading object needed, yes.

>removing adding quotes
I see i was not clear:
i have seen other script implementations who remove the outer quotes on processing,
so we  have to take care to double the quotes, so one pair can be removed from the engine.
Sounds easy to add an additional pair, but can be tricky.
Of course we can wait how this will works with HES and if we run into troubles.
I just wanted to mention it before it is to late for you to implement.

CU
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

zhouzh2

FYI Alex have you considered the following:
I think the concept of 'a macro is a script and a script is a macro' is fine.  but sometimes things get complicated in different situations. Fex. when in Column mode, overwrite mode, or tab when smart tab is on, or BS when smart backspace is on...same key stroke, but can yield different result.
To deal with such situation, Ultraedit treat macro differently from scripts, and macros are only combination of key strokes. the editor environment (such as column mode on/off, overwrite on/off, etc. anything that may change a key's behavior) when the macro is recorded is listed in the head of produced macros files.
VIM also treat macro and script differently. VIM only record key strokes. This is fine for VIM since every command of vim is a combination of key stroke.
Emeditor's approach is similar to HE. macro is just a script. Fex. it has document.selection.text object for text inputed in insert mode, and document.selection.DestructiveInsert object for text inputed in overwrte mode. But there is no such object for column mode, so macro recording when column mode is on is not supported in Emeditor.
As you can see, trying to interpret every key stroke to a script can be complex from time to time.
Therefore the idea of separating macros and scripts might not be as bad as it sounds. Wsh has WshShell Object that can send keys, such as shell.SendKeys() etc. In this way it maybe possible to have both macro and script to choose from for different situation , using the same Action Script engine.
However this is just for your information ;) Which style our HE will use, is up to you ::)

alex

Hi Angus,

I have already changed my mind and in actual implementation in 1.50 (can be already checked if you read carefully :) ) there are macros and scripts.

Macros are as you have mentioned recorded sequence of hippoedit commands (because in HE also most of actions are commands) with some special macro entities as Sleep, Mouse actions and keyboard actions when recorded activity from other applications.

Scripts are executed by implemented Active Scripting engine (WSH is not used) and can be in any language for which scripting engine installed (by default VB and JavaScript but can be Perl, PHP, Ruby, Lua etc). There are some specialties implemented as build in include support, register and init functions and resident scripts (you can subscribe on event from script dynamically and then script will be kept in memory until program exits).

But there is a way designed to convert Macro to Script (probably will be done also with help of scripts to support all engine conversion).

The reason for splitting macro and scripts was rather trivial: I want to support temporary macros which you do not need to save but they are kept alive even after HE restart until you record another macro. And to not bother users in which format (scripting language) macro should be serialized I introduced XML format which is lossless (if I will convert in some script silently, I can not do then conversion from one scripting language to another).
Also in case of macro recording all smart features are disabled, so the result will be more or less predictable (but maybe I will do this optional).

Macro support in 1.50 is already mostly ready (except of conversion to script) and for scripting only engine is done and I need to fill it with all functions and provide UI for resident script management. I have delayed that to time after plugin infrastructure implementation because they will use same objects.

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

scribbly

Hi: I'm not actually a HE user (yet -- but it's getting close). I've had a long history with PSPad, and it's code folding that's tempting me to change, so I'm sussing...

But I just thought I'd comment on this:
Quote from: alex on March 31, 2010, 07:42:32 PM
The reason for splitting macro and scripts was rather trivial: I want to support temporary macros which you do not need to save but they are kept alive even after HE restart until you record another macro.

PSPad can keep 4 recorded macros in memory, and it's very handy to have more than one -- and I often do!

Stefan

#38
Hi scribbly,

welcome to the community.

Good suggestion.

Just to make clear, what PSPad does is just to provide an shortcut for the very last recently used macros. (pic 1)
You can execute every time the last macro always by pressing "F5" key. That key is auto-assigned to the most recent macro.
The other hotkeys you have to assign on your own. (pic 3)
But you are always asked to give an name after you stop an macro recording. (pic 2) That's nothing special.
For HippoEDIT 1.50 there will be an "recent macro list" like "File > Open..." for that purpose.
And of course you will be able to load as many stored macros as you want.

HippoEDIT on the other hand want to provide you the option to not think about
an name to store the last macro, but just "keep it in memory" for re-use. (but an menu option to store it too, if you like)


Since Alex is on work to implement that feature right now, it's good to talk about such things, thank you for your input.
See you next.
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

Hi Stefan,

thanks for the help. Basically you have mentioned everything what I want to say.
From another side, I think you have not checked yet how this is already done in HE 1.50 ;)

Yes, the main idea was to not bother user at all. In HE temporary macro does not have name at all (and it is not asked of course at the end) and so can be only one (I mean in such, unsaved kind).
And as in PSPad there is a command to execute last macro (can be as temporary one as one of "named" ).

In same way, if you want to store the macro, you do save, give it a name, have in the execute dialog list and there is also recent list for macros.

For shortcut assigning I do not like style PSPad has, and want to have something similar to management for tools/help items, where you can organize your macros in way you like and can assign to any macro a shortcut.
How this will be done not yet clear, I need to clarify this after full implementation of scripting. Because scripts will also need to have a way to get a shortcut assigned. So I do not want to populate such management dialogs but maybe gather everything inside tools dialog.. This is not yet clear.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]