ruco 0.0.36 → 0.0.37

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.
data/Readme.md CHANGED
@@ -56,12 +56,15 @@ Customize
56
56
 
57
57
  TIPS
58
58
  ====
59
+ - [RVM] `alias r="rvm ree exec ruco"` and you only have to install ruco once
59
60
  - [Ruby1.9] Unicode support -> install libncursesw5-dev before installing ruby (does not work for 1.8)
60
61
  - [ssh vs clipboard] access your desktops clipboard by installing `xauth` on the server and then using `ssh -X`
61
62
  - [Alt key] if Alt does not work try your Meta/Win/Cmd key
62
63
 
63
64
  TODO
64
65
  =====
66
+ - big warning when editing a not-writeable file
67
+ - nice warning when failing to write a write-only file
65
68
  - find next (Alt+n)
66
69
  - add selection colors to forms in command_bar
67
70
  - session storage (stay at same line/column when reopening)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.36
1
+ 0.0.37
data/lib/ruco.rb CHANGED
@@ -9,6 +9,7 @@ require 'ruco/core_ext/range'
9
9
  require 'ruco/keyboard'
10
10
  require 'ruco/position'
11
11
  require 'ruco/history'
12
+ require 'ruco/window'
12
13
 
13
14
  require 'ruco/editor'
14
15
  require 'ruco/status_bar'
@@ -23,28 +23,26 @@ module Ruco
23
23
  end
24
24
 
25
25
  def delete_line
26
- lines.slice!(@line, 1)
27
- adjust_view
26
+ lines.slice!(line, 1)
27
+ sanitize_position
28
28
  end
29
29
 
30
30
  def indent
31
31
  selected_lines.each do |line|
32
- @lines[line].insert(0, ' ' * Ruco::TAB_SIZE)
32
+ lines[line].insert(0, ' ' * Ruco::TAB_SIZE)
33
33
  end
34
34
  adjust_to_indentation Ruco::TAB_SIZE
35
- adjust_view
36
35
  end
37
36
 
38
37
  def unindent
39
- lines_to_unindent = (selection ? selected_lines : [@line])
38
+ lines_to_unindent = (selection ? selected_lines : [line])
40
39
  removed = lines_to_unindent.map do |line|
41
- remove = [@lines[line].leading_whitespace.size, Ruco::TAB_SIZE].min
42
- @lines[line].slice!(0, remove)
40
+ remove = [lines[line].leading_whitespace.size, Ruco::TAB_SIZE].min
41
+ lines[line].slice!(0, remove)
43
42
  remove
44
43
  end
45
44
 
46
45
  adjust_to_indentation -removed.first, -removed.last
47
- adjust_view
48
46
  end
49
47
 
50
48
  private
@@ -60,14 +58,17 @@ module Ruco
60
58
  def state=(data)
61
59
  @selection = nil
62
60
  @lines = data[:content].naive_split("\n")
63
- @line, @column = data[:position]
64
- @scrolled_lines, @scrolled_columns = data[:screen_position]
65
- adjust_view
61
+ self.position = data[:position]
62
+ self.screen_position = data[:screen_position]
66
63
  end
67
64
 
68
65
  # TODO use this instead of instance variables
69
66
  def screen_position
70
- Position.new(@scrolled_lines, @scrolled_columns)
67
+ Position.new(@window.top, @window.left)
68
+ end
69
+
70
+ def screen_position=(pos)
71
+ @window.top, @window.left = pos
71
72
  end
72
73
 
73
74
  def adjust_to_indentation(first, last=nil)
@@ -76,9 +77,9 @@ module Ruco
76
77
  cursor_adjustment = (selection.first == position ? first : last)
77
78
  selection.first.column = [selection.first.column + first, 0].max
78
79
  selection.last.column = [selection.last.column + last, 0].max
79
- @column += cursor_adjustment
80
+ self.column += cursor_adjustment
80
81
  else
81
- @column += first
82
+ self.column += first
82
83
  end
83
84
  end
84
85
 
@@ -1,69 +1,57 @@
1
1
  module Ruco
2
2
  class TextArea
