Skip to content

Commit

Permalink
Support ansi-terminal-1.1 (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej authored Feb 7, 2024
1 parent 34282db commit 4a1f474
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 27 deletions.
45 changes: 26 additions & 19 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.16.3
# version: 0.17.20240109
#
# REGENDATA ("0.16.3",["github","cabal.project"])
# REGENDATA ("0.17.20240109",["github","cabal.project"])
#
name: Haskell-CI
on:
Expand All @@ -28,19 +28,24 @@ jobs:
strategy:
matrix:
include:
- compiler: ghc-9.6.2
- compiler: ghc-9.8.1
compilerKind: ghc
compilerVersion: 9.6.2
compilerVersion: 9.8.1
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.4.5
- compiler: ghc-9.6.4
compilerKind: ghc
compilerVersion: 9.4.5
compilerVersion: 9.6.4
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.7
- compiler: ghc-9.4.8
compilerKind: ghc
compilerVersion: 9.2.7
compilerVersion: 9.4.8
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.2.8
compilerKind: ghc
compilerVersion: 9.2.8
setup-method: ghcup
allow-failure: false
- compiler: ghc-9.0.2
Expand Down Expand Up @@ -86,18 +91,18 @@ jobs:
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME"
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
env:
HCKIND: ${{ matrix.compilerKind }}
Expand All @@ -111,17 +116,19 @@ jobs:
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
HCDIR=/opt/$HCKIND/$HCVER
if [ "${{ matrix.setup-method }}" = ghcup ]; then
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER")
HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#')
HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#')
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
Expand Down Expand Up @@ -182,8 +189,8 @@ jobs:
- name: install cabal-docspec
run: |
mkdir -p $HOME/.cabal/bin
curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20230517/cabal-docspec-0.0.0.20230517-x86_64-linux.xz > cabal-docspec.xz
echo '3b31bbe463ad4d671abbc103db49628562ec48a6604cab278207b5b6acd21ed7 cabal-docspec.xz' | sha256sum -c -
curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20231219/cabal-docspec-0.0.0.20231219-x86_64-linux.xz > cabal-docspec.xz
echo '8b60448275466bbe2b9409741b5dd07a41c541283017b95b44efe6e31379d067 cabal-docspec.xz' | sha256sum -c -
xz -d < cabal-docspec.xz > $HOME/.cabal/bin/cabal-docspec
rm -f cabal-docspec.xz
chmod a+x $HOME/.cabal/bin/cabal-docspec
Expand Down
7 changes: 4 additions & 3 deletions examples/trifecta-examples.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ tested-with: GHC == 8.0.2
, GHC == 8.8.4
, GHC == 8.10.7
, GHC == 9.0.2
, GHC == 9.2.7
, GHC == 9.4.5
, GHC == 9.6.2
, GHC == 9.2.8
, GHC == 9.4.8
, GHC == 9.6.4
, GHC == 9.8.1
extra-source-files: RFC2616.txt RFC2616-malformed.txt

source-repository head
Expand Down
4 changes: 4 additions & 0 deletions src/Text/Trifecta/Rendering.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# language CPP #-}
{-# language DeriveDataTypeable #-}
{-# language DeriveGeneric #-}
{-# language FlexibleInstances #-}
Expand Down Expand Up @@ -103,6 +104,9 @@ sgr xs0 = go (P.reverse xs0) where
go (SetUnderlining NoUnderline : xs) = annotate deunderline . go xs
go (SetUnderlining SingleUnderline : xs) = annotate underlined . go xs
go (SetColor f i c : xs) = case f of
#if MIN_VERSION_ansi_terminal(1,1,0)
Underlining -> go xs
#endif
Foreground -> case i of
Dull -> case c of
Black -> annotate (color Pretty.Black) . go xs
Expand Down
11 changes: 6 additions & 5 deletions trifecta.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: trifecta
category: Text, Parsing, Diagnostics, Pretty Printer, Logging
version: 2.1.3
version: 2.1.3.1
license: BSD3
cabal-version: 1.18
license-file: LICENSE
Expand Down Expand Up @@ -28,9 +28,10 @@ tested-with: GHC == 8.0.2
, GHC == 8.8.4
, GHC == 8.10.7
, GHC == 9.0.2
, GHC == 9.2.7
, GHC == 9.4.5
, GHC == 9.6.2
, GHC == 9.2.8
, GHC == 9.4.8
, GHC == 9.6.4
, GHC == 9.8.1

extra-doc-files:
images/*.png
Expand Down Expand Up @@ -68,7 +69,7 @@ library
Text.Trifecta.Util.Pretty

build-depends:
ansi-terminal >= 0.6 && < 1.1,
ansi-terminal >= 0.6 && < 1.2,
array >= 0.5.1.1 && < 0.6,
base >= 4.9 && < 5,
blaze-builder >= 0.3.0.1 && < 0.5,
Expand Down

0 comments on commit 4a1f474

Please sign in to comment.