Mercurial > my-enso-commands
changeset 14:9ca05d02bc3a
Added optional params to some commands
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sat, 27 Mar 2010 15:11:57 -0700 |
parents | 4e06df5f36c7 |
children | e96c724d3c7a |
files | my-enso-commands.py |
diffstat | 1 files changed, 20 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/my-enso-commands.py Sat Mar 27 14:54:46 2010 -0700 +++ b/my-enso-commands.py Sat Mar 27 15:11:57 2010 -0700 @@ -10,10 +10,11 @@ import logging from StringIO import StringIO -def _do_service(ensoapi, serviceName): +def _do_service(ensoapi, serviceName, text=None): import AppKit - text = ensoapi.get_selection().get("text", "").strip() + if not text: + text = ensoapi.get_selection().get("text", "").strip() if not text: ensoapi.display_message("No text selection!") @@ -32,19 +33,29 @@ finally: pass -def cmd_define(ensoapi): - _do_service(ensoapi, "Look Up in Dictionary") +def cmd_define(ensoapi, word=None): + "Look up the given word in the dictionary." + + _do_service(ensoapi, "Look Up in Dictionary", word) -def cmd_speak(ensoapi): - _do_service(ensoapi, "Speech/Start Speaking Text") +def cmd_speak(ensoapi, what=None): + "Speak the given text out loud." + + _do_service(ensoapi, "Speech/Start Speaking Text", what) def cmd_summarize(ensoapi): + "Summarize the selected text." + _do_service(ensoapi, "Summarize") -def cmd_spotlight(ensoapi): - _do_service(ensoapi, "Spotlight") +def cmd_spotlight(ensoapi, query=None): + "Search your computer for the given query." -def cmd_count_lines(ensoapi): + _do_service(ensoapi, "Spotlight", query) + +def cmd_line_count(ensoapi): + "Count the number of lines in your selection." + seldict = ensoapi.get_selection() ensoapi.display_message( "Selection is %s lines." % len(seldict.get("text","").splitlines()) )