summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/widget.h
diff options
context:
space:
mode:
authorSimon Rettberg2026-01-28 12:53:53 +0100
committerSimon Rettberg2026-01-28 12:53:53 +0100
commit8e82785c584dc13e20f9229decb95bd17bbe9cd1 (patch)
treea8b359e59196be5b2e3862bed189107f4bc9975f /src/include/ipxe/widget.h
parentMerge branch 'master' into openslx (diff)
parent[prefix] Make unlzma.S compatible with 386 class CPUs (diff)
downloadipxe-openslx.tar.gz
ipxe-openslx.tar.xz
ipxe-openslx.zip
Merge branch 'master' into openslxopenslx
Diffstat (limited to 'src/include/ipxe/widget.h')
-rw-r--r--src/include/ipxe/widget.h109
1 files changed, 109 insertions, 0 deletions
diff --git a/src/include/ipxe/widget.h b/src/include/ipxe/widget.h
new file mode 100644
index 000000000..6e61a8ca8
--- /dev/null
+++ b/src/include/ipxe/widget.h
@@ -0,0 +1,109 @@
+#ifndef _IPXE_WIDGET_H
+#define _IPXE_WIDGET_H
+
+/** @file
+ *
+ * Text widgets
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+FILE_SECBOOT ( PERMITTED );
+
+#include <curses.h>
+
+/** A text widget */
+struct widget {
+ /** Widget operations */
+ struct widget_operations *op;
+
+ /** Row */
+ unsigned int row;
+ /** Starting column */
+ unsigned int col;
+ /** Width */
+ unsigned int width;
+ /** Flags */
+ unsigned int flags;
+};
+
+/** Text widget flags */
+enum widget_flags {
+ /** Widget may have input focus */
+ WIDGET_EDITABLE = 0x0001,
+ /** Widget contains a secret */
+ WIDGET_SECRET = 0x0002,
+};
+
+/** Text widget operations */
+struct widget_operations {
+ /**
+ * Draw widget
+ *
+ * @v widget Text widget
+ */
+ void ( * draw ) ( struct widget *widget );
+ /**
+ * Edit widget
+ *
+ * @v widget Text widget
+ * @v key Key pressed by user
+ * @ret key Key returned to application, or zero
+ *
+ * This will not update the display: you must call the draw()
+ * method to ensure that any changes to an editable widget are
+ * displayed to the user.
+ */
+ int ( * edit ) ( struct widget *widget, int key );
+};
+
+/**
+ * Initialise text widget
+ *
+ * @v widget Text widget
+ * @v op Text widget operations
+ * @v row Row
+ * @v col Starting column
+ * @v width Width
+ */
+static inline __attribute__ (( always_inline )) void
+init_widget ( struct widget *widget, struct widget_operations *op,
+ unsigned int row, unsigned int col, unsigned int width,
+ unsigned int flags ) {
+
+ widget->op = op;
+ widget->row = row;
+ widget->col = col;
+ widget->width = width;
+ widget->flags = flags;
+}
+
+/**
+ * Draw text widget
+ *
+ * @v widget Text widget
+ */
+static inline __attribute__ (( always_inline )) void
+draw_widget ( struct widget *widget ) {
+
+ widget->op->draw ( widget );
+}
+
+/**
+ * Edit text widget
+ *
+ * @v widget Text widget
+ * @v key Key pressed by user
+ * @ret key Key returned to application, or zero
+ *
+ * This will not update the display: you must call draw_widget() to
+ * ensure that any changes to an editable widget are displayed to the
+ * user.
+ */
+static inline __attribute__ (( always_inline )) int
+edit_widget ( struct widget *widget, int key ) {
+
+ return widget->op->edit ( widget, key );
+}
+
+#endif /* _IPXE_WIDGET_H */