rumai 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,12 +18,12 @@ module Rumai
18
18
  ##
19
19
  # Number of this release of this project.
20
20
  #
21
- VERSION = '4.0.0'
21
+ VERSION = '4.1.0'
22
22
 
23
23
  ##
24
24
  # Date of this release of this project.
25
25
  #
26
- RELDATE = '2011-02-25'
26
+ RELDATE = '2011-03-28'
27
27
 
28
28
  ##
29
29
  # Description of this release of this project.
@@ -60,7 +60,7 @@ module Rumai
60
60
  # Transforms this object into a string of 9P2000 bytes.
61
61
  #
62
62
  def to_9p
63
- @fields.inject([]) {|s,f| s << f.to_9p(@values) }.join
63
+ @fields.map {|f| f.to_9p(@values) }.join
64
64
  end
65
65
 
66
66
  ##
@@ -182,17 +182,11 @@ module Rumai
182
182
  # Returns a Field class that best represents the given format.
183
183
  #
184
184
  def self.factory format
185
- if format == String
186
- StringField
187
-
188
- elsif format.is_a? Class
189
- ClassField
190
-
191
- elsif format == 8
192
- Integer8Field
193
-
194
- else
195
- Field
185
+ case format
186
+ when String then StringField
187
+ when Class then ClassField
188
+ when 8 then Integer8Field
189
+ else Field
196
190
  end
197
191
  end
198
192
 
@@ -898,34 +898,107 @@ module Rumai
898
898
  #-----------------------------------------------------------------------
899
899
 
900
900
  ##
901
- # Arranges the clients in this view, while maintaining
902
- # their relative order, in the tiling fashion of LarsWM.
901
+ # Arranges columns with the following number of clients in them:
903
902
  #
904
- # Only the first client in the primary column is kept; all others
905
- # are evicted to the *top* of the secondary column. Any subsequent
906
- # columns are squeezed into the *bottom* of the secondary column.
903
+ # 1, N
907
904
  #
908
- def arrange_as_larswm
909
- maintain_focus do
910
- # keep only one client in the primary column
911
- main = Area.new(1, self)
912
- main.length = 1
913
- main.layout = :default
905
+ def tile_right
906
+ arrange_columns [1, num_managed_clients-1], :default
907
+ end
914
908
 
915
- # collapse remaining areas into secondary column
916
- extra = squeeze_columns(1..-1)
909
+ ##
910
+ # Arranges columns with the following number of clients in them:
911
+ #
912
+ # 1, 2, 3, ...
913
+ #
914
+ # Imagine an equilateral triangle with its
915
+ # base on the right side of the screen and
916
+ # its peak on the left side of the screen.
917
+ #
918
+ def tile_rightward
919
+ width, summit = calculate_right_triangle
920
+ heights = (1 .. width).to_a.push(summit)
921
+ arrange_columns heights, :default
922
+ end
917
923
 
918
- if dock = extra.first
919
- dock.layout = :default
920
- end
924
+ ##
925
+ # Arranges columns with the following number of clients in them:
926
+ #
927
+ # N, 1
928
+ #
929
+ def tile_left
930
+ arrange_columns [num_managed_clients-1, 1], :default
931
+ end
932
+
933
+ ##
934
+ # Arranges columns with the following number of clients in them:
935
+ #
936
+ # ..., 3, 2, 1
937
+ #
938
+ # Imagine an equilateral triangle with its
939
+ # base on the left side of the screen and
940
+ # its peak on the right side of the screen.
941
+ #
942
+ def tile_leftward
943
+ width, summit = calculate_right_triangle
944
+ heights = (1 .. width).to_a.push(summit).reverse
945
+ arrange_columns heights, :default
946
+ end
947
+
948
+ ##
949
+ # Arranges columns with the following number of clients in them:
950
+ #
951
+ # 1, 2, 3, ..., 3, 2, 1
952
+ #
953
+ # Imagine two equilateral triangles with their bases on the left and right
954
+ # sides of the screen and their peaks meeting in the middle of the screen.
955
+ #
956
+ def tile_inward
957
+ arrange_columns calculate_equilateral_triangle.flatten, :default
958
+ end
959
+
960
+ ##
961
+ # Arranges columns with the following number of clients in them:
962
+ #
963
+ # ..., 3, 2, 1, 2, 3, ...
964
+ #
965
+ # Imagine two equilateral triangles with their bases meeting in the middle
966
+ # of the screen and their peaks reaching outward to the left and right
967
+ # sides of the screen.
968
+ #
969
+ def tile_outward
970
+ rising, summit, falling = calculate_equilateral_triangle
971
+ heights = falling[0..-2].concat(rising)
972
+
973
+ # distribute extra clients on the outsides
974
+ extra = summit[0].to_i + falling[-1].to_i
975
+ if extra > 0
976
+ split = extra / 2
977
+ carry = extra % 2
978
+ # put the remainder on the left side to minimize the need for
979
+ # rearrangement when clients are removed or added to the view
980
+ heights.unshift split + carry
981
+ heights.push split
921
982
  end
