mui 0.2.0 → 0.3.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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +13 -8
  3. data/CHANGELOG.md +99 -0
  4. data/README.md +309 -6
  5. data/docs/_config.yml +56 -0
  6. data/docs/configuration.md +301 -0
  7. data/docs/getting-started.md +140 -0
  8. data/docs/index.md +55 -0
  9. data/docs/jobs.md +297 -0
  10. data/docs/keybindings.md +229 -0
  11. data/docs/plugins.md +285 -0
  12. data/docs/syntax-highlighting.md +149 -0
  13. data/lib/mui/command_completer.rb +11 -2
  14. data/lib/mui/command_history.rb +89 -0
  15. data/lib/mui/command_line.rb +32 -2
  16. data/lib/mui/command_registry.rb +21 -2
  17. data/lib/mui/config.rb +3 -1
  18. data/lib/mui/editor.rb +78 -2
  19. data/lib/mui/handler_result.rb +13 -7
  20. data/lib/mui/highlighters/search_highlighter.rb +2 -1
  21. data/lib/mui/highlighters/syntax_highlighter.rb +3 -1
  22. data/lib/mui/key_handler/base.rb +87 -0
  23. data/lib/mui/key_handler/command_mode.rb +68 -0
  24. data/lib/mui/key_handler/insert_mode.rb +10 -41
  25. data/lib/mui/key_handler/normal_mode.rb +24 -51
  26. data/lib/mui/key_handler/operators/paste_operator.rb +9 -3
  27. data/lib/mui/key_handler/search_mode.rb +10 -7
  28. data/lib/mui/key_handler/visual_mode.rb +15 -10
  29. data/lib/mui/key_notation_parser.rb +152 -0
  30. data/lib/mui/key_sequence.rb +67 -0
  31. data/lib/mui/key_sequence_buffer.rb +85 -0
  32. data/lib/mui/key_sequence_handler.rb +163 -0
  33. data/lib/mui/key_sequence_matcher.rb +79 -0
  34. data/lib/mui/line_renderer.rb +52 -1
  35. data/lib/mui/mode_manager.rb +3 -2
  36. data/lib/mui/screen.rb +24 -6
  37. data/lib/mui/search_state.rb +61 -28
  38. data/lib/mui/syntax/language_detector.rb +33 -1
  39. data/lib/mui/syntax/lexers/css_lexer.rb +121 -0
  40. data/lib/mui/syntax/lexers/go_lexer.rb +205 -0
  41. data/lib/mui/syntax/lexers/html_lexer.rb +118 -0
  42. data/lib/mui/syntax/lexers/javascript_lexer.rb +197 -0
  43. data/lib/mui/syntax/lexers/markdown_lexer.rb +210 -0
  44. data/lib/mui/syntax/lexers/rust_lexer.rb +148 -0
  45. data/lib/mui/syntax/lexers/typescript_lexer.rb +203 -0
  46. data/lib/mui/terminal_adapter/curses.rb +13 -11
  47. data/lib/mui/version.rb +1 -1
  48. data/lib/mui/window.rb +83 -40
  49. data/lib/mui/window_manager.rb +7 -0
  50. data/lib/mui/wrap_cache.rb +40 -0
  51. data/lib/mui/wrap_helper.rb +84 -0
  52. data/lib/mui.rb +15 -0
  53. metadata +26 -3
