commit a9df2f072cee0e970ad2402544291f7705b6999a
parent 109b5007042374477c677e90cd778098fff49da1
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date: Sun, 10 Sep 2006 22:35:52 -0700
[project @ 9ff6be3f65ab5f6c5500baed3f13823d49cc637d]
[project @ 54]
add shortcut for moving selection to _i_th area
fix Area#setup_for_insertion is more robust
fix Client#index now correctly accesses self[:index]
fix Container#indices is now array of ints
Diffstat:
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/wm.rb b/wm.rb
@@ -207,7 +207,7 @@ class Wmii < IxpNode
# Returns a list of indices of items in this region.
def indices
if list = self.read
- list.grep(/^\d+$/)
+ list.grep(/^\d+$/).map {|s| s.to_i}
else
[]
end
@@ -253,6 +253,8 @@ class Wmii < IxpNode
super Area, IxpNode, *aArgs
end
+ undef index
+
TAG_DELIMITER = "+"
# Returns the tags associated with this client.
@@ -308,9 +310,6 @@ class Wmii < IxpNode
# Inserts the given clients at the bottom of this area.
def push! *aClients
- aClients.flatten!
- return if aClients.empty?
-
unless (list = clients).empty?
list.last.focus!
end
@@ -356,13 +355,20 @@ class Wmii < IxpNode
# Sets up this area for insertion and returns the area ID into which insertion is performed.
def setup_for_insertion aFirstClient
dstIdx = self.index
- maxIdx = parent.indices.length - 1
+ maxIdx = parent.indices.last
if dstIdx > maxIdx
aFirstClient.ctl = "sendto #{maxIdx}"
+ maxIdx = parent.indices.last # recalculate b/c sendto can be destructive
+
+ maxCol = parent[maxIdx]
- parent[maxIdx].sel.ctl = "sendto next"
- dstIdx = maxIdx.next
+ if maxCol.indices.length > 1
+ maxCol.sel.ctl = "sendto next"
+ dstIdx = maxIdx + 1
+ else
+ dstIdx = maxIdx
+ end
else
aFirstClient.ctl = "sendto #{dstIdx}"
end
diff --git a/wmiirc b/wmiirc
@@ -346,6 +346,15 @@ SHORTCUTS = {
end
end
+ # send selection to _i_th area
+ SHORTCUTS["#{SEND}Shift-#{i}"] = lambda do
+ dst = WM.focused_view[i]
+
+ WM.with_selection do |c|
+ dst.insert! c
+ end
+ end
+
# apply grid layout with _i_ clients per column
SHORTCUTS["#{LAYOUT}#{i}"] = lambda do
WM.focused_view.grid! i