ektoplayer 0.1.6 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -12
  3. data/lib/ektoplayer/application.rb +6 -5
  4. data/lib/ektoplayer/bindings.rb +61 -55
  5. data/lib/ektoplayer/common.rb +19 -6
  6. data/lib/ektoplayer/compat.rb +3 -3
  7. data/lib/ektoplayer/config.rb +1 -11
  8. data/lib/ektoplayer/controllers/browser.rb +7 -5
  9. data/lib/ektoplayer/controllers/help.rb +1 -1
  10. data/lib/ektoplayer/controllers/info.rb +1 -1
  11. data/lib/ektoplayer/controllers/playlist.rb +24 -12
  12. data/lib/ektoplayer/icurses.rb +21 -0
  13. data/lib/ektoplayer/icurses/curses.rb +53 -0
  14. data/lib/ektoplayer/icurses/ffi_ncurses.rb +69 -0
  15. data/lib/ektoplayer/icurses/ncurses.rb +79 -0
  16. data/lib/ektoplayer/icurses/ncursesw.rb +1 -0
  17. data/lib/ektoplayer/icurses/sugar.rb +65 -0
  18. data/lib/ektoplayer/icurses/test.rb +99 -0
  19. data/lib/ektoplayer/models/player.rb +2 -2
  20. data/lib/ektoplayer/{mp3player.rb → players/mpg_portaudio_player.rb} +3 -3
  21. data/lib/ektoplayer/players/mpg_wrapper_player.rb +107 -0
  22. data/lib/ektoplayer/theme.rb +1 -6
  23. data/lib/ektoplayer/ui.rb +100 -129
  24. data/lib/ektoplayer/ui/colors.rb +14 -14
  25. data/lib/ektoplayer/ui/widgets.rb +4 -4
  26. data/lib/ektoplayer/ui/widgets/labelwidget.rb +1 -1
  27. data/lib/ektoplayer/ui/widgets/listwidget.rb +115 -46
  28. data/lib/ektoplayer/views/help.rb +7 -10
  29. data/lib/ektoplayer/views/info.rb +29 -38
  30. data/lib/ektoplayer/views/mainwindow.rb +2 -5
  31. data/lib/ektoplayer/views/playinginfo.rb +15 -20
  32. data/lib/ektoplayer/views/progressbar.rb +30 -10
  33. data/lib/ektoplayer/views/splash.rb +24 -25
  34. data/lib/ektoplayer/views/tabbar.rb +6 -5
  35. data/lib/ektoplayer/views/trackrenderer.rb +20 -14
  36. metadata +15 -47
  37. data/lib/ektoplayer/views/volumemeter.rb +0 -76
@@ -1,11 +1,11 @@
1
1
  %w( ../ui/widgets/container playinginfo progressbar
2
- volumemeter splash playlist browser info help tabbar ).
2
+ splash playlist browser info help tabbar ).
3
3
  each {|_|require_relative(_)}
4
4
 
5
5
  module Ektoplayer
6
6
  module Views
7
7
  class MainWindow < UI::VerticalContainer
8
- attr_reader :progressbar, :volumemeter, :playinginfo, :tabbar
8
+ attr_reader :progressbar, :playinginfo, :tabbar
9
9
  attr_reader :windows, :splash, :playlist, :browser, :info, :help
10
10
 
11
11
  def initialize(**opts)
@@ -13,7 +13,6 @@ module Ektoplayer
13
13
 
14
14
  @playinginfo = sub(PlayingInfo, size: @size.update(height: 2))
15
15
  @progressbar = sub(ProgressBar, size: @size.update(height: 1))
16
- @volumemeter = sub(VolumeMeter, size: @size.update(height: 1))
17
16
  @tabbar = sub(TabBar, size: @size.update(height: 1))
18
17
  @windows = sub(UI::SwitchContainer, size: @size.calc(height: -4))
