Allan Rae <[EMAIL PROTECTED]> writes:
| On 23 Apr 2001, Lars Gullik [iso-8859-1] Bjønnes wrote:
|
| > Allan Rae <[EMAIL PROTECTED]> writes:
| >
| > * Just a thought spun-off from this work: using addition-order and a
| > * simple class we could have macro-recording and playback of LyXFunc
| > * actions in a few lines of code.
| >
| > That can be done a lot simpler.
| >
| > For macro:
| > - add two new LFUN's macro-begin and macro-end
| > - record (in Dispatch) all commands accessed between a
| > macro-begin and macro-end pair.
| >
| > Playback of complete session:
| > - just record every LFUN and store it to file.
| > - add a command arg that "runs" this file
|
| Sure, only the implementation I was thinking of had a:
| vector<pair<LFUN, string arg> >
mine did also.
| instead of a file and whenever you press macro-begin when already
| recording the record starts again.
I'd rather put that down as an error.
The recording to file would be more of a debuggin tool as it could
record and playback a whole session.
| I had considered doing something fancy like:
| vector<LFUNAction>
|
| struct LFUNAction {
| LFUNAction(LFUN, string const &);
| void operator() ();
|
| private:
| string what_the_arg_was;
| LFUN what_the_dispatch_number_was;
| };
|
| So the LFUNAction gets created and appended to the vector. Then to replay
| the macro you just iterate over the vector and execute the LFUNAction's.
I don't see the point. Just iterate over the vector and run Dispatch
on all elements instead.
| There are plenty of possible tweaks to do here and I've probably
| overlooked stuff. The good thing is that we can effectively record most
| dialog interaction as well so long as the dialog calls LyXFunc->Dispatch
| to get its outputs set (ie. when you press OK).
|
| The first version instead lets you create a:
|
| struct LFUNAction {
| void operator() (pair<LFUN, string>);
| };
|
| for_each(macro.begin(), macro.end(), LFUNAction());
Still don't like it.
std::for_each(macro.begin(), macro.end(),
lyx::class_fun(string, lyxfunc, LyXFunc::Dispatch));
seems better to me, more obvious and open.
| I wasn't intending to allow recorded macros to last longer than the
| duration of an editting session, unless, like emacs, you name the macro.
| Then you have the name of the macro file to use also.
sure.
--
Lgb