From c211b596605d5f7b4e0b0c90d6bff35119572bc6 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Fri, 21 Jul 2017 13:52:28 +0000 Subject: [PATCH] Implement delete --- lib/main.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/main.rb b/lib/main.rb index 58b6de1..24470d4 100644 --- a/lib/main.rb +++ b/lib/main.rb @@ -91,6 +91,8 @@ private @search.end when Curses::Key::BACKSPACE @search.backspace + when Curses::Key::DC + @search.delete when Curses::Key::UP @list.up when Curses::Key::DOWN @@ -173,6 +175,11 @@ class Search update end + def delete + return if cursor_pos > text.length + @text = "#{text[0...cursor_pos]}#{text[(cursor_pos + 1)..-1]}" + end + def update if @cursor_pos.negative? @cursor_pos = 0