Commit dab5f1b5 authored by Ian Lynagh's avatar Ian Lynagh

Use editline instead of readline

parent aaca29b7
......@@ -47,6 +47,7 @@
^libraries/concurrent(/|$)
^libraries/containers(/|$)
^libraries/directory(/|$)
^libraries/editline(/|$)
^libraries/fgl(/|$)
^libraries/filepath(/|$)
^libraries/haskell-src(/|$)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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 <time.h> and <sys/time.h>
AC_HEADER_TIME
......
......@@ -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.
......
......@@ -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
......
......@@ -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
......@@ -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@
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment