[all-commits] [llvm/llvm-project] 29cc50: [LLDB][GUI] Add initial forms support
Omar Emara via All-commits
all-commits at lists.llvm.org
Wed Jul 7 08:18:20 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 29cc50e17a6800ca75cd23ed85ae1ddf3e3dcc14
https://github.com/llvm/llvm-project/commit/29cc50e17a6800ca75cd23ed85ae1ddf3e3dcc14
Author: Omar Emara <mail at OmarEmara.dev>
Date: 2021-07-07 (Wed, 07 Jul 2021)
Changed paths:
M lldb/source/Core/IOHandlerCursesGUI.cpp
Log Message:
-----------
[LLDB][GUI] Add initial forms support
This patch adds initial support for forms for the LLDB GUI. The currently
supported form elements are Text fields, Integer fields, Boolean fields, Choices
fields, File fields, Directory fields, and List fields.
A form can be created by subclassing FormDelegate. In the constructor, field
factory methods can be used to add new fields, storing the returned pointer in a
member variable. One or more actions can be added using the AddAction method.
The method takes a function with an interface void(Window &). This function will
be executed whenever the user executes the action.
Example form definition:
```lang=cpp
class TestFormDelegate : public FormDelegate {
public:
TestFormDelegate() {
m_text_field = AddTextField("Text", "The big brown fox.");
m_file_field = AddFileField("File", "/tmp/a");
m_directory_field = AddDirectoryField("Directory", "/tmp/");
m_integer_field = AddIntegerField("Number", 5);
std::vector<std::string> choices;
choices.push_back(std::string("Choice 1"));
choices.push_back(std::string("Choice 2"));
choices.push_back(std::string("Choice 3"));
choices.push_back(std::string("Choice 4"));
choices.push_back(std::string("Choice 5"));
m_choices_field = AddChoicesField("Choices", 3, choices);
m_bool_field = AddBooleanField("Boolean", true);
TextFieldDelegate default_field =
TextFieldDelegate("Text", "The big brown fox.");
m_text_list_field = AddListField("Text List", default_field);
AddAction("Submit", [this](Window &window) { Submit(window); });
}
void Submit(Window &window) { SetError("An example error."); }
protected:
TextFieldDelegate *m_text_field;
FileFieldDelegate *m_file_field;
DirectoryFieldDelegate *m_directory_field;
IntegerFieldDelegate *m_integer_field;
BooleanFieldDelegate *m_bool_field;
ChoicesFieldDelegate *m_choices_field;
ListFieldDelegate<TextFieldDelegate> *m_text_list_field;
};
```
Reviewed By: clayborg
Differential Revision: https://reviews.llvm.org/D104395
More information about the All-commits
mailing list