wmiirc-rumai

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

commit dde942fa2ee3cf0411d4d7e4513b07b577b36f67
parent c03e7cadea6c2081bb10f212cf5b28f255799171
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date:   Sun, 24 Sep 2006 02:48:56 -0700

[project @ 71f2c950ed13a754a78f0783fe251e9b77fed472]

[project @ 129]
* When selecting views based on their first letter: if more than one view matches, then they are cycled (adapted from Fredrik Ternerot).

Diffstat:
HISTORY | 2++
wmiirc | 2+-
wmiirc-config.rb | 23+++++++++++++++--------
3 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/HISTORY b/HISTORY @@ -6,6 +6,8 @@ This is a history of major changes to {my wmii configuration}[http://people.ucsc * Fixed event & status bar loop. It was forgotten when I transitioned to the new Ixp::Node#method_missing behavior on 2006-09-22. * Thanks to Fredrik Ternerot for reporting this bug. +* When selecting views based on their first letter: if more than one view matches, then they are cycled (adapted from Fredrik Ternerot). + = 2006-09-22 diff --git a/wmiirc b/wmiirc @@ -24,7 +24,7 @@ require 'logger' def throw_life_saver aError system 'xterm &' - IO.popen('xmessage -file - -buttons recover:0,ignore:1', 'w') do |f| + IO.popen('xmessage -file - -buttons "recover from error:0,ignore this message:1"', 'w') do |f| f.puts aError.inspect, aError.backtrace end diff --git a/wmiirc-config.rb b/wmiirc-config.rb @@ -274,11 +274,13 @@ SHORTCUTS = { end, "#{SEND_SEQ}Delete" => lambda do - # reverse b/c client indices are reassigned upon deletion. + # reverse because client indices are reassigned upon deletion. # ex: imagine you have these clients: [1, 2, 3] # you delete the second client (id 2). # now, wmii reorders the remaining clients [1, 3] as: [1, 2] - # that is why we must go in reverse! + # you delete the third client (id 3) + # and, due to reordering, nothing happens! + # that is why we must go in reverse. Wmii.selected_clients.sort_by do |c| c.index.to_i end.reverse.each do |c| @@ -390,14 +392,19 @@ SHORTCUTS = { end end -# jump to view whose name begins with the pressed key +# jump to view whose name begins with the pressed key. +# if more than one view matches, then they are cycled (adapted from Fredrik Ternerot). ('a'..'z').each do |key| SHORTCUTS["#{MENU_SEQ}v,#{key}"] = lambda do - choices = Wmii.tags - choices.delete Wmii.current_view.name - - if view = choices.select {|t| t =~ /^#{key}/i}.first - Wmii.focus_view view + choices = Wmii.tags.select {|t| t =~ /^#{key}/i} + + unless choices.empty? + if curIdx = choices.index(Wmii.current_view.name) + maxIdx = choices.length + Wmii.focus_view choices[(curIdx + 1) % maxIdx] + else + Wmii.focus_view choices.first + end end end end