ruvim 0.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.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +15 -0
- data/README.md +135 -0
- data/Rakefile +36 -0
- data/docs/binding.md +125 -0
- data/docs/command.md +306 -0
- data/docs/config.md +155 -0
- data/docs/done.md +112 -0
- data/docs/plugin.md +559 -0
- data/docs/spec.md +655 -0
- data/docs/todo.md +63 -0
- data/docs/tutorial.md +490 -0
- data/docs/vim_diff.md +179 -0
- data/exe/ruvim +6 -0
- data/lib/ruvim/app.rb +1600 -0
- data/lib/ruvim/buffer.rb +421 -0
- data/lib/ruvim/cli.rb +264 -0
- data/lib/ruvim/clipboard.rb +73 -0
- data/lib/ruvim/command_invocation.rb +14 -0
- data/lib/ruvim/command_line.rb +63 -0
- data/lib/ruvim/command_registry.rb +38 -0
- data/lib/ruvim/config_dsl.rb +134 -0
- data/lib/ruvim/config_loader.rb +68 -0
- data/lib/ruvim/context.rb +26 -0
- data/lib/ruvim/dispatcher.rb +120 -0
- data/lib/ruvim/display_width.rb +110 -0
- data/lib/ruvim/editor.rb +1025 -0
- data/lib/ruvim/ex_command_registry.rb +80 -0
- data/lib/ruvim/global_commands.rb +1889 -0
- data/lib/ruvim/highlighter.rb +52 -0
- data/lib/ruvim/input.rb +66 -0
- data/lib/ruvim/keymap_manager.rb +96 -0
- data/lib/ruvim/screen.rb +452 -0
- data/lib/ruvim/terminal.rb +30 -0
- data/lib/ruvim/text_metrics.rb +96 -0
- data/lib/ruvim/version.rb +5 -0
- data/lib/ruvim/window.rb +71 -0
- data/lib/ruvim.rb +30 -0
- data/sig/ruvim.rbs +4 -0
- data/test/app_completion_test.rb +39 -0
- data/test/app_dot_repeat_test.rb +54 -0
- data/test/app_motion_test.rb +73 -0
- data/test/app_register_test.rb +47 -0
- data/test/app_scenario_test.rb +77 -0
- data/test/app_startup_test.rb +199 -0
- data/test/app_text_object_test.rb +54 -0
- data/test/app_unicode_behavior_test.rb +66 -0
- data/test/buffer_test.rb +72 -0
- data/test/cli_test.rb +165 -0
- data/test/config_dsl_test.rb +78 -0
- data/test/dispatcher_test.rb +124 -0
- data/test/editor_mark_test.rb +69 -0
- data/test/editor_register_test.rb +64 -0
- data/test/fixtures/render_basic_snapshot.txt +8 -0
- data/test/fixtures/render_basic_snapshot_nonumber.txt +8 -0
- data/test/fixtures/render_unicode_scrolled_snapshot.txt +7 -0
- data/test/highlighter_test.rb +16 -0
- data/test/input_screen_integration_test.rb +69 -0
- data/test/keymap_manager_test.rb +48 -0
- data/test/render_snapshot_test.rb +70 -0
- data/test/screen_test.rb +123 -0
- data/test/search_option_test.rb +39 -0
- data/test/test_helper.rb +15 -0
- data/test/text_metrics_test.rb +42 -0
- data/test/window_test.rb +21 -0
- metadata +106 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require_relative "test_helper"
|
|
2
|
+
|
|
3
|
+
class TextMetricsTest < Minitest::Test
|
|
4
|
+
def test_grapheme_navigation_uses_cluster_boundaries
|
|
5
|
+
s = "e\u0301x" # e + combining acute + x
|
|
6
|
+
|
|
7
|
+
assert_equal 0, RuVim::TextMetrics.previous_grapheme_char_index(s, 2)
|
|
8
|
+
assert_equal 2, RuVim::TextMetrics.next_grapheme_char_index(s, 0)
|
|
9
|
+
assert_equal 3, RuVim::TextMetrics.next_grapheme_char_index(s, 2)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_screen_col_for_char_index_handles_wide_chars
|
|
13
|
+
s = "ab日本"
|
|
14
|
+
assert_equal 0, RuVim::TextMetrics.screen_col_for_char_index(s, 0)
|
|
15
|
+
assert_equal 2, RuVim::TextMetrics.screen_col_for_char_index(s, 2)
|
|
16
|
+
assert_equal 4, RuVim::TextMetrics.screen_col_for_char_index(s, 3)
|
|
17
|
+
assert_equal 6, RuVim::TextMetrics.screen_col_for_char_index(s, 4)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_clip_cells_for_width_expands_tabs_and_preserves_source_col
|
|
21
|
+
cells, used = RuVim::TextMetrics.clip_cells_for_width("a\tb", 4, source_col_start: 0, tabstop: 4)
|
|
22
|
+
assert_equal 4, used
|
|
23
|
+
assert_equal ["a", " ", " ", " "], cells.map(&:glyph)
|
|
24
|
+
assert_equal [0, 1, 1, 1], cells.map(&:source_col)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_char_index_for_screen_col_is_grapheme_aligned
|
|
28
|
+
s = "ab日本c"
|
|
29
|
+
assert_equal 0, RuVim::TextMetrics.char_index_for_screen_col(s, 0)
|
|
30
|
+
assert_equal 2, RuVim::TextMetrics.char_index_for_screen_col(s, 2)
|
|
31
|
+
assert_equal 2, RuVim::TextMetrics.char_index_for_screen_col(s, 3) # inside wide char => start of 日本 cluster char
|
|
32
|
+
assert_equal 3, RuVim::TextMetrics.char_index_for_screen_col(s, 4)
|
|
33
|
+
assert_equal 4, RuVim::TextMetrics.char_index_for_screen_col(s, 6)
|
|
34
|
+
assert_equal 3, RuVim::TextMetrics.char_index_for_screen_col(s, 3, align: :ceil)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_pad_plain_to_screen_width_handles_japanese
|
|
38
|
+
out = RuVim::TextMetrics.pad_plain_to_screen_width("日本", 6, tabstop: 2)
|
|
39
|
+
assert_equal 6, RuVim::DisplayWidth.display_width(out, tabstop: 2)
|
|
40
|
+
assert_equal "日本 ", out
|
|
41
|
+
end
|
|
42
|
+
end
|
data/test/window_test.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require_relative "test_helper"
|
|
2
|
+
|
|
3
|
+
class WindowTest < Minitest::Test
|
|
4
|
+
def test_ensure_visible_uses_screen_width_for_wide_chars
|
|
5
|
+
buffer = RuVim::Buffer.new(id: 1, lines: ["ab日本cdef"])
|
|
6
|
+
win = RuVim::Window.new(id: 1, buffer_id: 1)
|
|
7
|
+
|
|
8
|
+
win.cursor_y = 0
|
|
9
|
+
win.cursor_x = 4 # after "本" (screen col 6)
|
|
10
|
+
win.col_offset = 0
|
|
11
|
+
win.ensure_visible(buffer, height: 5, width: 4, tabstop: 2)
|
|
12
|
+
|
|
13
|
+
line = buffer.line_at(0)
|
|
14
|
+
cursor_col = RuVim::TextMetrics.screen_col_for_char_index(line, win.cursor_x, tabstop: 2)
|
|
15
|
+
offset_col = RuVim::TextMetrics.screen_col_for_char_index(line, win.col_offset, tabstop: 2)
|
|
16
|
+
|
|
17
|
+
assert_operator cursor_col, :>=, offset_col
|
|
18
|
+
assert_operator cursor_col, :<, offset_col + 4
|
|
19
|
+
assert_equal 3, win.col_offset
|
|
20
|
+
end
|
|
21
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ruvim
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Koichi Sasada
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: vim clone on Ruby by codex
|
|
13
|
+
email:
|
|
14
|
+
- ko1@atdot.net
|
|
15
|
+
executables:
|
|
16
|
+
- ruvim
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- ".github/workflows/test.yml"
|
|
21
|
+
- README.md
|
|
22
|
+
- Rakefile
|
|
23
|
+
- docs/binding.md
|
|
24
|
+
- docs/command.md
|
|
25
|
+
- docs/config.md
|
|
26
|
+
- docs/done.md
|
|
27
|
+
- docs/plugin.md
|
|
28
|
+
- docs/spec.md
|
|
29
|
+
- docs/todo.md
|
|
30
|
+
- docs/tutorial.md
|
|
31
|
+
- docs/vim_diff.md
|
|
32
|
+
- exe/ruvim
|
|
33
|
+
- lib/ruvim.rb
|
|
34
|
+
- lib/ruvim/app.rb
|
|
35
|
+
- lib/ruvim/buffer.rb
|
|
36
|
+
- lib/ruvim/cli.rb
|
|
37
|
+
- lib/ruvim/clipboard.rb
|
|
38
|
+
- lib/ruvim/command_invocation.rb
|
|
39
|
+
- lib/ruvim/command_line.rb
|
|
40
|
+
- lib/ruvim/command_registry.rb
|
|
41
|
+
- lib/ruvim/config_dsl.rb
|
|
42
|
+
- lib/ruvim/config_loader.rb
|
|
43
|
+
- lib/ruvim/context.rb
|
|
44
|
+
- lib/ruvim/dispatcher.rb
|
|
45
|
+
- lib/ruvim/display_width.rb
|
|
46
|
+
- lib/ruvim/editor.rb
|
|
47
|
+
- lib/ruvim/ex_command_registry.rb
|
|
48
|
+
- lib/ruvim/global_commands.rb
|
|
49
|
+
- lib/ruvim/highlighter.rb
|
|
50
|
+
- lib/ruvim/input.rb
|
|
51
|
+
- lib/ruvim/keymap_manager.rb
|
|
52
|
+
- lib/ruvim/screen.rb
|
|
53
|
+
- lib/ruvim/terminal.rb
|
|
54
|
+
- lib/ruvim/text_metrics.rb
|
|
55
|
+
- lib/ruvim/version.rb
|
|
56
|
+
- lib/ruvim/window.rb
|
|
57
|
+
- sig/ruvim.rbs
|
|
58
|
+
- test/app_completion_test.rb
|
|
59
|
+
- test/app_dot_repeat_test.rb
|
|
60
|
+
- test/app_motion_test.rb
|
|
61
|
+
- test/app_register_test.rb
|
|
62
|
+
- test/app_scenario_test.rb
|
|
63
|
+
- test/app_startup_test.rb
|
|
64
|
+
- test/app_text_object_test.rb
|
|
65
|
+
- test/app_unicode_behavior_test.rb
|
|
66
|
+
- test/buffer_test.rb
|
|
67
|
+
- test/cli_test.rb
|
|
68
|
+
- test/config_dsl_test.rb
|
|
69
|
+
- test/dispatcher_test.rb
|
|
70
|
+
- test/editor_mark_test.rb
|
|
71
|
+
- test/editor_register_test.rb
|
|
72
|
+
- test/fixtures/render_basic_snapshot.txt
|
|
73
|
+
- test/fixtures/render_basic_snapshot_nonumber.txt
|
|
74
|
+
- test/fixtures/render_unicode_scrolled_snapshot.txt
|
|
75
|
+
- test/highlighter_test.rb
|
|
76
|
+
- test/input_screen_integration_test.rb
|
|
77
|
+
- test/keymap_manager_test.rb
|
|
78
|
+
- test/render_snapshot_test.rb
|
|
79
|
+
- test/screen_test.rb
|
|
80
|
+
- test/search_option_test.rb
|
|
81
|
+
- test/test_helper.rb
|
|
82
|
+
- test/text_metrics_test.rb
|
|
83
|
+
- test/window_test.rb
|
|
84
|
+
homepage: https://github.com/ko1/ruvim
|
|
85
|
+
licenses: []
|
|
86
|
+
metadata:
|
|
87
|
+
homepage_uri: https://github.com/ko1/ruvim
|
|
88
|
+
source_code_uri: https://github.com/ko1/ruvim
|
|
89
|
+
rdoc_options: []
|
|
90
|
+
require_paths:
|
|
91
|
+
- lib
|
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 3.2.0
|
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
102
|
+
requirements: []
|
|
103
|
+
rubygems_version: 4.0.3
|
|
104
|
+
specification_version: 4
|
|
105
|
+
summary: vim clone on Ruby by codex
|
|
106
|
+
test_files: []
|