983
+
984
+ arrange_columns heights, :default
985
+ end
986
+
987
+ ##
988
+ # Arranges the clients in this view, while maintaining
989
+ # their relative order, in the given number of columns.
990
+ #
991
+ def stack num_columns = 2
992
+ heights = [num_managed_clients / num_columns] * num_columns
993
+ heights[-1] += num_managed_clients % num_columns
994
+ arrange_columns heights, :stack
922
995
  end
923
996
 
924
997
  ##
925
998
  # Arranges the clients in this view, while maintaining
926
- # their relative order, in a (at best) square grid.
999
+ # their relative order, in (at best) a square grid.
927
1000
  #
928
- def arrange_in_grid max_clients_per_column = nil
1001
+ def grid max_clients_per_column = nil
929
1002
  # compute client distribution
930
1003
  unless max_clients_per_column
931
1004
  num_clients = num_managed_clients
@@ -946,91 +1019,61 @@ module Rumai
946
1019
  end
947
1020
  end
948
1021
 
1022
+ alias arrange_as_larswm tile_right
1023
+ alias arrange_in_diamond tile_inward
1024
+ alias arrange_in_stacks stack
1025
+ alias arrange_in_grid grid
1026
+
949
1027
  ##
950
- # Arranges the clients in this view, while maintaining
951
- # their relative order, in the given number of columns.
1028
+ # Applies the given length to each column in sequence. Also,
1029
+ # the given layout is applied to all columns, if specified.
952
1030
  #
953
- def arrange_in_stacks num_stacks
954
- return if num_stacks < 1
955
-
956
- # compute client distribution
957
- num_clients = num_managed_clients
958
- return unless num_clients > 0
959
-
960
- stack_length = num_clients / num_stacks
961
- return if stack_length < 1
962
-
963
- # apply the distribution
1031
+ def arrange_columns lengths, layout = nil
1032
+ i = 0
964
1033
  maintain_focus do
965
- each_column do |a|
966
- a.length = stack_length
967
- a.layout = :stack
1034
+ each_column do |column|
1035
+ if i < lengths.length
1036
+ column.length = lengths[i]
1037
+ column.layout = layout if layout
1038
+ i += 1
1039
+ else
1040
+ break
1041
+ end
968
1042
  end
969
-
970
- squeeze_columns num_stacks-1..-1
971
1043
  end
972
1044
  end
973
1045
 
974
- ##
975
- # Arranges the clients in this view, while
976
- # maintaining their relative order, in a (at
977
- # best) equilateral triangle. However, the
978
- # resulting arrangement appears like a diamond
979
- # because wmii does not waste screen space.
980
- #
981
- def arrange_in_diamond
982
- num_clients = num_managed_clients
983
- return unless num_clients > 1
984
-
985
- # determine dimensions of the rising sub-triangle
986
- rise = num_clients / 2
987
-
988
- span = sum = 0
989
- 1.upto rise do |h|
990
- if sum + h > rise
991
- break
992
- else
993
- sum += h
994
- span += 1
995
- end
996
- end
997
-
998
- peak = num_clients - (sum * 2)
1046
+ private
999
1047
 
1000
- # quantify overall triangle as a sequence of heights
1001
- rise_seq = (1..span).to_a
1002
- fall_seq = rise_seq.reverse
1048
+ def calculate_equilateral_triangle
1049
+ num_clients = num_managed_clients
1050
+ return [] unless num_clients > 1
1003
1051
 
1004
- heights = rise_seq
1005
- heights << peak if peak > 0
1006
- heights.concat fall_seq
1052
+ # calculate the dimensions of the rising sub-triangle
1053
+ num_rising_columns, num_summit_clients =
1054
+ calculate_right_triangle(num_clients / 2)
1007
1055
 
1008
- # apply the heights
1009
- maintain_focus do
1010
- each_column do |col|
1011
- if h = heights.shift
1012
- col.length = h
1013
- col.layout = :default
1014
- end
1015
- end
1016
- end
1056
+ # quantify entire triangle as a sequence of heights
1057
+ heights = (1 .. num_rising_columns).to_a
1058
+ summit = num_summit_clients > 0 ? [num_summit_clients] : []
1059
+ [heights, summit, heights.reverse]
1017
1060
  end