3
- attr_reader :lines, :selection
3
+ attr_reader :lines, :selection, :column, :line
4
4
 
5
5
  def initialize(content, options)
6
6
  @lines = content.naive_split("\n")
7
- @options = options
8
- @line = 0
7
+ @options = options.dup
9
8
  @column = 0
10
- @cursor_line = 0
11
- @cursor_column = 0
12
- @scrolled_lines = 0
13
- @scrolled_columns = 0
14
- @options[:line_scrolling_offset] ||= @options[:lines] / 2
15
- @options[:column_scrolling_offset] ||= @options[:columns] / 2
9
+ @line = 0
10
+ @window = Window.new(@options.delete(:lines), @options.delete(:columns))
11
+ @window.position = position
16
12
  end
17
13
 
18
14
  def view
19
- Array.new(@options[:lines]).map_with_index do |_,i|
20
- (lines[i + @scrolled_lines] || "").slice(@scrolled_columns, @options[:columns])
21
- end * "\n" + "\n"
15
+ @window.position = position
16
+ @window.crop(lines) * "\n" + "\n"
22
17
  end
23
18
 
24
- def color_mask
25
- mask = Array.new(@options[:lines])
26
- return mask unless @selection
27
-
28
- mask.map_with_index do |_,line|
29
- visible = visible_area(line)
30
- next unless @selection.overlap?(visible)
31
-
32
- first = [@selection.first, visible.first].max
33
- last = [@selection.last, visible.last].min
19
+ def cursor
20
+ @window.position = position
21
+ @window.cursor
22
+ end
34
23
 
35
- [
36
- [first[1]-@scrolled_columns,Curses::A_REVERSE],
37
- [last[1]-@scrolled_columns, Curses::A_NORMAL]
38
- ]
39
- end
24
+ def color_mask
25
+ @window.position = position
26
+ @window.color_mask(@selection)
40
27
  end
41
28
 
42
29
  def move(where, *args)
43
30
  case where
44
31
  when :relative then
45
- @line += args.first
46
- @column += args.last
32
+ self.line += args.first
33
+ self.column += args.last
47
34
  when :to then
48
- @line, @column = args
35
+ self.line, self.column = args
49
36
  when :to_bol then move_to_bol(*args)
50
37
  when :to_eol then move_to_eol(*args)
51
- when :to_line then @line = args.first
52
- when :to_column then @column = args.first
38
+ when :to_line then self.line = args.first
39
+ when :to_column then self.column = args.first
53
40
  when :to_index then move(:to, *position_for_index(*args))
54
41
  when :page_down then
55
- shift = @options[:lines] - 1
56
- @line += shift
57
- @scrolled_lines += shift
42
+ shift = @window.lines - 1
43
+ old = self.line
44
+ self.line += shift
45
+ @window.top += (line - old) # force scroll
58
46
  when :page_up then
59
- shift = @options[:lines] - 1
60
- @line -= shift
61
- @scrolled_lines -= shift
47
+ shift = @window.lines - 1
48
+ old = self.line
49
+ self.line -= shift
50
+ @window.top += (line - old) # force scroll
62
51
  else
63
52
  raise "Unknown move type #{where} with #{args.inspect}"
64
53
  end
65
54
  @selection = nil unless @selecting
66
- adjust_view
67
55
  end
68
56
 
69
57
  def selecting(&block)
@@ -98,7 +86,7 @@ module Ruco
98
86
  text.tabs_to_spaces!
99
87
  if text == "\n" and @column >= after_last_word
100
88
  current_whitespace = current_line.leading_whitespace
101
- next_whitespace = lines[@line+1].to_s.leading_whitespace
89
+ next_whitespace = lines[line+1].to_s.leading_whitespace
102
90
  text = text + [current_whitespace, next_whitespace].max
103
91
  end
104
92
  insert_into_content text
@@ -124,10 +112,6 @@ module Ruco
124
112
  end
125
113
  end
126
114
 
127
- def cursor
128
- Position.new @cursor_line, @cursor_column
129
- end
130
-
131
115
  def index_for_position(position=self.position)
