def get(): """ Create and return an instance of the FileSelectionContext subclass which is appropriate to the currently active application. """ windowClass = ContextUtils.getForegroundClassNameUnicode() if windowClass == u"ConsoleWindowClass": fsContext = NullFileSelectionContext() elif windowClass == u"Emacs": fsContext = NullFileSelectionContext() else: fsContext = DefaultFileSelectionContext() return fsContext
def get(): """ Creates and returns a TextSelection object of a subclass appropriate to the currently active application. If no text is selected, this must return a TextSelection object with no text in it -- NOT a None. """ className = ContextUtils.getForegroundClassNameUnicode() if className == u"Emacs": tsContext = EmacsTextSelection() elif className == u"MoonEdit": tsContext = NonReplacingTextSelection() elif className == u"ConsoleWindowClass": tsContext = CommandPromptTextSelection() else: tsContext = DefaultTextSelection() return tsContext