1018
1061
 
1019
- private
1062
+ def calculate_right_triangle num_rising_clients = num_managed_clients
1063
+ num_rising_columns = num_clients_processed = 0
1020
1064
 
1021
- ##
1022
- # Squeezes all columns in the given index range into a single one.
1023
- #
1024
- def squeeze_columns range
1025
- extra = columns[range]
1026
-
1027
- if extra.length > 1
1028
- extra.reverse.each_cons(2) do |src, dst|
1029
- dst.concat src
1065
+ 1.upto num_rising_clients do |height|
1066
+ if num_clients_processed + height > num_rising_clients
1067
+ break
1068
+ else
1069
+ num_clients_processed += height
1070
+ num_rising_columns += 1
1030
1071
  end
1031
1072
  end
1032
1073
 
1033
- extra
1074
+ num_summit_clients = num_rising_clients - num_clients_processed
1075
+
1076
+ [num_rising_columns, num_summit_clients]
1034
1077
  end
1035
1078
 
1036
1079
  ##
@@ -2,12 +2,12 @@
2
2
  .\" Title: rumai
3
3
  .\" Author: [see the "AUTHORS" section]
4
4
  .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
5
- .\" Date: 2011-02-25
5
+ .\" Date: 2011-03-28
6
6
  .\" Manual: \ \&
7
- .\" Source: \ \& 4.0.0
7
+ .\" Source: \ \& 4.1.0
8
8
  .\" Language: English
9
9
  .\"
10
- .TH "RUMAI" "1" "2011\-02\-25" "\ \& 4\&.0\&.0" "\ \&"
10
+ .TH "RUMAI" "1" "2011\-03\-28" "\ \& 4\&.1\&.0" "\ \&"
11
11
  .\" -----------------------------------------------------------------
12
12
  .\" * Define some portability stuff
13
13
  .\" -----------------------------------------------------------------
@@ -856,6 +856,154 @@ Its exit status will indicate whether all tests have passed\&. It may also print
856
856
  .sp
857
857
  \m[blue]\fBFork this project on GitHub\fR\m[] and send a pull request\&.
858
858
  .SH "HISTORY"
