#include <assert.h>
#include <string.h>
+#include <ctype.h>
#include <ipxe/keys.h>
#include <ipxe/editstring.h>
unsigned int character ) __nonnull;
static void delete_character ( struct edit_string *string ) __nonnull;
static void backspace ( struct edit_string *string ) __nonnull;
+static void previous_word ( struct edit_string *string ) __nonnull;
+static void kill_word ( struct edit_string *string ) __nonnull;
static void kill_sol ( struct edit_string *string ) __nonnull;
static void kill_eol ( struct edit_string *string ) __nonnull;
}
}
+/**
+ * Move to start of previous word
+ *
+ * @v string Editable string
+ */
+static void previous_word ( struct edit_string *string ) {
+ while ( string->cursor &&
+ isspace ( string->buf[ string->cursor - 1 ] ) ) {
+ string->cursor--;
+ }
+ while ( string->cursor &&
+ ( ! isspace ( string->buf[ string->cursor - 1 ] ) ) ) {
+ string->cursor--;
+ }
+}
+
+/**
+ * Delete to end of previous word
+ *
+ * @v string Editable string
+ */
+static void kill_word ( struct edit_string *string ) {
+ size_t old_cursor = string->cursor;
+ previous_word ( string );
+ insert_delete ( string, ( old_cursor - string->cursor ), NULL );
+}
+
/**
* Delete to start of line
*
- * @v string Editable string
+ * @v string Editable string
*/
static void kill_sol ( struct edit_string *string ) {
size_t old_cursor = string->cursor;
/* Delete character */
delete_character ( string );
break;
+ case CTRL_W:
+ /* Delete word */
+ kill_word ( string );
+ break;
case CTRL_U:
/* Delete to start of line */
kill_sol ( string );