commit a2b7c225c5b8d0a388f683934bb563bc5ffd2cc5
parent a7a489a6e122d09a0bf6c9e95ee5deb6681d5674
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date: Mon, 11 Sep 2006 01:30:51 -0700
[project @ f57d995fe7c089eade1fc7c9d7bd38a44c4e9a8c]
[project @ 57]
add IxpNode#{basename,dirname}
up swapping left & right no longer operates on group
fix Area#setup_for_insertion! now updates its path... so moving to bogus columns now works for all selection
Diffstat:
fs.rb | | | 8 | ++++++++ |
wm.rb | | | 28 | ++++++++++++++++------------ |
wmiirc | | | 12 | ++++-------- |
3 files changed, 28 insertions(+), 20 deletions(-)
diff --git a/fs.rb b/fs.rb
@@ -136,6 +136,14 @@ class IxpNode
IxpFs.exist? @path
end
+ def basename
+ File.basename @path
+ end
+
+ def dirname
+ File.dirname @path
+ end
+
# Accesses the given sub-path.
def [] aSubPath
child = IxpNode.new("#{@path}/#{aSubPath}")
diff --git a/wm.rb b/wm.rb
@@ -157,7 +157,7 @@ class Wmii < IxpNode
selected_clients.each do |c|
# resolve stale paths caused by destructive operations
unless c.exist?
- c = find_client(File.basename(c.path), curView)
+ c = find_client(c.basename, curView)
c || next # skip upon failure
end
@@ -213,7 +213,7 @@ class Wmii < IxpNode
# Returns the index of this region in the parent.
def index
- File.basename(@path).to_i
+ basename.to_i
end
# Returns the next region in the parent.
@@ -259,7 +259,7 @@ class Wmii < IxpNode
# Puts focus on this region.
def focus!
['select', 'view'].each do |cmd|
- parent.ctl = "#{cmd} #{File.basename @path}"
+ parent.ctl = "#{cmd} #{basename}"
end
end
end
@@ -339,10 +339,11 @@ class Wmii < IxpNode
aClients.flatten!
return if aClients.empty?
- dstIdx = setup_for_insertion(aClients.shift)
+ setup_for_insertion! aClients.shift
+ dst = self.index
aClients.each do |c|
- c.ctl = "sendto #{dstIdx}"
+ c.ctl = "sendto #{dst}"
end
end
@@ -355,11 +356,12 @@ class Wmii < IxpNode
list.first.focus!
end
- dstIdx = setup_for_insertion(aClients.shift)
- parent[dstIdx].sel.ctl = 'swap up'
+ setup_for_insertion! aClients.shift
+ parent.sel.ctl = 'swap up'
+ dst = self.index
aClients.each do |c|
- c.ctl = "sendto #{dstIdx}"
+ c.ctl = "sendto #{dst}"
end
end
@@ -369,8 +371,8 @@ class Wmii < IxpNode
end
private
- # Sets up this area for insertion and returns the area ID into which insertion is performed.
- def setup_for_insertion aFirstClient
+ # Updates the path of this area for proper insertion and inserts the given client.
+ def setup_for_insertion! aFirstClient
dstIdx = self.index
maxIdx = parent.indices.last
@@ -386,11 +388,13 @@ class Wmii < IxpNode
else
dstIdx = maxIdx
end
+
+ @path = "#{dirname}/#{dstIdx}"
+
else
aFirstClient.ctl = "sendto #{dstIdx}"
- end
- dstIdx
+ end
end
end
diff --git a/wmiirc b/wmiirc
@@ -302,18 +302,14 @@ SHORTCUTS = {
SHORTCUTS["#{LAYOUT}z"].call
end,
- # swap each selected client with the one to its left
+ # swap the currently focused client with the one to its left
"#{SWAP}#{LEFT}" => lambda do
- WM.with_selection do |c|
- c.ctl = 'swap prev'
- end
+ WM.focused_client.ctl = 'swap prev'
end,
- # swap each selected client with the one to its right
+ # swap the currently focused client with the one to its right
"#{SWAP}#{RIGHT}" => lambda do
- WM.with_selection do |c|
- c.ctl = 'swap next'
- end
+ WM.focused_client.ctl = 'swap next'
end,
# swap each selected client with the one below it