• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _GPXE_EDITBOX_H
2 #define _GPXE_EDITBOX_H
3 
4 /** @file
5  *
6  * Editable text box widget
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER );
11 
12 #include <curses.h>
13 #include <gpxe/editstring.h>
14 
15 /** An editable text box widget */
16 struct edit_box {
17 	/** Editable string */
18 	struct edit_string string;
19 	/** Containing window */
20 	WINDOW *win;
21 	/** Row */
22 	unsigned int row;
23 	/** Starting column */
24 	unsigned int col;
25 	/** Width */
26 	unsigned int width;
27 	/** First displayed character */
28 	unsigned int first;
29 	/** Flags */
30 	unsigned int flags;
31 };
32 
33 /** Editable text box widget flags */
34 enum edit_box_flags {
35 	/** Show stars instead of contents (for password widgets) */
36 	EDITBOX_STARS = 0x0001,
37 };
38 
39 extern void init_editbox ( struct edit_box *box, char *buf, size_t len,
40 			   WINDOW *win, unsigned int row, unsigned int col,
41 			   unsigned int width, unsigned int flags )
42 			   __attribute__ (( nonnull (1, 2) ));
43 extern void draw_editbox ( struct edit_box *box ) __nonnull;
44 static inline int edit_editbox ( struct edit_box *box, int key ) __nonnull;
45 
46 /**
47  * Edit text box widget
48  *
49  * @v box		Editable text box widget
50  * @v key		Key pressed by user
51  * @ret key		Key returned to application, or zero
52  *
53  * You must call draw_editbox() to update the display after calling
54  * edit_editbox().
55  *
56  */
edit_editbox(struct edit_box * box,int key)57 static inline int edit_editbox ( struct edit_box *box, int key ) {
58 	return edit_string ( &box->string, key );
59 }
60 
61 #endif /* _GPXE_EDITBOX_H */
62