Skip to content
This repository has been archived by the owner on Dec 30, 2018. It is now read-only.

Commit

Permalink
support newer list-windows format
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikh committed Nov 25, 2012
1 parent 34f1a7c commit 5597c01
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/tmux/session.rb
Expand Up @@ -65,6 +65,8 @@ def create_window(args = {})
# @see Client#current_window
# @return (see Client#current_window)
def current_window
# TODO figure out when tmux added "(active)" in list-windows and
# use that when possible
any_client.current_window
end

Expand Down Expand Up @@ -229,14 +231,16 @@ def windows_information(search = {})
hash = {}
output = @server.invoke_command "list-windows -t #{identifier}"
output.each_line do |session|
params = session.match(/^(?<num>\d+): (?<name>.+?) \[(?<width>\d+)x(?<height>\d+)\]$/)
# TODO make use of the layout information
params = session.match(/^(?<num>\d+): (?<name>.+?) \[(?<width>\d+)x(?<height>\d+)\](?: \[layout .+?\])?(?<active> \(active\))?$/)
next if params.nil? # >=1.3 displays layout information in indented lines
num = params[:num].to_i
name = params[:name]
width = params[:width].to_i
height = params[:height].to_i
active = !params[:active].nil?

hash[num] = {:num => num, :name => name, :width => width, :height => height}
hash[num] = {:num => num, :name => name, :width => width, :height => height, :active => active}
end
hash.extend FilterableHash
hash.filter(search)
Expand Down

0 comments on commit 5597c01

Please sign in to comment.