text_editor 0.0.0 → 0.0.1
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 +4 -4
- data/.rubocop.yml +3 -0
- data/.text_editor.rb +81 -2
- data/Gemfile.lock +1 -0
- data/README.org +103 -0
- data/bin/console +1 -1
- data/lib/core_ext/hash.rb +2 -0
- data/lib/core_ext/pathname.rb +2 -0
- data/lib/text_editor.rb +43 -13
- data/lib/text_editor/buffer.rb +3 -0
- data/lib/text_editor/clipboard.rb +1 -1
- data/lib/text_editor/clipboard/cygwin.rb +0 -4
- data/lib/text_editor/clipboard/linux.rb +0 -4
- data/lib/text_editor/clipboard/mac.rb +0 -4
- data/lib/text_editor/clipboard/unknown.rb +0 -4
- data/lib/text_editor/clipboard/windows.rb +0 -4
- data/lib/text_editor/command.rb +4 -4
- data/lib/text_editor/command/append_line_and_insert.rb +11 -0
- data/lib/text_editor/command/change_mode.rb +9 -0
- data/lib/text_editor/command/cursor_end_and_insert.rb +9 -0
- data/lib/text_editor/command/cursor_left.rb +1 -8
- data/lib/text_editor/command/cursor_left_with_wrap.rb +16 -0
- data/lib/text_editor/command/cursor_right.rb +2 -9
- data/lib/text_editor/command/cursor_right_and_insert.rb +9 -0
- data/lib/text_editor/command/cursor_right_with_wrap.rb +19 -0
- data/lib/text_editor/command/cursor_start_without_whitespace.rb +11 -0
- data/lib/text_editor/command/cursor_up.rb +1 -1
- data/lib/text_editor/command/forward_word.rb +16 -0
- data/lib/text_editor/command/insert_tab.rb +1 -1
- data/lib/text_editor/command/prepend_line_and_insert.rb +11 -0
- data/lib/text_editor/command/replace_line.rb +13 -0
- data/lib/text_editor/command/resolver.rb +3 -2
- data/lib/text_editor/component.rb +1 -1
- data/lib/text_editor/configuration.rb +11 -3
- data/lib/text_editor/configuration/bootstrap.rb +9 -3
- data/lib/text_editor/configuration/flavor.rb +20 -0
- data/lib/text_editor/configuration/log.rb +7 -0
- data/lib/text_editor/configuration/mode.rb +28 -0
- data/lib/text_editor/configuration/operating_system.rb +21 -0
- data/lib/text_editor/configuration/resolver.rb +1 -1
- data/lib/text_editor/configuration/tab.rb +11 -0
- data/lib/text_editor/cursor.rb +2 -0
- data/lib/text_editor/keyboard.rb +1 -1
- data/lib/text_editor/logger.rb +11 -0
- data/lib/text_editor/reactor.rb +5 -3
- data/lib/text_editor/terminal.rb +2 -19
- data/lib/text_editor/window.rb +34 -5
- data/spec/spec_helper.rb +3 -0
- data/spec/support/command_helper.rb +43 -0
- data/spec/text_editor/clipboard_spec.rb +0 -7
- data/spec/text_editor/command/append_line_and_insert_spec.rb +38 -0
- data/spec/text_editor/command/backspace_spec.rb +54 -0
- data/spec/text_editor/command/change_mode_spec.rb +17 -0
- data/spec/text_editor/command/cursor_down_spec.rb +57 -0
- data/spec/text_editor/command/cursor_end_and_insert_spec.rb +35 -0
- data/spec/text_editor/command/cursor_end_spec.rb +30 -0
- data/spec/text_editor/command/cursor_left_spec.rb +46 -0
- data/spec/text_editor/command/cursor_left_with_wrap_spec.rb +46 -0
- data/spec/text_editor/command/cursor_right_and_insert_spec.rb +58 -0
- data/spec/text_editor/command/cursor_right_spec.rb +53 -0
- data/spec/text_editor/command/cursor_right_with_wrap_spec.rb +54 -0
- data/spec/text_editor/command/cursor_start_spec.rb +33 -0
- data/spec/text_editor/command/cursor_start_without_whitespace_spec.rb +46 -0
- data/spec/text_editor/command/cursor_up_spec.rb +56 -0
- data/spec/text_editor/command/forward_word_spec.rb +8 -0
- data/spec/text_editor/command/insert_char_spec.rb +24 -0
- data/spec/text_editor/command/insert_line_spec.rb +26 -0
- data/spec/text_editor/command/insert_tab_spec.rb +27 -0
- data/spec/text_editor/command/prepend_line_and_insert_spec.rb +38 -0
- data/spec/text_editor/command/replace_line_spec.rb +34 -0
- data/spec/text_editor/command/resolver_spec.rb +2 -2
- data/spec/text_editor/command/write_file_spec.rb +25 -0
- data/spec/text_editor/command_spec.rb +8 -8
- data/spec/text_editor/component_spec.rb +7 -0
- data/spec/text_editor/configuration/log_spec.rb +26 -0
- data/spec/text_editor/{operating_system_spec.rb → configuration/operating_system_spec.rb} +1 -1
- data/spec/text_editor/configuration/tab_spec.rb +41 -0
- data/spec/text_editor/configuration_spec.rb +11 -4
- data/spec/text_editor/logger_spec.rb +17 -0
- data/text_editor.gemspec +2 -1
- metadata +84 -7
- data/lib/text_editor/mode.rb +0 -23
- data/lib/text_editor/mode/nano.rb +0 -30
- data/lib/text_editor/operating_system.rb +0 -19
@@ -0,0 +1,34 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe TextEditor::Command::ReplaceLine do
|
4
|
+
include CommandHelper
|
5
|
+
|
6
|
+
describe "#run" do
|
7
|
+
context "with an empty buffer" do
|
8
|
+
before do
|
9
|
+
expect_buffer("")
|
10
|
+
expect_cursor(0, 0)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "does not move cursor" do
|
14
|
+
subject.run
|
15
|
+
expect_buffer("")
|
16
|
+
expect_cursor(0, 0)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "with a one line buffer" do
|
21
|
+
before do
|
22
|
+
update_buffer("ab")
|
23
|
+
update_cursor(0, 1)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "clears line and changes to insert mode at start of line" do
|
27
|
+
subject.run
|
28
|
+
expect_buffer("")
|
29
|
+
expect_cursor(0, 0)
|
30
|
+
expect_mode(:insert)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -30,12 +30,12 @@ RSpec.describe TextEditor::Command::Resolver do
|
|
30
30
|
describe "#resolve" do
|
31
31
|
it "finds existing string commands" do
|
32
32
|
actual = subject.resolve("fake_command")
|
33
|
-
expect(actual).to
|
33
|
+
expect(actual).to eq(fake)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "finds existing symbol commands" do
|
37
37
|
actual = subject.resolve(:fake_command)
|
38
|
-
expect(actual).to
|
38
|
+
expect(actual).to eq(fake)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "returns nil for missing commands" do
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe TextEditor::Command::WriteFile do
|
4
|
+
include CommandHelper
|
5
|
+
|
6
|
+
describe "#run" do
|
7
|
+
context "with a specified file" do
|
8
|
+
let(:file) { Pathname.new("test") }
|
9
|
+
|
10
|
+
it "it writes the buffer to the file" do
|
11
|
+
expect(window).to receive(:file).and_return(file).exactly(3).times
|
12
|
+
expect(file).to receive(:write).with("testing")
|
13
|
+
update_buffer("testing")
|
14
|
+
subject.run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "without a specified file" do
|
19
|
+
it "it beeps the terminal" do
|
20
|
+
expect(subject.terminal).to receive(:beep)
|
21
|
+
subject.run
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -30,14 +30,6 @@ RSpec.describe TextEditor::Command do
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
describe "#command" do
|
34
|
-
let(:resolver) { described_class::Resolver }
|
35
|
-
|
36
|
-
it "returns a command resolver" do
|
37
|
-
expect(subject.command).to be_a(resolver)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
33
|
describe "#content" do
|
42
34
|
it "returns buffer content for the current line" do
|
43
35
|
line = "test"
|
@@ -69,6 +61,14 @@ RSpec.describe TextEditor::Command do
|
|
69
61
|
end
|
70
62
|
end
|
71
63
|
|
64
|
+
describe "#scan" do
|
65
|
+
it "returns a string scanner for the content of the current line" do
|
66
|
+
expect(subject).to receive(:content).and_return("test")
|
67
|
+
expect(StringScanner).to receive(:new).with("test").and_return(:example)
|
68
|
+
expect(subject.scan).to eq(:example)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
72
|
describe "#state" do
|
73
73
|
it "delegates to editor.window" do
|
74
74
|
expect(editor).to receive_message_chain(:window, :state)
|
@@ -11,6 +11,13 @@ RSpec.describe TextEditor::Component do
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
describe "#command" do
|
15
|
+
it "delegates to editor.command" do
|
16
|
+
expect(subject).to receive_message_chain(:editor, :command)
|
17
|
+
subject.command
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
14
21
|
describe "#config" do
|
15
22
|
it "delegates to editor.config" do
|
16
23
|
expect(subject).to receive_message_chain(:editor, :config)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe TextEditor::Configuration::Log do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
describe "#file" do
|
7
|
+
it "should be an accessor" do
|
8
|
+
subject.file = :test
|
9
|
+
expect(subject.file).to eq(:test)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#level" do
|
14
|
+
it "should be an accessor" do
|
15
|
+
subject.level = :test
|
16
|
+
expect(subject.level).to eq(:test)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#options" do
|
21
|
+
it "should be an accessor" do
|
22
|
+
subject.options = :test
|
23
|
+
expect(subject.options).to eq(:test)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe TextEditor::Configuration::Tab do
|
4
|
+
subject { described_class.new }
|
5
|
+
|
6
|
+
describe "#soft" do
|
7
|
+
it "should be an accessor" do
|
8
|
+
subject.soft = :test
|
9
|
+
expect(subject.soft).to eq(:test)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#to_s" do
|
14
|
+
context "with hard tabs" do
|
15
|
+
before { subject.soft = false }
|
16
|
+
|
17
|
+
it "returns a tab character" do
|
18
|
+
expect(subject.to_s).to eq("\t")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "with soft tabs" do
|
23
|
+
before { subject.soft = true }
|
24
|
+
|
25
|
+
it "returns tab.width spaces" do
|
26
|
+
subject.width = 2
|
27
|
+
expect(subject.to_s).to eq(" ")
|
28
|
+
|
29
|
+
subject.width = 3
|
30
|
+
expect(subject.to_s).to eq(" ")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#width" do
|
36
|
+
it "should be an accessor" do
|
37
|
+
subject.width = :test
|
38
|
+
expect(subject.width).to eq(:test)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -15,11 +15,18 @@ RSpec.describe TextEditor::Configuration do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe "#log" do
|
18
|
-
|
19
|
-
|
18
|
+
let(:log) { described_class::Log }
|
19
|
+
|
20
|
+
it "returns a Log instance" do
|
21
|
+
expect(subject.log).to be_a(log)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#tag" do
|
26
|
+
let(:tab) { described_class::Tab }
|
20
27
|
|
21
|
-
|
22
|
-
expect(subject.
|
28
|
+
it "returns a Tab instance" do
|
29
|
+
expect(subject.tab).to be_a(tab)
|
23
30
|
end
|
24
31
|
end
|
25
32
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe TextEditor::Logger do
|
4
|
+
subject { described_class.new(editor) }
|
5
|
+
|
6
|
+
let(:editor) { double("editor") }
|
7
|
+
let(:log) { double("log") }
|
8
|
+
|
9
|
+
describe "#initialize" do
|
10
|
+
it "inherits the top level logger with options from config" do
|
11
|
+
expect(editor).to receive_message_chain(:config, :log).and_return(log)
|
12
|
+
expect(log).to receive(:file)
|
13
|
+
expect(log).to receive(:options)
|
14
|
+
expect(subject).to be_a(::Logger)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/text_editor.gemspec
CHANGED
@@ -10,9 +10,10 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.rdoc_options = %w(--charset=UTF-8 --inline-source --line-numbers --main README.org)
|
11
11
|
s.summary = "Text editor"
|
12
12
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
13
|
-
s.version = "0.0.
|
13
|
+
s.version = "0.0.1"
|
14
14
|
|
15
15
|
s.executables << "te"
|
16
16
|
|
17
|
+
s.add_dependency "bundler"
|
17
18
|
s.add_dependency "curses", "1.0.2"
|
18
19
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: curses
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -54,29 +68,42 @@ files:
|
|
54
68
|
- lib/text_editor/clipboard/unknown.rb
|
55
69
|
- lib/text_editor/clipboard/windows.rb
|
56
70
|
- lib/text_editor/command.rb
|
71
|
+
- lib/text_editor/command/append_line_and_insert.rb
|
57
72
|
- lib/text_editor/command/backspace.rb
|
73
|
+
- lib/text_editor/command/change_mode.rb
|
58
74
|
- lib/text_editor/command/cursor_down.rb
|
59
75
|
- lib/text_editor/command/cursor_end.rb
|
76
|
+
- lib/text_editor/command/cursor_end_and_insert.rb
|
60
77
|
- lib/text_editor/command/cursor_left.rb
|
78
|
+
- lib/text_editor/command/cursor_left_with_wrap.rb
|
61
79
|
- lib/text_editor/command/cursor_right.rb
|
80
|
+
- lib/text_editor/command/cursor_right_and_insert.rb
|
81
|
+
- lib/text_editor/command/cursor_right_with_wrap.rb
|
62
82
|
- lib/text_editor/command/cursor_start.rb
|
83
|
+
- lib/text_editor/command/cursor_start_without_whitespace.rb
|
63
84
|
- lib/text_editor/command/cursor_up.rb
|
85
|
+
- lib/text_editor/command/forward_word.rb
|
64
86
|
- lib/text_editor/command/insert_char.rb
|
65
87
|
- lib/text_editor/command/insert_line.rb
|
66
88
|
- lib/text_editor/command/insert_tab.rb
|
89
|
+
- lib/text_editor/command/prepend_line_and_insert.rb
|
67
90
|
- lib/text_editor/command/quit.rb
|
91
|
+
- lib/text_editor/command/replace_line.rb
|
68
92
|
- lib/text_editor/command/resolver.rb
|
69
93
|
- lib/text_editor/command/write_file.rb
|
70
94
|
- lib/text_editor/component.rb
|
71
95
|
- lib/text_editor/configuration.rb
|
72
96
|
- lib/text_editor/configuration/bootstrap.rb
|
73
97
|
- lib/text_editor/configuration/dsl.rb
|
98
|
+
- lib/text_editor/configuration/flavor.rb
|
99
|
+
- lib/text_editor/configuration/log.rb
|
100
|
+
- lib/text_editor/configuration/mode.rb
|
101
|
+
- lib/text_editor/configuration/operating_system.rb
|
74
102
|
- lib/text_editor/configuration/resolver.rb
|
103
|
+
- lib/text_editor/configuration/tab.rb
|
75
104
|
- lib/text_editor/cursor.rb
|
76
105
|
- lib/text_editor/keyboard.rb
|
77
|
-
- lib/text_editor/
|
78
|
-
- lib/text_editor/mode/nano.rb
|
79
|
-
- lib/text_editor/operating_system.rb
|
106
|
+
- lib/text_editor/logger.rb
|
80
107
|
- lib/text_editor/reactor.rb
|
81
108
|
- lib/text_editor/state.rb
|
82
109
|
- lib/text_editor/terminal.rb
|
@@ -85,15 +112,40 @@ files:
|
|
85
112
|
- spec/core_ext/hash_spec.rb
|
86
113
|
- spec/core_ext/pathname_spec.rb
|
87
114
|
- spec/spec_helper.rb
|
115
|
+
- spec/support/command_helper.rb
|
88
116
|
- spec/text_editor/buffer_spec.rb
|
89
117
|
- spec/text_editor/clipboard_spec.rb
|
118
|
+
- spec/text_editor/command/append_line_and_insert_spec.rb
|
119
|
+
- spec/text_editor/command/backspace_spec.rb
|
120
|
+
- spec/text_editor/command/change_mode_spec.rb
|
121
|
+
- spec/text_editor/command/cursor_down_spec.rb
|
122
|
+
- spec/text_editor/command/cursor_end_and_insert_spec.rb
|
123
|
+
- spec/text_editor/command/cursor_end_spec.rb
|
124
|
+
- spec/text_editor/command/cursor_left_spec.rb
|
125
|
+
- spec/text_editor/command/cursor_left_with_wrap_spec.rb
|
126
|
+
- spec/text_editor/command/cursor_right_and_insert_spec.rb
|
127
|
+
- spec/text_editor/command/cursor_right_spec.rb
|
128
|
+
- spec/text_editor/command/cursor_right_with_wrap_spec.rb
|
129
|
+
- spec/text_editor/command/cursor_start_spec.rb
|
130
|
+
- spec/text_editor/command/cursor_start_without_whitespace_spec.rb
|
131
|
+
- spec/text_editor/command/cursor_up_spec.rb
|
132
|
+
- spec/text_editor/command/forward_word_spec.rb
|
133
|
+
- spec/text_editor/command/insert_char_spec.rb
|
134
|
+
- spec/text_editor/command/insert_line_spec.rb
|
135
|
+
- spec/text_editor/command/insert_tab_spec.rb
|
136
|
+
- spec/text_editor/command/prepend_line_and_insert_spec.rb
|
90
137
|
- spec/text_editor/command/quit_spec.rb
|
138
|
+
- spec/text_editor/command/replace_line_spec.rb
|
91
139
|
- spec/text_editor/command/resolver_spec.rb
|
140
|
+
- spec/text_editor/command/write_file_spec.rb
|
92
141
|
- spec/text_editor/command_spec.rb
|
93
142
|
- spec/text_editor/component_spec.rb
|
143
|
+
- spec/text_editor/configuration/log_spec.rb
|
144
|
+
- spec/text_editor/configuration/operating_system_spec.rb
|
145
|
+
- spec/text_editor/configuration/tab_spec.rb
|
94
146
|
- spec/text_editor/configuration_spec.rb
|
95
147
|
- spec/text_editor/cursor_spec.rb
|
96
|
-
- spec/text_editor/
|
148
|
+
- spec/text_editor/logger_spec.rb
|
97
149
|
- spec/text_editor/reactor_spec.rb
|
98
150
|
- spec/text_editor/state_spec.rb
|
99
151
|
- text_editor.gemspec
|
@@ -130,14 +182,39 @@ test_files:
|
|
130
182
|
- spec/core_ext/hash_spec.rb
|
131
183
|
- spec/core_ext/pathname_spec.rb
|
132
184
|
- spec/spec_helper.rb
|
185
|
+
- spec/support/command_helper.rb
|
133
186
|
- spec/text_editor/buffer_spec.rb
|
134
187
|
- spec/text_editor/clipboard_spec.rb
|
188
|
+
- spec/text_editor/command/append_line_and_insert_spec.rb
|
189
|
+
- spec/text_editor/command/backspace_spec.rb
|
190
|
+
- spec/text_editor/command/change_mode_spec.rb
|
191
|
+
- spec/text_editor/command/cursor_down_spec.rb
|
192
|
+
- spec/text_editor/command/cursor_end_and_insert_spec.rb
|
193
|
+
- spec/text_editor/command/cursor_end_spec.rb
|
194
|
+
- spec/text_editor/command/cursor_left_spec.rb
|
195
|
+
- spec/text_editor/command/cursor_left_with_wrap_spec.rb
|
196
|
+
- spec/text_editor/command/cursor_right_and_insert_spec.rb
|
197
|
+
- spec/text_editor/command/cursor_right_spec.rb
|
198
|
+
- spec/text_editor/command/cursor_right_with_wrap_spec.rb
|
199
|
+
- spec/text_editor/command/cursor_start_spec.rb
|
200
|
+
- spec/text_editor/command/cursor_start_without_whitespace_spec.rb
|
201
|
+
- spec/text_editor/command/cursor_up_spec.rb
|
202
|
+
- spec/text_editor/command/forward_word_spec.rb
|
203
|
+
- spec/text_editor/command/insert_char_spec.rb
|
204
|
+
- spec/text_editor/command/insert_line_spec.rb
|
205
|
+
- spec/text_editor/command/insert_tab_spec.rb
|
206
|
+
- spec/text_editor/command/prepend_line_and_insert_spec.rb
|
135
207
|
- spec/text_editor/command/quit_spec.rb
|
208
|
+
- spec/text_editor/command/replace_line_spec.rb
|
136
209
|
- spec/text_editor/command/resolver_spec.rb
|
210
|
+
- spec/text_editor/command/write_file_spec.rb
|
137
211
|
- spec/text_editor/command_spec.rb
|
138
212
|
- spec/text_editor/component_spec.rb
|
213
|
+
- spec/text_editor/configuration/log_spec.rb
|
214
|
+
- spec/text_editor/configuration/operating_system_spec.rb
|
215
|
+
- spec/text_editor/configuration/tab_spec.rb
|
139
216
|
- spec/text_editor/configuration_spec.rb
|
140
217
|
- spec/text_editor/cursor_spec.rb
|
141
|
-
- spec/text_editor/
|
218
|
+
- spec/text_editor/logger_spec.rb
|
142
219
|
- spec/text_editor/reactor_spec.rb
|
143
220
|
- spec/text_editor/state_spec.rb
|
data/lib/text_editor/mode.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
class TextEditor
|
2
|
-
class Mode
|
3
|
-
def self.bind(key, command = nil, &block)
|
4
|
-
keybindings[key] = command || block
|
5
|
-
end
|
6
|
-
|
7
|
-
def self.keybindings
|
8
|
-
@keybindings ||= {}
|
9
|
-
end
|
10
|
-
|
11
|
-
def keybindings
|
12
|
-
self.class.keybindings
|
13
|
-
end
|
14
|
-
|
15
|
-
def resolve(key)
|
16
|
-
keybindings.each do |keybinding, command|
|
17
|
-
return command if keybinding === key
|
18
|
-
end
|
19
|
-
|
20
|
-
nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class TextEditor
|
2
|
-
class Mode
|
3
|
-
class Nano < Mode
|
4
|
-
bind :ctrl_c, Command::Quit
|
5
|
-
|
6
|
-
bind :up, Command::CursorUp
|
7
|
-
bind :down, Command::CursorDown
|
8
|
-
bind :left, Command::CursorLeft
|
9
|
-
bind :right, Command::CursorRight
|
10
|
-
|
11
|
-
bind :ctrl_p, Command::CursorUp
|
12
|
-
bind :ctrl_n, Command::CursorDown
|
13
|
-
bind :ctrl_b, Command::CursorLeft
|
14
|
-
bind :ctrl_f, Command::CursorRight
|
15
|
-
|
16
|
-
bind :ctrl_a, Command::CursorStart
|
17
|
-
bind :ctrl_e, Command::CursorEnd
|
18
|
-
|
19
|
-
bind :backspace, Command::Backspace
|
20
|
-
bind :ctrl_h, Command::Backspace
|
21
|
-
|
22
|
-
bind :ctrl_o, Command::WriteFile
|
23
|
-
|
24
|
-
bind :enter, Command::InsertLine
|
25
|
-
bind :tab, Command::InsertTab
|
26
|
-
|
27
|
-
bind(/^[[:print:]]$/, Command::InsertChar)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|