Open alvinhochun opened 2 years ago
Maybe we can bring in PDCursesMod, which has a Win32 API and VT implementation, and doesn't have any dependencies.
For a no extra dependencies options: wineditline
For a no extra dependencies options: wineditline
winditline is not compatible with libedit's api https://github.com/llvm/llvm-project/blob/7207373e1eb0dd419b4e13a5e2d0ca146ef9544e/lldb/source/Host/common/Editline.cpp#L83-L91
PDCursesMod not support define_key
which lldb needed. https://github.com/llvm/llvm-project/issues/51296
gui may be work with ncurses
ncurses seems pretty heavyweight, so I'm not sure if @mstorsjo would be ok with that.
I tried to compile the gui interface using the PDCursesMod library via https://github.com/Bill-Gray/PDCursesMod/issues/214#issuecomment-926634755 . The interface looks ok but the Alt+Enter
shortcut does not work, that shortcut key is used to switch full screen under windows. PDC_WIDE
and PDC_FORCE_UTF8
is my custom curses build configure.I think lldb-vscode is better than gui.
diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 0151255631bf..44d9a78d3923 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -14,6 +14,8 @@
#include <ncurses/curses.h>
#include <ncurses/panel.h>
#else
+#define PDC_WIDE 1
+#define PDC_FORCE_UTF8 1
#include <curses.h>
#include <panel.h>
#endif
@@ -91,8 +93,13 @@ using llvm::StringRef;
#define KEY_ESCAPE 27
#define KEY_DELETE 127
+#ifdef __PDCURSES__
+#define KEY_SHIFT_TAB KEY_BTAB
+#define KEY_ALT_ENTER ALT_ENTER
+#else /* for ncurses */
#define KEY_SHIFT_TAB (KEY_MAX + 1)
#define KEY_ALT_ENTER (KEY_MAX + 2)
+#endif
namespace curses {
class Menu;
@@ -7699,8 +7706,10 @@ void IOHandlerCursesGUI::Activate() {
init_pair(18, COLOR_MAGENTA, COLOR_WHITE);
static_assert(LastColorPairIndex == 18, "Color indexes do not match.");
+#ifndef __PDCURSES__
define_key("\033[Z", KEY_SHIFT_TAB);
define_key("\033\015", KEY_ALT_ENTER);
+#endif
}
}
Just as a side note: CMake is using now https://gitlab.kitware.com/cmake/cmake/-/tree/master/Utilities/cmpdcurses for ccmake
on Windows.
windows terminal can config { "command": "null", "keys": "alt+enter" }
to avoid Alt+Enter
conflicting. It looks like all functions are working fine now.
Just a heads up: This went from getting tab completion to work (which requires libedit + a curses implementation) to getting LLDB TUI mode to work 😅 But since @SquallATF already got that working, can you also test out libedit?
found some problems, form from Target
and Process
submenu not work will.
lldb on linux
Then I tested PDCurses and ncurses, the results of PDCurses and PDCursesMod are the same, and ncurses can display the form normally, but Shift+Tab
and Alt+Enter
shortcuts and backspace
does not work
It seems LLDB needs libedit for tab completion, which in turn also depends on curses. This is probably hard to integrate on Windows. Had anyone tried? Would it be easier now that Windows have opt-in support for VT sequences?