Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell ncurses

main :: IO()
main = runCurses $ do 
  setEcho False
  w <- defaultWindow
  canvas <- newWindow 19 19 0 0
  panel <- newPanel canvas
  updateWindow canvas $ do 
    drawString "Hello world!"
  render
  waitFor w (\ev -> ev == EventCharacter 'q' || ev == EventCharacter 'Q')

waitFor :: Window -> (Event -> Bool) -> Curses ()
waitFor w p = loop where
    loop = do
        ev <- getEvent w Nothing
        case ev of
            Nothing -> loop
            Just ev' -> unless (p ev') loop

Hello. It is a bit modified example of ncurses package. Problem is that is do not display anything. In C API, as I remember, I have to refresh each window independently. But Haskell offer only render. Where I am wrong? I want to have some moveable widget.

like image 916
KAction Avatar asked Oct 07 '22 10:10

KAction


1 Answers

You have just to call refreshPanels.

like image 75
KAction Avatar answered Oct 13 '22 09:10

KAction