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

Update to support running on Windows #1617

Merged
merged 5 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/Swarm/App.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE OverloadedStrings #-}

-- |
Expand All @@ -18,6 +19,13 @@ import Data.IORef (newIORef, writeIORef)
import Data.Text qualified as T
import Data.Text.IO qualified as T
import Graphics.Vty qualified as V
#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
import Graphics.Vty.Platform.Windows.Settings qualified as VS
import Graphics.Vty.Platform.Windows qualified as VS
#else
import Graphics.Vty.Platform.Unix.Settings qualified as VS
import Graphics.Vty.Platform.Unix qualified as VS
#endif
import Swarm.Game.Failure (SystemFailure)
import Swarm.Language.Pretty (prettyText)
import Swarm.Log (LogSource (SystemLog), Severity (..))
Expand Down Expand Up @@ -103,12 +111,18 @@ appMain opts = do
handleEvent e

-- Setup virtual terminal
let buildVty = V.mkVty $ V.defaultConfig {V.colorMode = colorMode opts}
initialVty <- buildVty
V.setMode (V.outputIface initialVty) V.Mouse True
let buildVty =
case colorMode opts of
Nothing -> VS.mkVty V.defaultConfig
Just cMode -> do
platformSettings <- VS.defaultSettings
VS.mkVtyWithSettings V.defaultConfig $ platformSettings {VS.settingColorMode = cMode}
vty <- buildVty

V.setMode (V.outputIface vty) V.Mouse True

-- Run the app.
void $ customMain initialVty buildVty (Just chan) (app eventHandler) s'
void $ customMain vty buildVty (Just chan) (app eventHandler) s'

-- | A demo program to run the web service directly, without the terminal application.
-- This is useful to live update the code using @ghcid -W --test "Swarm.App.demoWeb"@.
Expand Down
11 changes: 8 additions & 3 deletions swarm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ library
astar >= 0.3 && < 0.3.1,
blaze-html >= 0.9.1 && < 0.9.2,
boolexpr >= 0.2 && < 0.3,
brick >= 1.10 && < 1.11,
brick >= 2.1.1 && < 2.2,
bytestring >= 0.10 && < 0.12,
clock >= 0.8.2 && < 0.9,
colour >= 2.3.6 && < 2.4,
Expand Down Expand Up @@ -310,13 +310,18 @@ library
unification-fd >= 0.11 && < 0.12,
unordered-containers >= 0.2.14 && < 0.3,
vector >= 0.12 && < 0.14,
vty >= 5.33 && < 5.39,
vty >= 6.0 && < 6.1,
vty-crossplatform >= 0.2.0.0 && < 0.3,
wai >= 3.2 && < 3.3,
warp >= 3.2 && < 3.4,
witch >= 1.1.1.0 && < 1.3,
witherable >= 0.4 && < 0.5,
word-wrap >= 0.5 && < 0.6,
yaml >= 0.11 && < 0.11.12.0,
yaml >= 0.11 && < 0.11.12.0
if os(windows)
build-depends: vty-windows >= 0.1.0.3 && < 0.2
else
build-depends: vty-unix >= 0.1.0.0 && < 0.2
hs-source-dirs: src
default-language: Haskell2010
default-extensions:
Expand Down
Loading