+Windows Terminal support

This commit is contained in:
theadam 2025-03-30 21:24:53 +02:00
parent 3aa8dafc5c
commit 13bfa7fa07
3 changed files with 158 additions and 0 deletions

51
wt-access/README.md Executable file
View file

@ -0,0 +1,51 @@
# Windows Terminal Access
## Why?
Microsoft announced in 2019 the new [Microsoft Terminal](https://github.com/microsoft/terminal/) which will replace the old Conhost solution in everyday use.
## Advantages of MS Terminal
It has a high number of advantages. Very personalizable, works as a normal window which makes easier to support accessibility, multitab support, extended mark mode, customizable keyboard commands, profiles and more.
## The problem
MS Terminal not supported the communication with screen readers first. After that Microsoft introduced UIA support, NVDA followed it and now supports it well however JAWS users can not use the Terminal.
The following problems might occurs in JAWS in the everyday usage
- Randomly readed lines
- When reading with JAWS cursor, the window and text jumping and focus might be lost
- On SSH sessions, randomly announced informations, not work with ncurses apps and other issues which makes it very unconfortable
### Behind the problem
The JAWS script that built in J2025 uses a method that grabs the text from Terminal and with a timer make comparison which updates on defined events. Problem with this is that ncurses-based APPS (E.G. nano, VI, Pico) writes to their GUI to screen with characters which causes that JAWS detects a redraw on every character change (delete, insert). It is not good.
UIA is available, but JAWS still uses the own development.
Freedom Scientific until 2025-03-30 does not fix the problem so Terminal unconfortable.
Issues related to this
- [#16734](https://github.com/microsoft/terminal/issues/16734)
- [#16545](https://github.com/microsoft/terminal/issues/16545)
- [#12051](https://github.com/microsoft/terminal/issues/12051)
## The fix
My script - based on Freedom's code - fixes this problem by adding the UIA support and removing the old, text scanning way.
### Features
- Support UIA, make the terminal and ncurses apps usable
- Fix UIA announcements to work with specified punctuation level and try to follow the line endings in the announcements to avoid the announcing of special chars with disabled punctuation level.
- Turn off the every screen item auto-read feature and read only the changed content
- Prevent announcing unneccessary information (honour the keyboard echo setting)
- Support the auto-completion feature
- Support
## Known issues and todo
- Try to detect prompt and turn it's announce off when navigating on the command history (up and down arrow).
- Ability to temporarily disable UIA for a while to avoid too large amount of text, E.G. using mtr or top, where content changing randomly
- Ability to switch the indentation announce feature with a hotkey to make easier to use argocd, kubectl and edit yaml files easily
- Saying bad characters when try to mark text in mark mode. Workaround is to mark only lines with CTRL+up-down arrow and press CTRL-SHIFT-c to copy. Do not mark single characters or partialy section of lines.

104
wt-access/WindowsTerminal.JSS Executable file
View file

@ -0,0 +1,104 @@
; Copyright 2022 Freedom Scientific Inc.
; Copyright 2025 TheAdam <theadam.eu>
import "uia.jsb"
include "hjconst.jsh"
include "common.jsm"
include "uia.jsh"
const
TerminalClassName = "TermControl"
globals
int WindowsTerminalObjectID,
object WindowsTerminalTextProvider,
int WindowsTerminalLastKeyPress
Script ScriptFileName()
ScriptAndAppNames("Windows Terminal")
EndScript
void function ProcessSayAppWindowOnFocusChange(handle AppWindow, handle FocusWindow)
EndFunction
void function ProcessSayRealWindowOnFocusChange( handle AppWindow, handle RealWindow, string RealWindowName, handle FocusWindow)
EndFunction
Int Function IgnoreObjectAtLevel(int level)
var
int type = GetObjectSubTypeCode()
if type == WT_LISTBOX ||
type == WT_LISTBOXITEM
return true ; prevent overspeaking with Ctrl+Tab
EndIf
return FALSE
EndFunction
string function GetTextInConsoleWindow()
var
object oNull,
object visibleRanges,
object range
if GetObjectClassName() != "TermControl"
return ""
EndIf
if !WindowsTerminalTextProvider
WindowsTerminalTextProvider = FSUIAGetFocusedElement().GetTextPattern()
EndIf
visibleRanges = WindowsTerminalTextProvider.GetVisibleRanges()
range = visibleRanges(0)
return range.GetText(-1)
EndFunction
script VirtualizeWindow()
var string text = StringTrimTrailingBlanks(GetTextInConsoleWindow())
if !text then
SayMessage(OT_ERROR,cmsgNoTextToVirtualize_L,cmsgNoTextToVirtualize_S)
return
endIf
SayMessage(ot_JAWS_Message,cmsgVirtualizeWindow_L,cmsgVirtualizeWindow_S)
UserBufferClear()
UserBufferAddText(text)
UserBufferActivate()
JAWSBottomOfFile()
EndScript
string function ProcessUiaText(string text)
var stringArray lines = StringSplit (text, "\n", false)
var int x = 0
var string out = ""
if ArrayLength(lines) == 1
out = StringConcatenate (out, lines[x])
EndIf
For x = 0 to ArrayLength(lines)
if StringLength (stringStripAllBlanks (lines[x+1])) < 2 & lines[x+1] != "\n" & x != ArrayLength(lines)
out = StringConcatenate (out, StringReplaceChars (lines[x], "\n", " "))
else
out = StringConcatenate (out, lines[x], "\n")
EndIf
EndFor
out = StringConcatenate (out, lines[x+1], "\n")
return out
EndFunction
Void Function KeyPressedEvent (int nKey, string strKeyName, int nIsBrailleKey, int nIsScriptKey)
if (nKey > 100000)
WindowsTerminalLastKeyPress = WindowsTerminalLastKeyPress+1
else
WindowsTerminalLastKeyPress = 0
EndIf
EndFunction
void function UIANotificationEvent(int notificationKind, int notificationProcessing, string displayString, string activityId, string appname)
var string ki = ProcessUiaText(displayString)
;Say (IntToString (WindowsTerminalLastKeyPress) , OT_NONHIGHLIGHTED_SCREEN_TEXT)
if WindowsTerminalLastKeyPress >= 2
WindowsTerminalLastKeyPress = 0
ENDIF
if WindowsTerminalLastKeyPress == 0
Say (ki, OT_NONHIGHLIGHTED_SCREEN_TEXT)
else
WindowsTerminalLastKeyPress = WindowsTerminalLastKeyPress+1
ENDIF
EndFunction

3
wt-access/WindowsTerminal.jcf Executable file
View file

@ -0,0 +1,3 @@
[options]
ScreenEcho=1