Hello,
I would like to monitor haw much time I spend on editing every single file in project.
It means I need macro triggered by "onchange_editor_window" what saves current
time - previous time. Is something like "events" in macro slick programming?
Or somebody has similar macro?
--
best regards
ml.
This is probably fairly easy. I'll post the code for you in a few days if you can't do it and no-one else does.
I would suggest using a one second timer callback or whatever rate you're comfortable with. The callback would check _mdi.p_child.p_buf_name or p_DocumentName to see which buffer/file is active, compare it with the last active buffer and either call the _time function to work out the elapsed time or increment a one second counter for that buffer. Calling _time is probably best/ more accurate. A hash table would be used to give fast lookup for the buffer time. When non-interrupt code wanted to inspect the times, it would need to set a flag/lock to prevent the timer callback from modifying any data for a short time. I'm not sure when timer callbacks occur - whether they can "interrupt" a piece of macro code or are called only from an event loop (I suspect the latter), but the lock is easy to do. If you want the elapsed time to stop counting when SlickEdit doesn't have the focus I would have to investigate how to achieve that.
You could probably use the _switchbuf and _buffer_add notifications but I would recommend the timer callback, or maybe a combination if you wanted more accuracy.
Graeme