Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StdScr will not update it's size after terminal is resized #34

Closed
wallnutkraken opened this issue Jun 18, 2016 · 1 comment
Closed

StdScr will not update it's size after terminal is resized #34

wallnutkraken opened this issue Jun 18, 2016 · 1 comment

Comments

@wallnutkraken
Copy link

I have a goroutine that just waits for the terminal to be resized, and then show the size of the new terminal. However, while SIGWINCH does get triggered, the size from GetMaxYX() never changes. Here is the application:

package main

import (
    "os"
    "os/signal"
    "strconv"
    "sync"
    "syscall"

    g "github.com/rthornton128/goncurses"
)

var wg sync.WaitGroup

func main() {
    wg.Add(1)
    resizeChannel := make(chan os.Signal)
    signal.Notify(resizeChannel, syscall.SIGWINCH)
    go onResize(resizeChannel)
    wg.Wait()
}

func onResize(channel chan os.Signal) {
    stdScr, _ := g.Init()
    stdScr.ScrollOk(true)
    g.NewLines(true)
    for {
        <-channel
        g.StdScr().Clear()

        y, x := g.StdScr().MaxYX()
        g.StdScr().Println(strconv.Itoa(x) + ", " + strconv.Itoa(y))
        g.StdScr().Refresh()

    }
    wg.Done()
}
@wallnutkraken
Copy link
Author

Nevermind, apparently using g.End() and then g.Update() every time the window is resized was what I needed to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant