Fix cimpiled ruby library system
This commit is contained in:
+18
-13
@@ -1,17 +1,25 @@
|
||||
module WM.Core where
|
||||
|
||||
import Control.Concurrent (threadDelay)
|
||||
import Control.Exception (bracket)
|
||||
import Foreign (Ptr)
|
||||
import System.Environment (getArgs)
|
||||
import WM.Mruby
|
||||
import WM.XKutu
|
||||
|
||||
data State = State
|
||||
{ mruby_pointer :: Ptr MrbState,
|
||||
running :: Bool
|
||||
{ mruby_pointer :: !(Ptr MrbState),
|
||||
running :: !Bool
|
||||
}
|
||||
deriving (Show)
|
||||
|
||||
newState :: Ptr MrbState -> State
|
||||
newState ptr =
|
||||
State
|
||||
{ mruby_pointer = ptr,
|
||||
running = True
|
||||
}
|
||||
|
||||
run :: IO ()
|
||||
run = do
|
||||
is_started <- deploy
|
||||
@@ -24,11 +32,10 @@ run = do
|
||||
print screen_info
|
||||
pointer_info <- get_pointer
|
||||
print pointer_info
|
||||
mrb <- mrb_open
|
||||
runRuby mrb runtimeRb
|
||||
handle_args mrb
|
||||
loop $ State mrb True
|
||||
mrb_close mrb
|
||||
bracket mrb_open mrb_close $ \mrb -> do
|
||||
loadRubyLibs mrb
|
||||
handle_args mrb
|
||||
loop (newState mrb)
|
||||
|
||||
handle_args :: Ptr MrbState -> IO ()
|
||||
handle_args mrb = do
|
||||
@@ -41,12 +48,10 @@ handle_args mrb = do
|
||||
_ -> putStrLn "unknown arguments"
|
||||
|
||||
handle_event :: Maybe Event -> State -> IO State
|
||||
handle_event Nothing state = pure state
|
||||
handle_event (Just ev) state
|
||||
| event_btn ev == 24 = pure state {running = False}
|
||||
| otherwise = do
|
||||
print ev
|
||||
pure state
|
||||
handle_event Nothing s = pure s
|
||||
handle_event (Just ev) s
|
||||
| event_btn ev == 24 = pure s {running = False}
|
||||
| otherwise = print ev >> pure s
|
||||
|
||||
loop :: State -> IO ()
|
||||
loop state
|
||||
|
||||
Reference in New Issue
Block a user