132
116
  index = lines[0...position.line].join("\n").size + position.column
133
117
  index += 1 if position.line > 0 # account for missing newline
@@ -139,14 +123,14 @@ module Ruco
139
123
  end
140
124
 
141
125
  def resize(lines, columns)
142
- @options[:lines] = lines
143
- @options[:columns] = columns
126
+ @window.lines = lines
127
+ @window.columns = columns
144
128
  end
145
129
 
146
130
  protected
147
131
 
148
132
  def position
149
- Position.new(@line, @column)
133
+ Position.new(line, column)
150
134
  end
151
135
 
152
136
  def position_for_index(index)
@@ -204,46 +188,17 @@ module Ruco
204
188
  end
205
189
  end
206
190
 
207
- def adjust_view
208
- @line = [[@line, 0].max, lines.size - 1].min
209
- @column = [[@column, 0].max, current_line.size].min
210
- reposition_cursor
211
- scroll_column_into_view
212
- scroll_line_into_view
213
- reposition_cursor
191
+ def line=(x)
192
+ @line = [[x, 0].max, [lines.size - 1, 0].max ].min
193
+ self.column = @column # e.g. now in an empty line
214
194
  end
215
195
 
216
- def scroll_column_into_view
217
- offset = [@options[:column_scrolling_offset], @options[:columns]].min
218
-
219
- if @cursor_column >= @options[:columns]
220
- @scrolled_columns = @column - @options[:columns] + offset
221
- end
222
-
223
- if @cursor_column < 0
224
- @scrolled_columns = @column - offset
225
- end
226
-
227
- @scrolled_columns = [[@scrolled_columns, 0].max, @column].min
228
- end
229
-
230
- def scroll_line_into_view
231
- offset = [@options[:line_scrolling_offset], @options[:lines]].min
232
-
233
- if @cursor_line >= @options[:lines]
234
- @scrolled_lines = @line - @options[:lines] + offset
235
- end
236
-
237
- if @cursor_line < 0
238
- @scrolled_lines = @line - offset
239
- end
240
-
241
- @scrolled_lines = [[@scrolled_lines, 0].max, @line].min
196
+ def column=(x)
197
+ @column = [[x, 0].max, current_line.size].min
242
198
  end
243
199
 
244
- def reposition_cursor
245
- @cursor_column = @column - @scrolled_columns
246
- @cursor_line = @line - @scrolled_lines
200
+ def position=(pos)
201
+ self.line, self.column = pos
247
202
  end
248
203
 
249
204
  def insert_into_content(text)
@@ -253,24 +208,23 @@ module Ruco
253
208
  end
254
209
  else
255
210
  # faster but complicated for newlines
256
- lines[@line].insert(@column, text)
211
+ lines[line].insert(@column, text)
257
212
  end
258
213
  end
259
214
 
260
215
  def position_inside_content?
261
- @line < lines.size and @column < lines[@line].to_s.size
216
+ line < lines.size and @column < lines[line].to_s.size
262
217
  end
263
218
 
264
219
  def current_line
265
- lines[@line] || ''
220
+ lines[line] || ''
266
221
  end
267
222
 
268
223
  def move_according_to_insert(text)
269
224
  inserted_lines = text.naive_split("\n")
270
225
  if inserted_lines.size > 1
271
- # column position does not add up when hitting return
272
- @column = inserted_lines.last.size
273
- move(:relative, inserted_lines.size - 1, 0)
226
+ self.line += inserted_lines.size - 1
227
+ self.column = inserted_lines.last.size
274
228
  else
275
229
  move(:relative, inserted_lines.size - 1, inserted_lines.last.size)
276
230
  end
@@ -286,12 +240,9 @@ module Ruco
286
240
  @selection = nil
287
241
  end
288
242
 
289
- def visible_area(line)
290
- line += @scrolled_lines
291
- start_of_line = [line, @scrolled_columns]
292
- last_visible_column = @scrolled_columns + @options[:columns]
293
- end_of_line = [line, last_visible_column]
294
- start_of_line..end_of_line
243
+ def sanitize_position
244
+ self.line = line
245
+ self.column = column
295
246
  end