19
18
  @help = @windows.sub(Help, visible: false)
@@ -37,12 +36,10 @@ module Ektoplayer
37
36
  height = @size.height
38
37
 
39
38
  @playinginfo.size=(@size.update(height: 2))
40
- @volumemeter.size=(@size.update(height: 1))
41
39
  @progressbar.size=(@size.update(height: 1))
42
40
  @tabbar.size=(@size.update(height: 1))
43
41
 
44
42
  height -= 2 if @playinginfo.visible?
45
- height -= 1 if @volumemeter.visible?
46
43
  height -= 1 if @progressbar.visible?
47
44
  height -= 1 if @tabbar.visible?
48
45
 
@@ -20,7 +20,7 @@ module Ektoplayer
20
20
 
21
21
  def stopped!
22
22
  return if @state == :stopped
23
- with_lock { @state = :stopped; want_redraw }
23
+ with_lock { @state = :stopped; @position = 0; want_redraw }
24
24
  end
25
25
 
26
26
  def track=(t)
@@ -42,11 +42,9 @@ module Ektoplayer
42
42
 
43
43
  def draw_position_and_length
44
44
  return unless visible?
45
- @win.setpos(0,0)
46
- @win.with_attr(Theme[:'playinginfo.position']) do
47
- @win << "[#{Common::to_time(@position)}/#{Common::to_time(@length)}]"
48
- end
49
- @win.refresh
45
+ @win.attrset(Theme[:'playinginfo.position'])
46
+ @win.mvaddstr(0, 0, "[#{Common::to_time(@position)}/#{Common::to_time(@length)}]")
47
+ @win.noutrefresh
50
48
  end
51
49
 
52
50
  def attach(playlist, player)
@@ -64,7 +62,7 @@ module Ektoplayer
64
62
  }
65
63
 
66
64
  # TODO: move mouse?
67
- self.mouse.on(Curses::BUTTON1_CLICKED) do |mevent|
65
+ self.mouse.on(ICurses::BUTTON1_CLICKED) do |mevent|
68
66
  player.toggle
69
67
  end
70
68
  end
@@ -94,31 +92,28 @@ module Ektoplayer
94
92
  if @track
95
93
  fill(Config[:'playinginfo.format1']).each_with_index do |fmt,i|
96
94
  @win.center(fmt[:sum]) if i == 0
97
- @win.with_attr(UI::Colors.set(nil, *fmt[:curses_attrs])) do
98
- @win << fmt[:filled]
99
- end
95
+ @win.attrset(UI::Colors.set(nil, *fmt[:curses_attrs]))
96
+ @win << fmt[:filled]
100
97
  end
101
98
 
102
- @win.with_attr(Theme[:'playinginfo.state']) do
103
- @win.from_right(@state.to_s.size + 2) << "[#{@state}]"
104
- end
99
+ @win.attrset(Theme[:'playinginfo.state'])
100
+ @win.from_right(@state.to_s.size + 2) << "[#{@state}]"
105
101
 
106
102
  @win.next_line
107
103
 
108
104
  fill(Config[:'playinginfo.format2']).each_with_index do |fmt,i|
109
105
  @win.center(fmt[:sum]) if i == 0
110
- @win.with_attr(UI::Colors.set(nil, *fmt[:curses_attrs])) do
111
- @win << fmt[:filled]
112
- end
106
+ @win.attrset(UI::Colors.set(nil, *fmt[:curses_attrs]))
107
+ @win << fmt[:filled]
113
108
  end
114
109
  else
110
+ @win.attrset(0)
115
111
  @win.center_string(STOPPED_HEADING)
116
- @win.with_attr(Theme[:'playinginfo.state']) do
117
- @win.from_right(9) << '[stopped]'
118
- end
112
+ @win.attrset(Theme[:'playinginfo.state'])
113
+ @win.from_right(9) << '[stopped]'
119
114
  end
120
115
 
