summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--edit.c49
1 files changed, 43 insertions, 6 deletions
diff --git a/edit.c b/edit.c
index 6b044cb..dde3396 100644
--- a/edit.c
+++ b/edit.c
@@ -58,9 +58,6 @@ static void home(void) {
 static void end(void) {
 	line.ptr = line.end;
 }
-static void kill(void) {
-	line.end = line.ptr;
-}
 
 static void backspace(void) {
 	if (line.ptr == line.buf) return;
@@ -96,6 +93,38 @@ static void enter(void) {
 	line.end = line.buf;
 }
 
+static void backWord(void) {
+	left();
+	editHead();
+	wchar_t *word = wcsrchr(line.buf, ' ');
+	editTail();
+	line.ptr = (word ? &word[1] : line.buf);
+}
+static void foreWord(void) {
+	right();
+	editHead();
+	editTail();
+	wchar_t *word = wcschr(line.ptr, ' ');
+	line.ptr = (word ? word : line.end);
+}
+
+static void killBackWord(void) {
+	wchar_t *from = line.ptr;
+	backWord();
+	wmemmove(line.ptr, from, line.end - from);
+	line.end -= from - line.ptr;
+}
+static void killForeWord(void) {
+	wchar_t *from = line.ptr;
+	foreWord();
+	wmemmove(from, line.ptr, line.end - line.ptr);
+	line.end -= line.ptr - from;
+	line.ptr = from;
+}
+static void killLine(void) {
+	line.end = line.ptr;
+}
+
 static char *prefix;
 static void complete(void) {
 	if (!line.tab) {
@@ -151,8 +180,15 @@ static void reject(void) {
 }
 
 static bool editMeta(wchar_t ch) {
-	(void)ch;
-	return false;
+	switch (ch) {
+		break; case L'b':  reject(); backWord();
+		break; case L'f':  reject(); foreWord();
+		break; case L'\b': reject(); killBackWord();
+		break; case L'd':  reject(); killForeWord();
+
+		break; default: return false;
+	}
+	return true;
 }
 
 static bool editCtrl(wchar_t ch) {
@@ -162,7 +198,8 @@ static bool editCtrl(wchar_t ch) {
 		break; case L'A': reject(); home();
 		break; case L'E': reject(); end();
 		break; case L'D': reject(); delete();
-		break; case L'K': reject(); kill();
+		break; case L'W': reject(); killBackWord();
+		break; case L'K': reject(); killLine();
 
 		break; case L'C': accept(); insert(IRC_COLOR);
 		break; case L'N': accept(); insert(IRC_RESET);
bular?id=15da054d16c17823941799275567d5d03484c1d1&follow=1'>Add tabular.vimJune McEnroe 2012-02-01Update Vim-Tomorrow-ThemeJune McEnroe PS. Chris Kempson is a jerk. 2012-01-30Disable menu bar in GVimJune McEnroe 2012-01-30Set shiftwidth to 4 for LuaJune McEnroe 2012-01-29Don't show Syntastic errors automaticallyJune McEnroe 2012-01-28Update to Quicktask 1.1June McEnroe 2012-01-22Use space-test branch of quicktaskJune McEnroe 2012-01-22Enable syntax-based foldingJune McEnroe 2012-01-22Update quicktaskJune McEnroe 2012-01-22Revert "Add AutoClose"June McEnroe This reverts commit 39cfdd62ba82f93f68a2b5fa7b5771303d8b9dee. This fixes the delay when leaving insert mode 2012-01-22Revert "Disable powerline for now"June McEnroe This reverts commit fa48f5965c57272e616721d92475cd2f1e35f667. 2012-01-22Revert "Add VCS repo directories to wildignore"June McEnroe This reverts commit 41cb1db33ba7b64d8af63bf55bb82f7e8a617518. This fixes not being able to commit with vim-fugitive 2012-01-22Disable powerline for nowJune McEnroe 2012-01-22Update some pluginsJune McEnroe 2012-01-22Add VCS repo directories to wildignoreJune McEnroe 2012-01-22Map ,e and ,b to CtrlP file and buffer respectivelyJune McEnroe 2012-01-22Add vim-spaceJune McEnroe 2012-01-22Add AutoCloseJune McEnroe 2012-01-22Add binding for GundoJune McEnroe 2012-01-22Add GundoJune McEnroe 2012-01-22Add Jellybeans colorschemeJune McEnroe 2012-01-22Add syntasticJune McEnroe 2012-01-21Add PowerlineJune McEnroe 2012-01-21Add quicktaskJune McEnroe 2012-01-15Moved comments out of mapsJune McEnroe 2012-01-14Disable scrollbarsJune McEnroe