winConsole.py
2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#NVDAObjects/WinConsole.py
#A part of NonVisual Desktop Access (NVDA)
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
#Copyright (C) 2007-2012 NV Access Limited
import winConsoleHandler
from . import Window
from ..behaviors import Terminal, EditableTextWithoutAutoSelectDetection
import api
import core
class WinConsole(Terminal, EditableTextWithoutAutoSelectDetection, Window):
STABILIZE_DELAY = 0.03
def _get_TextInfo(self):
consoleObject=winConsoleHandler.consoleObject
if consoleObject and self.windowHandle == consoleObject.windowHandle:
return winConsoleHandler.WinConsoleTextInfo
return super(WinConsole,self).TextInfo
def event_becomeNavigatorObject(self):
if winConsoleHandler.consoleObject is not self:
if winConsoleHandler.consoleObject:
winConsoleHandler.disconnectConsole()
winConsoleHandler.connectConsole(self)
if self == api.getFocusObject():
# The user is returning to the focus object with object navigation.
# The focused console should always be monitored if possible.
self.startMonitoring()
super(WinConsole,self).event_becomeNavigatorObject()
def event_gainFocus(self):
if winConsoleHandler.consoleObject is not self:
if winConsoleHandler.consoleObject:
winConsoleHandler.disconnectConsole()
winConsoleHandler.connectConsole(self)
super(WinConsole, self).event_gainFocus()
def event_loseFocus(self):
super(WinConsole, self).event_loseFocus()
if winConsoleHandler.consoleObject is self:
winConsoleHandler.disconnectConsole()
def event_nameChange(self):
pass
def _getTextLines(self):
return winConsoleHandler.getConsoleVisibleLines()
def script_caret_backspaceCharacter(self, gesture):
super(WinConsole, self).script_caret_backspaceCharacter(gesture)
# #2586: We use console update events for typed characters,
# so the typedCharacter event is never fired for the backspace key.
# Call it here so that speak typed words works as expected.
self.event_typedCharacter(u"\b")
def script_close(self,gesture):
# #5343: New consoles in Windows 10 close with alt+f4 and take any processes attached with it (including NVDA).
# Therefore detach from the console temporarily while sending the gesture.
winConsoleHandler.disconnectConsole()
gesture.send()
def reconnect():
if api.getFocusObject()==self:
winConsoleHandler.connectConsole(self)
self.startMonitoring()
core.callLater(200,reconnect)
__gestures={
"kb:alt+f4":"close",
}