I'm using gocui in Vuvuzela, a chat app with a UI similar to irssi's. I'd like to be able to edit chat messages that appear in a conversation window (e.g., to indicate when a message has been sent or received). Unfortunately, there does not appear to be an easy way to edit lines in a view buffer. I tried this code to delete a * character from a line after the line has been received by the other user:
func (c *Conversation) markAcked(line int) {
c.gc.gui.Update(func(_ *gocui.Gui) error {
v, err := c.gc.gui.View(c.ViewName())
if err != nil {
return err
}
// Column 9 contains the '*' right after the timestamp.
err = v.SetCursor(9, line)
if err != nil {
return err
}
// Delete the '*'
v.EditWrite(' ')
err = v.SetCursor(0, 0)
if err != nil {
return err
}
return nil
})
}
This code works until messages start to scroll offscreen, at which point the SetCursor call fails with "invalid point." Is it possible to edit lines that have scrolled offscreen?
Is there something in the API that I'm missing that would let me edit arbitrary lines in a view buffer? If not, would it be possible to expose such an API?
I'm using gocui in Vuvuzela, a chat app with a UI similar to irssi's. I'd like to be able to edit chat messages that appear in a conversation window (e.g., to indicate when a message has been sent or received). Unfortunately, there does not appear to be an easy way to edit lines in a view buffer. I tried this code to delete a
*
character from a line after the line has been received by the other user:This code works until messages start to scroll offscreen, at which point the SetCursor call fails with "invalid point." Is it possible to edit lines that have scrolled offscreen?
Is there something in the API that I'm missing that would let me edit arbitrary lines in a view buffer? If not, would it be possible to expose such an API?