wmiirc-rumai

git clone git://oldgit.suckless.org/wmiirc-rumai/
Log | Files | Refs | README | LICENSE

commit d1be34f62c14c63615e046ecd0000c00b7b21bd4
parent 2926120f9e2a08e0bab54cb42fd179f786e51b03
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date:   Sun, 10 Sep 2006 04:26:39 -0700

[project @ 7ef6c51c8036e66cecae014f13c628092c9a1dce]

[project @ 43]
sub current_* focused_*

Diffstat:
Wmii.rb | 32+++++++++++++++++---------------
wmiirc | 69++++++++++++++++++++++++++++++++-------------------------------------
2 files changed, 49 insertions(+), 52 deletions(-)

diff --git a/Wmii.rb b/Wmii.rb @@ -35,17 +35,17 @@ class Wmii < IxpNode ## access to WM state # Returns the currently focused client. - def current_client + def focused_client Client.new("/view/sel/sel") end # Returns the currently focused area. - def current_area + def focused_area Area.new("/view/sel") end # Returns the currently focused view. - def current_view + def focused_view View.new("/view") end @@ -89,10 +89,10 @@ class Wmii < IxpNode end end - # Changes the current view to an adjacent one (:left or :right). + # Changes the currently focused view to an adjacent one (:left or :right). def cycle_view aTarget tags = self.tags - curTag = current_view.name + curTag = focused_view.name curIndex = tags.index(curTag) newIndex = @@ -114,15 +114,15 @@ class Wmii < IxpNode ## Multiple client selection - # Returns a list of all selected clients in the current view. If there are no selected clients, then the currently focused client is returned in the list. + # Returns a list of all selected clients in the currently focused view. If there are no selected clients, then the currently focused client is returned in the list. def selected_clients - list = current_view.areas.map do |a| + list = focused_view.areas.map do |a| a.clients.select {|c| c.selected?} end list.flatten! if list.empty? - list << current_client + list << focused_client end list @@ -136,16 +136,18 @@ class Wmii < IxpNode ## wmii-2 style client detaching - # Detach the currently selected client - def detach_current_client - current_client.tags = DETACHED_TAG + # Detach the current selection. + def detach_selection + selected_clients.each do |c| + c.tags = DETACHED_TAG + end end # Attach the most recently detached client def attach_last_client if a = View.new("/#{DETACHED_TAG}").areas.first if c = a.clients.first - c.tags = current_view.name + c.tags = focused_view.name end end end @@ -285,7 +287,7 @@ class Wmii < IxpNode self.tags = t end - # Returns true if this client is included in the selection. + # Checks if this client is included in the current selection. def selected? tags.include? SELECTION_TAG end @@ -388,7 +390,7 @@ class Wmii < IxpNode alias areas children # Applies wmii-2 style tiling layout to this view while maintaining its order of clients. Only the first client in the primary column is kept; all others are evicted to the *top* of the secondary column. Any subsequent columns are squeezed into the *bottom* of the secondary column. - def apply_tile_layout + def tile! numAreas = self.indices.length if numAreas > 1 @@ -412,7 +414,7 @@ class Wmii < IxpNode end # Applies wmii-2 style grid layout to this view while maintaining its order of clients. If the maximum number of clients per column, the distribution of clients among the columns is calculated according to wmii-2 style. Only the first client in the primary column is kept; all others are evicted to the *top* of the secondary column. Any teritiary, quaternary, etc. columns are squeezed into the *bottom* of the secondary column. - def apply_grid_layout aMaxClientsPerColumn = nil + def grid! aMaxClientsPerColumn = nil # determine client distribution unless aMaxClientsPerColumn numClients = self.areas[1..-1].inject(0) do |count, area| diff --git a/wmiirc b/wmiirc @@ -114,66 +114,66 @@ SHORTCUTS = { # focus previous area "#{FOCUS}#{LEFT}" => lambda do - WM.current_view.ctl = 'select prev' + WM.focused_view.ctl = 'select prev' end, # focus next area "#{FOCUS}#{RIGHT}" => lambda do - WM.current_view.ctl = 'select next' + WM.focused_view.ctl = 'select next' end, # focus floating area "#{FOCUS}space" => lambda do - WM.current_view.ctl = 'select toggle' + WM.focused_view.ctl = 'select toggle' end, # focus previous client "#{FOCUS}#{UP}" => lambda do - WM.current_area.ctl = 'select prev' + WM.focused_area.ctl = 'select prev' end, # focus next client "#{FOCUS}#{DOWN}" => lambda do - WM.current_area.ctl = 'select next' + WM.focused_area.ctl = 'select next' end, "#{LAYOUT}w" => lambda do - WM.current_area.mode = 'default' + WM.focused_area.mode = 'default' end, "#{LAYOUT}v" => lambda do - WM.current_area.mode = 'stack' + WM.focused_area.mode = 'stack' end, "#{LAYOUT}m" => lambda do - WM.current_area.mode = 'max' + WM.focused_area.mode = 'max' end, "#{LAYOUT}z" => lambda do - WM.current_view[0].foci.geom = '0 0 east south' + WM.focused_view[0].foci.geom = '0 0 east south' end, "#{LAYOUT}t" => lambda do - WM.current_view.apply_tile_layout + WM.focused_view.tile! end, "#{LAYOUT}g" => lambda do - WM.current_view.apply_grid_layout + WM.focused_view.grid! end, "#{GROUP}g" => lambda do - WM.current_client.invert_selection! + WM.focused_client.invert_selection! end, "#{GROUP}a" => lambda do - WM.current_view.select! + WM.focused_view.select! end, "#{GROUP}i" => lambda do - WM.current_view.invert_selection! + WM.focused_view.invert_selection! end, "#{GROUP}n" => lambda do @@ -238,7 +238,7 @@ SHORTCUTS = { end end, - # change the tag of the current client + # change the tag of the currently focused client # +tag -tag idea from Jonas Pfenniger <http://zimbatm.oree.ch/articles/2006/06/15/wmii-3-and-ruby> "#{SEND}t" => lambda do choices = WM.tags.map {|t| [t, "+#{t}", "-#{t}"]}.flatten @@ -261,18 +261,18 @@ SHORTCUTS = { end end, - # remove current view from current selection's tags + # remove currently focused view from current selection's tags "#{SEND}Shift-minus" => lambda do WM.selected_clients.each do |c| c.with_tags do - delete WM.current_view.name + delete WM.focused_view.name end end end, # send to temporary view or switch back again "#{DEFAULT}b" => lambda do - curView = WM.current_view.name + curView = WM.focused_view.name if curView =~ /~\d+$/ WM.selected_clients.each do |c| @@ -294,47 +294,42 @@ SHORTCUTS = { end WM.focus_view tmpView - WM.current_view.apply_grid_layout + WM.focused_view.grid! end end, "#{SEND}d" => lambda do - WM.with_selection do |c| - c.focus! - WM.detach_current_client - end + WM.detach_selection end, "#{SEND}Shift-d" => lambda do - # WM.with_selection do - WM.attach_last_client - # end + WM.attach_last_client end, - # toggle maximizing the current client to full screen + # toggle maximizing the currently focused client to full screen "#{SEND}m" => lambda do SHORTCUTS["#{SEND}space"].call SHORTCUTS["#{LAYOUT}z"].call end, - # swap the current client with the one to its left + # swap the currently focused client with the one to its left "#{SWAP}#{LEFT}" => lambda do - WM.current_client.ctl = 'swap prev' + WM.focused_client.ctl = 'swap prev' end, - # swap the current client with the one to its right + # swap the currently focused client with the one to its right "#{SWAP}#{RIGHT}" => lambda do - WM.current_client.ctl = 'swap next' + WM.focused_client.ctl = 'swap next' end, - # swap the current client with the one below it + # swap the currently focused client with the one below it "#{SWAP}#{DOWN}" => lambda do - WM.current_client.ctl = 'swap down' + WM.focused_client.ctl = 'swap down' end, - # swap the current client with the one above it + # swap the currently focused client with the one above it "#{SWAP}#{UP}" => lambda do - WM.current_client.ctl = 'swap up' + WM.focused_client.ctl = 'swap up' end, } @@ -355,7 +350,7 @@ SHORTCUTS = { # apply grid layout with _i_ clients per column SHORTCUTS["#{LAYOUT}#{i}"] = lambda do - WM.current_view.apply_grid_layout i + WM.focused_view.grid! i end # add _i_th view to current selection's tags @@ -382,7 +377,7 @@ end ('a'..'z').each do |char| SHORTCUTS["#{MENU}v,#{char}"] = lambda do choices = WM.tags - choices.delete WM.current_view.name + choices.delete WM.focused_view.name if view = choices.select {|t| t =~ /^#{char}/i}.first WM.focus_view view