From 00f48f9a58aaafc394b49f4468bb21005fb08ac8 Mon Sep 17 00:00:00 2001 From: Braiden Vasco Date: Fri, 21 Jul 2017 13:16:53 +0000 Subject: [PATCH] More cursor control --- lib/main.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/main.rb b/lib/main.rb index a6de3f9..d885906 100644 --- a/lib/main.rb +++ b/lib/main.rb @@ -81,6 +81,10 @@ private case event when /[a-zA-Z0-9 _-]/ @search.putc event + when Curses::Key::HOME + @search.home + when Curses::Key.const_get(:END) + @search.end when Curses::Key::BACKSPACE @search.backspace when Curses::Key::UP @@ -135,6 +139,14 @@ class Search update end + def home + @cursor_pos = 0 + end + + def end + @cursor_pos = @text.length + end + def backspace @text = text[0...-1] @cursor_pos -= 1