Yes, certainly possible!
Two parts to creating a mode:
Decide on data structure. In FoldingText this almost always means “text formatting”.
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:
For each project you want to track you write the projects name and add a “clock” mode.
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.
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:
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.