296
247
  end
297
248
  end
@@ -0,0 +1,83 @@
1
+ module Ruco
2
+ class Window
3
+ OFFSET = 5
4
+
5
+ attr_accessor :position, :lines, :columns, :top, :left
6
+ attr_reader :cursor
7
+
8
+ def initialize(lines, columns)
9
+ @lines = lines
10
+ @columns = columns
11
+ @top = 0
12
+ @left = 0
13
+ @cursor = Position.new(0,0)
14
+ end
15
+
16
+ def crop(content)
17
+ lines = content[visible_lines] || []
18
+ lines[@lines-1] ||= nil
19
+ lines.map do |line|
20
+ line ||= ''
21
+ line[visible_columns] || ''
22
+ end
23
+ end
24
+
25
+ def position=(pos)
26
+ self.top = pos.line - line_offset unless visible_lines.include?(pos.line)
27
+ self.left = pos.column - column_offset unless visible_columns.include?(pos.column)
28
+ @cursor = Position.new(pos.line - @top, pos.column - @left)
29
+ end
30
+
31
+ def color_mask(selection)
32
+ mask = Array.new(lines)
33
+ return mask unless selection
34
+
35
+ mask.map_with_index do |_,line|
36
+ visible = visible_area(line)
37
+ next unless selection.overlap?(visible)
38
+
39
+ first = [selection.first, visible.first].max
40
+ last = [selection.last, visible.last].min
41
+
42
+ [
43
+ [first[1]-left, Curses::A_REVERSE],
44
+ [last[1]-left, Curses::A_NORMAL]
45
+ ]
46
+ end
47
+ end
48
+
49
+ def top=(x)
50
+ @top = [x,0].max
51
+ end
52
+
53
+ def left=(x)
54
+ @left = [x,0].max
55
+ end
56
+
57
+ private
58
+
59
+ def visible_area(line)
60
+ line += @top
61
+ start_of_line = [line, @left]
62
+ last_visible_column = @left + @columns
63
+ end_of_line = [line, last_visible_column]
64
+ start_of_line..end_of_line
65
+ end
66
+
67
+ def line_offset
68
+ @lines / 2
69
+ end
70
+
71
+ def column_offset
72
+ @columns / 2
73
+ end
74
+
75
+ def visible_lines
76
+ @top..(@top+@lines-1)
77
+ end
78
+
79
+ def visible_columns
80
+ @left..(@left+@columns-1)
81
+ end
82
+ end
83
+ end
data/ruco.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruco}
8
- s.version = "0.0.36"
8
+ s.version = "0.0.37"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-01-29}
12
+ s.date = %q{2011-01-31}
13
13
  s.default_executable = %q{ruco}
14
14
  s.email = %q{michael@grosser.it}
15
15
  s.executables = ["ruco"]
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
38
38
  "lib/ruco/text_area.rb",
39
39
  "lib/ruco/text_field.rb",
40
40
  "lib/ruco/version.rb",
41
+ "lib/ruco/window.rb",
41
42
  "ruco.gemspec",
42
43
  "spec/ruco/application_spec.rb",
43
44
  "spec/ruco/command_bar_spec.rb",
@@ -49,6 +50,7 @@ Gem::Specification.new do |s|
49
50
  "spec/ruco/keyboard_spec.rb",
50
51
  "spec/ruco/status_bar_spec.rb",
51
52
  "spec/ruco/text_area_spec.rb",
53
+ "spec/ruco/window_spec.rb",
52
54
  "spec/ruco_spec.rb",
53
55
  "spec/spec_helper.rb"
54
56
  ]
@@ -67,6 +69,7 @@ Gem::Specification.new do |s|
67
69
  "spec/ruco/keyboard_spec.rb",
68
70
  "spec/ruco/status_bar_spec.rb",
69
71
  "spec/ruco/text_area_spec.rb",
72
+ "spec/ruco/window_spec.rb",
70
73
  "spec/ruco_spec.rb",
71
74
  "spec/spec_helper.rb"
72
75
  ]
@@ -91,26 +91,26 @@ describe Ruco::Editor do
91
91
  editor.cursor.column.should == 4
