Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tab completion in LLDB command line #286

Open
alvinhochun opened this issue Jun 5, 2022 · 9 comments
Open

Tab completion in LLDB command line #286

alvinhochun opened this issue Jun 5, 2022 · 9 comments

Comments

@alvinhochun
Copy link
Contributor

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?

@longnguyen2004
Copy link
Contributor

Maybe we can bring in PDCursesMod, which has a Win32 API and VT implementation, and doesn't have any dependencies.

@longnguyen2004
Copy link
Contributor

For a no extra dependencies options: wineditline

@SquallATF
Copy link

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. llvm/llvm-project#51296
gui may be work with ncurses

@longnguyen2004
Copy link
Contributor

ncurses seems pretty heavyweight, so I'm not sure if @mstorsjo would be ok with that.

@SquallATF
Copy link

SquallATF commented Jun 16, 2022

I tried to compile the gui interface using the PDCursesMod library via Bill-Gray/PDCursesMod#214 (comment) . 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.
image

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
   }
 }
 

@cristianadam
Copy link

Just as a side note: CMake is using now https://gitlab.kitware.com/cmake/cmake/-/tree/master/Utilities/cmpdcurses for ccmake on Windows.

@SquallATF
Copy link

windows terminal can config { "command": "null", "keys": "alt+enter" } to avoid Alt+Enter conflicting. It looks like all functions are working fine now.

@longnguyen2004
Copy link
Contributor

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?

@SquallATF
Copy link

SquallATF commented Jun 16, 2022

found some problems, form from Target and Process submenu not work will.
image
lldb on linux
image
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
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants