Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions addon/appModules/notepad++/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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",
}
36 changes: 26 additions & 10 deletions addon/appModules/notepad++/editWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -157,7 +149,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",
Expand Down