[Lldb-commits] [lldb] 4d3d182 - Revert "[LLDB][GUI] Refactor form drawing using subsurfaces"
Jason Molenda via lldb-commits
lldb-commits at lists.llvm.org
Thu Aug 5 19:28:50 PDT 2021
Author: Jason Molenda
Date: 2021-08-05T19:27:55-07:00
New Revision: 4d3d182c1dcb99ddcce7d077060d87111cb8dbfa
URL: https://github.com/llvm/llvm-project/commit/4d3d182c1dcb99ddcce7d077060d87111cb8dbfa
DIFF: https://github.com/llvm/llvm-project/commit/4d3d182c1dcb99ddcce7d077060d87111cb8dbfa.diff
LOG: Revert "[LLDB][GUI] Refactor form drawing using subsurfaces"
Temporarily revert this patch to unbreak the bots/builds
until we can understand what was intended; is_pad() call
isn't defined.
This reverts commit 2b89f40a411cb9717232df61371b24d73ae84cb8.
Added:
Modified:
lldb/source/Core/IOHandlerCursesGUI.cpp
Removed:
################################################################################
diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp
index 5d3384c18b315..010f9300aa2e5 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -352,19 +352,6 @@ class Surface {
operator WINDOW *() { return m_window; }
- Surface SubSurface(Rect bounds) {
- Surface subSurface;
- if (is_pad(m_window))
- subSurface.m_window =
- ::subpad(m_window, bounds.size.height, bounds.size.width,
- bounds.origin.y, bounds.origin.x);
- else
- subSurface.m_window =
- ::derwin(m_window, bounds.size.height, bounds.size.width,
- bounds.origin.y, bounds.origin.x);
- return subSurface;
- }
-
// Copy a region of the surface to another surface.
void CopyToSurface(Surface &target, Point source_origin, Point target_origin,
Size size) {
@@ -1038,7 +1025,7 @@ class FieldDelegate {
// Draw the field in the given subpad surface. The surface have a height that
// is equal to the height returned by FieldDelegateGetHeight(). If the field
// is selected in the form window, then is_selected will be true.
- virtual void FieldDelegateDraw(Surface &surface, bool is_selected) = 0;
+ virtual void FieldDelegateDraw(SubPad &surface, bool is_selected) = 0;
// Handle the key that wasn't handled by the form window or a container field.
virtual HandleCharResult FieldDelegateHandleChar(int key) {
@@ -1125,7 +1112,7 @@ class TextFieldDelegate : public FieldDelegate {
int GetContentLength() { return m_content.length(); }
- void DrawContent(Surface &surface, bool is_selected) {
+ void DrawContent(SubPad &surface, bool is_selected) {
surface.MoveCursor(0, 0);
const char *text = m_content.c_str() + m_first_visibile_char;
surface.PutCString(text, surface.GetWidth());
@@ -1144,17 +1131,17 @@ class TextFieldDelegate : public FieldDelegate {
surface.AttributeOff(A_REVERSE);
}
- void DrawField(Surface &surface, bool is_selected) {
+ void DrawField(SubPad &surface, bool is_selected) {
surface.TitledBox(m_label.c_str());
Rect content_bounds = surface.GetFrame();
content_bounds.Inset(1, 1);
- Surface content_surface = surface.SubSurface(content_bounds);
+ SubPad content_surface = SubPad(surface, content_bounds);
DrawContent(content_surface, is_selected);
}
- void DrawError(Surface &surface) {
+ void DrawError(SubPad &surface) {
if (!FieldDelegateHasError())
return;
surface.MoveCursor(0, 0);
@@ -1165,12 +1152,12 @@ class TextFieldDelegate : public FieldDelegate {
surface.AttributeOff(COLOR_PAIR(RedOnBlack));
}
- void FieldDelegateDraw(Surface &surface, bool is_selected) override {
+ void FieldDelegateDraw(SubPad &surface, bool is_selected) override {
Rect frame = surface.GetFrame();
Rect field_bounds, error_bounds;
frame.HorizontalSplit(GetFieldHeight(), field_bounds, error_bounds);
- Surface field_surface = surface.SubSurface(field_bounds);
- Surface error_surface = surface.SubSurface(error_bounds);
+ SubPad field_surface = SubPad(surface, field_bounds);
+ SubPad error_surface = SubPad(surface, error_bounds);
DrawField(field_surface, is_selected);
DrawError(error_surface);
@@ -1419,7 +1406,7 @@ class BooleanFieldDelegate : public FieldDelegate {
// Boolean fields are have a single line.
int FieldDelegateGetHeight() override { return 1; }
- void FieldDelegateDraw(Surface &surface, bool is_selected) override {
+ void FieldDelegateDraw(SubPad &surface, bool is_selected) override {
surface.MoveCursor(0, 0);
surface.PutChar('[');
if (is_selected)
@@ -1499,7 +1486,7 @@ class ChoicesFieldDelegate : public FieldDelegate {
return std::min(index, GetNumberOfChoices()) - 1;
}
- void DrawContent(Surface &surface, bool is_selected) {
+ void DrawContent(SubPad &surface, bool is_selected) {
int choices_to_draw = GetLastVisibleChoice() - m_first_visibile_choice + 1;
for (int i = 0; i < choices_to_draw; i++) {
surface.MoveCursor(0, i);
@@ -1515,14 +1502,14 @@ class ChoicesFieldDelegate : public FieldDelegate {
}
}
- void FieldDelegateDraw(Surface &surface, bool is_selected) override {
+ void FieldDelegateDraw(SubPad &surface, bool is_selected) override {
UpdateScrolling();
surface.TitledBox(m_label.c_str());
Rect content_bounds = surface.GetFrame();
content_bounds.Inset(1, 1);
- Surface content_surface = surface.SubSurface(content_bounds);
+ SubPad content_surface = SubPad(surface, content_bounds);
DrawContent(content_surface, is_selected);
}
@@ -1697,7 +1684,7 @@ template <class T> class ListFieldDelegate : public FieldDelegate {
return context;
}
- void DrawRemoveButton(Surface &surface, int highlight) {
+ void DrawRemoveButton(SubPad &surface, int highlight) {
surface.MoveCursor(1, surface.GetHeight() / 2);
if (highlight)
surface.AttributeOn(A_REVERSE);
@@ -1706,7 +1693,7 @@ template <class T> class ListFieldDelegate : public FieldDelegate {
surface.AttributeOff(A_REVERSE);
}
- void DrawFields(Surface &surface, bool is_selected) {
+ void DrawFields(SubPad &surface, bool is_selected) {
int line = 0;
int width = surface.GetWidth();
for (int i = 0; i < GetNumberOfFields(); i++) {
@@ -1715,8 +1702,8 @@ template <class T> class ListFieldDelegate : public FieldDelegate {
Rect field_bounds, remove_button_bounds;
bounds.VerticalSplit(bounds.size.width - sizeof(" [Remove]"),
field_bounds, remove_button_bounds);
- Surface field_surface = surface.SubSurface(field_bounds);
- Surface remove_button_surface = surface.SubSurface(remove_button_bounds);
+ SubPad field_surface = SubPad(surface, field_bounds);
+ SubPad remove_button_surface = SubPad(surface, remove_button_bounds);
bool is_element_selected = m_selection_index == i && is_selected;
bool is_field_selected =
@@ -1731,7 +1718,7 @@ template <class T> class ListFieldDelegate : public FieldDelegate {
}
}
- void DrawNewButton(Surface &surface, bool is_selected) {
+ void DrawNewButton(SubPad &surface, bool is_selected) {
const char *button_text = "[New]";
int x = (surface.GetWidth() - sizeof(button_text) - 1) / 2;
surface.MoveCursor(x, 0);
@@ -1744,7 +1731,7 @@ template <class T> class ListFieldDelegate : public FieldDelegate {
surface.AttributeOff(A_REVERSE);
}
- void FieldDelegateDraw(Surface &surface, bool is_selected) override {
+ void FieldDelegateDraw(SubPad &surface, bool is_selected) override {
surface.TitledBox(m_label.c_str());
Rect content_bounds = surface.GetFrame();
@@ -1752,8 +1739,8 @@ template <class T> class ListFieldDelegate : public FieldDelegate {
Rect fields_bounds, new_button_bounds;
content_bounds.HorizontalSplit(content_bounds.size.height - 1,
fields_bounds, new_button_bounds);
- Surface fields_surface = surface.SubSurface(fields_bounds);
- Surface new_button_surface = surface.SubSurface(new_button_bounds);
+ SubPad fields_surface = SubPad(surface, fields_bounds);
+ SubPad new_button_surface = SubPad(surface, new_button_bounds);
DrawFields(fields_surface, is_selected);
DrawNewButton(new_button_surface, is_selected);
@@ -1949,12 +1936,12 @@ class MappingFieldDelegate : public FieldDelegate {
m_value_field.FieldDelegateGetHeight());
}
- void DrawArrow(Surface &surface) {
+ void DrawArrow(SubPad &surface) {
surface.MoveCursor(0, 1);
surface.PutChar(ACS_RARROW);
}
- void FieldDelegateDraw(Surface &surface, bool is_selected) override {
+ void FieldDelegateDraw(SubPad &surface, bool is_selected) override {
Rect bounds = surface.GetFrame();
Rect key_field_bounds, arrow_and_value_field_bounds;
bounds.VerticalSplit(bounds.size.width / 2, key_field_bounds,
@@ -1963,9 +1950,9 @@ class MappingFieldDelegate : public FieldDelegate {
arrow_and_value_field_bounds.VerticalSplit(1, arrow_bounds,
value_field_bounds);
- Surface key_field_surface = surface.SubSurface(key_field_bounds);
- Surface arrow_surface = surface.SubSurface(arrow_bounds);
- Surface value_field_surface = surface.SubSurface(value_field_bounds);
+ SubPad key_field_surface = SubPad(surface, key_field_bounds);
+ SubPad arrow_surface = SubPad(surface, arrow_bounds);
+ SubPad value_field_surface = SubPad(surface, value_field_bounds);
bool key_is_selected =
m_selection_type == SelectionType::Key && is_selected;
@@ -2101,7 +2088,7 @@ class FormAction {
}
// Draw a centered [Label].
- void Draw(Surface &surface, bool is_selected) {
+ void Draw(SubPad &surface, bool is_selected) {
int x = (surface.GetWidth() - m_label.length()) / 2;
surface.MoveCursor(x, 0);
if (is_selected)
@@ -2370,7 +2357,7 @@ class FormWindowDelegate : public WindowDelegate {
return context;
}
- void UpdateScrolling(Surface &surface) {
+ void UpdateScrolling(DerivedWindow &surface) {
ScrollContext context = GetScrollContext();
int content_height = GetContentHeight();
int surface_height = surface.GetHeight();
@@ -2394,7 +2381,7 @@ class FormWindowDelegate : public WindowDelegate {
}
}
- void DrawError(Surface &surface) {
+ void DrawError(SubPad &surface) {
if (!m_delegate_sp->HasError())
return;
surface.MoveCursor(0, 0);
@@ -2408,7 +2395,7 @@ class FormWindowDelegate : public WindowDelegate {
surface.HorizontalLine(surface.GetWidth());
}
- void DrawFields(Surface &surface) {
+ void DrawFields(SubPad &surface) {
int line = 0;
int width = surface.GetWidth();
bool a_field_is_selected = m_selection_type == SelectionType::Field;
@@ -2419,13 +2406,13 @@ class FormWindowDelegate : public WindowDelegate {
bool is_field_selected = a_field_is_selected && m_selection_index == i;
int height = field->FieldDelegateGetHeight();
Rect bounds = Rect(Point(0, line), Size(width, height));
- Surface field_surface = surface.SubSurface(bounds);
+ SubPad field_surface = SubPad(surface, bounds);
field->FieldDelegateDraw(field_surface, is_field_selected);
line += height;
}
}
- void DrawActions(Surface &surface) {
+ void DrawActions(SubPad &surface) {
int number_of_actions = m_delegate_sp->GetNumberOfActions();
int width = surface.GetWidth() / number_of_actions;
bool an_action_is_selected = m_selection_type == SelectionType::Action;
@@ -2434,19 +2421,19 @@ class FormWindowDelegate : public WindowDelegate {
bool is_action_selected = an_action_is_selected && m_selection_index == i;
FormAction &action = m_delegate_sp->GetAction(i);
Rect bounds = Rect(Point(x, 0), Size(width, 1));
- Surface action_surface = surface.SubSurface(bounds);
+ SubPad action_surface = SubPad(surface, bounds);
action.Draw(action_surface, is_action_selected);
x += width;
}
}
- void DrawElements(Surface &surface) {
+ void DrawElements(SubPad &surface) {
Rect frame = surface.GetFrame();
Rect fields_bounds, actions_bounds;
frame.HorizontalSplit(surface.GetHeight() - GetActionsHeight(),
fields_bounds, actions_bounds);
- Surface fields_surface = surface.SubSurface(fields_bounds);
- Surface actions_surface = surface.SubSurface(actions_bounds);
+ SubPad fields_surface = SubPad(surface, fields_bounds);
+ SubPad actions_surface = SubPad(surface, actions_bounds);
DrawFields(fields_surface);
DrawActions(actions_surface);
@@ -2455,7 +2442,7 @@ class FormWindowDelegate : public WindowDelegate {
// Contents are first drawn on a pad. Then a subset of that pad is copied to
// the derived window starting at the first visible line. This essentially
// provides scrolling functionality.
- void DrawContent(Surface &surface) {
+ void DrawContent(DerivedWindow &surface) {
UpdateScrolling(surface);
int width = surface.GetWidth();
@@ -2465,8 +2452,8 @@ class FormWindowDelegate : public WindowDelegate {
Rect frame = pad.GetFrame();
Rect error_bounds, elements_bounds;
frame.HorizontalSplit(GetErrorHeight(), error_bounds, elements_bounds);
- Surface error_surface = pad.SubSurface(error_bounds);
- Surface elements_surface = pad.SubSurface(elements_bounds);
+ SubPad error_surface = SubPad(pad, error_bounds);
+ SubPad elements_surface = SubPad(pad, elements_bounds);
DrawError(error_surface);
DrawElements(elements_surface);
@@ -2486,7 +2473,7 @@ class FormWindowDelegate : public WindowDelegate {
Rect content_bounds = window.GetFrame();
content_bounds.Inset(2, 2);
- Surface content_surface = window.SubSurface(content_bounds);
+ DerivedWindow content_surface = DerivedWindow(window, content_bounds);
DrawContent(content_surface);
return true;
More information about the lldb-commits
mailing list