Author Topic: Possibility of monitoring time of file edit activity  (Read 6083 times)

marlag

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Possibility of monitoring time of file edit activity
« on: April 15, 2008, 09:06:24 AM »
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.

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Possibility of monitoring time of file edit activity
« Reply #1 on: April 15, 2008, 10:39:11 PM »
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

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Possibility of monitoring time of file edit activity
« Reply #2 on: April 15, 2008, 11:00:03 PM »
@Graeme: I was also unsure about the timer management and asked an expert time ago.
And your supposition is right - there are no macro interrupts.
HS2