Merge lp:~zorba-coders/zorba/debugger_client_extras into lp:zorba

Proposed by Gabriel Petrovay
Status: Merged
Approved by: Gabriel Petrovay
Approved revision: 10608
Merged at revision: 10609
Proposed branch: lp:~zorba-coders/zorba/debugger_client_extras
Merge into: lp:zorba
Diff against target: 142 lines (+52/-10)
4 files modified
bin/CMakeLists.txt (+1/-1)
bin/debugger/command_prompt.cpp (+38/-8)
bin/debugger/command_prompt.h (+12/-0)
bin/debugger/config.h.cmake (+1/-1)
To merge this branch: bzr merge lp:~zorba-coders/zorba/debugger_client_extras
Reviewer Review Type Date Requested Status
David Graf (community) Approve
Gabriel Petrovay (community) Approve
Review via email: mp+87817@code.launchpad.net

Commit message

Fixed libedit search on mac issue.
Added history support from libedit for UNIX platforms.

Description of the change

Fixed libedit search on mac issue.
Added history support from libedit for UNIX platforms.

To post a comment you must log in.
Revision history for this message
Gabriel Petrovay (gabipetrovay) :
review: Approve
Revision history for this message
David Graf (davidagraf) wrote :

It works. Cool!

review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job debugger_client_extras-2012-01-09T15-36-08.398Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/CMakeLists.txt'
2--- bin/CMakeLists.txt 2012-01-03 12:10:06 +0000
3+++ bin/CMakeLists.txt 2012-01-06 21:21:33 +0000
4@@ -21,10 +21,10 @@
5 IF (LIBEDIT_FOUND)
6 INCLUDE_DIRECTORIES (${LIBEDIT_INCLUDE_DIRS})
7 SET (LIBEDIT_LIBS ${LIBEDIT_LIBRARIES})
8+ SET (ZORBA_HAVE_LIBEDIT_H ${LIBEDIT_FOUND})
9 ENDIF (LIBEDIT_FOUND)
10 ENDIF (NOT WIN32)
11
12- CHECK_INCLUDE_FILES ("editline/readline.h" ZORBA_HAVE_READLINE_H)
13 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/debugger/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/debugger/config.h)
14 MESSAGE(STATUS "configured ${CMAKE_CURRENT_SOURCE_DIR}/debugger/config.h.cmake --> ${CMAKE_CURRENT_BINARY_DIR}/debugger/config.h")
15 INCLUDE_DIRECTORIES (BEFORE ${CMAKE_CURRENT_BINARY_DIR}/debugger)
16
17=== modified file 'bin/debugger/command_prompt.cpp'
18--- bin/debugger/command_prompt.cpp 2011-12-19 19:16:32 +0000
19+++ bin/debugger/command_prompt.cpp 2012-01-06 21:21:33 +0000
20@@ -20,19 +20,40 @@
21 #include <map>
22 #include <iostream>
23
24-#include "config.h"
25-
26-#ifdef ZORBA_HAVE_READLINE_H
27-# include <editline/readline.h>
28-#endif
29-
30 #include "command.h"
31
32
33 namespace zorba { namespace debugger {
34
35+#ifdef ZORBA_HAVE_LIBEDIT_H
36+const char*
37+prompt(EditLine* aEl) {
38+ return "(xqdb) ";
39+}
40+#endif
41+
42+CommandPrompt::CommandPrompt()
43+{
44+#ifdef ZORBA_HAVE_LIBEDIT_H
45+ theEditLine = el_init("xqdb", stdin, stdout, stderr);
46+ theHistory = history_init();
47+ HistEvent lHistoryEvent;
48+ history(theHistory, &lHistoryEvent, H_SETSIZE, 100);
49+
50+ el_set(theEditLine, EL_PROMPT, prompt);
51+
52+ el_set(theEditLine, EL_HIST, history, theHistory);
53+ el_set(theEditLine, EL_EDITOR, "emacs");
54+#endif
55+}
56+
57 CommandPrompt::~CommandPrompt()
58 {
59+#ifdef ZORBA_HAVE_LIBEDIT_H
60+ history_end(theHistory);
61+ el_end(theEditLine);
62+#endif
63+
64 std::map<std::string, UntypedCommand*>::iterator lIter;
65 for (lIter = theCommands.begin(); lIter != theCommands.end(); ++lIter) {
66 delete lIter->second;
67@@ -74,8 +95,11 @@
68 CommandPrompt::execute()
69 {
70 for (;;) {
71-#ifdef ZORBA_HAVE_READLINE_H
72- std::string lCommandLine(readline("(xqdb) "));
73+#ifdef ZORBA_HAVE_LIBEDIT_H
74+ const char* lBuf;
75+ int lCharsRead = -1;
76+ lBuf = el_gets(theEditLine, &lCharsRead);
77+ std::string lCommandLine(lBuf, lCharsRead - 1);
78 #else
79 std::cout << "(xqdb) ";
80 std::string lCommandLine;
81@@ -94,6 +118,12 @@
82 continue;
83 }
84 }
85+#ifdef ZORBA_HAVE_LIBEDIT_H
86+ else {
87+ HistEvent lHistoryEvent;
88+ history(theHistory, &lHistoryEvent, H_ENTER, lCommandLine.c_str());
89+ }
90+#endif
91 theLastArgs = lArgs;
92
93 UntypedCommand* lCommand = NULL;
94
95=== modified file 'bin/debugger/command_prompt.h'
96--- bin/debugger/command_prompt.h 2011-11-16 09:32:47 +0000
97+++ bin/debugger/command_prompt.h 2012-01-06 21:21:33 +0000
98@@ -21,6 +21,12 @@
99 #include <map>
100 #include <vector>
101
102+#include "config.h"
103+
104+#ifdef ZORBA_HAVE_LIBEDIT_H
105+# include <histedit.h>
106+#endif
107+
108
109 namespace zorba { namespace debugger {
110
111@@ -29,6 +35,7 @@
112 class CommandPrompt
113 {
114 public:
115+ CommandPrompt();
116 ~CommandPrompt();
117
118 public:
119@@ -51,6 +58,11 @@
120 private:
121 std::map<std::string, UntypedCommand*> theCommands;
122 std::vector<std::string> theLastArgs;
123+
124+#ifdef ZORBA_HAVE_LIBEDIT_H
125+ EditLine* theEditLine;
126+ History* theHistory;
127+#endif
128 };
129
130
131
132=== modified file 'bin/debugger/config.h.cmake'
133--- bin/debugger/config.h.cmake 2011-12-19 19:16:32 +0000
134+++ bin/debugger/config.h.cmake 2012-01-06 21:21:33 +0000
135@@ -19,6 +19,6 @@
136 #ifndef ZORBA_DEBUGGER_CONFIG_H
137 #define ZORBA_DEBUGGER_CONFIG_H
138
139-#cmakedefine ZORBA_HAVE_READLINE_H
140+#cmakedefine ZORBA_HAVE_LIBEDIT_H
141
142 #endif /* ZORBA_DEBUGGER_CONFIG_H */

Subscribers

People subscribed via source and target branches