haskeline 0.8.2.1 → 0.8.3.0
raw patch · 6 files changed
+77/−31 lines, 6 filesdep ~Win32dep ~basenew-uploaderPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Win32, base
API changes (from Hackage documentation)
Files
- Changelog +4/−0
- System/Console/Haskeline.hs +5/−4
- System/Console/Haskeline/Backend/Win32.hsc +13/−1
- System/Console/Haskeline/InputT.hs +10/−7
- haskeline.cabal +44/−18
- includes/windows_cconv.h +1/−1
Changelog view
@@ -1,3 +1,7 @@+Changed in version 0.8.3.0:++ * User preferences are now read from $XDG_CONFIG_HOME/haskeline/haskeline.+ Changed in version 0.8.2.1: * Add `configure` check for `termios.h` and fallbacks for wasi.
System/Console/Haskeline.hs view
@@ -330,7 +330,7 @@ of type 'Interrupt'. For example: > tryAction :: InputT IO ()-> tryAction = handle (\Interrupt -> outputStrLn "Cancelled.")+> tryAction = handleInterrupt (outputStrLn "Cancelled.") > $ withInterrupt $ someLongAction The action can handle the interrupt itself; a new 'Interrupt' exception will be thrown@@ -338,7 +338,7 @@ > tryAction :: InputT IO () > tryAction = withInterrupt loop-> where loop = handle (\Interrupt -> outputStrLn "Cancelled; try again." >> loop)+> where loop = handleInterrupt (outputStrLn "Cancelled; try again." >> loop) > someLongAction This behavior differs from GHC's built-in Ctrl-C handling, which@@ -351,9 +351,10 @@ rterm <- InputT ask wrapInterrupt rterm act --- | Catch and handle an exception of type 'Interrupt'.+-- | Catch and handle an exception of type 'Interrupt'. See 'withInterrupt' for+-- more explanation. ----- > handleInterrupt f = handle $ \Interrupt -> f+-- > handleInterrupt (outputStrLn "Ctrl+C was pressed, aborting!") someLongAction handleInterrupt :: MonadMask m => m a -> m a -> m a handleInterrupt f = handle $ \Interrupt -> f
System/Console/Haskeline/Backend/Win32.hsc view
@@ -10,7 +10,19 @@ import System.IO import Foreign import Foreign.C-#if MIN_VERSION_Win32(2,9,0)+#if MIN_VERSION_Win32(2,14,1)+import System.Win32 hiding (+ multiByteToWideChar,+ setConsoleMode,+ getConsoleMode,+ KeyEvent,+ keyDown,+ virtualKeyCode,+ repeatCount,+ virtualScanCode,+ windowSize+ )+#elif MIN_VERSION_Win32(2,9,0) import System.Win32 hiding (multiByteToWideChar, setConsoleMode, getConsoleMode) #else import System.Win32 hiding (multiByteToWideChar)
System/Console/Haskeline/InputT.hs view
@@ -16,7 +16,7 @@ import Control.Monad.Fail as Fail import Control.Monad.Fix import Data.IORef-import System.Directory(getHomeDirectory)+import System.Directory(getXdgDirectory, XdgDirectory(XdgConfig), doesFileExist, getHomeDirectory) import System.FilePath import System.IO @@ -164,7 +164,7 @@ runInputTBehavior :: (MonadIO m, MonadMask m) => Behavior -> Settings m -> InputT m a -> m a runInputTBehavior behavior settings f = withBehavior behavior $ \run -> do prefs <- if isTerminalStyle run- then liftIO readPrefsFromHome+ then liftIO readUserPrefs else return defaultPrefs execInputT prefs settings run f @@ -217,10 +217,13 @@ preferTerm = Behavior terminalRunTerm --- | Read 'Prefs' from @~/.haskeline.@ If there is an error reading the file,+-- | Read 'Prefs' from @$XDG_CONFIG_HOME/haskeline/haskeline@ if present+-- ortherwise @~/.haskeline.@ If there is an error reading the file, -- the 'defaultPrefs' will be returned.-readPrefsFromHome :: IO Prefs-readPrefsFromHome = handle (\(_::IOException) -> return defaultPrefs) $ do- home <- getHomeDirectory- readPrefs (home </> ".haskeline")+readUserPrefs :: IO Prefs+readUserPrefs = handle (\(_::IOException) -> return defaultPrefs) $ do+ xdg <- getXdgDirectory XdgConfig ("haskeline/haskeline")+ exists <- doesFileExist xdg+ home <- getHomeDirectory+ readPrefs (if exists then xdg else (home </> ".haskeline"))
haskeline.cabal view
@@ -1,12 +1,12 @@ Name: haskeline Cabal-Version: >=1.10-Version: 0.8.2.1+Version: 0.8.3.0 Category: User Interfaces License: BSD3 License-File: LICENSE Copyright: (c) Judah Jacobson Author: Judah Jacobson-Maintainer: Judah Jacobson <judah.jacobson@gmail.com>+Maintainer: Troels Henriksen <athas@sigkill.dk> Synopsis: A command-line interface for user input, written in Haskell. Description: Haskeline provides a user interface for line input in command-line@@ -15,15 +15,30 @@ Haskell programs. . Haskeline runs both on POSIX-compatible systems and on Windows.-Homepage: https://github.com/judah/haskeline-Bug-Reports: https://github.com/judah/haskeline/issues+Homepage: https://github.com/haskell/haskeline+Bug-Reports: https://github.com/haskell/haskeline/issues Stability: Stable Build-Type: Simple++tested-with:+ GHC == 9.10.1+ GHC == 9.8.2+ GHC == 9.6.5+ GHC == 9.4.8+ GHC == 9.2.8+ GHC == 9.0.2+ GHC == 8.10.7+ GHC == 8.8.4+ GHC == 8.6.5+ GHC == 8.4.4+ GHC == 8.2.2+ GHC == 8.0.2+ extra-source-files: examples/Test.hs Changelog includes/*.h source-repository head type: git- location: git://github.com/judah/haskeline.git+ location: https://github.com/judah/haskeline.git -- There are three main advantages to the terminfo backend over the portable, -- "dumb" alternative. First, it enables more efficient control sequences@@ -46,14 +61,16 @@ Manual: True Library- -- We require ghc>=7.4.1 (base>=4.5) to use the base library encodings, even- -- though it was implemented in earlier releases, due to GHC bug #5436 which- -- wasn't fixed until 7.4.1- Build-depends: base >=4.9 && < 4.19, containers>=0.4 && < 0.7,- directory>=1.1 && < 1.4, bytestring>=0.9 && < 0.12,- filepath >= 1.2 && < 1.5, transformers >= 0.2 && < 0.7,- process >= 1.0 && < 1.7, stm >= 2.4 && < 2.6,- exceptions == 0.10.*+ Build-depends:+ base >= 4.9 && < 4.21+ , containers >= 0.4 && < 0.8+ , directory >= 1.1 && < 1.4+ , bytestring >= 0.9 && < 0.13+ , filepath >= 1.2 && < 1.6+ , transformers >= 0.2 && < 0.7+ , process >= 1.0 && < 1.7+ , stm >= 2.4 && < 2.6+ , exceptions == 0.10.* Default-Language: Haskell98 Default-Extensions: ForeignFunctionInterface, Rank2Types, FlexibleInstances,@@ -93,15 +110,15 @@ include-dirs: includes c-sources: cbits/h_wcwidth.c - if os(windows) {- Build-depends: Win32>=2.0+ if os(windows)+ Build-depends: Win32 >= 2.1 && < 2.10 || >= 2.12 Other-modules: System.Console.Haskeline.Backend.Win32 System.Console.Haskeline.Backend.Win32.Echo c-sources: cbits/win_console.c includes: win_console.h, windows_cconv.h install-includes: win_console.h cpp-options: -DMINGW- } else {+ else Build-depends: unix>=2.0 && < 2.9 Other-modules: System.Console.Haskeline.Backend.Posix@@ -115,7 +132,6 @@ if os(solaris) { cpp-options: -DUSE_TERMIOS_H }- } ghc-options: -Wall -Wcompat @@ -131,7 +147,17 @@ buildable: False } Main-Is: Unit.hs- Build-depends: base, containers, text, bytestring, HUnit, process, unix+ Build-depends:+ -- shared dependencies with library+ base >= 4.9 && < 4.21+ , containers >= 0.4 && < 0.8+ , bytestring >= 0.9 && < 0.13+ , process >= 1.0 && < 1.7+ -- dependencies for test-suite+ , HUnit+ , text+ , unix >= 2.0 && < 2.9+ Other-Modules: RunTTY, Pty build-tool-depends: haskeline:haskeline-examples-Test
includes/windows_cconv.h view
@@ -3,7 +3,7 @@ #if defined(i386_HOST_ARCH) # define WINDOWS_CCONV stdcall-#elif defined(x86_64_HOST_ARCH)+#elif defined(x86_64_HOST_ARCH) || defined(aarch64_HOST_ARCH) # define WINDOWS_CCONV ccall #else # error Unknown mingw32 arch