Use common v0.8.0 UI, transport, and translation APIs
This commit is contained in:
1 parent
317303adb7
commit
92fd479336
344 files changed
+4102
-4973
No files matched your search
@@ -10,10 +10,10 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Default_attribute_format is Python Fenrir's default, including its tokens.
|
||||
const Default_attribute_format = "Background fenrirBGColor,Foreground fenrirFGColor,fenrirUnderline,fenrirBold,fenrirBlink, Font fenrirFont,Fontsize fenrirFontSize"
|
||||
// DefaultAttributeFormat is Python Fenrir's default, including its tokens.
|
||||
const DefaultAttributeFormat = "Background fenrirBGColor,Foreground fenrirFGColor,fenrirUnderline,fenrirBold,fenrirBlink, Font fenrirFont,Fontsize fenrirFontSize"
|
||||
|
||||
func attribute_color(color uint32, background bool) string {
|
||||
func attributeColor(color uint32, background bool) string {
|
||||
if color == screen.ColorDefault {
|
||||
return i18n.T("default")
|
||||
}
|
||||
@@ -38,10 +38,10 @@ func attribute_color(color uint32, background bool) string {
|
||||
return fmt.Sprintf("#%02x%02x%02x", value, value, value)
|
||||
}
|
||||
|
||||
// Format_attributes substitutes the Python tokens. Font metadata is not
|
||||
// FormatAttributes substitutes the Python tokens. Font metadata is not
|
||||
// available from either backend; default means unspecified, not a detected font.
|
||||
func Format_attributes(attribute screen.Attribute, format string) string {
|
||||
pairs := []string{"fenrirFGColor", attribute_color(attribute.Foreground, false), "fenrirBGColor", attribute_color(attribute.Background, true), "fenrirFontSize", i18n.T("default"), "fenrirFont", i18n.T("default")}
|
||||
func FormatAttributes(attribute screen.Attribute, format string) string {
|
||||
pairs := []string{"fenrirFGColor", attributeColor(attribute.Foreground, false), "fenrirBGColor", attributeColor(attribute.Background, true), "fenrirFontSize", i18n.T("default"), "fenrirFont", i18n.T("default")}
|
||||
for _, style := range []struct {
|
||||
token, text string
|
||||
mask uint32
|
||||
@@ -59,8 +59,8 @@ func Format_attributes(attribute screen.Attribute, format string) string {
|
||||
return strings.NewReplacer(pairs...).Replace(format)
|
||||
}
|
||||
|
||||
func Attribute_message(attribute screen.Attribute, mode, format string) Message {
|
||||
text := Format_attributes(attribute, format)
|
||||
func AttributeMessage(attribute screen.Attribute, mode, format string) Message {
|
||||
text := FormatAttributes(attribute, format)
|
||||
if mode == "beeps" || strings.TrimSpace(text) == "" && !attribute.Default() {
|
||||
text = i18n.T("has attribute")
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
func TestAttributeColorsStylesAndPythonFormat(t *testing.T) {
|
||||
format := "fenrirFGColor|fenrirBGColor|fenrirBold|fenrirUnderline|fenrirItalics|fenrirBlink|fenrirReverse|fenrirStrikethrough|fenrirFontSize|fenrirFont"
|
||||
a := screen.Attribute{Foreground: screen.ColorIndexed | 1, Background: screen.ColorIndexed | 4, Style: screen.Bold | screen.Underline | screen.Italic | screen.Blink | screen.Reverse | screen.Strike}
|
||||
if got := Format_attributes(a, format); got != "red|blue|bold|underline|italic|blink|reverse|strikethrough|default|default" {
|
||||
if got := FormatAttributes(a, format); got != "red|blue|bold|underline|italic|blink|reverse|strikethrough|default|default" {
|
||||
t.Fatal(got)
|
||||
}
|
||||
for _, trial := range []struct {
|
||||
@@ -24,14 +24,14 @@ func TestAttributeColorsStylesAndPythonFormat(t *testing.T) {
|
||||
{screen.ColorIndexed | 16, "#000000"}, {screen.ColorIndexed | 196, "#ff0000"},
|
||||
{screen.ColorIndexed | 231, "#ffffff"}, {screen.ColorIndexed | 232, "#080808"}, {screen.ColorIndexed | 255, "#eeeeee"},
|
||||
} {
|
||||
if got := Format_attributes(screen.Attribute{Foreground: trial.color}, "fenrirFGColor"); got != trial.want {
|
||||
if got := FormatAttributes(screen.Attribute{Foreground: trial.color}, "fenrirFGColor"); got != trial.want {
|
||||
t.Fatal(trial, got)
|
||||
}
|
||||
}
|
||||
if got := Format_attributes(screen.Attribute{}, "fenrirBold fenrirUnderline fenrirBlink"); strings.TrimSpace(got) != "" {
|
||||
if got := FormatAttributes(screen.Attribute{}, "fenrirBold fenrirUnderline fenrirBlink"); strings.TrimSpace(got) != "" {
|
||||
t.Fatal(got)
|
||||
}
|
||||
if got := Format_attributes(a, ""); got != "" {
|
||||
if got := FormatAttributes(a, ""); got != "" {
|
||||
t.Fatal(got)
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,10 @@ import (
|
||||
"git.stormux.org/storm/fenrir/internal/i18n"
|
||||
)
|
||||
|
||||
// Indentation_level counts leading visible whitespace cells. Terminal backends
|
||||
// IndentationLevel counts leading visible whitespace cells. Terminal backends
|
||||
// normally expand tabs already; a literal tab advances to the next 8-cell stop.
|
||||
// Blank rows have no meaningful indentation, including terminal padding.
|
||||
func Indentation_level(line []rune) (int, bool) {
|
||||
func IndentationLevel(line []rune) (int, bool) {
|
||||
level := 0
|
||||
for _, char := range line {
|
||||
if !unicode.IsSpace(char) {
|
||||
@@ -28,7 +28,7 @@ func Indentation_level(line []rune) (int, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func Indentation_message(level int, mode string) Message {
|
||||
func IndentationMessage(level int, mode string) Message {
|
||||
message := Message{Text: i18n.T("indented ") + strconv.Itoa(level) + " "}
|
||||
if mode == "beeps" || mode == "both" {
|
||||
message.Indentation = &Indentation{Level: level, Speech: mode == "both"}
|
||||
|
||||
@@ -15,7 +15,7 @@ func TestIndentationCountsVisibleWhitespaceAndIgnoresBlankRows(t *testing.T) {
|
||||
{"\t \tvalue", 16, true}, {"\u00a0\u2003É", 2, true},
|
||||
{"", 0, false}, {" ", 0, false}, {"\t ", 0, false},
|
||||
} {
|
||||
level, valid := Indentation_level([]rune(trial.text))
|
||||
level, valid := IndentationLevel([]rune(trial.text))
|
||||
if level != trial.level || valid != trial.valid {
|
||||
t.Fatalf("%q: %d %v", trial.text, level, valid)
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"git.stormux.org/storm/screenreader-common/phonetic"
|
||||
)
|
||||
|
||||
// Phonetic_letter matches the shared spelling alphabet with Fenrir capitalization.
|
||||
// PhoneticLetter matches the shared spelling alphabet with Fenrir capitalization.
|
||||
// Other runes use the active punctuation profile's character naming instead.
|
||||
func Phonetic_letter(char rune) string {
|
||||
func PhoneticLetter(char rune) string {
|
||||
word := phonetic.Letter(char)
|
||||
if word == "" {
|
||||
return ""
|
||||
|
||||
@@ -14,7 +14,7 @@ func TestPythonPhoneticNamesAndUnicodeFallback(t *testing.T) {
|
||||
{'w', "whiskey"}, {'W', "Whiskey"}, {'x', "x ray"}, {'X', "X ray"},
|
||||
{'É', ""}, {'界', ""}, {'1', ""}, {'?', ""}, {' ', ""},
|
||||
} {
|
||||
if got := Phonetic_letter(trial.char); got != trial.want {
|
||||
if got := PhoneticLetter(trial.char); got != trial.want {
|
||||
t.Fatal(trial, got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ func Line(s screen.Snapshot, row int) string {
|
||||
return text
|
||||
}
|
||||
|
||||
// Line_message describes a row with Python's blank-line sound alternative.
|
||||
func Line_message(s screen.Snapshot, row int) Message {
|
||||
// LineMessage describes a row with Python's blank-line sound alternative.
|
||||
func LineMessage(s screen.Snapshot, row int) Message {
|
||||
message := Message{Text: Line(s, row)}
|
||||
if strings.TrimSpace(s.Text(row)) == "" {
|
||||
message.Cue = Blank
|
||||
@@ -46,7 +46,7 @@ func Line_message(s screen.Snapshot, row int) Message {
|
||||
return message
|
||||
}
|
||||
|
||||
func Character_message(char rune) Message {
|
||||
func CharacterMessage(char rune) Message {
|
||||
return Message{Text: Character(char), Character: &char}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user