121
- #@win.next_line.addstr('' * @size.width)
116
+ #@win.next_line.addstr('~' * @size.width)
122
117
  end
123
118
  end
124
119
  end
@@ -5,13 +5,36 @@ require_relative '../theme'
5
5
  module Ektoplayer
6
6
  module Views
7
7
  class ProgressBar < UI::Window
8
+ def layout
9
+ super
10
+ load_colors
11
+ end
12
+
13
+ def load_colors(force=false)
14
+ return if @fade and not force
15
+
16
+ if Theme.current == 256
17
+ fader = UI::ColorFader.new([25,26,27,32,39,38,44,44,45,51,87,159,195])
18
+ elsif Theme.current == 8
19
+ fader = UI::ColorFader.new([:blue])
20
+ else
21
+ fader = UI::ColorFader.new([-1])
22
+ end
23
+
24
+ @fade = fader.fade(@size.width)
25
+ @progress_width = @size.width
26
+ @progress_char = Config[:'progressbar.progress_char']
27
+ @rest_char = Config[:'progressbar.rest_char']
28
+ end
29
+
30
+
8
31
  def attach(player)
9
32
  player.events.on(:position_change) do
10
33
  self.percent_playing = player.position_percent
11
34
  end
12
35
 
13
36
  view=self # TODO
14
- [Curses::BUTTON1_CLICKED, Curses::BUTTON2_CLICKED, Curses::BUTTON3_CLICKED].
37
+ [ICurses::BUTTON1_CLICKED, ICurses::BUTTON2_CLICKED, ICurses::BUTTON3_CLICKED].
15
38
  each do |button|
16
39
  view.mouse.on(button) do |mevent|
17
40
  pos = Float(mevent.x) / (self.size.width - 1) * player.length rescue player.position
@@ -31,15 +54,12 @@ module Ektoplayer
31
54
  end
32
55
 
33
56
  def draw
34
- @win.setpos(0,0)
35
- @progress_width ||= 0
36
- @progress_char ||= Config[:'progressbar.progress_char']
37
- @rest_char ||= Config[:'progressbar.rest_char']
38
-
39
- @win.with_attr(Theme[:'progressbar.progress']) do
40
- repeat = (@progress_width - @progress_char.size)
41
- @win << @progress_char[0] * repeat if repeat > 0
42
- @win << @progress_char[1..-1] if @progress_width > 0
57
+ load_colors
58
+ @win.move(0,0)
59
+
60
+ @progress_width.times do |i|
61
+ @win.attron(@fade[i])
62
+ @win << @progress_char
43
63
  end
44
64
 
45
65
  @win.attron(Theme[:'progressbar.rest'])
@@ -18,35 +18,35 @@ module Ektoplayer
18
18
  \ \__ | | |\ | |__ | | | :___ | |_| | , /____ | | | |
19
19
  \____) |_| |_| \___/ |_| \____/ \_____| |______| |_| |_|..
20
20
  split(?\n)[1..-1].freeze
21
- EKTOPLAZM_SIGNATURE = %q;
21
+ EKTOPLAZM_SIGNATURE = %q{
22
22
  ___ _ _ _ _ _ _
23
23
  / __| ___ _ _ _ _ __| | | | (_) |__ ___ _ _ __ _| |_(_)___ _ _
24
24
  \__ \/ _ \ || | ' \/ _` | | |__| | '_ \/ -_) '_/ _` | _| / _ \ ' \
25
- |___/\___/\_,_|_||_\__,_| |____|_|_.__/\___|_| \__,_|\__|_\___/_||_|;.
25
+ |___/\___/\_,_|_||_\__,_| |____|_|_.__/\___|_| \__,_|\__|_\___/_||_|}.
26
26
  split(?\n)[1..-1].freeze
27
27
 
