From b64f0fd31b42a43c117a49c08ae1c894405d4485 Mon Sep 17 00:00:00 2001 From: Niklas Larsson Date: Thu, 3 Mar 2016 12:43:50 +0100 Subject: [PATCH] Remove curses dependency --- custom.mk-alldeps | 2 +- idris.cabal | 9 +-------- src/Util/ScreenSize.hs | 24 +++++++----------------- stack-shell.nix | 1 - stack.yaml | 1 - 5 files changed, 9 insertions(+), 28 deletions(-) diff --git a/custom.mk-alldeps b/custom.mk-alldeps index 46f6a6c8a..321d66709 100644 --- a/custom.mk-alldeps +++ b/custom.mk-alldeps @@ -1 +1 @@ -CABALFLAGS += -f LLVM -f FFI -f curses --disable-documentation --disable-profiling --disable-library-profiling +CABALFLAGS += -f GMP -f FFI --disable-documentation --disable-profiling --disable-library-profiling diff --git a/idris.cabal b/idris.cabal index 808a09423..00d942e8f 100644 --- a/idris.cabal +++ b/idris.cabal @@ -839,11 +839,6 @@ Flag GMP Default: False manual: True -Flag curses - Description: Use Curses to get the screen width - Default: False - manual: True - -- This flag determines whether to show Git hashes in version strings -- Defaults to True because Hackage is a source release Flag release @@ -1002,6 +997,7 @@ Library , pretty < 1.2 , process < 1.3 , split < 0.3 + , terminal-size < 0.4 , text >=1.2.1.0 && < 1.3 , time >= 1.4 && < 1.6 , transformers < 0.5 @@ -1053,9 +1049,6 @@ Library build-depends: libffi < 0.2 extra-libraries: gmp cpp-options: -DIDRIS_GMP - if flag(curses) - build-depends: hscurses < 1.5 - cpp-options: -DCURSES if flag(freestanding) other-modules: Target_idris cpp-options: -DFREESTANDING diff --git a/src/Util/ScreenSize.hs b/src/Util/ScreenSize.hs index a9c45eba6..2210cf7ee 100644 --- a/src/Util/ScreenSize.hs +++ b/src/Util/ScreenSize.hs @@ -1,24 +1,14 @@ -{-# LANGUAGE CPP #-} module Util.ScreenSize(getScreenWidth) where -#ifndef CURSES - -getScreenWidth :: IO Int -getScreenWidth = return 80 - -#else - -import UI.HSCurses.Curses +import System.Console.Terminal.Size (size, width) import System.IO (hIsTerminalDevice, stdout) getScreenWidth :: IO Int getScreenWidth = do term <- hIsTerminalDevice stdout + sz <- size if term - then do - initScr - refresh - size <- scrSize - endWin - return (snd size) - else return 80 -#endif + then case sz of + Just w -> return $ width w + Nothing -> return 80 + else return 80 + diff --git a/stack-shell.nix b/stack-shell.nix index 4db41f408..7b4273dcd 100644 --- a/stack-shell.nix +++ b/stack-shell.nix @@ -7,7 +7,6 @@ let native_libs = [ libffi zlib - ncurses gmp pkgconfig ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ diff --git a/stack.yaml b/stack.yaml index 23549e297..c6a4af14c 100644 --- a/stack.yaml +++ b/stack.yaml @@ -9,7 +9,6 @@ flags: extra-deps: - annotated-wl-pprint-0.7.0 - cheapskate-0.1.0.4 -- hscurses-1.4.2.0 - libffi-0.1 nix: enable: false