Mercurial > firefox-enso
diff enso_pyxpcom.py @ 3:21f5e1dc0a4c default tip
text selection for firefox will return the full contents of the current text field if no text is selected. also, the seldict contains references to the currently-focused element and window, if any.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 09 May 2008 12:59:10 -0700 |
parents | 4f22928c7a2c |
children |
line wrap: on
line diff
--- a/enso_pyxpcom.py Thu May 08 13:00:26 2008 -0700 +++ b/enso_pyxpcom.py Fri May 09 12:59:10 2008 -0700 @@ -22,7 +22,9 @@ Application = getFuelApplication() document = Application.activeWindow.activeTab.document - mediator = cc["@mozilla.org/appshell/window-mediator;1"].getService(ci.nsIWindowMediator) + mediator = cc["@mozilla.org/appshell/window-mediator;1"].getService( + ci.nsIWindowMediator + ) window = mediator.getMostRecentWindow("navigator:browser") return window.document.commandDispatcher @@ -46,12 +48,16 @@ end = dispatcher.focusedElement.selectionEnd if start != end: text = dispatcher.focusedElement.value[start:end] + else: + text = dispatcher.focusedElement.value elif dispatcher.focusedWindow: sel = dispatcher.focusedWindow.getSelection() if sel.rangeCount >= 1: text = sel.toString() - return {"text" : text} + return {"text" : text, + "dom.element" : dispatcher.focusedElement, + "dom.window" : dispatcher.focusedWindow} def installFirefoxSelectionHook(): from enso.platform.osx import selection