Browse Source

[readline] Accept Ctrl-U for "delete to start of line"

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Robin Smidsrød 12 years ago
parent
commit
aac9718fd6
1 changed files with 16 additions and 0 deletions
  1. 16
    0
      src/hci/editstring.c

+ 16
- 0
src/hci/editstring.c View File

@@ -36,6 +36,7 @@ static void insert_character ( struct edit_string *string,
36 36
                                unsigned int character ) __nonnull;
37 37
 static void delete_character ( struct edit_string *string ) __nonnull;
38 38
 static void backspace ( struct edit_string *string ) __nonnull;
39
+static void kill_sol ( struct edit_string *string ) __nonnull;
39 40
 static void kill_eol ( struct edit_string *string ) __nonnull;
40 41
 
41 42
 /**
@@ -108,6 +109,17 @@ static void backspace ( struct edit_string *string ) {
108 109
 	}
109 110
 }
110 111
 
112
+/**
113
+ * Delete to start of line
114
+ *
115
+ * @v string           Editable string
116
+ */
117
+static void kill_sol ( struct edit_string *string ) {
118
+	size_t old_cursor = string->cursor;
119
+	string->cursor = 0;
120
+	insert_delete ( string, old_cursor, NULL );
121
+}
122
+
111 123
 /**
112 124
  * Delete to end of line
113 125
  *
@@ -168,6 +180,10 @@ int edit_string ( struct edit_string *string, int key ) {
168 180
 		/* Delete character */
169 181
 		delete_character ( string );
170 182
 		break;
183
+	case CTRL_U:
184
+		/* Delete to start of line */
185
+		kill_sol ( string );
186
+		break;
171 187
 	case CTRL_K:
172 188
 		/* Delete to end of line */
173 189
 		kill_eol ( string );

Loading…
Cancel
Save