38 lines
994 B
Go
38 lines
994 B
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// isReadonly reports whether the editor should open in read-only mode.
|
|
func isReadonly() bool {
|
|
return os.Getenv("READONLY") == "true"
|
|
}
|
|
|
|
// fixedPitchEnabled reports whether the user opted into a monospace
|
|
// (programmer) font. The value comes from the TINY_ENCRYPT_ENABLE_FIXED_PITCH
|
|
// environment variable; when that is unset it falls back to the file at
|
|
// ~/.config/envs/TINY_ENCRYPT_ENABLE_FIXED_PITCH (content trimmed). The values
|
|
// true/on/yes/1 are accepted, case-insensitively.
|
|
func fixedPitchEnabled() bool {
|
|
v := os.Getenv("TINY_ENCRYPT_ENABLE_FIXED_PITCH")
|
|
if v == "" {
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
return false
|
|
}
|
|
data, err := os.ReadFile(filepath.Join(home, ".config", "envs", "TINY_ENCRYPT_ENABLE_FIXED_PITCH"))
|
|
if err != nil {
|
|
return false
|
|
}
|
|
v = strings.TrimSpace(string(data))
|
|
}
|
|
switch strings.ToLower(v) {
|
|
case "true", "on", "yes", "1":
|
|
return true
|
|
}
|
|
return false
|
|
}
|