weixin_39706367 2020-11-30 02:10
浏览 0

no public Surface interface impl

function:

go
func NewPainter(s Surface, p *Theme) *Painter

need Surface interface param, but the interface Surface:

go
type Surface interface {
    SetCell(x, y int, ch rune, s Style)
    SetCursor(x, y int)
    HideCursor()
    Begin()
    End()
    Size() image.Point
}

has the only one impl:

go
type tcellSurface struct {
    screen tcell.Screen
}

and that cannot got outside the tui package

so, how to use NewPainter?

该提问来源于开源项目:marcusolsson/tui-go

  • 写回答

5条回答 默认 最新

  • weixin_39706367 2020-11-30 02:10
    关注

    by the way , i try to make a chatroom app.

    and i add the new message to message quene , and then render the new message to ui,

    but , i must press tab or other key to create a event to go to the follow code:

    go
    func (ui *tcellUI) handleEvent(ev event) {
        switch e := ev.(type) {
        case KeyEvent:
            logger.Printf("Received key event: %s", e.Name())
    
            for _, b := range ui.keybindings {
                if b.match(e) {
                    b.handler()
                }
            }
            ui.kbFocus.OnKeyEvent(e)
            ui.root.OnKeyEvent(e)
            ui.painter.Repaint(ui.root)
        case callbackEvent:
            // Gets stuck in a print loop when the logger is a widget.
            //logger.Printf("Received callback event")
            e.cbFn()
            ui.painter.Repaint(ui.root)
        case paintEvent:
            logger.Printf("Received paint event")
            ui.painter.Repaint(ui.root)
        }
    }
    

    in this code, ui.painter.Repaint(ui.root) will repaint the ui , and i need it.

    but i have not found a way to use it.

    if you know , please let me knoe.

    thank you very much.

    评论

报告相同问题?