Skip to content

Commit

Permalink
Versi├│n 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hxebolax committed Mar 31, 2024
1 parent cbf11d9 commit 89cd6d8
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 13 deletions.
55 changes: 47 additions & 8 deletions addon/globalPlugins/consoleLog/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2023 Héctor J. Benítez Corredera <xebolax@gmail.com>
# Copyright (C) 2024 Héctor J. Benítez Corredera <xebolax@gmail.com>
# This file is covered by the GNU General Public License.

import globalPluginHandler
Expand All @@ -8,7 +8,7 @@
import ui
import globalVars
import gui
import gui.contextHelp
import UIAHandler
from scriptHandler import script
import ctypes
import wx
Expand Down Expand Up @@ -113,6 +113,32 @@ def beep_suave():
# TRANSLATORS: Mensaje de error
data_queue.put(_("Error: {}").format(e))

def leer_consola_wt(data_queue):
try:
# Lógica para emitir un beep suave mientras el hilo está en funcionamiento, en otro hilo
def beep_suave():
while not leer_consola_wt.stop_signal:
winsound.Beep(1000, 100)
wx.MilliSleep(1000)

beep_thread = threading.Thread(target=beep_suave, daemon=True)
beep_thread.start()

# Aquí comienza la lógica para obtener el texto de la consola
UIAHandler.initialize()
focused_element = UIAHandler.handler.clientObject.getFocusedElement()
pattern = focused_element.getCurrentPattern(UIAHandler.UIA_TextPatternId)
text_pattern = pattern.QueryInterface(UIAHandler.IUIAutomationTextPattern)
text_range = text_pattern.documentRange
texto_terminal = text_range.getText(-1)
text = '\n'.join(line.rstrip() for line in texto_terminal.splitlines() if line.strip())
data_queue.put(text)
except Exception as e:
# TRANSLATORS: Mensaje de error
data_queue.put(_("Error: {}").format(e))
finally:
UIAHandler.terminate()

def disableInSecureMode(decoratedCls):
if globalVars.appArgs.secure:
return globalPluginHandler.GlobalPlugin
Expand All @@ -126,6 +152,7 @@ def __init__(self, *args, **kwargs):
self.proceso_en_marcha = False
self.dialogo_abierto = False
self.fichero_temporal = os.path.join(tempfile.gettempdir(),"consoleLog_temp.txt")
self.foreground_window = None

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

foreground_window = api.getForegroundObject()
if not foreground_window.windowClassName.startswith("ConsoleWindowClass"):
self.foreground_window = api.getForegroundObject()
if not (
self.foreground_window.windowClassName.startswith("ConsoleWindowClass")
or self.foreground_window.windowClassName == "CASCADIA_HOSTING_WINDOW_CLASS"
):
# TRANSLATORS: Mensaje informativo
ui.message(_("Esta no es una ventana de consola."))
return

self.proceso_en_marcha = True

data_queue = queue.Queue()
leer_consola.stop_signal = False
thread = threading.Thread(target=leer_consola, args=(data_queue,), daemon=True)
thread.start()
if self.foreground_window.appModule.productName in ['Microsoft.WindowsTerminal']:
leer_consola_wt.stop_signal = False
thread = threading.Thread(target=leer_consola_wt, args=(data_queue,), daemon=True)
thread.start()
else:
leer_consola.stop_signal = False
thread = threading.Thread(target=leer_consola, args=(data_queue,), daemon=True)
thread.start()

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

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

leer_consola.stop_signal = True
if self.foreground_window.appModule.productName in ['Microsoft.WindowsTerminal']:
leer_consola_wt.stop_signal = True
else:
leer_consola.stop_signal = True

self.proceso_en_marcha = False

try:
Expand Down
4 changes: 2 additions & 2 deletions buildVars.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _(arg):
Asignar tecla en Gestos de entrada / Visor de consola."""),
# version
"addon_version": "1.2",
"addon_version": "1.3",
# Author(s)
"addon_author": u"Héctor J. Benítez Corredera <xebolax@gmail.com>",
# URL for the add-on documentation support
Expand All @@ -37,7 +37,7 @@ def _(arg):
# Minimum NVDA version supported (e.g. "2018.3.0", minor version is optional)
"addon_minimumNVDAVersion": "2022.1.0",
# Last NVDA version supported/tested (e.g. "2018.4.0", ideally more recent than minimum version)
"addon_lastTestedNVDAVersion": "2023.1.0",
"addon_lastTestedNVDAVersion": "2024.1.0",
# Add-on update channel (default is None, denoting stable releases,
# and for development releases, use "dev".)
# Do not change unless you know what you are doing!
Expand Down
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ En Windows, existen varias consolas o terminales que puedes utilizar para ejecut
> **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.
## Registro de cambios.
###Versión 1.3.

* Agregada compatibilidad con Windows Terminal.

Esta función esta de prueba.

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.

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.

Al pulsar dicha combinación detectara que clase de consola tenemos enfocada y actuara en consecuencia.

###Versión 1.2.

* Solucionado error critico en Windows 10 de denegación de permisos (código 5).
Expand Down
2 changes: 1 addition & 1 deletion run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
scons --clean
scons pot
scons
consoleLog-1.1.nvda-addon
consoleLog-1.3.nvda-addon
4 changes: 2 additions & 2 deletions run_git.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ scons --clean
scons pot
git init
git add --all
git commit -m "Versión 1.2"
git commit -m "Versión 1.3"
git push -u origin master
git tag 1.2
git tag 1.3
git push --tags
pause

0 comments on commit 89cd6d8

Please sign in to comment.