From 924a85d14fa007351399921a0f4a04479503ada6 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 26 Sep 2011 08:59:32 +0000 Subject: [PATCH] erase, change: yank current selection before erasing --- src/main.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main.cc b/src/main.cc index e971b066..59fbc4ee 100644 --- a/src/main.cc +++ b/src/main.cc @@ -389,6 +389,20 @@ void do_yank(Window& window, int count) RegisterManager::instance()['"'] = window.selection_content(); } +void do_erase(Window& window, int count) +{ + do_yank(window, 0); + window.erase(); + window.empty_selections(); +} + +void do_change(Window& window, int count) +{ + do_yank(window, 0); + window.erase(); + do_insert(window); +} + void do_paste(Window& window, int count) { window.append(RegisterManager::instance()['"']); @@ -413,8 +427,8 @@ std::unordered_map> keymap { 't', [](Window& window, int count) { window.select(false, std::bind(select_to, _1, getch(), false)); } }, { 'f', [](Window& window, int count) { window.select(false, std::bind(select_to, _1, getch(), true)); } }, - { 'd', [](Window& window, int count) { window.erase(); window.empty_selections(); } }, - { 'c', [](Window& window, int count) { window.erase(); do_insert(window); } }, + { 'd', do_erase }, + { 'c', do_change }, { 'i', [](Window& window, int count) { do_insert(window); } }, { 'a', [](Window& window, int count) { do_insert(window, true); } }, { 'o', [](Window& window, int count) { window.select(true, select_line); window.append("\n"); do_insert(window, true); } },