commit 1248b5c46cb2803f9293cc410ff6afc7b9cf7d59
parent 201e919dd25bd8d6f72597f200f7b0629a51034d
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date: Thu, 31 Aug 2006 05:19:55 -0700
[project @ f251f61b16a9b288c99598f2e21364fb4618a773]
[project @ 19]
fix BarClick handling
add #{MENU}v,alphabet shortcut for alpabetic view selection
Diffstat:
| status | | | 4 | ++-- |
| wmii.rb | | | 40 | +++++++++++++++++++--------------------- |
| wmiirc | | | 23 | +++++++++++++++++------ |
3 files changed, 38 insertions(+), 29 deletions(-)
diff --git a/status b/status
@@ -8,8 +8,8 @@ DELAY = 1
WM = Wmii.instance
-system('wmiir remove /bar/status') && sleep(DELAY * 2)
-system 'wmiir create /bar/status'
+WM.remove '/bar/status'
+WM.create '/bar/status'
WM.write '/bar/status/colors', ENV['WMII_NORMCOLORS']
while WM.write('/bar/status/data', Time.now.to_s << " " << `uptime`.scan(/\d+\.\d+/).join(' '))
diff --git a/wmii.rb b/wmii.rb
@@ -67,18 +67,16 @@ class Wmii
# 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.
def selected_clients
- clientList = current_view.areas.map do |a|
- a.clients.select do |c|
- c.tags.include? SELECTION_TAG
- end
+ list = current_view.areas.map do |a|
+ a.clients.select do |c| c.selected? end
end
- clientList.flatten!
+ list.flatten!
- if clientList.empty?
- clientList << current_client
+ if list.empty?
+ list << current_client
end
- clientList
+ list
end
# Creates the given WM path.
@@ -323,14 +321,18 @@ class Wmii
def initialize aWmii, aPath
@wm = aWmii
@path = aPath
- @subordinate = nil
+ @subordinateClass = nil
end
- def method_missing aMeth
- if content = @wm.read("#{@path}/#{aMeth}")
- content
+ def method_missing aMeth, *aArgs
+ if aMeth.to_s =~ /=$/
+ @wm.write "#{@path}/#{$`}", *aArgs
else
- super
+ if content = @wm.read("#{@path}/#{aMeth}")
+ content
+ else
+ super
+ end
end
end
end
@@ -347,17 +349,13 @@ class Wmii
end
def subordinates
- if @subordinate
- indices.map {|i| @subordinate.new @wm, "#{@path}/#{i}"}
+ if @subordinateClass
+ indices.map {|i| @subordinateClass.new @wm, "#{@path}/#{i}"}
else
[]
end
end
- def control aCommand
- @wm.write "#{@path}/ctl", aCommand
- end
-
def select!
subordinates.each do |s|
s.select!
@@ -431,7 +429,7 @@ class Wmii
class Area < Container
def initialize *args
super
- @subordinate = Client
+ @subordinateClass = Client
end
alias clients subordinates
@@ -441,7 +439,7 @@ class Wmii
class View < Container
def initialize *args
super
- @subordinate = Area
+ @subordinateClass = Area
end
alias areas subordinates
diff --git a/wmiirc b/wmiirc
@@ -168,7 +168,9 @@ SHORTCUTS = {
system(program << '&') unless program.empty?
end,
- "#{MENU}v" => lambda do WM.focus_view(WM.show_menu(WM.read('/tags'))) end,
+ "#{MENU}Shift-v" => lambda do
+ WM.focus_view(WM.show_menu(WM.read('/tags')))
+ end,
# focus any client by choosing from a menu
"#{MENU}a" => lambda do
@@ -197,25 +199,25 @@ SHORTCUTS = {
"#{SEND}#{LEFT}" => lambda do
WM.selected_clients.each do |c|
- c.control 'sendto prev'
+ c.ctl = 'sendto prev'
end
end,
"#{SEND}#{RIGHT}" => lambda do
WM.selected_clients.each do |c|
- c.control 'sendto next'
+ c.ctl = 'sendto next'
end
end,
"#{SEND}space" => lambda do
WM.selected_clients.each do |c|
- c.control 'sendto toggle'
+ c.ctl = 'sendto toggle'
end
end,
"#{SEND}Delete" => lambda do
WM.selected_clients.each do |c|
- c.control 'kill'
+ c.ctl = 'kill'
end
end,
@@ -325,6 +327,14 @@ SHORTCUTS = {
end
end
+ ('a'..'z').each do |char|
+ SHORTCUTS["#{MENU}v,#{char}"] = lambda do
+ if view = WM.tags.select {|t| t =~ /^#{char}/i}.first
+ WM.focus_view view
+ end
+ end
+ end
+
WM.write '/def/grabmod', MODKEY
WM.write '/def/keys', SHORTCUTS.keys.join("\n")
@@ -342,7 +352,8 @@ begin
exit if arg == 'wmiirc'
when 'BarClick'
- WM.focus_view arg
+ view, button = arg.split
+ WM.focus_view view
when 'ClientClick'
client, button = arg.split