92
92
 
93
93
  editor.move(:relative, 0,1)
94
- editor.view.should == "6789\n\n\n"
95
- editor.cursor.column.should == 0
94
+ editor.view.should == "45678\n\n\n"
95
+ editor.cursor.column.should == 2
96
96
  end
97
97
 
98
98
  it "cannot scroll past the screen" do
99
99
  write('123456789')
100
100
  editor.move(:relative, 0,4)
101
101
  6.times{ editor.move(:relative, 0,1) }
102
- editor.view.should == "6789\n\n\n"
103
- editor.cursor.column.should == 4
102
+ editor.view.should == "89\n\n\n"
103
+ editor.cursor.column.should == 2
104
104
  end
105
105
 
106
106
  it "can scroll columns backwards" do
107
107
  write('123456789')
108
108
  editor.move(:relative, 0,5)
109
- editor.view.should == "6789\n\n\n"
109
+ editor.view.should == "45678\n\n\n"
110
110
 
111
- editor.move(:relative, 0,-1)
111
+ editor.move(:relative, 0,-3)
112
112
  editor.view.should == "12345\n\n\n"
113
- editor.cursor.column.should == 4
113
+ editor.cursor.column.should == 2
114
114
  end
115
115
  end
116
116
 
@@ -119,19 +119,19 @@ describe Ruco::Editor do
119
119
  write("1\n2\n3\n4\n5\n6\n7\n8\n9")
120
120
  end
121
121
 
122
- it "can scroll lines down (at maximum of screen size)" do
122
+ it "can scroll lines down" do
123
123
  editor.move(:relative, 2,0)
124
124
  editor.view.should == "1\n2\n3\n"
125
125
 
126
126
  editor.move(:relative, 1,0)
127
- editor.view.should == "4\n5\n6\n"
128
- editor.cursor.line.should == 0
127
+ editor.view.should == "3\n4\n5\n"
128
+ editor.cursor.line.should == 1
129
129
  end
130
130
 
131
131
  it "can scroll till end of file" do
132
132
  editor.move(:relative, 15,0)
133
- editor.view.should == "9\n\n\n"
134
- editor.cursor.line.should == 0
133
+ editor.view.should == "8\n9\n\n"
134
+ editor.cursor.line.should == 1
135
135
  end
136
136
  end
137
137
 
@@ -386,8 +386,9 @@ describe Ruco::Editor do
386
386
 
387
387
  it "shows multi-line selection in scrolled space" do
388
388
  write("\n\n\n\n\n0123456789\n0123456789\n0123456789\n\n")
389
- editor.move(:to, 5,7)
390
- editor.move(:relative, 0, 1)
389
+ ta = editor.send(:text_area)
390
+ ta.send(:position=, [5,8])
391
+ ta.send(:screen_position=, [5,7])
391
392
  editor.selecting do
392
393
  move(:relative, 2, 1)
393
394
  end
@@ -591,11 +592,6 @@ describe Ruco::Editor do
591
592
  editor.unindent
592
593
  editor.cursor.should == [0,0]
593
594
  end
594
-
595
- it "marks as modified" do
596
- editor.unindent
597
- editor.modified?.should == true
598
- end
599
595
  end
600
596
 
601
597
  describe 'history' do
@@ -629,16 +625,6 @@ describe Ruco::Editor do
629
625
  editor.undo
630
626
  editor.modified?.should == true
631
627
  end
632
-
633
- it "sets modified on undo" do
634
- editor.insert('a')
635
- editor.view # trigger save point
636
- editor.undo
637
- editor.save
638
- editor.modified?.should == false
639
- editor.redo
640
- editor.modified?.should == true
641
- end
642
628
  end
643
629
 
644
630
  describe :save do
@@ -21,36 +21,36 @@ describe Ruco::TextArea do
21
21
  it "can move up a page" do
22
22
  text = Ruco::TextArea.new("0\n1\n2\n3\n4\n5\n6\n7\n8\n", :lines => 3, :columns => 3)
23
23
  text.move(:to, 4, 0)
