[RFC PATCH 7/8] ui/ncurses: Add current_field accessor

Samuel Mendoza-Jonas sam at mendozajonas.com
Tue Dec 18 15:19:52 AEDT 2018


Signed-off-by: Samuel Mendoza-Jonas <sam at mendozajonas.com>
---
 ui/ncurses/nc-widgets.c | 13 +++++++++++++
 ui/ncurses/nc-widgets.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/ui/ncurses/nc-widgets.c b/ui/ncurses/nc-widgets.c
index afd56d71..86587bc8 100644
--- a/ui/ncurses/nc-widgets.c
+++ b/ui/ncurses/nc-widgets.c
@@ -1402,3 +1402,16 @@ int widget_focus_y(struct nc_widget *widget)
 	return widget->focus_y;
 }
 
+struct nc_widget *current_widget(struct nc_widgetset *set)
+{
+	FIELD *f;
+
+	f = current_field(set->form);
+
+	if (!f) {
+		pb_debug_fn("No field is selected!\n");
+		return NULL;
+	}
+
+	return field_userptr(f);
+}
diff --git a/ui/ncurses/nc-widgets.h b/ui/ncurses/nc-widgets.h
index ce3b0386..88ca2125 100644
--- a/ui/ncurses/nc-widgets.h
+++ b/ui/ncurses/nc-widgets.h
@@ -90,6 +90,7 @@ int widget_width(struct nc_widget *widget);
 int widget_y(struct nc_widget *widget);
 int widget_x(struct nc_widget *widget);
 int widget_focus_y(struct nc_widget *widget);
+struct nc_widget *current_widget(struct nc_widgetset *set);
 
 /* widgetset API */
 typedef void (*widget_focus_cb)(struct nc_widget *widget, void *arg);
-- 
2.20.0



More information about the Petitboot mailing list