Skip to content

Commit 89cd6d8

Browse files
committed
Versi├│n 1.3
1 parent cbf11d9 commit 89cd6d8

File tree

5 files changed

+64
-13
lines changed

5 files changed

+64
-13
lines changed

addon/globalPlugins/consoleLog/__init__.py

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Copyright (C) 2023 Héctor J. Benítez Corredera <[email protected]>
2+
# Copyright (C) 2024 Héctor J. Benítez Corredera <[email protected]>
33
# This file is covered by the GNU General Public License.
44

55
import globalPluginHandler
@@ -8,7 +8,7 @@
88
import ui
99
import globalVars
1010
import gui
11-
import gui.contextHelp
11+
import UIAHandler
1212
from scriptHandler import script
1313
import ctypes
1414
import wx
@@ -113,6 +113,32 @@ def beep_suave():
113113
# TRANSLATORS: Mensaje de error
114114
data_queue.put(_("Error: {}").format(e))
115115

116+
def leer_consola_wt(data_queue):
117+
try:
118+
# Lógica para emitir un beep suave mientras el hilo está en funcionamiento, en otro hilo
119+
def beep_suave():
120+
while not leer_consola_wt.stop_signal:
121+
winsound.Beep(1000, 100)
122+
wx.MilliSleep(1000)
123+
124+
beep_thread = threading.Thread(target=beep_suave, daemon=True)
125+
beep_thread.start()
126+
127+
# Aquí comienza la lógica para obtener el texto de la consola
128+
UIAHandler.initialize()
129+
focused_element = UIAHandler.handler.clientObject.getFocusedElement()
130+
pattern = focused_element.getCurrentPattern(UIAHandler.UIA_TextPatternId)
131+
text_pattern = pattern.QueryInterface(UIAHandler.IUIAutomationTextPattern)
132+
text_range = text_pattern.documentRange
133+
texto_terminal = text_range.getText(-1)
134+
text = '\n'.join(line.rstrip() for line in texto_terminal.splitlines() if line.strip())
135+
data_queue.put(text)
136+
except Exception as e:
137+
# TRANSLATORS: Mensaje de error
138+
data_queue.put(_("Error: {}").format(e))
139+
finally:
140+
UIAHandler.terminate()
141+
116142
def disableInSecureMode(decoratedCls):
117143
if globalVars.appArgs.secure:
118144
return globalPluginHandler.GlobalPlugin
@@ -126,6 +152,7 @@ def __init__(self, *args, **kwargs):
126152
self.proceso_en_marcha = False
127153
self.dialogo_abierto = False
128154
self.fichero_temporal = os.path.join(tempfile.gettempdir(),"consoleLog_temp.txt")
155+
self.foreground_window = None
129156

130157
@script(gesture=None,
131158
# TRANSLATORS: Descripción para el dialogo de gestos
@@ -144,18 +171,26 @@ def script_leerConsola(self, gesture):
144171
ui.message(_("Por favor, cierre el diálogo actual antes de iniciar uno nuevo."))
145172
return
146173

147-
foreground_window = api.getForegroundObject()
148-
if not foreground_window.windowClassName.startswith("ConsoleWindowClass"):
174+
self.foreground_window = api.getForegroundObject()
175+
if not (
176+
self.foreground_window.windowClassName.startswith("ConsoleWindowClass")
177+
or self.foreground_window.windowClassName == "CASCADIA_HOSTING_WINDOW_CLASS"
178+
):
149179
# TRANSLATORS: Mensaje informativo
150180
ui.message(_("Esta no es una ventana de consola."))
151181
return
152182

153183
self.proceso_en_marcha = True
154184

155185
data_queue = queue.Queue()
156-
leer_consola.stop_signal = False
157-
thread = threading.Thread(target=leer_consola, args=(data_queue,), daemon=True)
158-
thread.start()
186+
if self.foreground_window.appModule.productName in ['Microsoft.WindowsTerminal']:
187+
leer_consola_wt.stop_signal = False
188+
thread = threading.Thread(target=leer_consola_wt, args=(data_queue,), daemon=True)
189+
thread.start()
190+
else:
191+
leer_consola.stop_signal = False
192+
thread = threading.Thread(target=leer_consola, args=(data_queue,), daemon=True)
193+
thread.start()
159194

160195
wx.CallLater(100, self.mostrar_dialogo, data_queue)
161196

@@ -166,7 +201,11 @@ def mostrar_dialogo(self, data_queue):
166201
wx.CallLater(100, self.mostrar_dialogo, data_queue)
167202
return
168203

169-
leer_consola.stop_signal = True
204+
if self.foreground_window.appModule.productName in ['Microsoft.WindowsTerminal']:
205+
leer_consola_wt.stop_signal = True
206+
else:
207+
leer_consola.stop_signal = True
208+
170209
self.proceso_en_marcha = False
171210

172211
try:

buildVars.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def _(arg):
2727
2828
Asignar tecla en Gestos de entrada / Visor de consola."""),
2929
# version
30-
"addon_version": "1.2",
30+
"addon_version": "1.3",
3131
# Author(s)
3232
"addon_author": u"Héctor J. Benítez Corredera <[email protected]>",
3333
# URL for the add-on documentation support
@@ -37,7 +37,7 @@ def _(arg):
3737
# Minimum NVDA version supported (e.g. "2018.3.0", minor version is optional)
3838
"addon_minimumNVDAVersion": "2022.1.0",
3939
# Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version)
40-
"addon_lastTestedNVDAVersion": "2023.1.0",
40+
"addon_lastTestedNVDAVersion": "2024.1.0",
4141
# Add-on update channel (default is None, denoting stable releases,
4242
# and for development releases, use "dev".)
4343
# Do not change unless you know what you are doing!

readme.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ En Windows, existen varias consolas o terminales que puedes utilizar para ejecut
6363
> **Nota**: Puedes acceder a estas consolas a través del menú inicio de Windows o mediante la búsqueda de Windows, escribiendo el nombre de la consola que deseas utilizar.
6464
6565
## Registro de cambios.
66+
###Versión 1.3.
67+
68+
* Agregada compatibilidad con Windows Terminal.
69+
70+
Esta función esta de prueba.
71+
72+
De momento en las pruebas realizadas extrae correctamente el texto y lo muestra para poder ser visualizado cómodamente en un dialogo y poder trabajar con él.
73+
74+
Esta nueva función se agrega al visor de consolas cmd, powershell y bash usando su misma combinación de teclas que tengamos agregado al complemento.
75+
76+
Al pulsar dicha combinación detectara que clase de consola tenemos enfocada y actuara en consecuencia.
77+
6678
###Versión 1.2.
6779

6880
* Solucionado error critico en Windows 10 de denegación de permisos (código 5).

run.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
scons --clean
44
scons pot
55
scons
6-
consoleLog-1.1.nvda-addon
6+
consoleLog-1.3.nvda-addon

run_git.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ scons --clean
44
scons pot
55
git init
66
git add --all
7-
git commit -m "Versión 1.2"
7+
git commit -m "Versión 1.3"
88
git push -u origin master
9-
git tag 1.2
9+
git tag 1.3
1010
git push --tags
1111
pause

0 commit comments

Comments
 (0)