28
28
  BUBBLES = [
29
- UI::Point.new(x: 6, y: 3).frz, UI::Point.new(x: 6, y: 7).frz,
30
- UI::Point.new(x: 28, y: 1).frz, UI::Point.new(x: 28, y: 9).frz,
31
- UI::Point.new(x: 46, y: 7).frz, UI::Point.new(x: 71, y: 9).frz
29
+ UI::Point.new(x: 6, y: 3).freeze, UI::Point.new(x: 6, y: 7).freeze,
30
+ UI::Point.new(x: 28, y: 1).freeze, UI::Point.new(x: 28, y: 9).freeze,
31
+ UI::Point.new(x: 46, y: 7).freeze, UI::Point.new(x: 71, y: 9).freeze
32
32
  ].freeze
33
33
 
34
34
  def load_colors
35
- @signature_fade = @ekto_logo_fade = @bubble_fade = [-1].freeze
35
+ signature_fade = ekto_logo_fade = bubble_fade = [-1].freeze
36
36
 
37
37
  if Theme.current == 256
38
- @bubble_fade = [161,162,167,168]
39
- @signature_fade = [99, 105, 111, 117]
40
- @ekto_logo_fade = [23, 23, 29, 36, 42, 48, 42, 36, 29, 23]
38
+ bubble_fade = [168,167,161,161,161].freeze
39
+ signature_fade = [99, 105, 111, 117].freeze
40
+ ekto_logo_fade = [23, 23, 29, 36, 42, 48, 42, 36, 29, 23].freeze
41
41
  elsif Theme.current == 8
42
- @bubble_fade = [:red]
43
- @ekto_logo_fade = [:blue]
44
- @signature_fade = [:magenta]
42
+ bubble_fade = [:red].freeze
43
+ ekto_logo_fade = [:blue].freeze
44
+ signature_fade = [:magenta].freeze
45
45
  end
46
46
 
47
- @bubble_fade = UI::ColorFader.new(@bubble_fade)
48
- @signature_fade = UI::ColorFader.new(@signature_fade)
49
- @ekto_logo_fade = UI::ColorFader.new(@ekto_logo_fade)
47
+ @bubble_fade = UI::ColorFader.new(bubble_fade)
48
+ @signature_fade = UI::ColorFader.new(signature_fade)
49
+ @ekto_logo_fade = UI::ColorFader.new(ekto_logo_fade)
50
50
  end
51
51
 
52
52
  def draw
@@ -68,18 +68,16 @@ module Ektoplayer
68
68
  end
69
69
 
70
70
  @ekto_logo_fade.fade(EKTOPLAZM_LOGO.size).each_with_index do |c,i|
71
- @win.with_attr(c) do
72
- @win.setpos(top_pad + i, left_pad)
73
- @win << EKTOPLAZM_LOGO[i]
74
- end
71
+ @win.attrset(c)
72
+ @win.mvaddstr(top_pad + i, left_pad, EKTOPLAZM_LOGO[i])
75
73
  end
76
74
 
77
75
  f = @bubble_fade.fade(EKTOPLAZM_LOGO.size)
78
76
  BUBBLES.each do |p|
79
- @win.setpos(top_pad + p.y - 1, left_pad + p.x + 1)
80
- @win.attron(f[p.y - 1]) { @win.addch(?_) }
81
- @win.setpos(top_pad + p.y, left_pad + p.x)
82
- @win.attron(f[p.y]) { @win << '(_)' }
77
+ @win.attrset(f[p.y - 1])
78
+ @win.mvaddstr(top_pad + p.y - 1, left_pad + p.x + 1, ?_)
79
+ @win.attrset(f[p.y])
80
+ @win.mvaddstr(top_pad + p.y, left_pad + p.x, '(_)')
83
81
  end
84
82
 
85
83
  return unless draw_signature
@@ -88,9 +86,10 @@ module Ektoplayer
88
86
  left_pad = w_center - (EKTOPLAZM_SIGNATURE.max.size / 2)
89
87
 
