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
- view
-
the view object which contains this 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.
491 492 493 |
# File 'lib/rumai/wm.rb', line 491 def view @view end |
Class Method Details
.curr ⇒ Object
Returns the currently focused area.
522 523 524 |
# File 'lib/rumai/wm.rb', line 522 def self.curr View.curr.area_of_client Client.curr end |
.floating(view = View.curr) ⇒ Object
Returns the floating area in the given view.
529 530 531 |
# File 'lib/rumai/wm.rb', line 529 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.
538 539 540 |
# File 'lib/rumai/wm.rb', line 538 def chain @view.areas end |
#client_ids ⇒ Object
Returns the IDs of the clients in this area.
554 555 556 |
# File 'lib/rumai/wm.rb', line 554 def client_ids @view.client_ids @id end |
#column? ⇒ Boolean Also known as: managed?
Checks if this is a managed area (a column).
511 512 513 |
# File 'lib/rumai/wm.rb', line 511 def column? not floating? end |
#concat(area) ⇒ Object
Concatenates the given area to the bottom of this area.
653 654 655 |
# File 'lib/rumai/wm.rb', line 653 def concat area push area.clients end |
#each(&block) ⇒ Object
Iterates through each client in this container.
563 564 565 |
# File 'lib/rumai/wm.rb', line 563 def each &block clients.each(&block) end |
#exist? ⇒ Boolean
Checks if this object exists in the chain.
545 546 547 |
# File 'lib/rumai/wm.rb', line 545 def exist? chain.include? self end |
#floating? ⇒ Boolean
Checks if this area is the floating area.
504 505 506 |
# File 'lib/rumai/wm.rb', line 504 def floating? @id == FLOATING_AREA_ID end |
#focus ⇒ Object
Puts focus on this area.
586 587 588 |
# File 'lib/rumai/wm.rb', line 586 def focus @view.ctl.write "select #{@id}" end |
#insert(*clients) ⇒ Object
Inserts the given clients after the currently focused client in this area.
624 625 626 627 628 629 630 631 |
# File 'lib/rumai/wm.rb', line 624 def insert *clients clients.flatten! return if clients.empty? clients.each do |c| import_client c end end |
#layout=(mode) ⇒ Object
Sets the layout of clients in this column.
570 571 572 573 574 575 576 577 |
# File 'lib/rumai/wm.rb', line 570 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.
597 598 599 |
# File 'lib/rumai/wm.rb', line 597 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.
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 |
# File 'lib/rumai/wm.rb', line 663 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.
604 605 606 607 608 609 610 611 612 613 614 615 616 |
# File 'lib/rumai/wm.rb', line 604 def push *clients clients.flatten! 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.
636 637 638 639 640 641 642 643 644 645 646 647 648 |
# File 'lib/rumai/wm.rb', line 636 def unshift *clients clients.flatten! 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 |