diff mbox series

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

Message ID 20181218041953.8960-8-sam@mendozajonas.com
State New
Headers show
Series Introduce pb-plugin 'commands' & Rust PoC | expand

Commit Message

Sam Mendoza-Jonas Dec. 18, 2018, 4:19 a.m. UTC
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
---
 ui/ncurses/nc-widgets.c | 13 +++++++++++++
 ui/ncurses/nc-widgets.h |  1 +
 2 files changed, 14 insertions(+)
diff mbox series

Patch

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);