feat: add placeholder text for message input widget (#618)

This commit is contained in:
xqrs 2025-11-10 19:45:57 +03:00 • committed by GitHub
parent 924658f0c7
commit 18e0378955
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 16 additions and 4 deletions

View file

@ -119,7 +119,9 @@ func (a *application) onPagesInputCapture(event *tcell.EventKey) *tcell.EventKey
a.SetFocus(a.messagesList)
return nil
case a.cfg.Keys.FocusMessageInput:
a.SetFocus(a.messageInput)
if !a.messageInput.GetDisabled() {
a.SetFocus(a.messageInput)
}
return nil
case a.cfg.Keys.FocusPrevious:
a.focusPrevious()

View file

@ -189,12 +189,17 @@ func (gt *guildsTree) onSelected(node *tview.TreeNode) {
app.messagesList.drawMessages(messages)
app.messagesList.ScrollToEnd()
hasPerm := channel.Type != discord.DirectMessage && channel.Type != discord.GroupDM && !discordState.HasPermissions(channel.ID, discord.PermissionSendMessages)
app.messageInput.SetDisabled(hasPerm)
hasNoPerm := channel.Type != discord.DirectMessage && channel.Type != discord.GroupDM && !discordState.HasPermissions(channel.ID, discord.PermissionSendMessages)
app.messageInput.SetDisabled(hasNoPerm)
if hasNoPerm {
app.messageInput.SetPlaceholder("You do not have permission to send messages in this channel.")
} else {
app.messageInput.SetPlaceholder("Message...")
app.SetFocus(app.messageInput)
}
gt.selectedChannelID = channel.ID
gt.selectedGuildID = channel.GuildID
app.SetFocus(app.messageInput)
case nil: // Direct messages
channels, err := discordState.PrivateChannels()
if err != nil {

View file

@ -84,6 +84,11 @@ func newMessageInput(cfg *config.Config) *messageInput {
b.BottomLeft, b.BottomRight = b.BottomT, b.BottomT
mi.mentionsList.SetBorderSet(b)
mi.TextArea.
SetPlaceholder("Select a channel to start chatting").
SetPlaceholderStyle(tcell.StyleDefault.Dim(true)).
SetDisabled(true)
return mi
}