859
+ .SS "Version 4\&.1\&.0 (2011\-03\-28)"
860
+ .sp
861
+ This release adds new automated client arrangements and cleans up the code\&.
862
+ .PP
863
+ \fBNew features\fR
864
+ .sp
865
+ .RS 4
866
+ .ie n \{\
867
+ \h'-04'\(bu\h'+03'\c
868
+ .\}
869
+ .el \{\
870
+ .sp -1
871
+ .IP \(bu 2.3
872
+ .\}
873
+ Added new automated client arrangements:
874
+ .sp
875
+ .RS 4
876
+ .ie n \{\
877
+ \h'-04'\(bu\h'+03'\c
878
+ .\}
879
+ .el \{\
880
+ .sp -1
881
+ .IP \(bu 2.3
882
+ .\}
883
+
884
+ Rumai::View#tile_left()
885
+ \- Horizontal mirror of the LarsWM arrangement\&.
886
+ .RE
887
+ .sp
888
+ .RS 4
889
+ .ie n \{\
890
+ \h'-04'\(bu\h'+03'\c
891
+ .\}
892
+ .el \{\
893
+ .sp -1
894
+ .IP \(bu 2.3
895
+ .\}
896
+
897
+ Rumai::View#tile_leftward()
898
+ \- Imagine an equilateral triangle with its base on the left side of the screen and its peak on the right side of the screen\&.
899
+ .RE
900
+ .sp
901
+ .RS 4
902
+ .ie n \{\
903
+ \h'-04'\(bu\h'+03'\c
904
+ .\}
905
+ .el \{\
906
+ .sp -1
907
+ .IP \(bu 2.3
908
+ .\}
909
+
910
+ Rumai::View#tile_rightward()
911
+ \- Imagine an equilateral triangle with its base on the right side of the screen and its peak on the left side of the screen\&.
912
+ .RE
913
+ .sp
914
+ .RS 4
915
+ .ie n \{\
916
+ \h'-04'\(bu\h'+03'\c
917
+ .\}
918
+ .el \{\
919
+ .sp -1
920
+ .IP \(bu 2.3
921
+ .\}
922
+
923
+ Rumai::View#tile_inward()
924
+ \- 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\&.
925
+ .RE
926
+ .sp
927
+ .RS 4
928
+ .ie n \{\
929
+ \h'-04'\(bu\h'+03'\c
930
+ .\}
931
+ .el \{\
932
+ .sp -1
933
+ .IP \(bu 2.3
934
+ .\}
935
+
936
+ Rumai::View#tile_outward()
937
+ \- 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\&.
938
+ .RE
939
+ .RE
940
+ .sp
941
+ .RS 4
942
+ .ie n \{\
943
+ \h'-04'\(bu\h'+03'\c
944
+ .\}
945
+ .el \{\
946
+ .sp -1
947
+ .IP \(bu 2.3
948
+ .\}
949
+ Renamed existing automated client arrangement method names:
950
+ .sp
951
+ .RS 4
952
+ .ie n \{\
953
+ \h'-04'\(bu\h'+03'\c
954
+ .\}
955
+ .el \{\
956
+ .sp -1
957
+ .IP \(bu 2.3
958
+ .\}
959
+
960
+ Rumai::View#arrange_as_larswm()
961
+ is now aliased to
962
+ tile_right()
963
+ .RE
964
+ .sp
965
+ .RS 4
966
+ .ie n \{\
967
+ \h'-04'\(bu\h'+03'\c
968
+ .\}
969
+ .el \{\
970
+ .sp -1
971
+ .IP \(bu 2.3
972
+ .\}
973
+
974
+ Rumai::View#arrange_in_diamond()
975
+ is now aliased to
976
+ tile_inward()
977
+ .RE
978
+ .sp
979
+ .RS 4
980
+ .ie n \{\
981
+ \h'-04'\(bu\h'+03'\c
982
+ .\}
983
+ .el \{\
984
+ .sp -1
985
+ .IP \(bu 2.3
986
+ .\}
987
+
988
+ Rumai::View#arrange_in_stacks()
989
+ is now aliased to
990
+ stack()
991
+ .RE
992
+ .sp
993
+ .RS 4
994
+ .ie n \{\
995
+ \h'-04'\(bu\h'+03'\c
996
+ .\}
997
+ .el \{\
998
+ .sp -1
999
+ .IP \(bu 2.3
1000
+ .\}
1001
+
1002
+ Rumai::View#arrange_in_grid()
1003
+ is now aliased to
1004
+ grid()
1005
+ .RE
1006
+ .RE
859
1007
  .SS "Version 4\&.0\&.0 (2011\-02\-25)"
860
1008
  .sp
861
1009
  This release fixes a bug regarding the $WMII_ADDRESS environment variable\&.
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumai
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 4
7
- - 0
8
- - 0
9
- version: 4.0.0
4
+ prerelease:
5
+ version: 4.1.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Suraj N. Kurapati
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-02-25 00:00:00 -08:00
13
+ date: 2011-03-28 00:00:00 -07:00
18
14
  default_executable:
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
@@ -25,15 +21,9 @@ dependencies:
25
21
  requirements:
26
22
  - - ">="
27
23
  - !ruby/object:Gem::Version
28
- segments:
29
- - 5
30
- - 0
31
- - 2
32
24
  version: 5.0.2
33
25
  - - <
34
26
  - !ruby/object:Gem::Version
35
- segments:
36
- - 6
37
27
  version: "6"
38
28
  type: :development
39
29
  version_requirements: *id001
@@ -45,15 +35,9 @@ dependencies:
45
35
  requirements:
46
36
  - - ">="
47
37
  - !ruby/object:Gem::Version
48
- segments:
49
- - 3
50
- - 1
51
- - 0
52
38
  version: 3.1.0
53
39
  - - <
54
40
  - !ruby/object:Gem::Version
55
- segments:
56
- - 4
57
41
  version: "4"
58
42
  type: :development
59
43
  version_requirements: *id002
@@ -92,21 +76,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
76
  requirements:
93
77
  - - ">="
94
78
  - !ruby/object:Gem::Version
95
- segments:
96
- - 0
97
79
  version: "0"
98
80
  required_rubygems_version: !ruby/object:Gem::Requirement
99
81
  none: false
100
82
  requirements:
101
83
  - - ">="
102
84
  - !ruby/object:Gem::Version
103
- segments:
104
- - 0
105
85
  version: "0"
106
86
  requirements: []
107
87
 
108
88
  rubyforge_project:
109
- rubygems_version: 1.3.7
89
+ rubygems_version: 1.6.2
110
90
  signing_key:
111
91
  specification_version: 3
112
92
  summary: Ruby interface to the wmii window manager