packages feed

ncurses 0.1.0.3 → 0.2

raw patch · 2 files changed

+32/−21 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- UI.NCurses: getEvent :: Window -> Curses Event
+ UI.NCurses: getEvent :: Window -> Maybe Integer -> Curses (Maybe Event)

Files

UI/NCurses.chs view
@@ -179,16 +179,17 @@ runCurses = bracket_ initCurses {# call endwin #} . unCurses where 	allEvents = fromInteger (E.fromEnum E.ALL_MOUSE_EVENTS) 	initCurses = do-		{# call initscr #}-		{# call mousemask #} allEvents nullPtr+		void {# call initscr #}+		void {# call cbreak #}+		void $ {# call mousemask #} allEvents nullPtr 		hasColor <- {# call has_colors #} 		when (hasColor == 1) $ do-			{# call start_color #}-			{# call use_default_colors #}-			return ()+			void {# call start_color #}+			void {# call use_default_colors #} 		stdscr <- peek c_stdscr-		{# call keypad #} (Window stdscr) 1-		{# call meta #} (Window stdscr) 1+		void $ {# call keypad #} (Window stdscr) 1+		void $ {# call meta #} (Window stdscr) 1+		{# call wtimeout #} (Window stdscr) (- 1)  -- | The default window created when @ncurses@ is initialized, also known -- as @stdscr@.@@ -222,8 +223,9 @@ 	if windowPtr win == nullPtr 		then error "newWindow: newwin() returned NULL" 		else do-			{# call keypad #} win 1-			{# call meta #} win 1+			void $ {# call keypad #} win 1+			void $ {# call meta #} win 1+			{# call wtimeout #} win (- 1) 			return win  -- | Close a window, and free all resources associated with it. Once a@@ -507,7 +509,7 @@ 	let cAttrs = foldl' (\acc a -> acc .|. attrToInt a) 0 attrs in 	 	allocaBytes {# sizeof cchar_t #} $ \pBuf -> do-	{# call memset #} (castPtr pBuf) 0 {# sizeof cchar_t #}+	void $ {# call memset #} (castPtr pBuf) 0 {# sizeof cchar_t #} 	{# set cchar_t->attr #} pBuf cAttrs 	{# set cchar_t->chars #} pBuf (wordPtrToPtr (fromIntegral (ord char))) 	io (CCharT pBuf)@@ -664,13 +666,26 @@ 	| EventUnknown Integer 	deriving (Show, Eq) --- | Get the next 'Event' from a given window. This blocks until an event--- is received.-getEvent :: Window -> Curses Event-getEvent win = Curses io where+-- | Get the next 'Event' from a given window.+--+-- If the timeout is specified, and no event is received within the timeout,+-- @getEvent@ returns 'Nothing'. If the timeout is 0 or less, @getEvent@+-- will not block at all.+getEvent :: Window+         -> Maybe Integer -- ^ Timeout, in milliseconds+         -> Curses (Maybe Event)+getEvent win timeout = Curses io where 	io = alloca $ \ptr -> do+		{# call wtimeout #} win $ case timeout of+			Nothing -> -1+			Just n | n <= 0 -> 0+			Just n -> fromInteger n 		rc <- {# call wget_wch #} win ptr-		checkRC "getEvent" rc+		if toInteger rc == E.fromEnum E.ERR+			then return Nothing+			else fmap Just (parseCode ptr rc)++	parseCode ptr rc = do 		code <- toInteger `fmap` peek ptr 		if rc == 0 			then return (charEvent code)
ncurses.cabal view
@@ -1,5 +1,5 @@ name: ncurses-version: 0.1.0.3+version: 0.2 synopsis: Modernised bindings to GNU ncurses license: GPL-3 license-file: license.txt@@ -20,11 +20,7 @@   location: http://john-millikin.com/software/bindings/ncurses/  library-  if true-    ghc-options: -Wall--  if impl(ghc >= 6.11)-    ghc-options: -fno-warn-unused-do-bind+  ghc-options: -Wall    build-depends:       base >= 4 && < 5