Cthulhu is no longer a fork. Now it is a screen reader written in Golang.

This commit is contained in:
Storm Dragon committed 2026-10-14 00:16:34 -04:00
1 parent a998fe67de
commit 069fc674dc
708 files changed
+112482 -532

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
// SPDX-License-Identifier: GPL-3.0-or-later
// Package ocrconfirm runs only in the short-lived confirmation helper.
package ocrconfirm
/*
#cgo pkg-config: gtk+-3.0
#include <stdlib.h>
int cthulhu_ocr_confirm(const char *word);
*/
import "C"
import (
"bytes"
"io"
"unicode/utf8"
"unsafe"
)
func Run(input io.Reader, output io.Writer) error {
data, err := io.ReadAll(io.LimitReader(input, 4097))
if err != nil || len(data) == 0 || len(data) > 4096 || !utf8.Valid(data) || bytes.IndexByte(data, 0) >= 0 {
return io.ErrUnexpectedEOF
}
word := C.CString(string(data))
defer C.free(unsafe.Pointer(word))
if C.cthulhu_ocr_confirm(word) == 1 {
_, err = io.WriteString(output, "yes\n")
} else {
_, err = io.WriteString(output, "cancel\n")
}
return err
}