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.

editstring.h 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _IPXE_EDITSTRING_H
  2. #define _IPXE_EDITSTRING_H
  3. /** @file
  4. *
  5. * Editable strings
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. /** An editable string */
  10. struct edit_string {
  11. /** Buffer for string */
  12. char *buf;
  13. /** Size of buffer (including terminating NUL) */
  14. size_t len;
  15. /** Cursor position */
  16. unsigned int cursor;
  17. /* The following items are the edit history */
  18. /** Last cursor position */
  19. unsigned int last_cursor;
  20. /** Start of modified portion of string */
  21. unsigned int mod_start;
  22. /** End of modified portion of string */
  23. unsigned int mod_end;
  24. };
  25. /**
  26. * Initialise editable string
  27. *
  28. * @v string Editable string
  29. * @v buf Buffer for string
  30. * @v len Length of buffer
  31. */
  32. static inline void init_editstring ( struct edit_string *string, char *buf,
  33. size_t len ) {
  34. string->buf = buf;
  35. string->len = len;
  36. }
  37. extern void replace_string ( struct edit_string *string,
  38. const char *replacement ) __nonnull;
  39. extern int edit_string ( struct edit_string *string, int key ) __nonnull;
  40. #endif /* _IPXE_EDITSTRING_H */