Class: PM::PatchWindow

Inherits:
PmWindow
  • Object
show all
Defined in:
lib/patchmaster/curses/patch_window.rb

Instance Attribute Summary collapse

Attributes inherited from PmWindow

#title, #title_prefix, #win

Instance Method Summary collapse

Methods inherited from PmWindow

#initialize, #make_fit, #move_and_resize, #set_max_contents_len, #visible_height

Constructor Details

This class inherits a constructor from PM::PmWindow

Instance Attribute Details

#patchObject

Returns the value of attribute patch.



6
7
8
# File 'lib/patchmaster/curses/patch_window.rb', line 6

def patch
  @patch
end

Instance Method Details

#drawObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/patchmaster/curses/patch_window.rb', line 14

def draw
  super
  @win.setpos(1, 1)
  draw_headers
  return unless @patch

  @patch.connections[0, visible_height].each_with_index do |connection, i|
    @win.setpos(i+2, 1)
    draw_connection(connection)
  end
end

#draw_connection(connection) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/patchmaster/curses/patch_window.rb', line 34

def draw_connection(connection)
  str =  " #{'%16s' % connection.input.name}"
  str << " #{connection.input_chan ? ('%2d' % (connection.input_chan+1)) : '  '} |"
  str << " #{'%16s' % connection.output.name}"
  str << " #{'%2d' % (connection.output_chan+1)} |"
  str << if connection.pc?
           "  #{'%3d' % connection.pc_prog} |"
         else
           "      |"
         end
  str << if connection.zone
           " #{'%3s' % connection.note_num_to_name(connection.zone.begin)}" +
           " - #{'%3s' % connection.note_num_to_name(connection.zone.end)} |"
         else
           '           |'
         end
  str << if connection.xpose && connection.xpose != 0
           "   #{connection.xpose < 0 ? '' : ' '}#{'%2d' % connection.xpose.to_i} |"
         else
           "       |"
         end
  str << " #{filter_string(connection.filter)}"
  @win.addstr(make_fit(str))
end

#draw_headersObject



26
27
28
29
30
31
32
# File 'lib/patchmaster/curses/patch_window.rb', line 26

def draw_headers
  @win.attron(A_REVERSE) {
    str = " Input          Chan | Output         Chan | Prog | Zone      | Xpose | Filter"
    str << ' ' * (@win.maxx - 2 - str.length)
    @win.addstr(str)
  }
end

#filter_string(filter) ⇒ Object



59
60
61
# File 'lib/patchmaster/curses/patch_window.rb', line 59

def filter_string(filter)
  filter.to_s.gsub(/\s*#.*/, '').gsub(/\n\s*/, "; ")
end