zorba-coders team mailing list archive
-
zorba-coders team
-
Mailing list archive
-
Message #03400
[Merge] lp:~zorba-coders/zorba/debugger_client_extras into lp:zorba
Gabriel Petrovay has proposed merging lp:~zorba-coders/zorba/debugger_client_extras into lp:zorba.
Requested reviews:
Gabriel Petrovay (gabipetrovay)
David Graf (davidagraf)
For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/debugger_client_extras/+merge/87817
Fixed libedit search on mac issue.
Added history support from libedit for UNIX platforms.
--
https://code.launchpad.net/~zorba-coders/zorba/debugger_client_extras/+merge/87817
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'bin/CMakeLists.txt'
--- bin/CMakeLists.txt 2012-01-03 12:10:06 +0000
+++ bin/CMakeLists.txt 2012-01-06 21:21:33 +0000
@@ -21,10 +21,10 @@
IF (LIBEDIT_FOUND)
INCLUDE_DIRECTORIES (${LIBEDIT_INCLUDE_DIRS})
SET (LIBEDIT_LIBS ${LIBEDIT_LIBRARIES})
+ SET (ZORBA_HAVE_LIBEDIT_H ${LIBEDIT_FOUND})
ENDIF (LIBEDIT_FOUND)
ENDIF (NOT WIN32)
- CHECK_INCLUDE_FILES ("editline/readline.h" ZORBA_HAVE_READLINE_H)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/debugger/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/debugger/config.h)
MESSAGE(STATUS "configured ${CMAKE_CURRENT_SOURCE_DIR}/debugger/config.h.cmake --> ${CMAKE_CURRENT_BINARY_DIR}/debugger/config.h")
INCLUDE_DIRECTORIES (BEFORE ${CMAKE_CURRENT_BINARY_DIR}/debugger)
=== modified file 'bin/debugger/command_prompt.cpp'
--- bin/debugger/command_prompt.cpp 2011-12-19 19:16:32 +0000
+++ bin/debugger/command_prompt.cpp 2012-01-06 21:21:33 +0000
@@ -20,19 +20,40 @@
#include <map>
#include <iostream>
-#include "config.h"
-
-#ifdef ZORBA_HAVE_READLINE_H
-# include <editline/readline.h>
-#endif
-
#include "command.h"
namespace zorba { namespace debugger {
+#ifdef ZORBA_HAVE_LIBEDIT_H
+const char*
+prompt(EditLine* aEl) {
+ return "(xqdb) ";
+}
+#endif
+
+CommandPrompt::CommandPrompt()
+{
+#ifdef ZORBA_HAVE_LIBEDIT_H
+ theEditLine = el_init("xqdb", stdin, stdout, stderr);
+ theHistory = history_init();
+ HistEvent lHistoryEvent;
+ history(theHistory, &lHistoryEvent, H_SETSIZE, 100);
+
+ el_set(theEditLine, EL_PROMPT, prompt);
+
+ el_set(theEditLine, EL_HIST, history, theHistory);
+ el_set(theEditLine, EL_EDITOR, "emacs");
+#endif
+}
+
CommandPrompt::~CommandPrompt()
{
+#ifdef ZORBA_HAVE_LIBEDIT_H
+ history_end(theHistory);
+ el_end(theEditLine);
+#endif
+
std::map<std::string, UntypedCommand*>::iterator lIter;
for (lIter = theCommands.begin(); lIter != theCommands.end(); ++lIter) {
delete lIter->second;
@@ -74,8 +95,11 @@
CommandPrompt::execute()
{
for (;;) {
-#ifdef ZORBA_HAVE_READLINE_H
- std::string lCommandLine(readline("(xqdb) "));
+#ifdef ZORBA_HAVE_LIBEDIT_H
+ const char* lBuf;
+ int lCharsRead = -1;
+ lBuf = el_gets(theEditLine, &lCharsRead);
+ std::string lCommandLine(lBuf, lCharsRead - 1);
#else
std::cout << "(xqdb) ";
std::string lCommandLine;
@@ -94,6 +118,12 @@
continue;
}
}
+#ifdef ZORBA_HAVE_LIBEDIT_H
+ else {
+ HistEvent lHistoryEvent;
+ history(theHistory, &lHistoryEvent, H_ENTER, lCommandLine.c_str());
+ }
+#endif
theLastArgs = lArgs;
UntypedCommand* lCommand = NULL;
=== modified file 'bin/debugger/command_prompt.h'
--- bin/debugger/command_prompt.h 2011-11-16 09:32:47 +0000
+++ bin/debugger/command_prompt.h 2012-01-06 21:21:33 +0000
@@ -21,6 +21,12 @@
#include <map>
#include <vector>
+#include "config.h"
+
+#ifdef ZORBA_HAVE_LIBEDIT_H
+# include <histedit.h>
+#endif
+
namespace zorba { namespace debugger {
@@ -29,6 +35,7 @@
class CommandPrompt
{
public:
+ CommandPrompt();
~CommandPrompt();
public:
@@ -51,6 +58,11 @@
private:
std::map<std::string, UntypedCommand*> theCommands;
std::vector<std::string> theLastArgs;
+
+#ifdef ZORBA_HAVE_LIBEDIT_H
+ EditLine* theEditLine;
+ History* theHistory;
+#endif
};
=== modified file 'bin/debugger/config.h.cmake'
--- bin/debugger/config.h.cmake 2011-12-19 19:16:32 +0000
+++ bin/debugger/config.h.cmake 2012-01-06 21:21:33 +0000
@@ -19,6 +19,6 @@
#ifndef ZORBA_DEBUGGER_CONFIG_H
#define ZORBA_DEBUGGER_CONFIG_H
-#cmakedefine ZORBA_HAVE_READLINE_H
+#cmakedefine ZORBA_HAVE_LIBEDIT_H
#endif /* ZORBA_DEBUGGER_CONFIG_H */
Follow ups