@@ -573,6 +573,19 @@ static void scene_render_background(struct scene_obj *obj, bool box_only,
}
}
+static void draw_string(struct udevice *cons, const char *str, int len,
+ bool password)
+{
+ if (password) {
+ int i;
+
+ for (i = 0; i < len; i++)
+ vidconsole_put_char(cons, '*');
+ } else {
+ vidconsole_put_stringn(cons, str, len);
+ }
+}
+
static int scene_txt_render(struct expo *exp, struct udevice *dev,
struct udevice *cons, struct scene_obj *obj,
struct scene_txt_generic *gen, int x, int y,
@@ -630,7 +643,8 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev,
if (!mline) {
vidconsole_set_cursor_pos(cons, x, y);
- vidconsole_put_string(cons, str);
+ draw_string(cons, str, strlen(str),
+ obj->flags & SCENEOF_PASSWORD);
}
alist_for_each(mline, &gen->lines) {
@@ -648,7 +662,8 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev,
if (y > bbox.y1)
break; /* clip this line and any following */
vidconsole_set_cursor_pos(cons, x, y);
- vidconsole_put_stringn(cons, str + mline->start, mline->len);
+ draw_string(cons, str + mline->start, mline->len,
+ obj->flags & SCENEOF_PASSWORD);
}
if (obj->flags & SCENEOF_POINT)
vidconsole_pop_colour(cons, &old);
@@ -320,6 +320,7 @@ enum scene_obj_align {
* @SCENEOF_SYNC_BBOX: object's bounding box has changed
* @SCENEOF_MANUAL: manually arrange the items associated with this object
* @SCENEOF_DIRTY: object has been modified and needs to be redrawn
+ * @SCENEOF_PASSWORD: textline input should show stars instead of characters
* @SCENEOF_LAST: used just as a check for the size of the flags mask
*/
enum scene_obj_flags_t {
@@ -333,6 +334,7 @@ enum scene_obj_flags_t {
SCENEOF_SYNC_BBOX = BIT(7),
SCENEOF_MANUAL = BIT(8),
SCENEOF_DIRTY = BIT(9),
+ SCENEOF_PASSWORD = BIT(10),
SCENEOF_LAST, /* check for size of flags below */
};
@@ -376,6 +376,7 @@ static int cedit_render_lineedit(struct unit_test_state *uts)
extern struct expo *cur_exp;
struct expo_action evt;
struct expo_action act;
+ struct scene_obj *edit;
struct udevice *dev, *con;
struct stdio_dev *sdev;
struct scene *scn;
@@ -405,6 +406,16 @@ static int cedit_render_lineedit(struct unit_test_state *uts)
ut_asserteq(5344, video_compress_fb(uts, dev, false));
ut_assertok(video_check_copy_fb(uts, dev));
+ edit = scene_obj_find(scn, ID_MACHINE_NAME_EDIT, SCENEOBJT_TEXT);
+ ut_assert(edit);
+
+ /* try the password flag */
+ edit->flags |= SCENEOF_PASSWORD;
+ ut_assertok(expo_render(exp));
+ ut_asserteq(5135, video_compress_fb(uts, dev, false));
+ ut_assertok(video_check_copy_fb(uts, dev));
+ edit->flags &= ~SCENEOF_PASSWORD;
+
/* move to the line-edit field */
act.type = EXPOACT_POINT_OBJ;
act.select.id = ID_MACHINE_NAME;