Skip to content

Commit

Permalink
add command history and history expansion to lua console
Browse files Browse the repository at this point in the history
Adds an optional dependency on the readline library.
  • Loading branch information
cbeck88 committed Nov 22, 2014
1 parent 21e614c commit ba46cc8
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 80 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Expand Up @@ -88,6 +88,7 @@ option(ENABLE_PANDORA "Add support for the OpenPandora by deactivating libvorbis
option(ENABLE_SDL_GPU "Enable building with SDL_gpu (experimental" OFF)
option(ENABLE_BOOST_FILESYSTEM "Enable building with the boost filesystem and boost locale code" ON)
option(ENABLE_LIBPNG "Enable support for writing png files (screenshots, images)" ON)
option(ENABLE_READLINE "Enable using readline for history in lua console" OFF)

if(NOT DEFINED ENABLE_DISPLAY_REVISION)
# Test whether the code is used in a repository if not autorevision will
Expand Down Expand Up @@ -605,6 +606,13 @@ if(ENABLE_GAME)
else(ENABLE_LIBPNG AND PNG_FOUND)
message("Could not find lib PNG. Disabling support for writing PNG images.")
endif(ENABLE_LIBPNG AND PNG_FOUND)

find_package( READLINE )
if(ENABLE_READLINE AND READLINE_FOUND)
add_definitions(-DHAVE_READLINE)
else(ENABLE_READLINE AND READLINE_FOUND)
message("Could not find readline. Disabling support for command history in lua console.")
endif(ENABLE_READLINE AND READLINE_FOUND)
endif(ENABLE_GAME)

if(ENABLE_POT_UPDATE_TARGET)
Expand Down
1 change: 1 addition & 0 deletions INSTALL
Expand Up @@ -38,6 +38,7 @@ These libraries are optional dependencies that enable additional features:

libdbus-1 (used for desktop notifications)
libpng (save images as pngs, otherwise only bmp is possible)
readline (for command history and history expansion in the lua console)

As a temporary compatibility measure, it is possible to build the game without requiring boost filesystem or boost locale, using libintl for translations instead. The cost is that wesnoth won't support UTF-8 in filepaths on all platforms.
For this, target filesystem.cpp and gettext.cpp instead of filesystem_boost.cpp and gettext_boost.cpp. For scons/cmake the "boost filesystem" option toggles these.
Expand Down
5 changes: 5 additions & 0 deletions SConstruct
Expand Up @@ -106,6 +106,7 @@ opts.AddVariables(
BoolVariable("fast", "Make scons faster at cost of less precise dependency tracking.", False),
BoolVariable("lockfile", "Create a lockfile to prevent multiple instances of scons from being run at the same time on this working copy.", False),
BoolVariable("OS_ENV", "Forward the entire OS environment to scons", False),
BoolVariable("readline", "Clear to disable readline support in lua console", False),
BoolVariable("sdl2", "Build with SDL2 support (experimental!)", False)
)

Expand Down Expand Up @@ -414,6 +415,10 @@ if env["prereqs"]:
if env["png"]:
client_env.Append(CPPDEFINES = ["HAVE_LIBPNG"])

env["readline"] = env["readline"] and conf.CheckLib("readline")
if env["readline"]:
client_env.Append(CPPDEFINES = ["HAVE_READLINE"])

if env["forum_user_handler"]:
flags = env.ParseFlags("!mysql_config --libs --cflags")
try: # Some versions of mysql_config add -DNDEBUG but we don't want it
Expand Down

0 comments on commit ba46cc8

Please sign in to comment.