[Lldb-commits] [PATCH] D108331: [LLDB][GUI] Handle return key for compound fields
Omar Emara via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 18 14:45:43 PDT 2021
OmarEmaraDev created this revision.
OmarEmaraDev added a reviewer: clayborg.
Herald added a reviewer: teemperor.
OmarEmaraDev requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
This patch handles the return key for compound fields like lists and
mapping fields. The return key, if not handled by the field will select
the next primary element, skipping secondary elements like remove
buttons and the like.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D108331
Files:
lldb/source/Core/IOHandlerCursesGUI.cpp
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===================================================================
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -1816,6 +1816,31 @@
return eKeyHandled;
}
+ // If the last element of the field is selected and it didn't handle the key.
+ // Select the next field or new button if the selected field is the last one.
+ HandleCharResult SelectNextInList(int key) {
+ assert(m_selection_type == SelectionType::Field);
+
+ FieldDelegate &field = m_fields[m_selection_index];
+ if (field.FieldDelegateHandleChar(key) == eKeyHandled)
+ return eKeyHandled;
+
+ if (!field.FieldDelegateOnLastOrOnlyElement())
+ return eKeyNotHandled;
+
+ field.FieldDelegateExitCallback();
+
+ if (m_selection_index == GetNumberOfFields() - 1) {
+ m_selection_type = SelectionType::NewButton;
+ return eKeyHandled;
+ }
+
+ m_selection_index++;
+ FieldDelegate &next_field = m_fields[m_selection_index];
+ next_field.FieldDelegateSelectFirstElement();
+ return eKeyHandled;
+ }
+
HandleCharResult FieldDelegateHandleChar(int key) override {
switch (key) {
case '\r':
@@ -1828,16 +1853,14 @@
case SelectionType::RemoveButton:
RemoveField();
return eKeyHandled;
- default:
- break;
+ case SelectionType::Field:
+ return SelectNextInList(key);
}
break;
case '\t':
- SelectNext(key);
- return eKeyHandled;
+ return SelectNext(key);
case KEY_SHIFT_TAB:
- SelectPrevious(key);
- return eKeyHandled;
+ return SelectPrevious(key);
default:
break;
}
@@ -1984,14 +2007,34 @@
return eKeyHandled;
}
+ // If the value field is selected, pass the key to it. If the key field is
+ // selected, its last element is selected, and it didn't handle the key, then
+ // select its corresponding value field.
+ HandleCharResult SelectNextField(int key) {
+ if (m_selection_type == SelectionType::Value) {
+ return m_value_field.FieldDelegateHandleChar(key);
+ }
+
+ if (m_key_field.FieldDelegateHandleChar(key) == eKeyHandled)
+ return eKeyHandled;
+
+ if (!m_key_field.FieldDelegateOnLastOrOnlyElement())
+ return eKeyNotHandled;
+
+ m_key_field.FieldDelegateExitCallback();
+ m_selection_type = SelectionType::Value;
+ m_value_field.FieldDelegateSelectFirstElement();
+ return eKeyHandled;
+ }
+
HandleCharResult FieldDelegateHandleChar(int key) override {
switch (key) {
+ case KEY_RETURN:
+ return SelectNextField(key);
case '\t':
- SelectNext(key);
- return eKeyHandled;
+ return SelectNext(key);
case KEY_SHIFT_TAB:
- SelectPrevious(key);
- return eKeyHandled;
+ return SelectPrevious(key);
default:
break;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108331.367327.patch
Type: text/x-patch
Size: 2886 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210818/8d381691/attachment-0001.bin>
More information about the lldb-commits
mailing list