Class: Rumai::Area
- Includes:
- Enumerable, Chain, ClientContainer, WidgetImpl
- Defined in:
- lib/rumai/wm.rb
Overview
A region that contains clients. This can be either the floating area or a column in the managed area.
Instance Attribute Summary collapse
-
#view ⇒ Object
readonly
Returns the value of attribute view.
Attributes included from WidgetImpl
Class Method Summary collapse
-
.curr ⇒ Object
Returns the currently focused area.
-
.floating(view = View.curr) ⇒ Object
Returns the floating area in the given view.
Instance Method Summary collapse
-
#chain ⇒ Object
Returns a list of all areas in the current view.
-
#client_ids ⇒ Object
Returns the IDs of the clients in this area.
-
#column? ⇒ Boolean
(also: #managed?)
Checks if this is a managed area (a column).
-
#concat(area) ⇒ Object
Concatenates the given area to the bottom of this area.
-
#each(&block) ⇒ Object
Iterates through each client in this container.
-
#exist? ⇒ Boolean
Checks if this object exists in the chain.
-
#floating? ⇒ Boolean
Checks if this area is the floating area.
-
#focus ⇒ Object
Puts focus on this area.
-
#initialize(area_id, view = View.curr) ⇒ Area
constructor
A new instance of Area.
-
#insert(*clients) ⇒ Object
Inserts the given clients after the currently focused client in this area.
-
#layout=(mode) ⇒ Object
Sets the layout of clients in this column.
-
#length ⇒ Object
Returns the number of clients in this area.
-
#length=(max_clients) ⇒ Object
Ensures that this area has at most the given number of clients.
-
#push(*clients) ⇒ Object
(also: #<<)
Inserts the given clients at the bottom of this area.
-
#unshift(*clients) ⇒ Object
Inserts the given clients at the top of this area.
Methods included from ClientContainer
Methods included from Chain
Methods included from WidgetImpl
Constructor Details
Instance Attribute Details
#view ⇒ Object (readonly)
Returns the value of attribute view.
520 521 522 |
# File 'lib/rumai/wm.rb', line 520 def view @view end |
Class Method Details
.curr ⇒ Object
Returns the currently focused area.
554 555 556 |
# File 'lib/rumai/wm.rb', line 554 def self.curr View.curr.area_of_client Client.curr end |
.floating(view = View.curr) ⇒ Object
Returns the floating area in the given view.
561 562 563 |
# File 'lib/rumai/wm.rb', line 561 def self.floating view = View.curr new FLOATING_AREA_ID, view end |
Instance Method Details
#chain ⇒ Object
Returns a list of all areas in the current view.
572 573 574 |
# File 'lib/rumai/wm.rb', line 572 def chain @view.areas end |
#client_ids ⇒ Object
Returns the IDs of the clients in this area.
590 591 592 |
# File 'lib/rumai/wm.rb', line 590 def client_ids @view.client_ids @id end |
#column? ⇒ Boolean Also known as: managed?
Checks if this is a managed area (a column).
541 542 543 |
# File 'lib/rumai/wm.rb', line 541 def column? not floating? end |
#concat(area) ⇒ Object
Concatenates the given area to the bottom of this area.
686 687 688 |
# File 'lib/rumai/wm.rb', line 686 def concat area push *area.clients end |
#each(&block) ⇒ Object
Iterates through each client in this container.
601 602 603 |
# File 'lib/rumai/wm.rb', line 601 def each &block clients.each(&block) end |
#exist? ⇒ Boolean
Checks if this object exists in the chain.
579 580 581 |
# File 'lib/rumai/wm.rb', line 579 def exist? chain.include? self end |
#floating? ⇒ Boolean
Checks if this area is the floating area.
534 535 536 |
# File 'lib/rumai/wm.rb', line 534 def floating? @id == FLOATING_AREA_ID end |
#focus ⇒ Object
Puts focus on this area.
612 613 614 |
# File 'lib/rumai/wm.rb', line 612 def focus @view.ctl.write "select #{@id}" end |
#insert(*clients) ⇒ Object
Inserts the given clients after the currently focused client in this area.
661 662 663 664 665 |
# File 'lib/rumai/wm.rb', line 661 def insert *clients clients.each do |c| import_client c end end |
#layout=(mode) ⇒ Object
Sets the layout of clients in this column.
619 620 621 622 623 624 625 626 |
# File 'lib/rumai/wm.rb', line 619 def layout= mode case mode when :stack then mode = 'stack-max' when :max then mode = 'stack+max' end @view.ctl.write "colmode #{@id} #{mode}" end |
#length ⇒ Object
Returns the number of clients in this area.
635 636 637 |
# File 'lib/rumai/wm.rb', line 635 def length client_ids.length end |
#length=(max_clients) ⇒ Object
Ensures that this area has at most the given number of clients.
Areas to the right of this one serve as a buffer into which excess clients are evicted and from which deficit clients are imported.
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 |
# File 'lib/rumai/wm.rb', line 696 def length= max_clients return unless max_clients > 0 len, out = length, fringe if len > max_clients out.unshift *clients[max_clients..-1] elsif len < max_clients until (diff = max_clients - length) == 0 importable = out.clients[0, diff] break if importable.empty? push *importable end end end |
#push(*clients) ⇒ Object Also known as: <<
Inserts the given clients at the bottom of this area.
642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/rumai/wm.rb', line 642 def push *clients return if clients.empty? insert *clients # move inserted clients to bottom clients.reverse.each_with_index do |c, i| until c.id == self.client_ids[-i.succ] c.send :down end end end |
#unshift(*clients) ⇒ Object
Inserts the given clients at the top of this area.
670 671 672 673 674 675 676 677 678 679 680 681 |
# File 'lib/rumai/wm.rb', line 670 def unshift *clients return if clients.empty? insert *clients # move inserted clients to top clients.each_with_index do |c, i| until c.id == self.client_ids[i] c.send :up end end end |