Editorial Workflows

stopwatch

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: A stopwatch that's part of a collection of workflows I use to log exercises and workouts. If the caret sits in a line that doesn't contain a clock in the format "h:mm:ss", the workflow will add a blank clock wherever the caret is placed when the workflow is invoked. Once started, press the active workflow spinner (top right hand corner of the screen) to stop the clock.

The workflow also allows for restarting a previously stopped clock...

2018-04-24

Shared by: @jsamlarose

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Set Variable ?
Variable Name
anchor
Value
Sel. Range: Start:Sel. Range: End
Extend Selection ?
Direction
  • Backward
  • Forward
  • Both
Unit
  • Start/End of Document
  • Start/End of Line
  • Number of Characters...
1
Find ?
Search for
\d:\d\d:\d\d
Match Group (RegEx)
0 (entire match)
Search Type
  • Regular Expression
  • Case-insensitive Search (A = a)
  • Case-sensitive Search (A ≠ a)
Output
  • Found Text
  • Range of Text (from:to)
insert clock if none detected ?
Run the block if
Input
  • is Equal to
  • is Not Equal to
  • Contains
  • Doesn't Contain
  • Matches Regular Expression
0:0
Select Range ?
Range (from:to)
anchor
Relative to
  • Entire Document
  • Current Selection
Replace Selected Text ?
Replacement Text
0:00:00
Extend Selection ?
Direction
  • Backward
  • Forward
  • Both
Unit
  • Start/End of Document
  • Start/End of Line
  • Number of Characters...
1
Find ?
Search for
\d:\d\d:\d\d
Match Group (RegEx)
0 (entire match)
Search Type
  • Regular Expression
  • Case-insensitive Search (A = a)
  • Case-sensitive Search (A ≠ a)
Output
  • Found Text
  • Range of Text (from:to)
…End If
Select Range ?
Range (from:to)
Input
Relative to
  • Entire Document
  • Current Selection
Run Python Script ?
Source Code
import time
import editor
import workflow
import sys
import os

startclock = workflow.get_input()
selectstart = editor.get_selection()[0]
selectend = editor.get_selection()[1]
hours, minutes, seconds = startclock.split(":")
hours = int(hours)
minutes = int(minutes)
seconds = int(seconds)

a = 0
while a < 1:
	time.sleep(1)
	try:
		if seconds < 59:
			seconds = seconds + 1	
		else:
			seconds = 0
			if minutes == 59:
				minutes = 0
				hours += 1
			else:
				minutes += 1		
		editor.replace_text(selectstart, selectend, str(hours) + ":" + str(minutes).zfill(2) + ":" + str(seconds).zfill(2))
	except (KeyboardInterrupt, SystemExit):
		sys.exit()