I have had several people request what, on the surface, seems a simple and innocuous feature in Terminology: search for the text in my clipboard when Terminology is launched. I’ve been working on this feature in Terminology 2 (shipping in July 2011). What follows is a rumination on how a feature that seems so simple to an end user can present interesting challenges when trying to implement it in an elegant way [1].
Let’s start by unpacking the feature request.
“search for the text in my clipboard when Terminology is launched.”
We have an action, “search”. We have target data, “the text in my clipboard”. We have a trigger, “when Terminology is launched”.
Terminology is a dictionary app, there is a standard search view with an input that returns a list of matching words. The action is pretty straight forward. I’ll set the value of the search input to the target data, trigger the search query just as if you had typed the text. Also, in both the iPad and iPhone versions of Terminology, the search view may not be visible, I need to make sure it’s showing or you won’t know I’ve done this nice thing for you.
What am I putting in the search input? Oh, yes, the target data from the clipboard. Wait, look, you’ve got “http://myfavoritewebsite.com/funny_video” in your clipboard. You probably put that there 5 hours ago and really don’t want to search for it in Terminology. Seems like you might use your clipboard for things that have nothing to do with Terminology. I better run some checks to see if what you have in your clipboard might actually be something you would want to lookup in Terminology.
I suppose I could ask you if you want me to lookup what’s in your clipboard. I’ve run into apps that do that, but it just feels wrong and annoying to me. I’m going to try to discern your intent. That might be a bit arrogant, but even if I fail, that text is still in your clipboard and you can still manually paste it into Terminology’s search input.
If it’s just one word, that’s pretty good. Terminology has multi-word entries as well, so that might be OK, too. If it’s not too long. You probably don’t want to lookup a whole paragraph in a dictionary. How about I only trigger this clipboard search if you have something that starts with alpha-numeric characters and is less that 40 characters long. That’s probably pretty close.
Finally, you want me to trigger this “when Terminology is launched”. On iOS that could be a cold start of the app, or the app resuming from it’s “multitasking” nap. I will check the clipboard on both states, and if it matches the criteria I laid out for something you might want to lookup in Terminology, I will fill-in the search input, trigger the search and make sure the search view is visible. Yippee, we’re done!
Wait, you mean you now looked up some other words, left, checked your email and decided to comeback to Terminology to lookup something else. And, you carelessly left the same word in your clipboard? I’m guessing you don’t want to look it up again, since I just looked it up for you the last time you launched Terminology – unless you have short-term memory issues. I better keep track of what I’ve looked up based on clipboard texts, and if it matches the last clipboard lookup, I’ll skip it. Yippee?!?!?
Darn it, now you went and really confused the issue. You left Terminology again, copied some nice juicy looking word into your clipboard to use in a tweet, then went and started reading your Instapaper queue. Since you had to go Instapaper that New Yorker article with all the fancy words, you need to lookup one up in Terminology using the built-in integration. This integration sends Terminology a URL that let me know what to lookup already – so I guess I need to test for incoming URL arguments to handle before messing with your clipboard, and if I get them, I’ll just pretend that juicy word isn’t in your clipboard after all.
Yippie!?!? Not sure I’m quite there yet, but it’s starting to “feel” right.
[1] One of my focuses is Terminology is to prevent people from having to take this step of copying text to the clipboard. I’ve been developing and championing the x-callback-url protocol for URL schemes in iOS apps largely because it solves this problem, by allowing users to signal their intent to lookup a specific word before they ever get to the app. Terminology lookup support is now in Instapaper and Elements, with other apps on the way. But, however many apps implement support for Terminology, the vast majority of the text on your iOS device is still not going to have an easy way to select the text and jump to Terminology — so one of the primary entry points is still likely to be the clipboard.