From 4517da9427e43fb50a26044b659a7efa3132e1ee Mon Sep 17 00:00:00 2001 From: David CM Date: Tue, 2 Jun 2020 06:07:02 -0600 Subject: [PATCH 1/2] add support for the function list view. after activate it in the view menu,use control + shift + . to place the focus in the view, use enter to jump to the selected item. Use escape to return to the edit field area. --- addon/appModules/notepad++/__init__.py | 34 ++++++++++++++++++++---- addon/appModules/notepad++/editWindow.py | 24 +++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/addon/appModules/notepad++/__init__.py b/addon/appModules/notepad++/__init__.py index 521194b..51c0ebc 100644 --- a/addon/appModules/notepad++/__init__.py +++ b/addon/appModules/notepad++/__init__.py @@ -4,9 +4,7 @@ #This file is covered by the GNU General Public License. #See the file COPYING for more details. -import os -import time -import weakref + # NVDA core imports import appModuleHandler import core @@ -16,8 +14,8 @@ import controlTypes import eventHandler import speech -import nvwave -from NVDAObjects.window.scintilla import Scintilla +from NVDAObjects.IAccessible import OutlineItem +from NVDAObjects.IAccessible.sysTreeView32 import TreeViewItem # Do not try an absolute import. Because I have to name this module notepad++, # and + isn't a valid character in a normal python module, # You need to use from . import foo, for now. @@ -38,6 +36,9 @@ def chooseNVDAObjectOverlayClasses(self,obj,clsList): obj.parent.parent.parent.windowClassName == u'ListBoxX'): clsList.insert(0, autocomplete.AutocompleteList) return + if obj.role == controlTypes.ROLE_TREEVIEWITEM and obj.parent.parent.parent.name == 'Function List': + clsList.insert(0, FunctionListView) + return except AttributeError: pass @@ -100,3 +101,26 @@ def waitforAndReportDestruction(self, obj): return eventHandler.executeEvent("suggestionsClosed", edit) +class FunctionListView(TreeViewItem, OutlineItem): + def script_goToCurrentFunction(self, gesture): + gesture.send() + # it seems that is not possible to jump to a element that contains children, E.G. a class. So we don't set the focus in this case. + if not (controlTypes.STATE_EXPANDED in self.states or controlTypes.STATE_COLLAPSED in self.states): + self.appModule.edit.setFocus() + + #Translators: When pressed, set the cursor to the current element and set te focus in the edit window from notepad++. + script_goToCurrentFunction.__doc__ = _("Set the focus in the editable text field, presumably with the cursor in the current element of function list.") + script_goToCurrentFunction.category = "Notepad++" + + def script_goToEditWindow(self, gesture): + self.appModule.edit.setFocus() + + #Translators: When pressed, set te focus in the edit window from notepad++. + script_goToEditWindow.__doc__ = _("Set the focus in the editable text field") + script_goToEditWindow.category = "Notepad++" + + + __gestures = { + "kb:enter" : "goToCurrentFunction", + "kb:escape" : "goToEditWindow", + } diff --git a/addon/appModules/notepad++/editWindow.py b/addon/appModules/notepad++/editWindow.py index 36dc239..46fc953 100644 --- a/addon/appModules/notepad++/editWindow.py +++ b/addon/appModules/notepad++/editWindow.py @@ -157,7 +157,31 @@ def script_reportFindResult(self, gesture): script_reportFindResult.__doc__ = _("Queries the next or previous search result and speaks the selection and current line.") script_reportFindResult.category = "Notepad++" + def script_goToFunctionList(self, gesture): + obj = self.simplePrevious + while (obj): + if obj.role == controlTypes.ROLE_MENUBAR: + break + if obj.windowClassName == '#32770' and obj.name == 'Selected Tab': + try: + fl = obj.simpleLastChild # sometimes the object 'Function List' is here. + if fl.name == 'Function List': + fl.setFocus() + return + fl = fl.simpleFirstChild + if fl.name == 'Function List': + fl.setFocus() + return + except: pass + obj = obj.simplePrevious + speech.speakMessage(_("Function list view not found")) + + #Translators: when pressed, goes to the function list view in notepad++. + script_goToFunctionList.__doc__ = _("Set the focus in the function list view, if is currently present.") + script_goToFunctionList.category = "Notepad++" + __gestures = { + "kb:control+shift+." : "goToFunctionList", "kb:control+b" : "goToMatchingBrace", "kb:f2": "goToNextBookmark", "kb:shift+f2": "goToPreviousBookmark", From f6588b8de0b849e76b32c5c987bb7f287a293247 Mon Sep 17 00:00:00 2001 From: David CM Date: Tue, 2 Jun 2020 06:34:40 -0600 Subject: [PATCH 2/2] deleted unused imports. --- addon/appModules/notepad++/editWindow.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/addon/appModules/notepad++/editWindow.py b/addon/appModules/notepad++/editWindow.py index 46fc953..5792d52 100644 --- a/addon/appModules/notepad++/editWindow.py +++ b/addon/appModules/notepad++/editWindow.py @@ -7,22 +7,14 @@ import weakref import addonHandler import config +import controlTypes from NVDAObjects.behaviors import EditableTextWithAutoSelectDetection, EditableTextWithSuggestions -from editableText import EditableText -import api + from queueHandler import registerGeneratorObject import speech import textInfos import tones import ui -import eventHandler -import scriptHandler -import sys -import os -import tempfile -from threading import Timer -import re - addonHandler.initTranslation() class EditWindow(EditableTextWithAutoSelectDetection, EditableTextWithSuggestions):