How do I create an open-ended 'stopwatch' timer?

Id like to be able to log support time in FT.

At the moment Im using toggl which operates on a pretty simple clock on / off principle.

Can I do something similar with FT, ie start a named timer without specifying an end time, and just manually finish it.

I guess I could simulate by using short 15 minute tasks and repeating them sequentialky as required - and that has the advantage of making it less likely I forget my timer is running - but is an open ended timed event possible?

Yes, certainly possible!

Two parts to creating a mode:

  1. Decide on data structure. In FoldingText this almost always means “text formatting”.

  2. Decide on behavior, how should it work.

Generally I would recommend thinking a lot about what you want the text formatting to look like first. Ideally you can come up with a format that’s even somewhat useful in any plain text editor. Then later you can add behavior code, but that data structure is first.

When designing the data structure you have a few tools at your disposal. First basic structure is created using Markdown formatting. Second if you need to represent state and property values you can use “tags” or “properties”.

So with that in mind here’s my idea on how it might be structured:

  1. For each project you want to track you write the projects name and add a “clock” mode.

  2. The project should maintain some sort of on/off state. I think that could be done with a “@running” tag on the project. Alternatively it might be done with a contained “running” property line. That might actually be better since then we could track the time it started as the value of that property line. Then if you saved and quit (or app crashed) any running timers would still have correct time since start is stored in text.

  3. So that gives us a basic timer. Next step is to make it so that it remembers each session work session so that it will know the projects total time. I think we can do that by adding a line for each sessions duration, contained in the project. Could do this a number of ways, but maybe simplest is to just follow “timer” mode convention and add those items as unordered lists. So the end result would look like:

my project.clock
	Running : Jun 5, 2014 2:40:50 PM
- 30 min
- 15 min
- 2 hours

Does that seem like it would work and encodes all the needed information?

Later once the data structure is set we can add behavior, such as a Start/Stop button that will automatically add those lines for you and calculate and display a total time.

@mrsean2k I’ve created a stopwatch mode plugin for you to try out. Please try it out and let me know how you like it. I had to use a bit of private API, I’ll document that API for future release and I’m also planning to do a post describing the overall design and coding process for this plugin.

Hi Jesse,

Despite being silent on the matter, I’ve had a small dig into plugin development, but still just nibbling at the edges; I had n almost-solution by defining a simple plugin to duplicate the current timer and restart it, so I’d kick off a 15 minute timer with the appropriate reference and then just duplicate with a keystroke when I had notification it expired.

A bit more familiar with some of the concepts (particulary the relationships between nodes / lines and other basic structures) but I definitely need more time.

Thanks for adding this; I’ll install and feed back.

Sean

Just a quick tip, nodes and lines are 1:1. In some “normal” text editors the text is read into an array of lines… FoldingText is doing pretty much that, except:

  1. It stores each “line” in a node.

  2. It does that so that the classifier process can assign each line parent/child relationships.

I’ve installed the plugin, and it’s just about perfect for my use-case - thanks for taking the time to do it.

I love the fact I can add a quick note under each stopwatch line to remind myself what a particular burst of activity was for if I needed to explain / justify to a customer / myself what I was actually doing - customers rarely ask, but I like to feel comfortable about billing time down the line.

I’ve been using this for a few days now, and it’s extremely useful - the main advantage being there’s so little friction to the process of timing that it’s easy to time everything without interrupting my flow.

On occasion I leave a timer running when I’ve wandered onto something else, so I thought I’d see if I can add a notification every 15 minutes to see if a simple beep would be enough to remind me the clock’s still ticking. Looking at the plugin code, I’d expected to see a setTimeout / setInterval or equivalent to update the timed display that I could piggyback on, but I can’t see it (or I’m staring at it and it just isn’t registering)

Can you point me in the right direction?

Ach, clocktick at the bottom of main.js, sorry!

@mrsean2k No problem, glad you are looking at the code. The reason for doing it with “clock tick” extension point is so that all timer like things can update with the exact same update cycle.