90
88
  EKTOPLAZM_SIGNATURE.each_with_index do |line, i|
91
- @win.setpos(top_pad + i, left_pad)
89
+ @win.move(top_pad + i, left_pad)
92
90
  @signature_fade.fade2(line.size).each_with_index do |color,y|
93
- @win.with_attr(color) { @win << line[y] }
91
+ @win.attrset(color)
92
+ @win.addstr(line[y])
94
93
  end
95
94
  end
96
95
  end
@@ -31,19 +31,20 @@ module Ektoplayer
31
31
  self.pad_size=(@size.update(height: 1))
32
32
  mouse_section.clear
33
33
  @win.erase
34
- @win.setpos(0,0)
34
+ @win.move(0,0)
35
35
 
36
36
  @tabs.each_with_index do |title, i|
37
37
  mevent = with_mouse_section_event do
38
38
  if i == @selected
39
- @win.with_attr(Theme[:'tabbar.selected']) { @win << title.to_s }
39
+ @win.attrset(Theme[:'tabbar.selected'])
40
40
  else
41
- @win.with_attr(Theme[:'tabbar.unselected']) { @win << title.to_s }
41
+ @win.attrset(Theme[:'tabbar.unselected'])
42
42
  end
43
43
 
44
- @win.addch(' ')
44
+ @win << title.to_s
45
+ @win.addch(32) # ' '
45
46
  end
46
- mevent.on(Curses::BUTTON1_CLICKED) do
47
+ mevent.on(ICurses::BUTTON1_CLICKED) do
47
48
  trigger(@events, :tab_clicked, i)
48
49
  end
49
50
  end
@@ -90,31 +90,38 @@ module Ektoplayer
90
90
  end
91
91
  end
92
92
 
93
- def render(scr, item, index, selected: false, marked: false)
93
+ def render(scr, item, index, selected: false, marked: false, selection: false)
94
94
  fail ArgumentError, 'item is nil' unless item
95
95
  return unless @column_format
96
96
 
97
97
  additional_attributes = 0
98
- additional_attributes |= Curses::A_BOLD if marked
99
- additional_attributes |= Curses::A_STANDOUT if selected
98
+ additional_attributes |= ICurses::A_BOLD if marked
99
+ additional_attributes |= ICurses::A_STANDOUT if selected
100
100
 
101
101
  if item.is_a? String or item.is_a? Symbol
102
- if index % 2 == 0
102
+ if selection
103
+ color = Theme[:'list.item_selection']
104
+ elsif index % 2 == 0
103
105
  color = Theme[:'list.item_even']
104
106
  else
105
107
  color = Theme[:'list.item_odd']
106
108
  end
107
109
 
108
- scr.with_attr(color | additional_attributes) do
109
- scr << "[#{item}]".ljust(@width)
110
- end
110
+ scr.attrset(color | additional_attributes)
111
+ scr.addstr("[#{item}]".ljust(@width))
111
112
  return
112
113
  end
113
114
 
114
115
  @column_format.each_with_index do |c,i|
115
- scr.with_attr(c[:curses_codes] | additional_attributes) do
116
- value = (item[c[:tag]] or '')
116
+ scr.addch(32) if i > 0
117
+
118
+ if selection
119
+ scr.attrset(Theme[:'list.item_selection'] | additional_attributes)
120
+ else
121
+ scr.attrset(c[:curses_codes] | additional_attributes)
122
+ end
117
123
 
124
+ if value = item[c[:tag]]
118
125
  if value.is_a?(Integer)
119
126
  value = "%.2d" % value
120
127
  else
@@ -122,13 +129,12 @@ module Ektoplayer
122
129
  end
123
130
 
124
131
  if c[:justify] == :right
125
- value = value.rjust(c[:render_size])
132
+ scr.addstr(value.rjust(c[:render_size]))
126
133
  else
