Cthulhu is no longer a fork. Now it is a screen reader written in Golang.
This commit is contained in:
1 parent
a998fe67de
commit
069fc674dc
708 files changed
+112482
-532
No files matched your search
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2026 Storm Dragon
|
||||
// Authors: Storm Dragon, Angus Kola
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"git.stormux.org/storm/cthulhu/internal/atspi"
|
||||
"git.stormux.org/storm/cthulhu/internal/braille"
|
||||
"git.stormux.org/storm/cthulhu/internal/config"
|
||||
)
|
||||
|
||||
func markTextAttributeRun(frame *braille.Frame, run atspi.TextAttributeRun, sourceStart, frameStart, textLength int, settings config.TextAttributeSettings) {
|
||||
if settings.Indicator == 0 || run.End <= run.Start || textLength <= 0 {
|
||||
return
|
||||
}
|
||||
marked := false
|
||||
for _, choice := range settings.Choices {
|
||||
if !choice.Braille {
|
||||
continue
|
||||
}
|
||||
if choice.Key == "text-spelling" {
|
||||
if atspi.TextAttributesMisspelled(run.Values) {
|
||||
marked = true
|
||||
break
|
||||
}
|
||||
continue
|
||||
}
|
||||
value := strings.TrimSpace(run.Values[choice.Key])
|
||||
if value == "" {
|
||||
continue
|
||||
}
|
||||
for _, known := range characterAttributeOrder {
|
||||
if known.key != choice.Key {
|
||||
continue
|
||||
}
|
||||
if value != known.ignore {
|
||||
marked = true
|
||||
}
|
||||
break
|
||||
}
|
||||
if marked {
|
||||
break
|
||||
}
|
||||
}
|
||||
if !marked {
|
||||
return
|
||||
}
|
||||
begin := max(run.Start, sourceStart)
|
||||
end := min(run.End, sourceStart+textLength)
|
||||
if begin >= end {
|
||||
return
|
||||
}
|
||||
count := utf8.RuneCountInString(frame.Text)
|
||||
if len(frame.Dots) < count {
|
||||
frame.Dots = append(frame.Dots, make([]byte, count-len(frame.Dots))...)
|
||||
}
|
||||
for offset := begin; offset < end; offset++ {
|
||||
frame.Dots[frameStart+offset-sourceStart] |= byte(settings.Indicator)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user