forked from sunglocto/pi-im
Add reply text fallback for systems which do not have UTF-8
This commit is contained in:
23
main.go
23
main.go
@@ -43,7 +43,8 @@ var version string = "3i"
|
||||
var statBar widget.Label
|
||||
var chatInfo fyne.Container
|
||||
var chatSidebar fyne.Container
|
||||
|
||||
var replyNameIcon string = ">"
|
||||
var replyBodyIcon string = ">"
|
||||
var agreesToSendingHotFuckIntoChannel bool = false
|
||||
|
||||
// by sunglocto
|
||||
@@ -79,6 +80,17 @@ type CustomMultiLineEntry struct {
|
||||
widget.Entry
|
||||
}
|
||||
|
||||
func isUTF8Locale() bool {
|
||||
localeVars := []string{"LC_ALL", "LC_CTYPE", "LANG"}
|
||||
for _, envVar := range localeVars {
|
||||
value := os.Getenv(envVar)
|
||||
if strings.Contains(strings.ToLower(value), "utf-8") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func NewCustomMultiLineEntry() *CustomMultiLineEntry {
|
||||
entry := &CustomMultiLineEntry{}
|
||||
entry.ExtendBaseWidget(entry)
|
||||
@@ -249,13 +261,13 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
for i := len(chatTabs[chatJidStr].Messages) - 1; i >= 0; i-- {
|
||||
if reply.ID == chatTabs[chatJidStr].Messages[i].Raw.StanzaID.ID {
|
||||
replytext.Show()
|
||||
replytext.SetText(fmt.Sprintf("↱ %s", chatTabs[chatJidStr].Messages[i].Content))
|
||||
replytext.SetText(fmt.Sprintf("%s %s", replyBodyIcon, chatTabs[chatJidStr].Messages[i].Content))
|
||||
guy = chatTabs[chatJidStr].Messages[i].Author
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
author.SetText(fmt.Sprintf("%s → %s", chatTabs[chatJidStr].Messages[i].Author, guy))
|
||||
author.SetText(fmt.Sprintf("%s %s %s", chatTabs[chatJidStr].Messages[i].Author, replyNameIcon, guy))
|
||||
} else {
|
||||
author.SetText(chatTabs[chatJidStr].Messages[i].Author)
|
||||
replytext.Hide()
|
||||
@@ -422,6 +434,11 @@ func main() {
|
||||
login = config.Login
|
||||
notifications = config.Notifications
|
||||
|
||||
if isUTF8Locale() {
|
||||
replyBodyIcon = "↱"
|
||||
replyNameIcon = "→ "
|
||||
}
|
||||
|
||||
client, err := oasisSdk.CreateClient(
|
||||
&login)
|
||||
|
||||
|
Reference in New Issue
Block a user