1
1
mirror of https://github.com/Yvee1/hascard.git synced 2024-11-22 12:51:58 +03:00

Update dependency versions and add Windows support

This commit is contained in:
Yvee1 2023-12-17 13:01:03 +01:00
parent b9e44fd2e7
commit 5e14b17ce8
4 changed files with 39 additions and 29 deletions

View File

@ -21,22 +21,23 @@ description: Hascard is a text-based user interface for reviewing notes
dependencies:
- base >= 4.7 && < 5
- brick >= 1.4 && < 2.0
- containers > 0.6.0 && < 0.7
- brick >= 2.1.1 && < 3.0
- containers > 0.6.0 && < 0.8
- directory >= 1.3.3 && < 1.4
- filepath >= 1.4.2 && < 1.5
- microlens >= 0.4.11 && < 0.5
- microlens-platform >= 0.4.1 && < 0.5
- mwc-random >= 0.14 && < 0.16
- optparse-applicative >= 0.15.1 && < 0.18
- optparse-applicative >= 0.18.0 && < 0.19
- ordered-containers >= 0.2.2 && < 0.3
- megaparsec >= 8.0.0 && < 10
- process >= 1.6.5 && < 1.7
- random-fu >= 0.2.7 && < 0.4
- strict >= 0.3.2 && < 0.5
- text >= 1.2.3 && < 1.3
- vector >= 0.12.0 && < 0.13
- vty >= 5.28.2 && < 5.38
- strict >= 0.3.2 && < 0.6
- text >= 2.0 && < 3.0
- vector >= 0.12.0 && < 0.14
- vty >= 6.0 && < 7.0
- vty-crossplatform >= 0.2 && < 0.5
- word-wrap >= 0.4.1 && < 0.6
- tasty >= 1.2.1 && < 1.5
- tasty-hunit >= 0.10.0 && < 0.11

View File

@ -1,11 +1,11 @@
module Types where
import Data.Functor
import Data.List
import Data.List ( intercalate, intersperse )
import Data.List.NonEmpty (NonEmpty)
import System.FilePath
import System.Process
import System.Info
import System.IO
import System.FilePath ( (</>) )
import System.Process ( runCommand, readProcess )
import System.Info ( os )
import System.IO ( openTempFile, hPutStrLn, hClose )
import qualified Data.List.NonEmpty as NE
import qualified System.Directory as D
@ -57,17 +57,18 @@ openCommand :: String
openCommand = case os of
"darwin" -> "open"
"linux" -> "xdg-open"
_ -> error "Unkown OS for opening images"
"mingw32" -> ""
_ -> error $ "Unknown OS (" <> os <> ") for opening files"
openImage :: FilePath -> FilePath -> IO ()
openImage origin relative = openImage' (origin </> relative)
openFile :: FilePath -> FilePath -> IO ()
openFile origin relative = openFile' (origin </> relative)
openImage' :: FilePath -> IO ()
openImage' fp = do
openFile' :: FilePath -> IO ()
openFile' fp = do
exists <- D.doesFileExist fp
if exists
then void $ runCommand (openCommand <> " \"" <> fp <> "\"")
else error $ "The image you were trying to open does not exist: " <> fp
else error $ "The file you were trying to open does not exist: " <> fp
openLatex :: String -> IO ()
openLatex latex = do
@ -82,14 +83,14 @@ openLatex latex = do
(tempfile, temph) <- openTempFile dir "hascard-latex-"
hPutStrLn temph text
hClose temph
callProcess "pdflatex" ["-output-directory", dir, tempfile]
openImage' (tempfile <> ".pdf")
readProcess "pdflatex" ["-output-directory", dir, tempfile] ""
openFile' (tempfile <> ".pdf")
openCardExternal :: FilePath -> Card -> IO ()
openCardExternal origin card =
case external card of
Nothing -> pure ()
Just (Image _ relative) -> openImage origin relative
Just (Image _ relative) -> openFile origin relative
Just (Latex text) -> openLatex text
whenJust :: Applicative m => Maybe a -> (a -> m ()) -> m ()

View File

@ -17,7 +17,7 @@
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver: lts-20.21
resolver: lts-22.0
# User packages to be built.
# Various formats can be used as shown in the example below.
@ -35,6 +35,7 @@ packages:
# forks / in-progress versions pinned to a git hash. For example:
#
extra-deps:
- vty-windows-0.2.0.1
# - acme-missiles-0.3
# - git: https://github.com/commercialhaskell/stack.git
# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a

View File

@ -3,10 +3,17 @@
# For more information, please see the documentation at:
# https://docs.haskellstack.org/en/stable/lock_files
packages: []
packages:
- completed:
hackage: vty-windows-0.2.0.1@sha256:6c75230057a708168dbc420975572511ad3ec09956bf73c3b6f4be03324e8b13,2815
pantry-tree:
sha256: 0de977580639c2a90958ef68ec03128d0362ff13657c66c4f25cedc12ba3259e
size: 2160
original:
hackage: vty-windows-0.2.0.1
snapshots:
- completed:
size: 650044
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/20/21.yaml
sha256: 401a0e813162ba62f04517f60c7d25e93a0f867f94a902421ebf07d1fb5a8c46
original: lts-20.21
sha256: e176944bc843f740e05242fa7a66ca1f440c127e425254f7f1257f9b19add23f
size: 712153
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/0.yaml
original: lts-22.0