24
- text.view.should == "2\n3\n4\n"
25
- text.cursor.should == [2,0]
24
+ text.view.should == "3\n4\n5\n"
25
+ text.cursor.should == [1,0]
26
26
  text.move(:page_up)
27
- text.view.should == "0\n1\n2\n"
28
- text.cursor.should == [2,0]
27
+ text.view.should == "1\n2\n3\n"
28
+ text.cursor.should == [1,0]
29
29
  end
30
30
 
31
31
  it "keeps column position when moving up" do
32
32
  text = Ruco::TextArea.new("0\n1\n2\n3ab\n4\n5abc\n6\n7\n8\n", :lines => 3, :columns => 5)
33
33
  text.move(:to, 5, 4)
34
- text.view.should == "3ab\n4\n5abc\n"
35
- text.cursor.should == [2,4]
34
+ text.view.should == "4\n5abc\n6\n"
35
+ text.cursor.should == [1,4]
36
36
  text.move(:page_up)
37
- text.view.should == "1\n2\n3ab\n"
38
- text.cursor.should == [2,3]
37
+ text.view.should == "2\n3ab\n4\n"
38
+ text.cursor.should == [1,3]
39
39
  end
40
40
 
41
41
  it "moves pages symetric" do
42
42
  text = Ruco::TextArea.new("0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n", :lines => 3, :columns => 3)
43
43
  text.move(:to, 4, 1)
44
- text.view.should == "2\n3\n4\n"
45
- text.cursor.should == [2,1]
44
+ text.view.should == "3\n4\n5\n"
45
+ text.cursor.should == [1,1]
46
46
 
47
47
  text.move(:page_down)
48
48
  text.move(:page_down)
49
49
  text.move(:page_up)
50
50
  text.move(:page_up)
51
51
 
52
- text.cursor.should == [2,1]
53
- text.view.should == "2\n3\n4\n"
52
+ text.cursor.should == [1,1]
53
+ text.view.should == "3\n4\n5\n"
54
54
  end
55
55
  end
56
56
  end