@@ -0,0 +1,301 @@
1
+ ---
2
+ title: Configuration
3
+ layout: default
4
+ nav_order: 4
5
+ ---
6
+
7
+ # Configuration
8
+ {: .no_toc }
9
+
10
+ ## Table of contents
11
+ {: .no_toc .text-delta }
12
+
13
+ 1. TOC
14
+ {:toc}
15
+
16
+ ---
17
+
18
+ ## Configuration Files
19
+
20
+ Mui supports two configuration files:
21
+
22
+ | File | Scope |
23
+ |------|-------|
24
+ | `~/.muirc` | Global settings (all projects) |
25
+ | `.lmuirc` | Local settings (current directory) |
26
+
27
+ Local settings (`.lmuirc`) override global settings (`~/.muirc`).
28
+
29
+ Configuration files are written in Ruby using Mui's DSL.
30
+
31
+ ## Basic Settings
32
+
33
+ ### Color Scheme
34
+
35
+ ```ruby
36
+ Mui.set :colorscheme, "tokyo_night"
37
+ ```
38
+
39
+ Available themes:
40
+ - `mui` (default)
41
+ - `solarized_dark`
42
+ - `solarized_light`
43
+ - `monokai`
44
+ - `nord`
45
+ - `gruvbox_dark`
46
+ - `dracula`
47
+ - `tokyo_night`
48
+
49
+ ### Indentation
50
+
51
+ ```ruby
52
+ # Number of spaces for Tab display
53
+ Mui.set :tabstop, 4
54
+
55
+ # Number of spaces for indent operations (>, <)
56
+ Mui.set :shiftwidth, 4
57
+
58
+ # Use spaces instead of tabs
59
+ Mui.set :expandtab, true
60
+ ```
61
+
62
+ ### Syntax Highlighting
63
+
64
+ ```ruby
65
+ # Enable/disable syntax highlighting
66
+ Mui.set :syntax, true
67
+ ```
68
+
69
+ ### Leader Key
70
+
71
+ ```ruby
72
+ # Set leader key (default: backslash)
73
+ Mui.set :leader, " " # Space as leader
74
+ ```
75
+
76
+ ### Key Timeout
77
+
78
+ ```ruby
79
+ # Timeout for multi-key sequences (milliseconds)
80
+ Mui.set :timeoutlen, 1000
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Custom Key Mappings
86
+
87
+ Define custom key bindings with `Mui.keymap`:
88
+
89
+ ```ruby
90
+ Mui.keymap :mode, "key" do |ctx|
91
+ # action
92
+ end
93
+ ```
94
+
95
+ ### Modes
96
+
97
+ - `:normal` - Normal mode
98
+ - `:insert` - Insert mode
99
+ - `:visual` - Visual mode
100
+ - `:command` - Command mode
101
+
102
+ ### Examples
103
+
104
+ ```ruby
105
+ # Save with <Leader>w
106
+ Mui.keymap :normal, "<Leader>w" do |ctx|
107
+ ctx.editor.execute_command("w")
108
+ end
109
+
110
+ # Quick escape in Insert mode
111
+ Mui.keymap :insert, "jk" do |ctx|
112
+ ctx.change_mode(:normal)
113
+ end
114
+
115
+ # Close buffer with <Leader>q
116
+ Mui.keymap :normal, "<Leader>q" do |ctx|
117
+ ctx.editor.execute_command("q")
118
+ end
119
+ ```
120
+
121
+ ### Special Key Notation
122
+
123
+ | Notation | Key |
124
+ |----------|-----|
125
+ | `<Leader>` | Leader key |
126
+ | `<Space>` | Space bar |
127
+ | `<Tab>` | Tab key |
128
+ | `<CR>`, `<Enter>` | Enter key |
129
+ | `<Esc>` | Escape key |
130
+ | `<BS>` | Backspace |
131
+ | `<C-x>` | Ctrl+x |
132
+ | `<C-S-x>` | Ctrl+Shift+x |
133
+ | `<S-x>` | Shift+x |
134
+
135
+ ### Multi-key Sequences
136
+
137
+ ```ruby
138
+ # <Leader>ff for find files
139
+ Mui.keymap :normal, "<Leader>ff" do |ctx|
140
+ ctx.editor.execute_command("Files")
141
+ end
142
+
143
+ # <Leader>fg for grep
144
+ Mui.keymap :normal, "<Leader>fg" do |ctx|
145
+ ctx.editor.execute_command("Rg")
146
+ end
147
+
148
+ # Ctrl-x Ctrl-s to save (Emacs style)
149
+ Mui.keymap :normal, "<C-x><C-s>" do |ctx|
150
+ ctx.editor.execute_command("w")
151
+ end
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Custom Commands
157
+
158
+ Define custom Ex commands with `Mui.command`:
159
+
160
+ ```ruby
161
+ Mui.command :name do |ctx|
162
+ # action
163
+ end
164
+ ```
165
+
166
+ ### Examples
167
+
168
+ ```ruby
169
+ # Simple greeting
170
+ Mui.command :hello do |ctx|
171
+ ctx.set_message("Hello, World!")
172
+ end
173
+
174
+ # Command with arguments
175
+ Mui.command :echo do |ctx, *args|
176
+ ctx.set_message(args.join(" "))
177
+ end
178
+
179
+ # Open configuration file
180
+ Mui.command :config do |ctx|
181
+ ctx.editor.execute_command("e ~/.muirc")
182
+ end
183
+ ```
184
+
185
+ ---
186
+
187
+ ## Autocmd Events
188
+
189
+ Execute code when events occur with `Mui.autocmd`:
190
+
191
+ ```ruby
192
+ Mui.autocmd :event, pattern: "*.ext" do |ctx|
193
+ # action
194
+ end
195
+ ```
196
+
197
+ ### Available Events
198
+
199
+ | Event | Trigger |
200
+ |-------|---------|
201
+ | `BufEnter` | When entering a buffer |
202
+ | `BufLeave` | When leaving a buffer |
203
+ | `BufWrite` | When writing a buffer |
204
+ | `BufWritePre` | Before writing a buffer |
205
+ | `BufWritePost` | After writing a buffer |
206
+ | `ModeChanged` | When mode changes |
207
+ | `CursorMoved` | When cursor moves |
208
+ | `TextChanged` | When text is modified |
209
+ | `InsertEnter` | When entering Insert mode |
210
+ | `InsertLeave` | When leaving Insert mode |
211
+ | `InsertCompletion` | When completion is triggered |
212
+ | `JobStarted` | When a job starts |
213
+ | `JobCompleted` | When a job completes |
214
+ | `JobFailed` | When a job fails |
215
+ | `JobCancelled` | When a job is cancelled |
216
+
217
+ ### Examples
218
+
219
+ ```ruby
220
+ # Auto-save on leaving Insert mode
221
+ Mui.autocmd :InsertLeave do |ctx|
222
+ ctx.editor.execute_command("w") if ctx.buffer.modified?
223
+ end
224
+
225
+ # Show message when opening Ruby files
226
+ Mui.autocmd :BufEnter, pattern: "*.rb" do |ctx|
227
+ ctx.set_message("Ruby file loaded")
228
+ end
229
+
230
+ # Format before saving
231
+ Mui.autocmd :BufWritePre, pattern: "*.rb" do |ctx|
232
+ # Run formatter
233
+ end
234
+ ```
235
+
236
+ ---
237
+
238
+ ## Using Plugins
239
+
240
+ Load plugins with `Mui.use`:
241
+
242
+ ```ruby
243
+ Mui.use "mui-lsp"
244
+ Mui.use "mui-git"
245
+ Mui.use "mui-fzf"
246
+ ```
247
+
248
+ See [Plugins]({{ site.baseurl }}/plugins) for more details.
249
+
250
+ ---
251
+
252
+ ## Complete Example
253
+
254
+ ```ruby
255
+ # ~/.muirc
256
+
257
+ # Appearance
258
+ Mui.set :colorscheme, "tokyo_night"
259
+ Mui.set :syntax, true
260
+
261
+ # Indentation
262
+ Mui.set :tabstop, 2
263
+ Mui.set :shiftwidth, 2
264
+ Mui.set :expandtab, true
265
+
266
+ # Leader key
267
+ Mui.set :leader, " "
268
+
269
+ # Plugins
270
+ Mui.use "mui-lsp"
271
+ Mui.use "mui-fzf"
272
+
273
+ # Key mappings
274
+ Mui.keymap :normal, "<Leader>w" do |ctx|
275
+ ctx.editor.execute_command("w")
276
+ end
277
+
278
+ Mui.keymap :normal, "<Leader>q" do |ctx|
279
+ ctx.editor.execute_command("q")
280
+ end
281
+
282
+ Mui.keymap :normal, "<Leader>ff" do |ctx|
283
+ ctx.editor.execute_command("Files")
284
+ end
285
+
286
+ # Custom commands
287
+ Mui.command :reload do |ctx|
288
+ ctx.editor.execute_command("e")
289
+ ctx.set_message("File reloaded")
290
+ end
291
+
292
+ # LSP configuration
293
+ Mui.lsp do
294
+ use :ruby
295
+
296
+ # TypeScript (requires typescript-language-server)
297
+ server :typescript,
298
+ command: ["typescript-language-server", "--stdio"],
299
+ filetypes: ["typescript", "typescriptreact", "javascript", "javascriptreact"]
300
+ end
301
+ ```
@@ -0,0 +1,140 @@
1
+ ---
2
+ title: Getting Started
3
+ layout: default
4
+ nav_order: 2
5
+ ---
6
+
7
+ # Getting Started
8
+ {: .no_toc }
9
+
10
+ ## Table of contents
11
+ {: .no_toc .text-delta }
12
+
13
+ 1. TOC
14
+ {:toc}
15
+
16
+ ---
17
+
18
+ ## Installation
19
+
20
+ Install Mui from RubyGems:
21
+
22
+ ```bash
23
+ gem install mui
24
+ ```
25
+
26
+ ### Requirements
27
+
28
+ - Ruby 3.0 or later
29
+ - A terminal that supports 256 colors
30
+
31
+ ## Basic Usage
32
+
33
+ ### Opening a File
34
+
35
+ ```bash
36
+ mui filename.rb
37
+ ```
38
+
39
+ ### Creating a New File
40
+
41
+ ```bash
42
+ mui
43
+ ```
44
+
45
+ Or open a non-existent file path:
46
+
47
+ ```bash
48
+ mui new_file.rb
49
+ ```
50
+
51
+ ## Modes
52
+
53
+ Mui is a modal editor, similar to Vim. Understanding modes is essential.
54
+
55
+ ### Normal Mode
56
+
57
+ The default mode. Used for navigation and commands.
58
+
59
+ - Press `Esc` from any mode to return to Normal mode
60
+
61
+ ### Insert Mode
62
+
63
+ For typing text. Enter from Normal mode with:
64
+
65
+ | Key | Action |
66
+ |-----|--------|
67
+ | `i` | Insert before cursor |
68
+ | `a` | Append after cursor |
69
+ | `o` | Open new line below |
70
+ | `O` | Open new line above |
71
+
72
+ ### Visual Mode
73
+
74
+ For selecting text:
75
+
76
+ | Key | Action |
77
+ |-----|--------|
78
+ | `v` | Character-wise selection |
79
+ | `V` | Line-wise selection |
80
+
81
+ ### Command Mode
82
+
83
+ For Ex commands. Press `:` from Normal mode.
84
+
85
+ ## Essential Commands
86
+
87
+ ### Saving and Quitting
88
+
89
+ | Command | Action |
90
+ |---------|--------|
91
+ | `:w` | Save file |
92
+ | `:q` | Quit (fails if unsaved changes) |
93
+ | `:q!` | Force quit without saving |
94
+ | `:wq` | Save and quit |
95
+
96
+ ### Opening Files
97
+
98
+ | Command | Action |
99
+ |---------|--------|
100
+ | `:e filename` | Open file |
101
+ | `:sp filename` | Open in horizontal split |
102
+ | `:vs filename` | Open in vertical split |
103
+ | `:tabnew filename` | Open in new tab |
104
+
105
+ ### Navigation
106
+
107
+ | Key | Action |
108
+ |-----|--------|
109
+ | `h`, `j`, `k`, `l` | Left, down, up, right |
110
+ | `w`, `b` | Word forward, backward |
111
+ | `0`, `$` | Line start, end |
112
+ | `gg`, `G` | File start, end |
113
+ | `/pattern` | Search forward |
114
+ | `?pattern` | Search backward |
115
+ | `n`, `N` | Next, previous match |
116
+
117
+ ## Configuration
118
+
119
+ Create `~/.muirc` for global settings:
120
+
121
+ ```ruby
122
+ # Set color scheme
123
+ Mui.set :colorscheme, "tokyo_night"
124
+
125
+ # Enable syntax highlighting
126
+ Mui.set :syntax, true
127
+
128
+ # Set indentation
129
+ Mui.set :tabstop, 2
130
+ Mui.set :shiftwidth, 2
131
+ Mui.set :expandtab, true
132
+ ```
133
+
134
+ See [Configuration]({{ site.baseurl }}/configuration) for all options.
135
+
136
+ ## Next Steps
137
+
138
+ - [Key Bindings]({{ site.baseurl }}/keybindings) - Complete key reference
139
+ - [Configuration]({{ site.baseurl }}/configuration) - Customize Mui
140
+ - [Plugins]({{ site.baseurl }}/plugins) - Extend functionality
data/docs/index.md ADDED
@@ -0,0 +1,55 @@
1
+ ---
2
+ title: Home
3
+ layout: home
4
+ nav_order: 1
5
+ ---
6
+
7
+ # Mui (無為)
8
+
9
+ A Vim-like TUI text editor written in Ruby.
10
+ {: .fs-6 .fw-300 }
11
+
12
+ > **無為 (むい, mui)** - "Effortless action" from Taoist philosophy.
13
+ > *"Form without forcing, existing as it is. Yet from nothing, something is born."*
14
+
15
+ [Get Started]({{ site.baseurl }}/getting-started){: .btn .btn-primary .fs-5 .mb-4 .mb-md-0 .mr-2 }
16
+ [View on GitHub](https://github.com/S-H-GAMELINKS/mui){: .btn .fs-5 .mb-4 .mb-md-0 .mr-2 }
17
+ [RubyGems](https://rubygems.org/gems/mui){: .btn .btn-green .fs-5 .mb-4 .mb-md-0 }
18
+
19
+ ---
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ gem install mui
25
+ ```
26
+
27
+ ## Features
28
+
29
+ - **Modal Editing** - Vim-like Normal, Insert, Visual, Command modes
30
+ - **Syntax Highlighting** - Ruby, C, Go, Rust, JavaScript, TypeScript, Markdown, HTML, CSS
31
+ - **Tab Pages & Window Splits** - Multiple files with flexible layouts
32
+ - **Plugin System** - Extend functionality with Ruby gems
33
+ - **LSP Support** - Language Server Protocol via mui-lsp plugin
34
+ - **Japanese/UTF-8 Support** - Full multibyte character support
35
+
36
+ ## Quick Start
37
+
38
+ ```bash
39
+ # Install from RubyGems
40
+ gem install mui
41
+
42
+ # Open a file
43
+ mui myfile.rb
44
+
45
+ # Or start with an empty buffer
46
+ mui
47
+ ```
48
+
49
+ ## Official Plugins
50
+
51
+ | Plugin | Description |
52
+ |--------|-------------|
53
+ | [mui-lsp](https://github.com/S-H-GAMELINKS/mui-lsp) | LSP (Language Server Protocol) support |
54
+ | [mui-git](https://github.com/S-H-GAMELINKS/mui-git) | Git integration |
55
+ | [mui-fzf](https://github.com/S-H-GAMELINKS/mui-fzf) | Fuzzy finder integration with fzf |