Class: Rumai::View
- Inherits:
-
WidgetNode
- Object
- Node
- WidgetNode
- Rumai::View
- Includes:
- Enumerable, Chain, ClientContainer, WidgetImpl
- Defined in:
- lib/rumai/wm.rb
Overview
The visualization of a tag.
Instance Attribute Summary
Attributes included from WidgetImpl
Attributes inherited from Node
Class Method Summary (collapse)
-
+ (Object) curr
Returns the currently focused view.
Instance Method Summary (collapse)
-
- (Object) area_ids
Returns the IDs of all areas in this view.
-
- (Object) area_of_client(client_or_id)
Returns the area which contains the given client in this view.
-
- (Object) areas
Returns all areas in this view.
-
- (Object) arrange_columns(lengths, layout = nil)
Applies the given length to each column in sequence.
-
- (Object) chain
Returns a list of all views.
-
- (Object) client_ids(area_id = '\S+')
Returns the IDs of the clients contained in the given area within this view.
-
- (Object) columns
(also: #managed_areas)
Returns all columns (managed areas) in this view.
-
- (Object) each(&block)
Iterates through each area in this view.
-
- (Object) each_column(starting_column_id = 1)
(also: #each_managed_area)
Resiliently iterates through possibly destructive changes to each column.
-
- (Object) floating_area
Returns the floating area of this view.
-
- (Object) focus
Focuses this view.
-
- (Object) grid(max_clients_per_column = nil)
(also: #arrange_in_grid)
Arranges the clients in this view, while maintaining their relative order, in (at best) a square grid.
-
- (View) initialize(view_id)
constructor
A new instance of View.
-
- (Object) manifest
Returns the manifest of all areas and clients in this view.
-
- (Object) select(direction)
Moves the focus from the current client in the given direction.
-
- (Object) stack(num_columns = 2)
(also: #arrange_in_stacks)
Arranges the clients in this view, while maintaining their relative order, in the given number of columns.
-
- (Object) tile_inward
(also: #arrange_in_diamond)
Arranges columns with the following number of clients in them:.
-
- (Object) tile_left
Arranges columns with the following number of clients in them:.
-
- (Object) tile_leftward
Arranges columns with the following number of clients in them:.
-
- (Object) tile_outward
Arranges columns with the following number of clients in them:.
-
- (Object) tile_right
(also: #arrange_as_larswm)
Arranges columns with the following number of clients in them:.
-
- (Object) tile_rightward
Arranges columns with the following number of clients in them:.
Methods included from ClientContainer
Methods included from Chain
near, #next, next, prev, #prev
Methods included from WidgetImpl
Methods inherited from Node
#[], #children, #clear, #create, #directory?, #each_line, #entries, #exist?, #method_missing, #open, #parent, #read, #remove, #stat, #write
Constructor Details
- (View) initialize(view_id)
A new instance of View
765 766 767 |
# File 'lib/rumai/wm.rb', line 765 def initialize view_id super view_id, '/tag' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rumai::Node
Class Method Details
+ (Object) curr
Returns the currently focused view.
776 777 778 |
# File 'lib/rumai/wm.rb', line 776 def self.curr new FOCUSED_WIDGET_ID end |
Instance Method Details
- (Object) area_ids
Returns the IDs of all areas in this view.
863 864 865 |
# File 'lib/rumai/wm.rb', line 863 def area_ids manifest.scan(/^# (\d+) /).flatten.unshift(FLOATING_AREA_ID) end |
- (Object) area_of_client(client_or_id)
Returns the area which contains the given client in this view.
846 847 848 849 850 851 852 853 854 855 856 857 858 |
# File 'lib/rumai/wm.rb', line 846 def area_of_client client_or_id arg = if client_or_id.respond_to? :id client_or_id.id else client_or_id end manifest =~ /^(\S+) #{arg}/ if area_id = $1 Area.new area_id, self end end |
- (Object) areas
Returns all areas in this view.
870 871 872 |
# File 'lib/rumai/wm.rb', line 870 def areas area_ids.map! {|i| Area.new i, self } end |
- (Object) arrange_columns(lengths, layout = nil)
Applies the given length to each column in sequence. Also, the given layout is applied to all columns, if specified.
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 |
# File 'lib/rumai/wm.rb', line 1056 def arrange_columns lengths, layout = nil maintain_focus do i = 0 each_column do |column| if i < lengths.length column.length = lengths[i] column.layout = layout if layout i += 1 else break end end end end |
- (Object) chain
Returns a list of all views.
794 795 796 |
# File 'lib/rumai/wm.rb', line 794 def chain Rumai.views end |
- (Object) client_ids(area_id = '\S+')
Returns the IDs of the clients contained in the given area within this view.
806 807 808 |
# File 'lib/rumai/wm.rb', line 806 def client_ids area_id = '\S+' manifest.scan(/^#{area_id} (0x\S+)/).flatten end |
- (Object) columns Also known as: managed_areas
Returns all columns (managed areas) in this view.
884 885 886 |
# File 'lib/rumai/wm.rb', line 884 def columns areas[1..-1] end |
- (Object) each(&block)
Iterates through each area in this view.
817 818 819 |
# File 'lib/rumai/wm.rb', line 817 def each &block areas.each(&block) end |
- (Object) each_column(starting_column_id = 1) Also known as: each_managed_area
Resiliently iterates through possibly destructive changes to each column. That is, if the given block creates new columns, then those will also be processed in the iteration.
895 896 897 898 899 900 901 |
# File 'lib/rumai/wm.rb', line 895 def each_column starting_column_id = 1 i = starting_column_id while (column = Area.new(i, self)).exist? yield column i += 1 end end |
- (Object) floating_area
Returns the floating area of this view.
877 878 879 |
# File 'lib/rumai/wm.rb', line 877 def floating_area Area.floating self end |
- (Object) focus
Focuses this view.
783 784 785 |
# File 'lib/rumai/wm.rb', line 783 def focus IXP_FS_ROOT.ctl.write "view #{@id}" end |
- (Object) grid(max_clients_per_column = nil) Also known as: arrange_in_grid
Arranges the clients in this view, while maintaining their relative order, in (at best) a square grid.
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
# File 'lib/rumai/wm.rb', line 1026 def grid max_clients_per_column = nil # compute client distribution unless max_clients_per_column num_clients = num_managed_clients return unless num_clients > 0 num_columns = Math.sqrt(num_clients) max_clients_per_column = (num_clients / num_columns).round end return if max_clients_per_column < 1 # apply the distribution maintain_focus do each_column do |a| a.length = max_clients_per_column a.layout = :default end end end |
- (Object) manifest
Returns the manifest of all areas and clients in this view.
828 829 830 |
# File 'lib/rumai/wm.rb', line 828 def manifest index.read || '' end |
- (Object) select(direction)
Moves the focus from the current client in the given direction.
835 836 837 |
# File 'lib/rumai/wm.rb', line 835 def select direction ctl.write "select #{direction}" end |
- (Object) stack(num_columns = 2) Also known as: arrange_in_stacks
Arranges the clients in this view, while maintaining their relative order, in the given number of columns.
1016 1017 1018 1019 1020 |
# File 'lib/rumai/wm.rb', line 1016 def stack num_columns = 2 heights = [num_managed_clients / num_columns] * num_columns heights[-1] += num_managed_clients % num_columns arrange_columns heights, :stack end |
- (Object) tile_inward Also known as: arrange_in_diamond
Arranges columns with the following number of clients in them:
1, 2, 3, ..., 3, 2, 1
Imagine two equilateral triangles with their bases on the left and right sides of the screen and their peaks meeting in the middle of the screen.
965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 |
# File 'lib/rumai/wm.rb', line 965 def tile_inward rising, num_summit_clients, falling = calculate_equilateral_triangle # distribute extra clients in the middle summit = [] if num_summit_clients > 0 split = num_summit_clients / 2 carry = num_summit_clients % 2 summit = [split, carry, split].reject(&:zero?) # one client per column cannot be considered as "tiling" so squeeze # these singular columns together to create one giant middle column if summit.length == num_summit_clients summit = [num_summit_clients] end end arrange_columns rising + summit + falling, :default end |
- (Object) tile_left
Arranges columns with the following number of clients in them:
N, 1
938 939 940 |
# File 'lib/rumai/wm.rb', line 938 def tile_left arrange_columns [num_managed_clients-1, 1], :default end |
- (Object) tile_leftward
Arranges columns with the following number of clients in them:
..., 3, 2, 1
Imagine an equilateral triangle with its base on the left side of the screen and its peak on the right side of the screen.
951 952 953 954 955 |
# File 'lib/rumai/wm.rb', line 951 def tile_leftward num_rising_columns, num_summit_clients = calculate_right_triangle heights = (1..num_rising_columns).to_a.push(num_summit_clients).reverse arrange_columns heights, :default end |
- (Object) tile_outward
Arranges columns with the following number of clients in them:
..., 3, 2, 1, 2, 3, ...
Imagine two equilateral triangles with their bases meeting in the middle of the screen and their peaks reaching outward to the left and right sides of the screen.
994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 |
# File 'lib/rumai/wm.rb', line 994 def tile_outward rising, num_summit_clients, falling = calculate_equilateral_triangle heights = falling + rising[1..-1] # distribute extra clients on the outsides num_summit_clients += rising[0].to_i if num_summit_clients > 0 split = num_summit_clients / 2 carry = num_summit_clients % 2 # put the remainder on the left side to minimize the need for # rearrangement when clients are removed or added to the view heights.unshift split + carry heights.push split end arrange_columns heights, :default end |
- (Object) tile_right Also known as: arrange_as_larswm
Arranges columns with the following number of clients in them:
1, N
914 915 916 |
# File 'lib/rumai/wm.rb', line 914 def tile_right arrange_columns [1, num_managed_clients-1], :default end |
- (Object) tile_rightward
Arranges columns with the following number of clients in them:
1, 2, 3, ...
Imagine an equilateral triangle with its base on the right side of the screen and its peak on the left side of the screen.
927 928 929 930 931 |
# File 'lib/rumai/wm.rb', line 927 def tile_rightward num_rising_columns, num_summit_clients = calculate_right_triangle heights = (1..num_rising_columns).to_a.push(num_summit_clients) arrange_columns heights, :default end |