@@ -0,0 +1,143 @@
1
+ require File.expand_path('spec/spec_helper')
2
+
3
+ describe Ruco::Window do
4
+ let(:window){ Ruco::Window.new(10,10) }
5
+
6
+ describe :crop do
7
+ let(:window){ Ruco::Window.new(2,4) }
8
+
9
+ it "does not modify given lines" do
10
+ original = ['1234','1234']
11
+ window.crop(original)
12
+ original.should == ['1234','1234']
13
+ end
14
+
15
+ it "removes un-displayable chars" do
16
+ result = window.crop(['12345','12345','12345'])
17
+ result.should == ['1234','1234']
18
+ end
19
+
20
+ it "does not add whitespace" do
21
+ result = window.crop(['1','',''])
22
+ result.should == ['1','']
23
+ end
24
+
25
+ it "creates lines if necessary" do
26
+ result = window.crop(['1234'])
27
+ result.should == ['1234','']
28
+ end
29
+
30
+ it "stays inside frame as long as position is in frame" do
31
+ window.position = Ruco::Position.new(1,3)
32
+ result = window.crop(['12345678','12345678'])
33
+ result.should == ['1234','1234']
34
+ end
35
+
36
+ it "can display empty lines" do
37
+ window.crop([]).should == ['','']
38
+ end
39
+
40
+ describe 'scrolled' do
41
+ it "goes out of frame if line is out of frame" do
42
+ window = Ruco::Window.new(6,1)
43
+ window.position = Ruco::Position.new(6,0)
44
+ result = window.crop(['1','2','3','4','5','6','7','8','9'])
45
+ result.should == ['4','5','6','7','8','9']
46
+ end
47
+
48
+ it "goes out of frame if column is out of frame" do
49
+ window = Ruco::Window.new(1,6)
50
+ window.position = Ruco::Position.new(0,6)
51
+ result = window.crop(['1234567890'])
52
+ result.should == ['456789']
53
+ end
54
+ end
55
+ end
56
+
57
+ describe :top do
58
+ it "does not change when staying in frame" do
59
+ window.top.should == 0
60
+ window.position = Ruco::Position.new(9,0)
61
+ window.top.should == 0
62
+ end
63
+
64
+ it "changes by offset when going vertically out of frame" do
65
+ window.position = Ruco::Position.new(10,0)
66
+ window.top.should == 5
67
+ end
68
+
69
+ it "changes to x - offset when going down out of frame" do
70
+ window.position = Ruco::Position.new(20,0)
71
+ window.top.should == 15
72
+ end
73
+
74
+ it "changes to x - offset when going down out of frame" do
75
+ window.position = Ruco::Position.new(20,0)
76
+ window.position = Ruco::Position.new(7,0)
77
+ window.top.should == 2
78
+ end
79
+ end
80
+
81
+ describe :left do
82
+ it "does not change when staying in frame" do
83
+ window.left.should == 0
84
+ window.position = Ruco::Position.new(0,9)
85
+ window.left.should == 0
86
+ end
87
+
88
+ it "changes by offset when going vertically out of frame" do
89
+ window.position = Ruco::Position.new(0,9)
90
+ window.position = Ruco::Position.new(0,10)
91
+ window.left.should == 5
92
+ end
93
+
94
+ it "changes to x - offset when going right out of frame" do
95
+ window.position = Ruco::Position.new(0,20)
96
+ window.left.should == 15
97
+ end
98
+
99
+ it "changes to x - offset when going left out of frame" do
100
+ window.position = Ruco::Position.new(0,20)
101
+ window.position = Ruco::Position.new(0,7)
102
+ window.left.should == 2
103
+ end
104
+
105
+ it "changes to 0 when going left out of frame to 1" do
106
+ window.position = Ruco::Position.new(0,20)
107
+ window.position = Ruco::Position.new(0,1)
108
+ window.left.should == 0
109
+ end
110
+
111
+ it "does not change when staying in changed frame" do
112
+ window.position = Ruco::Position.new(0,9)
113
+ window.position = Ruco::Position.new(0,10)
114
+ window.left.should == 5
115
+ window.position = Ruco::Position.new(0,14)
116
+ window.left.should == 5
117
+ end
118
+ end
119
+
120
+ describe :top= do
121
+ it "sets" do
122
+ window.top = 1
123
+ window.top.should == 1
124
+ end
125
+
126
+ it "does not allow negative" do
127
+ window.top = -1
128
+ window.top.should == 0
129
+ end
130
+ end
131
+
132
+ describe :left= do
133
+ it "sets" do
134
+ window.left = 1
135
+ window.left.should == 1
136
+ end
137
+
138
+ it "does not allow negative" do
139
+ window.left = -1
140
+ window.left.should == 0
141
+ end
142
+ end
143
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 87
4
+ hash: 85
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 36
10
- version: 0.0.36
9
+ - 37
10
+ version: 0.0.37
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-29 00:00:00 +01:00
18
+ date: 2011-01-31 00:00:00 +01:00
19
19
  default_executable: ruco
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -67,6 +67,7 @@ files:
67
67
  - lib/ruco/text_area.rb
68
68
  - lib/ruco/text_field.rb
69
69
  - lib/ruco/version.rb
70
+ - lib/ruco/window.rb
70
71
  - ruco.gemspec
71
72
  - spec/ruco/application_spec.rb
72
73
  - spec/ruco/command_bar_spec.rb
@@ -78,6 +79,7 @@ files:
78
79
  - spec/ruco/keyboard_spec.rb
79
80
  - spec/ruco/status_bar_spec.rb
80
81
  - spec/ruco/text_area_spec.rb
82
+ - spec/ruco/window_spec.rb
81
83
  - spec/ruco_spec.rb
82
84
  - spec/spec_helper.rb
83
85
  has_rdoc: true
@@ -125,5 +127,6 @@ test_files:
125
127
  - spec/ruco/keyboard_spec.rb
126
128
  - spec/ruco/status_bar_spec.rb
127
129
  - spec/ruco/text_area_spec.rb
130
+ - spec/ruco/window_spec.rb
128
131
  - spec/ruco_spec.rb
129
132
  - spec/spec_helper.rb