ruco 0.2.18 → 0.2.19
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE.txt +20 -0
- data/bin/ruco +24 -30
- data/lib/ruco.rb +1 -3
- data/lib/ruco/command_bar.rb +1 -1
- data/lib/ruco/core_ext/range.rb +1 -1
- data/lib/ruco/core_ext/string.rb +2 -15
- data/lib/ruco/editor/colors.rb +2 -2
- data/lib/ruco/status_bar.rb +1 -1
- data/lib/ruco/syntax_parser.rb +1 -1
- data/lib/ruco/version.rb +1 -1
- data/lib/ruco/window.rb +1 -1
- metadata +34 -64
- data/.gitignore +0 -2
- data/.travis.yml +0 -7
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -39
- data/Rakefile +0 -32
- data/Readme.md +0 -164
- data/lib/ruco/keyboard.rb +0 -206
- data/lib/ruco/screen.rb +0 -148
- data/lib/ruco/style_map.rb +0 -108
- data/playground/benchmark_syntax_parser.rb +0 -23
- data/ruco.gemspec +0 -22
- data/spec/fixtures/slow.js +0 -4
- data/spec/fixtures/test.tmTheme +0 -186
- data/spec/ruco/application_spec.rb +0 -433
- data/spec/ruco/array_processor_spec.rb +0 -46
- data/spec/ruco/command_bar_spec.rb +0 -127
- data/spec/ruco/core_ext/array_spec.rb +0 -31
- data/spec/ruco/core_ext/range_spec.rb +0 -37
- data/spec/ruco/core_ext/string_spec.rb +0 -36
- data/spec/ruco/editor_spec.rb +0 -1261
- data/spec/ruco/file_store_spec.rb +0 -102
- data/spec/ruco/form_spec.rb +0 -83
- data/spec/ruco/history_spec.rb +0 -143
- data/spec/ruco/keyboard_spec.rb +0 -136
- data/spec/ruco/option_accessor_spec.rb +0 -26
- data/spec/ruco/screen_spec.rb +0 -52
- data/spec/ruco/status_bar_spec.rb +0 -49
- data/spec/ruco/style_map_spec.rb +0 -124
- data/spec/ruco/syntax_parser_spec.rb +0 -78
- data/spec/ruco/text_area_spec.rb +0 -183
- data/spec/ruco/tm_theme_spec.rb +0 -14
- data/spec/ruco/window_spec.rb +0 -170
- data/spec/ruco_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -36
@@ -1,26 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Ruco::OptionAccessor do
|
4
|
-
let(:options){ Ruco::OptionAccessor.new }
|
5
|
-
|
6
|
-
it "can be accessed like a hash" do
|
7
|
-
options[:xx].should == nil
|
8
|
-
options[:xx] = 1
|
9
|
-
options[:xx].should == 1
|
10
|
-
end
|
11
|
-
|
12
|
-
it "can be written" do
|
13
|
-
options.foo = true
|
14
|
-
options[:foo].should == true
|
15
|
-
end
|
16
|
-
|
17
|
-
it "can access nested keys" do
|
18
|
-
options.foo_bar = 1
|
19
|
-
options.history_size = 1
|
20
|
-
options.nested(:history).should == {:size => 1}
|
21
|
-
end
|
22
|
-
|
23
|
-
it "has empty hash for nested key" do
|
24
|
-
options.nested(:history).should == {}
|
25
|
-
end
|
26
|
-
end
|
data/spec/ruco/screen_spec.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Ruco::Screen do
|
4
|
-
describe :curses_style do
|
5
|
-
it "is 'normal' for nothing" do
|
6
|
-
Ruco::Screen.curses_style(:normal, true).should == 256
|
7
|
-
end
|
8
|
-
|
9
|
-
it "is red for red" do
|
10
|
-
pending
|
11
|
-
Ruco::Screen.curses_style(:red, true).should == Curses::color_pair( Curses::COLOR_RED )
|
12
|
-
end
|
13
|
-
|
14
|
-
it "is reverse for reverse" do
|
15
|
-
Ruco::Screen.curses_style(:reverse, true).should == 512
|
16
|
-
end
|
17
|
-
|
18
|
-
it "raises on unknown style" do
|
19
|
-
lambda{
|
20
|
-
Ruco::Screen.curses_style(:foo, true)
|
21
|
-
}.should raise_error
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'without colors' do
|
25
|
-
it "is 'normal' for normal" do
|
26
|
-
Ruco::Screen.curses_style(:normal, false).should == Curses::A_NORMAL
|
27
|
-
end
|
28
|
-
|
29
|
-
it "is reverse for reverse" do
|
30
|
-
Ruco::Screen.curses_style(:reverse, false).should == Curses::A_REVERSE
|
31
|
-
end
|
32
|
-
|
33
|
-
it "is normal for unknown style" do
|
34
|
-
Ruco::Screen.curses_style(:foo, false).should == Curses::A_NORMAL
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe :html_to_terminal_color do
|
40
|
-
# http://www.mudpedia.org/wiki/Xterm_256_colors
|
41
|
-
[
|
42
|
-
['#ff0000', 196],
|
43
|
-
['#00ff00', 46],
|
44
|
-
['#0000ff', 21],
|
45
|
-
['#ffffff', 231]
|
46
|
-
].each do |html,term|
|
47
|
-
it "converts #{html} to #{term}" do
|
48
|
-
Ruco::Screen.html_to_terminal_color(html).should == term
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Ruco::StatusBar do
|
4
|
-
let(:file){ 'spec/temp.txt' }
|
5
|
-
let(:editor){ Ruco::Editor.new(file, :lines => 5, :columns => 35) }
|
6
|
-
let(:bar){ Ruco::StatusBar.new(editor, :columns => 35) }
|
7
|
-
|
8
|
-
it "shows name and version" do
|
9
|
-
bar.view.should include("Ruco #{Ruco::VERSION}")
|
10
|
-
end
|
11
|
-
|
12
|
-
it "shows the file" do
|
13
|
-
bar.view.should include(file)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "can show to long files" do
|
17
|
-
editor = Ruco::Editor.new('123456789abcdefghijklmnop', :lines => 5, :columns => 20)
|
18
|
-
bar = Ruco::StatusBar.new(editor, :columns => 30)
|
19
|
-
bar.view.should == "Ruco #{Ruco::VERSION} -- 1234...nop 1:1"
|
20
|
-
bar.view.size.should == 30
|
21
|
-
end
|
22
|
-
|
23
|
-
it "indicates modified" do
|
24
|
-
bar.view.should_not include('*')
|
25
|
-
editor.insert('x')
|
26
|
-
bar.view.should include('*')
|
27
|
-
end
|
28
|
-
|
29
|
-
it "indicates writable" do
|
30
|
-
bar.view.should_not include('!')
|
31
|
-
end
|
32
|
-
|
33
|
-
it "indicates writable if file is missing" do
|
34
|
-
editor.stub!(:file).and_return '/gradasadadsds'
|
35
|
-
bar.view.should_not include('!')
|
36
|
-
end
|
37
|
-
|
38
|
-
it "indicates not writable" do
|
39
|
-
# this test will always fail on Windows with cygwin because of how cygwin sets up permissions
|
40
|
-
unless RUBY_PLATFORM =~ /mingw/
|
41
|
-
editor.stub!(:file).and_return '/etc/sudoers'
|
42
|
-
bar.view.should include('!')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
it "shows line and column and right side" do
|
47
|
-
bar.view.should =~ /1:1$/
|
48
|
-
end
|
49
|
-
end
|
data/spec/ruco/style_map_spec.rb
DELETED
@@ -1,124 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Ruco::StyleMap do
|
4
|
-
let(:map){ Ruco::StyleMap.new(3) }
|
5
|
-
|
6
|
-
describe :flat do
|
7
|
-
it "is empty by default" do
|
8
|
-
map.flatten.should == [nil, nil, nil]
|
9
|
-
end
|
10
|
-
|
11
|
-
it "reproduces simple styles" do
|
12
|
-
map.add(:red, 1, 3..5)
|
13
|
-
# red from 3 to 5
|
14
|
-
map.flatten.should == [
|
15
|
-
nil,
|
16
|
-
[nil, nil, nil, :red, nil, nil, :normal],
|
17
|
-
nil
|
18
|
-
]
|
19
|
-
end
|
20
|
-
|
21
|
-
it "reproduces merged styles" do
|
22
|
-
map.add(:reverse, 1, 2..4)
|
23
|
-
map.add(:red, 1, 3..5)
|
24
|
-
# reverse at 2 -- reverse and red at 3,4 -- red at 5
|
25
|
-
map.flatten.should == [
|
26
|
-
nil,
|
27
|
-
[nil, nil, :reverse, :red, nil, :red, :normal],
|
28
|
-
nil
|
29
|
-
]
|
30
|
-
end
|
31
|
-
|
32
|
-
it "reproduces styles with same style repeated" do
|
33
|
-
map.add(:red, 1, 2..4)
|
34
|
-
map.add(:red, 1, 6..7)
|
35
|
-
# red 2,3,4 normal on 5 red on 6,7
|
36
|
-
map.flatten.should == [
|
37
|
-
nil,
|
38
|
-
[nil, nil, :red, nil, nil, :normal, :red, nil, :normal],
|
39
|
-
nil
|
40
|
-
]
|
41
|
-
end
|
42
|
-
|
43
|
-
it "overwrites styles" do
|
44
|
-
map.add(:reverse, 0, 0..1)
|
45
|
-
map.add(:normal, 0, 0..1)
|
46
|
-
map.flatten.should == [
|
47
|
-
[:normal, nil, :normal],
|
48
|
-
nil,
|
49
|
-
nil
|
50
|
-
]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe 'array style operations' do
|
55
|
-
it "adds two maps" do
|
56
|
-
s1 = Ruco::StyleMap.new(1)
|
57
|
-
s1.add(:reverse, 0, 0..1)
|
58
|
-
s2 = Ruco::StyleMap.new(2)
|
59
|
-
s2.add(:reverse, 0, 2..3)
|
60
|
-
(s1 + s2).flatten.should == [
|
61
|
-
[:reverse, nil, :normal],
|
62
|
-
[nil, nil, :reverse, nil, :normal],
|
63
|
-
nil
|
64
|
-
]
|
65
|
-
end
|
66
|
-
|
67
|
-
it "can shift" do
|
68
|
-
s = Ruco::StyleMap.new(2)
|
69
|
-
s.add(:reverse, 0, 0..1)
|
70
|
-
s.add(:reverse, 1, 1..2)
|
71
|
-
s.shift.flatten.should == [[:reverse, nil, :normal]]
|
72
|
-
s.flatten.should == [[nil, :reverse, nil, :normal]]
|
73
|
-
end
|
74
|
-
|
75
|
-
it "can pop" do
|
76
|
-
s = Ruco::StyleMap.new(2)
|
77
|
-
s.add(:reverse, 0, 0..1)
|
78
|
-
s.add(:reverse, 1, 1..2)
|
79
|
-
s.pop.flatten.should == [[nil, :reverse, nil, :normal]]
|
80
|
-
s.flatten.should == [[:reverse, nil, :normal]]
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe :left_pad! do
|
85
|
-
it "adds whitespace to left side" do
|
86
|
-
s = Ruco::StyleMap.new(2)
|
87
|
-
s.add(:reverse, 0, 0..1)
|
88
|
-
s.add(:reverse, 1, 1..2)
|
89
|
-
s.left_pad!(3)
|
90
|
-
s.flatten.should == [
|
91
|
-
[nil, nil, nil, :reverse, nil, :normal],
|
92
|
-
[nil, nil, nil, nil, :reverse, nil, :normal]
|
93
|
-
]
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe :invert! do
|
98
|
-
it "inverts styles" do
|
99
|
-
s = Ruco::StyleMap.new(2)
|
100
|
-
s.add(:reverse, 0, 0..1)
|
101
|
-
s.add(:normal, 1, 1..2)
|
102
|
-
s.add(:red, 1, 4..5)
|
103
|
-
s.invert!
|
104
|
-
s.flatten.should == [
|
105
|
-
[:normal, nil, :normal],
|
106
|
-
[nil, :reverse, nil, :normal, :red, nil, :normal]
|
107
|
-
]
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe :styled do
|
112
|
-
it "can style an unstyled line" do
|
113
|
-
Ruco::StyleMap.styled("a", nil).should == [[:normal, "a"]]
|
114
|
-
end
|
115
|
-
|
116
|
-
it "can style a styled line" do
|
117
|
-
Ruco::StyleMap.styled("a", [:reverse ,nil]).should == [[:normal, ""], [:reverse, "a"]]
|
118
|
-
end
|
119
|
-
|
120
|
-
it "keeps unstyled parts" do
|
121
|
-
Ruco::StyleMap.styled("abc", [:reverse, :normal]).should == [[:normal, ""], [:reverse, "a"],[:normal,'bc']]
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Ruco::SyntaxParser do
|
4
|
-
def parse(text, languages=['ruby'])
|
5
|
-
Ruco::SyntaxParser.syntax_for_lines(text, languages)
|
6
|
-
end
|
7
|
-
|
8
|
-
describe :parse_lines do
|
9
|
-
it "shows positions for simple lines" do
|
10
|
-
parse(["class Foo","end"]).should == [[
|
11
|
-
["keyword.control.class.ruby", 0...5],
|
12
|
-
["entity.name.type.class.ruby", 6...9],
|
13
|
-
["meta.class.ruby", 0...9]],
|
14
|
-
[["keyword.control.ruby", 0...3]
|
15
|
-
]]
|
16
|
-
end
|
17
|
-
|
18
|
-
it "shows positions for complicated lines" do
|
19
|
-
parse(["class foo end blob else Foo"]).should == [[
|
20
|
-
["keyword.control.class.ruby", 0...5],
|
21
|
-
["entity.name.type.class.ruby", 6...9],
|
22
|
-
["meta.class.ruby", 0...9],
|
23
|
-
["keyword.control.ruby", 10...13],
|
24
|
-
["keyword.control.ruby", 19...23],
|
25
|
-
["variable.other.constant.ruby", 24...27]
|
26
|
-
]]
|
27
|
-
end
|
28
|
-
|
29
|
-
it "does not show keywords in strings" do
|
30
|
-
parse(["Bar 'Bar' foo"]).should == [[
|
31
|
-
["variable.other.constant.ruby", 0...3],
|
32
|
-
["punctuation.definition.string.begin.ruby", 4...5],
|
33
|
-
["punctuation.definition.string.end.ruby", 8...9],
|
34
|
-
["string.quoted.single.ruby", 4...9]
|
35
|
-
]]
|
36
|
-
end
|
37
|
-
|
38
|
-
it "does not show strings in comments" do
|
39
|
-
parse(["'Bar' # 'Bar'"]).should == [[
|
40
|
-
["punctuation.definition.string.begin.ruby", 0...1],
|
41
|
-
["punctuation.definition.string.end.ruby", 4...5],
|
42
|
-
["string.quoted.single.ruby", 0...5],
|
43
|
-
["punctuation.definition.comment.ruby", 6...7],
|
44
|
-
["comment.line.number-sign.ruby", 6...13]
|
45
|
-
]]
|
46
|
-
end
|
47
|
-
|
48
|
-
it "shows multiline comments" do
|
49
|
-
parse(["=begin","1 : 2","=end"]).should == [
|
50
|
-
[["punctuation.definition.comment.ruby", 0...6], ["comment.block.documentation.ruby", 0...7]],
|
51
|
-
[["comment.block.documentation.ruby", 0...6]],
|
52
|
-
[["punctuation.definition.comment.ruby", 0...4], ["comment.block.documentation.ruby", 0...4]]
|
53
|
-
]
|
54
|
-
end
|
55
|
-
|
56
|
-
it "continues multiline on last line before closing it" do
|
57
|
-
parse(["%Q{\n\na }"]).should == [
|
58
|
-
[["punctuation.definition.string.begin.ruby", 0...3], ["string.quoted.double.ruby.mod", 0...4]],
|
59
|
-
[["string.quoted.double.ruby.mod", 0...1]],
|
60
|
-
[["punctuation.definition.string.end.ruby", 3...4], ["string.quoted.double.ruby.mod", 0...4]]
|
61
|
-
]
|
62
|
-
end
|
63
|
-
|
64
|
-
it "can handle unfound syntaxes" do
|
65
|
-
parse('aaaa', ['fooo']).should == []
|
66
|
-
end
|
67
|
-
|
68
|
-
it "can handle RegexpErrors" do
|
69
|
-
parse(["(?# 2: NIL )(NIL)(?=[\\x80-\\xff(){ \\x00-\\x1f\\x7f%*\#{'\"'}\\\\\\[\\]+])|\\"])
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe :syntax_nodes do
|
74
|
-
it "detects languages not present in ultraviolet" do
|
75
|
-
Ruco::SyntaxParser.syntax_node(['html+erb']).should_not == nil
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
data/spec/ruco/text_area_spec.rb
DELETED
@@ -1,183 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe Ruco::TextArea do
|
5
|
-
describe :move do
|
6
|
-
describe 'pages' do
|
7
|
-
it "can move down a page" do
|
8
|
-
text = Ruco::TextArea.new("1\n2\n3\n4\n5\n6\n7\n8\n9\n", :lines => 3, :columns => 3)
|
9
|
-
text.move(:page_down)
|
10
|
-
text.view.should == "3\n4\n5"
|
11
|
-
text.cursor.should == [1,0]
|
12
|
-
end
|
13
|
-
|
14
|
-
it "keeps cursor position when moving down" do
|
15
|
-
text = Ruco::TextArea.new("1\n2abc\n3\n4\n5ab\n6\n7\n8\n9\n", :lines => 3, :columns => 5)
|
16
|
-
text.move(:to, 1,4)
|
17
|
-
text.move(:page_down)
|
18
|
-
text.view.should == "4\n5ab\n6"
|
19
|
-
text.cursor.should == [1,3]
|
20
|
-
end
|
21
|
-
|
22
|
-
it "can move up a page" do
|
23
|
-
text = Ruco::TextArea.new("0\n1\n2\n3\n4\n5\n6\n7\n8\n", :lines => 3, :columns => 3)
|
24
|
-
text.move(:to, 4, 0)
|
25
|
-
text.view.should == "3\n4\n5"
|
26
|
-
text.cursor.should == [1,0]
|
27
|
-
text.move(:page_up)
|
28
|
-
text.view.should == "0\n1\n2"
|
29
|
-
text.cursor.should == [1,0]
|
30
|
-
end
|
31
|
-
|
32
|
-
it "keeps column position when moving up" do
|
33
|
-
text = Ruco::TextArea.new("0\n1\n2ab\n3\n4\n5abc\n6\n7\n8\n9\n10\n11\n", :lines => 3, :columns => 5)
|
34
|
-
text.move(:to, 5, 3)
|
35
|
-
text.view.should == "4\n5abc\n6"
|
36
|
-
text.cursor.should == [1,3]
|
37
|
-
text.move(:page_up)
|
38
|
-
text.view.should == "1\n2ab\n3"
|
39
|
-
text.cursor.should == [1,3]
|
40
|
-
end
|
41
|
-
|
42
|
-
it "moves pages symetric" do
|
43
|
-
text = Ruco::TextArea.new("0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n0\n", :lines => 3, :columns => 3)
|
44
|
-
text.move(:to, 4, 1)
|
45
|
-
text.view.should == "3\n4\n5"
|
46
|
-
text.cursor.should == [1,1]
|
47
|
-
|
48
|
-
text.move(:page_down)
|
49
|
-
text.move(:page_down)
|
50
|
-
text.move(:page_up)
|
51
|
-
text.move(:page_up)
|
52
|
-
|
53
|
-
text.cursor.should == [1,1]
|
54
|
-
text.view.should == "3\n4\n5"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe :insert do
|
60
|
-
let(:text){Ruco::TextArea.new("", :lines => 3, :columns => 10)}
|
61
|
-
|
62
|
-
describe "inserting surrounding characters" do
|
63
|
-
xit "does nothing special when pasting" do
|
64
|
-
text.insert("'bar'")
|
65
|
-
text.view.should == "'bar'\n\n"
|
66
|
-
text.cursor.should == [0,5]
|
67
|
-
end
|
68
|
-
|
69
|
-
xit "inserts a pair when just typing" do
|
70
|
-
text.insert("'")
|
71
|
-
text.view.should == "''\n\n"
|
72
|
-
text.cursor.should == [0,1]
|
73
|
-
end
|
74
|
-
|
75
|
-
xit "closes the surround if only char in surround" do
|
76
|
-
text.insert("'")
|
77
|
-
text.insert("'")
|
78
|
-
text.view.should == "''\n\n"
|
79
|
-
text.cursor.should == [0,2]
|
80
|
-
end
|
81
|
-
|
82
|
-
xit "overwrites next if its the same" do
|
83
|
-
text.insert("'bar'")
|
84
|
-
text.move(:relative, 0,-1)
|
85
|
-
text.insert("'")
|
86
|
-
text.view.should == "'bar'\n\n"
|
87
|
-
text.cursor.should == [0,5]
|
88
|
-
end
|
89
|
-
|
90
|
-
it "surrounds text when selecting" do
|
91
|
-
text.insert('bar')
|
92
|
-
text.move(:to, 0,0)
|
93
|
-
text.selecting{ move(:to, 0,2) }
|
94
|
-
text.insert("{")
|
95
|
-
text.view.should == "{ba}r\n\n"
|
96
|
-
text.cursor.should == [0,4]
|
97
|
-
end
|
98
|
-
|
99
|
-
it "does not surround text with closing char when selecting" do
|
100
|
-
text.insert('bar')
|
101
|
-
text.move(:to, 0,0)
|
102
|
-
text.selecting{ move(:to, 0,2) }
|
103
|
-
text.insert("}")
|
104
|
-
text.view.should == "}r\n\n"
|
105
|
-
text.cursor.should == [0,1]
|
106
|
-
end
|
107
|
-
|
108
|
-
it "replaces surrounding quotes" do
|
109
|
-
text.insert('"bar"')
|
110
|
-
text.move(:to, 0,0)
|
111
|
-
text.selecting{ move(:to, 0,5) }
|
112
|
-
text.insert("'")
|
113
|
-
text.view.should == "'bar'\n\n"
|
114
|
-
text.cursor.should == [0,5]
|
115
|
-
end
|
116
|
-
|
117
|
-
it "replace surrounding braces" do
|
118
|
-
text.insert('(bar)')
|
119
|
-
text.move(:to, 0,0)
|
120
|
-
text.selecting{ move(:to, 0,5) }
|
121
|
-
text.insert("'")
|
122
|
-
text.view.should == "'bar'\n\n"
|
123
|
-
text.cursor.should == [0,5]
|
124
|
-
end
|
125
|
-
|
126
|
-
it "does not replace when only one side has surrounding char" do
|
127
|
-
text.insert("\"bar\"")
|
128
|
-
text.move(:to, 0,0)
|
129
|
-
text.selecting{ move(:to, 0,3) }
|
130
|
-
text.insert("'")
|
131
|
-
text.view.should == "'\"ba'r\"\n\n"
|
132
|
-
text.cursor.should == [0,5]
|
133
|
-
end
|
134
|
-
|
135
|
-
it "expands selection when surrounding" do
|
136
|
-
text.insert('bar')
|
137
|
-
text.move(:to, 0,0)
|
138
|
-
text.selecting{ move(:to, 0,2) }
|
139
|
-
text.insert("{")
|
140
|
-
text.view.should == "{ba}r\n\n"
|
141
|
-
text.selection.should == ([0,0]..[0,4])
|
142
|
-
end
|
143
|
-
|
144
|
-
it "keeps selection when replacing surround" do
|
145
|
-
text.insert('"bar"')
|
146
|
-
text.move(:to, 0,0)
|
147
|
-
text.selecting{ move(:to, 0,5) }
|
148
|
-
text.insert("'")
|
149
|
-
text.view.should == "'bar'\n\n"
|
150
|
-
text.selection.should == ([0,0]..[0,5])
|
151
|
-
end
|
152
|
-
|
153
|
-
it "surrounds across lines" do
|
154
|
-
text.insert("ab\ncd\nef")
|
155
|
-
text.move(:to, 0,0)
|
156
|
-
text.selecting{ move(:to, 1,0) }
|
157
|
-
text.insert("'")
|
158
|
-
text.view.should == "'ab\n'cd\nef"
|
159
|
-
text.selection.should == ([0,0]..[1,1])
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
if ''.respond_to?(:encoding)
|
165
|
-
describe "encoding" do
|
166
|
-
def build(encoding)
|
167
|
-
Ruco::TextArea.new("asd".force_encoding(encoding), :lines => 3, :columns => 10)
|
168
|
-
end
|
169
|
-
|
170
|
-
it "upgrades ascii-8 to utf8" do
|
171
|
-
build('ASCII-8BIT').lines.first.encoding.to_s.should == 'UTF-8'
|
172
|
-
end
|
173
|
-
|
174
|
-
it "upgrades ascii-7 to utf8" do
|
175
|
-
build('US-ASCII').lines.first.encoding.to_s.should == 'UTF-8'
|
176
|
-
end
|
177
|
-
|
178
|
-
it "does not convert weird encodings to utf-8" do
|
179
|
-
build('eucJP').lines.first.encoding.to_s.should == 'EUC-JP'
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|