| 1 |
# find_file.rb: the class definition of Edmaru::FindFileHandler |
| 2 |
# |
| 3 |
# Copyright (C) 2007 Takashi Nakamoto |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License version 2 as |
| 7 |
# published by the Free Software Foundation. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, but |
| 10 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
# General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program; if not, write to the Free Software |
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 17 |
# 02110-1301 USA. |
| 18 |
# |
| 19 |
|
| 20 |
require "event_handler/event_handler_base.rb" |
| 21 |
|
| 22 |
module Edmaru |
| 23 |
class FindFileHandler |
| 24 |
include EventHandlerBase |
| 25 |
|
| 26 |
def init_action_table |
| 27 |
@action_table = Hash.new |
| 28 |
|
| 29 |
for ch in 0x21..0x7f # normal ASCII characters |
| 30 |
@action_table["KeyPress:#{ch.chr}"] = Action.new("insert", [ch.chr]) |
| 31 |
end |
| 32 |
|
| 33 |
@action_table["KeyPress:space"] = Action.new("insert", [" "]) |
| 34 |
@action_table["KeyPress:return"] = Action.new("find-file-open") |
| 35 |
@action_table["KeyPress:delete"] = Action.new("delete") |
| 36 |
@action_table["KeyPress:backspace"] = Action.new("backspace") |
| 37 |
|
| 38 |
@action_table["KeyPress:left-arrow"] = Action.new("cursor-backward") |
| 39 |
@action_table["KeyPress:right-arrow"] = Action.new("cursor-forward") |
| 40 |
|
| 41 |
@action_table["KeyPress:control-a"] = Action.new("cursor-goto-line-head") |
| 42 |
@action_table["KeyPress:control-b"] = Action.new("cursor-backward") |
| 43 |
@action_table["KeyPress:control-d"] = Action.new("delete") |
| 44 |
@action_table["KeyPress:control-e"] = Action.new("cursor-goto-line-tail") |
| 45 |
@action_table["KeyPress:control-f"] = Action.new("cursor-forward") |
| 46 |
@action_table["KeyPress:control-g"] = Action.new("mini-buffer-quit") |
| 47 |
@action_table["KeyPress:control-h"] = Action.new("backspace") |
| 48 |
@action_table["KeyPress:control-j"] = Action.new("find-file-open") |
| 49 |
@action_table["KeyPress:control-k"] = Action.new("kill-line") |
| 50 |
@action_table["KeyPress:control-y"] = Action.new("yank") |
| 51 |
end |
| 52 |
|
| 53 |
def handle_unknown_event(event_name) |
| 54 |
raise "Unknown event: #{event_name}." |
| 55 |
end |
| 56 |
end |
| 57 |
end |