21
22
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/ektoplayer/bindings.rb', line 21
def initialize
@commands = {}
reg 'quit', 'Quit the program'
reg 'refresh', 'Refresh the screen'
reg 'reload', 'Apply database changes to browser'
reg 'update', 'Start a database update'
reg 'player.stop', 'Stop playing'
reg 'player.toggle', 'Toggle play/pause'
reg 'player.forward', 'Seek forward'
reg 'player.backward', 'Seek backward'
reg 'tabs.next', 'Select next tab'
reg 'tabs.prev', 'Select previous tab'
reg 'browser.enter', 'Enter selected directory'
reg 'browser.add_to_playlist', 'Add tracks under cursor to playlist'
reg 'browser.back', 'Change to parent directory'
reg 'playinginfo.toggle', 'Toggle playinginfo visibility'
reg 'progressbar.toggle', 'Toggle progressbar visibility'
reg 'tabbar.toggle', 'Toggle tabbar visibility'
reg 'playlist.goto_current', 'Go to current playing track'
reg 'playlist.clear', 'Delete all items in playlist'
reg 'playlist.delete', 'Delete selected track from playlist'
reg 'playlist.download_album', 'Download album archive for selected track'
reg 'playlist.play', 'Play selected track'
reg 'playlist.reload', 'Force redownload of selected track'
reg 'playlist.play_next', 'Play next track in playlist'
reg 'playlist.play_prev', 'Play previous track in playlist'
%w(info help browser playlist splash).each do |w|
reg("#{w}.show", "Show #{w}")
end
{ up: 'Move cursor up', down: 'Move cursor down',
page_up: 'Scroll page up', page_down: 'Scroll page down',
top: 'Move to top', bottom: 'Move to bottom'
}.each do |cmd, desc|
%w(browser info help playlist).each { |w| reg("#{w}.#{cmd}", desc) }
end
{ search_up: 'Start search upwards', search_next: 'Goto next search result',
search_down: 'Start search downwards', search_prev: 'Goto previous search result',
toggle_selection: 'Toggle multi line selection',
}.each do |cmd, desc|
%w(browser playlist).each { |w| reg("#{w}.#{cmd}", desc) }
end
@bindings = { }
@bindings[:global] = {
:'splash.show' => [?`, ?^ ],
:'playlist.show' => [?1 ],
:'browser.show' => [?2 ],
:'info.show' => [?3 ],
:'help.show' => [?4, ICurses::KEY_F1 ],
:'playinginfo.toggle' => [?!, ?\\, ICurses::KEY_F2 ],
:'progressbar.toggle' => [?%, ?~, ICurses::KEY_F3 ],
:'tabbar.toggle' => [?=, ICurses::KEY_F4 ],
:'player.forward' => [?f, ICurses::KEY_RIGHT ],
:'player.backward' => [?b, ICurses::KEY_LEFT ],
:'player.stop' => [?s ],
:'player.toggle' => [?p ],
:'playlist.play_next' => [?> ],
:'playlist.play_prev' => [?< ],
:'tabs.next' => [?l, ?}, '^i' ],
:'tabs.prev' => [?h, ?{, 353 ],
:quit => [?q ],
:refresh => ['^l' ],
:reload => ['^r' ],
:update => [?U ]
}
@bindings[:playlist] = {
:'playlist.top' => [?g, ICurses::KEY_HOME ],
:'playlist.bottom' => [?G, ICurses::KEY_END ],
:'playlist.up' => [?k, ICurses::KEY_UP ],
:'playlist.down' => [?j, ICurses::KEY_DOWN ],
:'playlist.page_down' => ['^d', ICurses::KEY_NPAGE ],
:'playlist.page_up' => ['^u', ICurses::KEY_PPAGE ],
:'playlist.toggle_selection' => ['^v' ],
:'playlist.search_next' => [?n ],
:'playlist.search_prev' => [?N ],
:'playlist.search_up' => [?? ],
:'playlist.search_down' => [?/ ],
:'playlist.play' => [ ICurses::KEY_ENTER ],
:'playlist.download_album' => [?$ ],
:'playlist.reload' => [?r ],
:'playlist.goto_current' => [?o ],
:'playlist.clear' => [?c ],
:'playlist.delete' => [?d ],
:'player.toggle' => [' ' ]
}
@bindings[:browser] = {
:'browser.top' => [?g, ICurses::KEY_HOME ],
:'browser.bottom' => [?G, ICurses::KEY_END ],
:'browser.up' => [?k, ICurses::KEY_UP ],
:'browser.down' => [?j, ICurses::KEY_DOWN ],
:'browser.page_up' => ['^u', ICurses::KEY_PPAGE ],
:'browser.page_down' => ['^d', ICurses::KEY_NPAGE ],
:'browser.toggle_selection' => ['^v' ],
:'browser.search_next' => [?n ],
:'browser.search_prev' => [?N ],
:'browser.search_up' => [?? ],
:'browser.search_down' => [?/ ],
:'browser.add_to_playlist' => [' ', ?a ],
:'browser.enter' => [ ICurses::KEY_ENTER ],
:'browser.back' => [?B, ICurses::KEY_BACKSPACE ]
}
@bindings[:help] = {
:'help.top' => [?g, ICurses::KEY_HOME ],
:'help.bottom' => [?G, ICurses::KEY_END ],
:'help.up' => [?k, ICurses::KEY_UP ],
:'help.down' => [?j, ICurses::KEY_DOWN ],
:'help.page_up' => ['^u', ICurses::KEY_PPAGE ],
:'help.page_down' => ['^d', ICurses::KEY_NPAGE ]
}
@bindings[:info] = {
:'info.top' => [?g, ICurses::KEY_HOME ],
:'info.bottom' => [?G, ICurses::KEY_END ],
:'info.up' => [?k, ICurses::KEY_UP ],
:'info.down' => [?j, ICurses::KEY_DOWN ],
:'info.page_up' => ['^u', ICurses::KEY_PPAGE ],
:'info.page_down' => ['^d', ICurses::KEY_NPAGE ]
}
@bindings[:splash] = {}
@bindings.default_proc = proc { |h,k| fail "Unknown widget #{k}" }
@bindings.each do |widget, hash|
hash.default_proc = proc { |h,k| h[k] = [] }
hash.values.each do |keys|
keys.map!(&method(:parse_key))
end
end
end
|