Bläddra i källkod

[editbox] Allow for password widgets that do not display their contents

tags/v0.9.7
Michael Brown 15 år sedan
förälder
incheckning
67ee41ad6d
3 ändrade filer med 19 tillägg och 6 borttagningar
  1. 8
    3
      src/hci/mucurses/widgets/editbox.c
  2. 1
    1
      src/hci/tui/settings_ui.c
  3. 10
    2
      src/include/gpxe/editbox.h

+ 8
- 3
src/hci/mucurses/widgets/editbox.c Visa fil

38
  * @v row		Row
38
  * @v row		Row
39
  * @v col		Starting column
39
  * @v col		Starting column
40
  * @v width		Width
40
  * @v width		Width
41
- *
41
+ * @v flags		Flags
42
  */
42
  */
43
 void init_editbox ( struct edit_box *box, char *buf, size_t len,
43
 void init_editbox ( struct edit_box *box, char *buf, size_t len,
44
 		    WINDOW *win, unsigned int row, unsigned int col,
44
 		    WINDOW *win, unsigned int row, unsigned int col,
45
-		    unsigned int width ) {
45
+		    unsigned int width, unsigned int flags ) {
46
 	memset ( box, 0, sizeof ( *box ) );
46
 	memset ( box, 0, sizeof ( *box ) );
47
 	box->string.buf = buf;
47
 	box->string.buf = buf;
48
 	box->string.len = len;
48
 	box->string.len = len;
51
 	box->row = row;
51
 	box->row = row;
52
 	box->col = col;
52
 	box->col = col;
53
 	box->width = width;
53
 	box->width = width;
54
+	box->flags = flags;
54
 }
55
 }
55
 
56
 
56
 /**
57
 /**
86
 	len = ( strlen ( box->string.buf ) - first );
87
 	len = ( strlen ( box->string.buf ) - first );
87
 	if ( len > width )
88
 	if ( len > width )
88
 		len = width;
89
 		len = width;
89
-	memcpy ( buf, ( box->string.buf + first ), len );
90
+	if ( box->flags & EDITBOX_STARS ) {
91
+		memset ( buf, '*', len );
92
+	} else {
93
+		memcpy ( buf, ( box->string.buf + first ), len );
94
+	}
90
 
95
 
91
 	/* Print box content and move cursor */
96
 	/* Print box content and move cursor */
92
 	if ( ! box->win )
97
 	if ( ! box->win )

+ 1
- 1
src/hci/tui/settings_ui.c Visa fil

123
 	init_editbox ( &widget->editbox, widget->value,
123
 	init_editbox ( &widget->editbox, widget->value,
124
 		       sizeof ( widget->value ), NULL, widget->row,
124
 		       sizeof ( widget->value ), NULL, widget->row,
125
 		       ( widget->col + offsetof ( struct setting_row, value )),
125
 		       ( widget->col + offsetof ( struct setting_row, value )),
126
-		       sizeof ( ( ( struct setting_row * ) NULL )->value ) );
126
+		       sizeof ( ( ( struct setting_row * ) NULL )->value ), 0);
127
 }
127
 }
128
 
128
 
129
 /**
129
 /**

+ 10
- 2
src/include/gpxe/editbox.h Visa fil

24
 	unsigned int width;
24
 	unsigned int width;
25
 	/** First displayed character */
25
 	/** First displayed character */
26
 	unsigned int first;
26
 	unsigned int first;
27
+	/** Flags */
28
+	unsigned int flags;
29
+};
30
+
31
+/** Editable text box widget flags */
32
+enum edit_box_flags {
33
+	/** Show stars instead of contents (for password widgets) */
34
+	EDITBOX_STARS = 0x0001,
27
 };
35
 };
28
 
36
 
29
 extern void init_editbox ( struct edit_box *box, char *buf, size_t len,
37
 extern void init_editbox ( struct edit_box *box, char *buf, size_t len,
30
 			   WINDOW *win, unsigned int row, unsigned int col,
38
 			   WINDOW *win, unsigned int row, unsigned int col,
31
-			   unsigned int width ) 
39
+			   unsigned int width, unsigned int flags )
32
 			   __attribute__ (( nonnull (1, 2) ));
40
 			   __attribute__ (( nonnull (1, 2) ));
33
 extern void draw_editbox ( struct edit_box *box ) __nonnull;
41
 extern void draw_editbox ( struct edit_box *box ) __nonnull;
34
-static inline int __pure edit_editbox ( struct edit_box *box, int key ) __nonnull;
42
+static inline int edit_editbox ( struct edit_box *box, int key ) __nonnull;
35
 
43
 
36
 /**
44
 /**
37
  * Edit text box widget
45
  * Edit text box widget

Laddar…
Avbryt
Spara