From 01ab33591924d5e2b95b6b38c327d3947831cb76 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Mon, 1 Jul 2019 00:40:55 +0200 Subject: [PATCH] Implement key Delete in component > Input. The BS key is used to delete the character on the left of the cursor. The DEL key is used to delete the character on the right of the cursor. BackSpace was already implemented. This CL implements DEL. This is related to bug: https://github.com/ArthurSonzogni/FTXUI/issues/4 --- src/ftxui/component/input.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/ftxui/component/input.cpp b/src/ftxui/component/input.cpp index da117d5..2f1838d 100644 --- a/src/ftxui/component/input.cpp +++ b/src/ftxui/component/input.cpp @@ -52,6 +52,14 @@ bool Input::OnEvent(Event event) { return true; } + // Delete + if (event == Event::Delete) { + if (cursor_position == int(content.size())) + return false; + content.erase(cursor_position, 1); + return true; + } + // Enter. if (event == Event::Return) { on_enter();