iPXE
editbox.h
Go to the documentation of this file.
00001 #ifndef _IPXE_EDITBOX_H
00002 #define _IPXE_EDITBOX_H
00003 
00004 /** @file
00005  *
00006  * Editable text box widget
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <curses.h>
00013 #include <ipxe/editstring.h>
00014 
00015 /** An editable text box widget */
00016 struct edit_box {
00017         /** Editable string */
00018         struct edit_string string;
00019         /** Containing window */
00020         WINDOW *win;
00021         /** Row */
00022         unsigned int row;
00023         /** Starting column */
00024         unsigned int col;
00025         /** Width */
00026         unsigned int width;
00027         /** First displayed character */
00028         unsigned int first;
00029         /** Flags */
00030         unsigned int flags;
00031 };
00032 
00033 /** Editable text box widget flags */
00034 enum edit_box_flags {
00035         /** Show stars instead of contents (for password widgets) */
00036         EDITBOX_STARS = 0x0001,
00037 };
00038 
00039 extern void init_editbox ( struct edit_box *box, char *buf, size_t len,
00040                            WINDOW *win, unsigned int row, unsigned int col,
00041                            unsigned int width, unsigned int flags )
00042                            __attribute__ (( nonnull (1, 2) ));
00043 extern void draw_editbox ( struct edit_box *box ) __nonnull;
00044 static inline int edit_editbox ( struct edit_box *box, int key ) __nonnull;
00045 
00046 /**
00047  * Edit text box widget
00048  *
00049  * @v box               Editable text box widget
00050  * @v key               Key pressed by user
00051  * @ret key             Key returned to application, or zero
00052  *
00053  * You must call draw_editbox() to update the display after calling
00054  * edit_editbox().
00055  *
00056  */
00057 static inline int edit_editbox ( struct edit_box *box, int key ) {
00058         return edit_string ( &box->string, key );
00059 }
00060 
00061 #endif /* _IPXE_EDITBOX_H */