HSCurses - Hello World? (can't find much documentation)

Hi everyone, Haven't posted here since I was a kid, when this language first warped my poor imperative brain. My main work environment is a three-split terminal session using `Yakuake' as a dropdown-terminal (one for vim, one for interactive interpreter, one for MySQL). I don't mind using the MySQL cli *that* much, but I find typing my queries all the time much takes up precious time when I'm developing things, and it annoys me. Since there is currently no TUI for mysql administration (besides links/phpadmin? o.0). I decided to make one, choosing Haskell because, well, it's awesome. I've made curses apps before, but never in Haskell (only wx, cgi, cli, etc). Couldn't find anything besides an api reference; Which was impossible to find before typing haddock specifically, even after an exhausting search on google, krugle, archives, etc... It's livable (I've learned more complex things with less). But since I've never seen how the HSCurses functions really integrate together, or any tutorials/examples (besides hsFishEx), I fear toying with it is going to be annoying until I figure it out on my own, especially since I'm already doing a project for someone... So, I was wondering if anyone would be kind enough to point me to (or write me) a basic example of how HSCurses works, maybe w/ some very simple example of interactivity (e.g. getch processing, screen refresh, ..) support. Also, maybe warn me of some of the common pitfalls and differences in hscurses vs ncurses in other languages. Having found the haddock, and having done curses apps in other languages, that should be enough for me to get a handle on it. I'm just dreading the "read the haddock, assume it works this way, find out you do it this way, repeat" loop of learning w/o a starting point. Any help would be greatly appreciated, and will save me some (anticipated) hassle. TYIA, -Pete

On Fri, Oct 22, 2010 at 11:18 PM, Anonymous Void
But since I've never seen how the HSCurses functions really integrate together, or any tutorials/examples (besides hsFishEx), I fear toying with it is going to be annoying until I figure it out on my own, especially since I'm already doing a project for someone... So, I was wondering if anyone would be kind enough to point me to (or write me) a basic example of how HSCurses works, maybe w/ some very simple example of interactivity (e.g. getch processing, screen refresh, ..) support. Also, maybe warn me of some of the common pitfalls and differences in hscurses vs ncurses in other languages.
UI.HSCurses.Curses follows ncurses quite closely so you can get pretty far reading the NCurses Programming HOWTO: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/ .Don't forget to have the ncurses man pages handy - usually you'll just need to lowercase the name of a HSCurses function to get the name of the same function in ncurses. If you're going to be using colours or styles (bold, underline, etc), do take a look at CursesHelper too - its API documentation is somewhat better than Curses's. You could also try looking at the ContactManager program in hscurses's example directory. Just to get you started, though, here's a trivial HSCurses program to exhibit simple interaction (a walking '@'): module Main where import UI.HSCurses.Curses -- | Useful for transforming a Char to a ChType. Not sure if this is safe outside of the 7-bit ASCII range. castEnum = toEnum . fromEnum -- note that curses positions are (y, x) coordinates, with (0, 0) being the upmost leftmost position moveAbout pY pX = do erase -- clear curses's virtual screen but don't force a redraw mvAddCh pY pX (castEnum '@') -- place a character in curses's virtual screen refresh -- copy the virtual screen to the terminal c <- getCh case c of KeyUp -> moveAbout (pY - 1) pX KeyDown -> moveAbout (pY + 1) pX KeyLeft -> moveAbout pY (pX - 1) KeyRight -> moveAbout pY (pX + 1) _ -> return () main = do initCurses keypad stdScr True -- make the cursor keys usable echo False -- disable terminal echo cursSet CursorInvisible (sizeY, sizeX) <- scrSize moveAbout (sizeY `div` 2) (sizeX `div` 2) endWin
participants (2)
-
Anonymous Void
-
Ari Rahikkala