You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

editbox.h 1.4KB

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