23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/patchmaster/curses/main.rb', line 23
def run
@pm.start
begin
config_curses
create_windows
loop do
begin
refresh_all
ch = getch
message("ch = #{ch}") if $DEBUG
case ch
when 'j', Key::DOWN, ' '
@pm.next_patch
when 'k', Key::UP
@pm.prev_patch
when 'n', Key::RIGHT
@pm.next_song
when 'p', Key::LEFT
@pm.prev_song
when 'g'
name = PromptWindow.new('Go To Song', 'Go to song:').gets
@pm.goto_song(name) if name.length > 0
when 't'
name = PromptWindow.new('Go To Song List', 'Go to Song List:').gets
@pm.goto_song_list(name) if name.length > 0
when 'e'
close_screen
file = @pm.loaded_file || PromptWindow.new('Edit', 'Edit file:').gets
edit(file) if file.length > 0
when 'r'
load(@pm.loaded_file) if @pm.loaded_file && @pm.loaded_file.length > 0
when 'h', '?'
help
when 27
message('Sending panic note off messages...')
@pm.panic(@prev_cmd == 27)
message('Panic sent')
when 'l'
file = PromptWindow.new('Load', 'Load file:').gets
if file.length > 0
begin
load(file)
message("Loaded #{file}")
rescue => ex
message(ex.to_s)
end
end
when 's'
file = PromptWindow.new('Save', 'Save into file:').gets
if file.length > 0
begin
save(file)
message("Saved #{file}")
rescue => ex
message(ex.to_s)
end
end
when 'q'
break
when Key::RESIZE
resize_windows
end
@prev_cmd = ch
rescue => ex
message(ex.to_s)
@pm.debug caller.join("\n")
end
msg_name = @pm.message_bindings[ch]
@pm.send_message(msg_name) if msg_name
code_key = @pm.code_bindings[ch]
code_key.run if code_key
end
ensure
clear
refresh
close_screen
@pm.stop
@pm.close_debug_file
end
end
|