127
- value = value.ljust(c[:render_size])
134
+ scr.addstr(value.ljust(c[:render_size]))
128
135
  end
129
-
130
- scr.addstr(value)
131
- scr.addstr(' ') if i < (@column_format.size - 1)
136
+ else
137
+ scr.addstr(' ' * c[:render_size])
132
138
  end
133
139
  end
134
140
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ektoplayer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Abendroth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-21 00:00:00.000000000 Z
11
+ date: 2017-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: audite
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.4'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '0.4'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: sqlite3
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +24,6 @@ dependencies:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
26
  version: '1.3'
41
- - !ruby/object:Gem::Dependency
42
- name: curses
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.0'
55
27
  - !ruby/object:Gem::Dependency
56
28
  name: nokogiri
57
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +38,6 @@ dependencies:
66
38
  - - "~>"
67
39
  - !ruby/object:Gem::Version
68
40
  version: '1.7'
69
- - !ruby/object:Gem::Dependency
70
- name: rubyzip
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.2'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.2'
83
41
  description: Ektoplayer is a commandline client for http://ektoplazm.com, a website
84
42
  providing free electronic music such as techno, goa and psy-trance
85
43
  email: braph93@gmx.de
@@ -107,6 +65,13 @@ files:
107
65
  - lib/ektoplayer/controllers/playlist.rb
108
66
  - lib/ektoplayer/database.rb
109
67
  - lib/ektoplayer/events.rb
68
+ - lib/ektoplayer/icurses.rb
69
+ - lib/ektoplayer/icurses/curses.rb
70
+ - lib/ektoplayer/icurses/ffi_ncurses.rb
71
+ - lib/ektoplayer/icurses/ncurses.rb
72
+ - lib/ektoplayer/icurses/ncursesw.rb
73
+ - lib/ektoplayer/icurses/sugar.rb
74
+ - lib/ektoplayer/icurses/test.rb
110
75
  - lib/ektoplayer/models/browser.rb
111
76
  - lib/ektoplayer/models/database.rb
112
77
  - lib/ektoplayer/models/model.rb
@@ -114,11 +79,12 @@ files:
114
79
  - lib/ektoplayer/models/playlist.rb
115
80
  - lib/ektoplayer/models/search.rb
116
81
  - lib/ektoplayer/models/trackloader.rb
117
- - lib/ektoplayer/mp3player.rb
118
82
  - lib/ektoplayer/operations/browser.rb
119
83
  - lib/ektoplayer/operations/operations.rb
120
84
  - lib/ektoplayer/operations/player.rb
121
85
  - lib/ektoplayer/operations/playlist.rb
86
+ - lib/ektoplayer/players/mpg_portaudio_player.rb
87
+ - lib/ektoplayer/players/mpg_wrapper_player.rb
122
88
  - lib/ektoplayer/theme.rb
123
89
  - lib/ektoplayer/trackloader.rb
124
90
  - lib/ektoplayer/ui.rb
@@ -138,7 +104,6 @@ files:
138
104
  - lib/ektoplayer/views/splash.rb
139
105
  - lib/ektoplayer/views/tabbar.rb
140
106
  - lib/ektoplayer/views/trackrenderer.rb
141
- - lib/ektoplayer/views/volumemeter.rb
142
107
  homepage: http://github.com/braph/ektoplayer
143
108
  licenses:
144
109
  - GPL-3.0
@@ -157,7 +122,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
122
  - - ">="
158
123
  - !ruby/object:Gem::Version
159
124
  version: '0'
160
- requirements: []
125
+ requirements:
126
+ - 'For playback: /bin/mpg123 or the "audite-lib" RubyGem'
127
+ - 'For archive extracting: /bin/unzip, /bin/7z or "rubyzip" RubyGem'
128
+ - 'One of the following curses-gems: ffi-ncurses, curses'
161
129
  rubyforge_project:
162
130
  rubygems_version: 2.6.8
163
131
  signing_key: