From: Ian Lynagh Date: Sun, 16 Mar 2008 06:04:07 +0000 (+0000) Subject: Use editline instead of readline X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=dab5f1b5a1df0fdff2c9942ca311616ad472adcd Use editline instead of readline --- diff --git a/.darcs-boring b/.darcs-boring index 86bea42..b8d4abe 100644 --- a/.darcs-boring +++ b/.darcs-boring @@ -47,6 +47,7 @@ ^libraries/concurrent(/|$) ^libraries/containers(/|$) ^libraries/directory(/|$) +^libraries/editline(/|$) ^libraries/fgl(/|$) ^libraries/filepath(/|$) ^libraries/haskell-src(/|$) diff --git a/Makefile b/Makefile index 73443f6..e6d9866 100644 --- a/Makefile +++ b/Makefile @@ -353,7 +353,7 @@ binary-dist:: echo "HaveLibGmp = $(HaveLibGmp)" >> $(VARFILE) echo "GhcLibsWithUnix = $(GhcLibsWithUnix)" >> $(VARFILE) echo "GhcWithInterpreter = $(GhcWithInterpreter)" >> $(VARFILE) - echo "GhcHasReadline = $(GhcHasReadline)" >> $(VARFILE) + echo "GhcHasEditline = $(GhcHasEditline)" >> $(VARFILE) echo "BootingFromHc = $(BootingFromHc)" >> $(VARFILE) echo "XMLDocWays = $(XMLDocWays)" >> $(VARFILE) # We won't actually use xsltproc, but we need to know if it's "" or not diff --git a/aclocal.m4 b/aclocal.m4 index 3df243f..2ab48ea 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -922,18 +922,18 @@ else fi])# FP_PROG_GHC_PKG -# FP_GHC_HAS_READLINE +# FP_GHC_HAS_EDITLINE # ------------------- -AC_DEFUN([FP_GHC_HAS_READLINE], +AC_DEFUN([FP_GHC_HAS_EDITLINE], [AC_REQUIRE([FP_PROG_GHC_PKG]) -AC_CACHE_CHECK([whether ghc has readline package], [fp_cv_ghc_has_readline], -[if "${GhcPkgCmd-ghc-pkg}" --show-package readline >/dev/null 2>&1; then - fp_cv_ghc_has_readline=yes +AC_CACHE_CHECK([whether ghc has editline package], [fp_cv_ghc_has_editline], +[if "${GhcPkgCmd-ghc-pkg}" --show-package editline >/dev/null 2>&1; then + fp_cv_ghc_has_editline=yes else - fp_cv_ghc_has_readline=no + fp_cv_ghc_has_editline=no fi]) -AC_SUBST([GhcHasReadline], [`echo $fp_cv_ghc_has_readline | sed 'y/yesno/YESNO/'`]) -])# FP_GHC_HAS_READLINE +AC_SUBST([GhcHasEditline], [`echo $fp_cv_ghc_has_editline | sed 'y/yesno/YESNO/'`]) +])# FP_GHC_HAS_EDITLINE # FP_GCC_EXTRA_FLAGS diff --git a/compiler/Makefile b/compiler/Makefile index adddc06..2dd6203 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -529,23 +529,23 @@ else EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c endif -# Enable readline if either: -# - we're building stage 1 and $(GhcHasReadline)="YES" -# - we're building stage 2/3, and we have built the readline package +# Enable editline if either: +# - we're building stage 1 and $(GhcHasEditline)="YES" +# - we're building stage 2/3, and we have built the editline package # -# But we don't enable readline on Windows, because readline is fairly -# broken there. +# But we don't enable editline on Windows, as Windows terminals have +# editline-like support builtin. # ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32" ifeq "$(stage)" "1" -ifeq "$(GhcHasReadline)" "YES" -SRC_HC_OPTS += -package readline -DUSE_READLINE -PKG_DEPENDS += readline +ifeq "$(GhcHasEditline)" "YES" +SRC_HC_OPTS += -package editline -DUSE_EDITLINE +PKG_DEPENDS += editline endif else -ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/readline/unbuildable)" "" -SRC_HC_OPTS += -package readline -DUSE_READLINE -PKG_DEPENDS += readline +ifeq "$(wildcard $(FPTOOLS_TOP_ABS)/libraries/editline/unbuildable)" "" +SRC_HC_OPTS += -package editline -DUSE_EDITLINE +PKG_DEPENDS += editline endif endif # stage=1 endif # not windows diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs index c865943..ed90e99 100644 --- a/compiler/ghci/InteractiveUI.hs +++ b/compiler/ghci/InteractiveUI.hs @@ -24,7 +24,7 @@ import PprTyThing import DynFlags import Packages -#ifdef USE_READLINE +#ifdef USE_EDITLINE import PackageConfig import UniqFM #endif @@ -56,9 +56,9 @@ import GHC.ConsoleHandler ( flushConsole ) import qualified System.Win32 #endif -#ifdef USE_READLINE +#ifdef USE_EDITLINE import Control.Concurrent ( yield ) -- Used in readline loop -import System.Console.Readline as Readline +import System.Console.Editline.Readline as Readline #endif --import SystemExts @@ -89,7 +89,7 @@ import GHC.TopHandler import Data.IORef ( IORef, readIORef, writeIORef ) -#ifdef USE_READLINE +#ifdef USE_EDITLINE import System.Posix.Internals ( setNonBlockingFD ) #endif @@ -161,7 +161,7 @@ builtin_commands = [ -- -- NOTE: in order for us to override the default correctly, any custom entry -- must be a SUBSET of word_break_chars. -#ifdef USE_READLINE +#ifdef USE_EDITLINE word_break_chars :: String word_break_chars = let symbols = "!#$%&*+/<=>?@\\^|-~" specials = "(),;[]`{}" @@ -312,14 +312,15 @@ interactiveUI session srcs maybe_exprs = do -- intended for the program, so unbuffer stdin. hSetBuffering stdin NoBuffering -#ifdef USE_READLINE +#ifdef USE_EDITLINE is_tty <- hIsTerminalDevice stdin when is_tty $ do Readline.initialize + -- XXX Should we be catching exceptions thrown by readHistory? withGhcAppData (\dir -> Readline.readHistory (dir "ghci_history")) - (return True) + (return ()) Readline.setAttemptedCompletionFunction (Just completeWord) --Readline.parseAndBind "set show-all-if-ambiguous 1" @@ -353,10 +354,11 @@ interactiveUI session srcs maybe_exprs = do remembered_ctx = [] } -#ifdef USE_READLINE +#ifdef USE_EDITLINE Readline.stifleHistory 100 + -- XXX Should we be catching exceptions thrown by readHistory? withGhcAppData (\dir -> Readline.writeHistory (dir "ghci_history")) - (return True) + (return ()) Readline.resetTerminal Nothing #endif @@ -473,7 +475,7 @@ interactiveLoop is_tty show_prompt = -- exception handler above. -- read commands from stdin -#ifdef USE_READLINE +#ifdef USE_EDITLINE if (is_tty) then runCommands readlineLoop else runCommands (fileLoop stdin show_prompt is_tty) @@ -601,7 +603,7 @@ mkPrompt = do return (showSDoc (f (prompt st))) -#ifdef USE_READLINE +#ifdef USE_EDITLINE readlineLoop :: GHCi (Maybe String) readlineLoop = do io yield @@ -1659,7 +1661,7 @@ completeMacro, completeIdentifier, completeModule, completeHomeModuleOrFile :: String -> IO [String] -#ifdef USE_READLINE +#ifdef USE_EDITLINE completeWord :: String -> Int -> Int -> IO (Maybe (String, [String])) completeWord w start end = do line <- Readline.getLineBuffer diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs index 892171c..4f4b3ce 100644 --- a/compiler/ghci/Linker.lhs +++ b/compiler/ghci/Linker.lhs @@ -947,7 +947,7 @@ partOfGHCi # if defined(mingw32_TARGET_OS) || defined(darwin_TARGET_OS) = [ ] # else - = [ "base", "haskell98", "template-haskell", "readline" ] + = [ "base", "haskell98", "template-haskell", "editline" ] # endif showLS (Object nm) = "(static) " ++ nm diff --git a/configure.ac b/configure.ac index cd8b0ff..8892ba0 100644 --- a/configure.ac +++ b/configure.ac @@ -660,8 +660,8 @@ if test "$WithGhc" != ""; then AC_SUBST(ghc_ge_607)dnl fi -# Check whether this GHC has readline installed -FP_GHC_HAS_READLINE +# Check whether this GHC has editline installed +FP_GHC_HAS_EDITLINE AC_PATH_PROGS(NHC,nhc nhc98) AC_PATH_PROG(HBC,hbc) @@ -1004,18 +1004,6 @@ AC_SYS_LARGEFILE dnl ** check for specific header (.h) files that we are interested in AC_CHECK_HEADERS([bfd.h ctype.h dirent.h dlfcn.h errno.h fcntl.h grp.h limits.h locale.h nlist.h pthread.h pwd.h signal.h sys/mman.h sys/resource.h sys/time.h sys/timeb.h sys/timers.h sys/times.h sys/utsname.h sys/wait.h termios.h time.h utime.h windows.h winsock.h]) -AC_CHECK_HEADER([readline/readline.h], [HaveReadlineReadlineH=YES], [HaveReadlineReadlineH=NO]) -AC_CHECK_HEADER([readline/history.h], [HaveReadlineHistoryH=YES], [HaveReadlineHistoryH=NO]) - -if test $HaveReadlineReadlineH = YES && test $HaveReadlineHistoryH = YES ; then - GhcLibsWithReadline=YES - AC_DEFINE([HAVE_READLINE_HEADERS], [1], [Define to 1 if readline/readline.h and readline/history.h exist.]) -else - GhcLibsWithReadline=NO - AC_DEFINE([HAVE_READLINE_HEADERS], [0], [Define to 1 if readline/readline.h and readline/history.h exist.]) -fi -AC_SUBST(GhcLibsWithReadline) - dnl ** check if it is safe to include both and AC_HEADER_TIME diff --git a/libraries/Makefile b/libraries/Makefile index 5af0f7e..c172f88 100644 --- a/libraries/Makefile +++ b/libraries/Makefile @@ -46,7 +46,7 @@ endif ifeq "$(Windows)" "YES" SUBDIRS += $(wildcard Win32) endif -SUBDIRS += process pretty hpc template-haskell readline Cabal random haskell98 +SUBDIRS += process pretty hpc template-haskell editline Cabal random haskell98 # Set GhcBootLibs=YES from the command line to work with just the libraries # needed to bootstrap GHC. diff --git a/libraries/boot-packages b/libraries/boot-packages index dde6ff1..940683d 100644 --- a/libraries/boot-packages +++ b/libraries/boot-packages @@ -4,6 +4,7 @@ bytestring Cabal containers directory +editline filepath haskell98 old-locale @@ -12,7 +13,6 @@ packedstring pretty process random -readline template-haskell unix Win32 diff --git a/libraries/ifBuildable.hs b/libraries/ifBuildable.hs index f163ca2..93118ab 100644 --- a/libraries/ifBuildable.hs +++ b/libraries/ifBuildable.hs @@ -32,4 +32,4 @@ doit package getMustBeBuildablePackages :: IO [String] getMustBeBuildablePackages = do xs <- readFile "../boot-packages" - return $ filter ("readline" /=) $ lines xs + return $ filter ("editline" /=) $ lines xs diff --git a/mk/config.mk.in b/mk/config.mk.in index 0e0a613..7d0e025 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -860,8 +860,8 @@ EXECUTABLE_FILE = chmod +x GHC = @WithGhc@ GhcDir = $(dir $(GHC)) -# Set to YES if $(GHC) has the readline package installed -GhcHasReadline = @GhcHasReadline@ +# Set to YES if $(GHC) has the editline package installed +GhcHasEditline = @GhcHasEditline@ HBC = @HBC@ NHC = @NHC@