[Lldb-commits] [lldb] 292f013 - [LLDB][GUI] Handle extra navigation keys in forms

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 23 22:43:04 PDT 2021


Author: Omar Emara
Date: 2021-08-23T22:42:57-07:00
New Revision: 292f013395f2e2eafd803b787a33eddfc5cc4918

URL: https://github.com/llvm/llvm-project/commit/292f013395f2e2eafd803b787a33eddfc5cc4918
DIFF: https://github.com/llvm/llvm-project/commit/292f013395f2e2eafd803b787a33eddfc5cc4918.diff

LOG: [LLDB][GUI] Handle extra navigation keys in forms

This patch handles the up and down keys if they weren't handled by the
selected field. Moreover, it makes sure the form always absorb the key
to take full control until the form is canceled or submitted.

Differential Revision: https://reviews.llvm.org/D108414

Added: 
    

Modified: 
    lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index ca06a332e4ed..ef4f5c3d35f6 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -2801,6 +2801,8 @@ class FormWindowDelegate : public WindowDelegate {
     }
   }
 
+  // Always return eKeyHandled to absorb all events since forms are always
+  // added as pop-ups that should take full control until canceled or submitted.
   HandleCharResult WindowDelegateHandleChar(Window &window, int key) override {
     switch (key) {
     case '\r':
@@ -2815,9 +2817,11 @@ class FormWindowDelegate : public WindowDelegate {
       ExecuteAction(window, 0);
       return eKeyHandled;
     case '\t':
-      return SelectNext(key);
+      SelectNext(key);
+      return eKeyHandled;
     case KEY_SHIFT_TAB:
-      return SelectPrevious(key);
+      SelectPrevious(key);
+      return eKeyHandled;
     case KEY_ESCAPE:
       window.GetParent()->RemoveSubWindow(&window);
       return eKeyHandled;
@@ -2829,10 +2833,24 @@ class FormWindowDelegate : public WindowDelegate {
     // to that field.
     if (m_selection_type == SelectionType::Field) {
       FieldDelegate *field = m_delegate_sp->GetField(m_selection_index);
-      return field->FieldDelegateHandleChar(key);
+      if (field->FieldDelegateHandleChar(key) == eKeyHandled)
+        return eKeyHandled;
     }
 
-    return eKeyNotHandled;
+    // If the key wasn't handled by the possibly selected field, handle some
+    // extra keys for navigation.
+    switch (key) {
+    case KEY_DOWN:
+      SelectNext(key);
+      return eKeyHandled;
+    case KEY_UP:
+      SelectPrevious(key);
+      return eKeyHandled;
+    default:
+      break;
+    }
+
+    return eKeyHandled;
   }
 
 protected:


        


More information about the lldb-commits mailing list