textbringer 1.1.2 → 1.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.
- checksums.yaml +4 -4
- data/.github/workflows/ubuntu.yml +1 -1
- data/.github/workflows/windows.yml +1 -1
- data/CHANGES.md +13 -0
- data/README.ja.md +103 -0
- data/README.md +12 -3
- data/exe/{textbringer → txtb} +2 -1
- data/lib/textbringer/commands/files.rb +15 -0
- data/lib/textbringer/commands/help.rb +41 -0
- data/lib/textbringer/commands/misc.rb +1 -1
- data/lib/textbringer/default_output.rb +18 -0
- data/lib/textbringer/keymap.rb +2 -0
- data/lib/textbringer/modes/c_mode.rb +3 -3
- data/lib/textbringer/utils.rb +15 -1
- data/lib/textbringer/version.rb +1 -1
- data/lib/textbringer.rb +1 -0
- data/textbringer.gemspec +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e9f67d3a60acc75b16f9f5ede7d7670068590b2331aa905b73d9fe09676e305
|
4
|
+
data.tar.gz: 388e2c7cdecee2292ea17167810944f1ccfc2f7ed0dfb48db9732e31c71b5818
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8973ef2ee4f24b829ebb505229ca45ee48a7f2d5fa21f20afb5bfce4c0b9df5333cbb5614ba1a48dcc1633e286edc2199d68b7fab347d090be94e43d376d205
|
7
|
+
data.tar.gz: e5847cd0e51bd26a8b4d38a5682ff9347d5886022e62b11a6e1b294dc78df455718e9be5319098050709545a98b75b41775db618562dd2bdee72a3e65baf91bd
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 1.3.0
|
2
|
+
|
3
|
+
* Kernel#print etc. inserts the given string into the current buffer now.
|
4
|
+
* Add find_source.
|
5
|
+
* Add describe_class and describe_method.
|
6
|
+
* Support completion for eval_expression
|
7
|
+
* Fix digraph indentation in C mode.
|
8
|
+
|
9
|
+
## 1.2.0
|
10
|
+
|
11
|
+
* Drop Ruby 2.6 support.
|
12
|
+
* Change the command name to `txtb`.
|
13
|
+
|
1
14
|
## 1.1.2
|
2
15
|
|
3
16
|
* Buf fixes.
|
data/README.ja.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# 
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/textbringer)
|
4
|
+
[](https://github.com/shugo/textbringer/actions?query=workflow%3Aubuntu)
|
5
|
+
[](https://github.com/shugo/textbringer/actions?query=workflow%3Awindows)
|
6
|
+
[](https://github.com/shugo/textbringer/actions?query=workflow%3Amacos)
|
7
|
+
|
8
|
+
TextbringerはRubyで実装されたEmacsライクなテキストエディタです。
|
9
|
+
Lispの代りにRubyで拡張することができます。
|
10
|
+
|
11
|
+
## スクリーンショット
|
12
|
+
|
13
|
+

|
14
|
+
|
15
|
+
## デモ
|
16
|
+
|
17
|
+
* FizzBuzz: https://asciinema.org/a/103357
|
18
|
+
* Rubyプログラミング: https://asciinema.org/a/100156
|
19
|
+
* 日本語テキストの編集: https://asciinema.org/a/100166
|
20
|
+
|
21
|
+
## インストール
|
22
|
+
|
23
|
+
$ gem install textbringer
|
24
|
+
|
25
|
+
マルチバイト文字を使用するためにはncurseswが必要です。
|
26
|
+
Textbringerが依存するcurses.gemをインストールする前に、ncurseswをインストールしておいてください。
|
27
|
+
|
28
|
+
$ sudo apt-get install libncursesw5-dev
|
29
|
+
$ gem install curses
|
30
|
+
|
31
|
+
## 使い方
|
32
|
+
|
33
|
+
$ txtb
|
34
|
+
|
35
|
+
`Ctrl-x Ctrl-c` で終了できます。
|
36
|
+
|
37
|
+
多くのコマンドとキーバインディングは[Emacs](https://www.gnu.org/software/emacs/)に似ています。
|
38
|
+
|
39
|
+
キーバインディングを確認するには、 `F1 b` または `Alt+x describe_bindings RET` とタイプしてください。
|
40
|
+
|
41
|
+
## 設定
|
42
|
+
|
43
|
+
### メタキー
|
44
|
+
|
45
|
+
端末エミュレータでメタキーを使用するためには、以下のような設定が必要です。
|
46
|
+
|
47
|
+
#### xterm
|
48
|
+
|
49
|
+
~/.Xresourcesに以下の行を追加してください。
|
50
|
+
|
51
|
+
XTerm*metaSendsEscape: true
|
52
|
+
|
53
|
+
#### mlterm
|
54
|
+
|
55
|
+
~/.mlterm/mainに以下の行を追加してください。
|
56
|
+
|
57
|
+
mod_meta_key = alt
|
58
|
+
mod_meta_mode = esc
|
59
|
+
|
60
|
+
### 東アジアの曖昧な文字幅
|
61
|
+
|
62
|
+
[曖昧な文字](http://unicode.org/reports/tr11/#Ambiguous)を全角扱いするには、以下の設定を~/.textbringer.rbに記述してください。
|
63
|
+
|
64
|
+
CONFIG[:east_asian_ambiguous_width] = 2
|
65
|
+
|
66
|
+
ncurseswはwcwidth(3)を使用するため、LD_PRELOADハックやlocale charmapの修正が必要かもしれません。
|
67
|
+
|
68
|
+
* https://github.com/fumiyas/wcwidth-cjk
|
69
|
+
* https://github.com/hamano/locale-eaw
|
70
|
+
|
71
|
+
xterm、 mlterm、screenにはそれぞれ独自の設定項目があります。
|
72
|
+
|
73
|
+
#### xterm
|
74
|
+
|
75
|
+
~/.Xresourcesに以下の設定を追加してください。
|
76
|
+
|
77
|
+
xterm*utf8: 1
|
78
|
+
xterm*locale: true
|
79
|
+
xterm*cjkWidth: true
|
80
|
+
|
81
|
+
#### mlterm
|
82
|
+
|
83
|
+
~/.mlterm/mainに以下の設定を追加してください。
|
84
|
+
|
85
|
+
col_size_of_width_a = 2
|
86
|
+
|
87
|
+
#### screen
|
88
|
+
|
89
|
+
~/.screenrcに以下の設定を追加してください。
|
90
|
+
|
91
|
+
cjkwidth on
|
92
|
+
|
93
|
+
## プラグイン
|
94
|
+
|
95
|
+
* [Mournmamil](https://github.com/shugo/mournmail): 電子メールクライアント
|
96
|
+
* [MedicineShield](https://github.com/shugo/medicine_shield): Mastodonクライアント
|
97
|
+
* [textbringer-presentation](https://github.com/shugo/textbringer-presentation): プレゼンテーションツール
|
98
|
+
* [textbringer-ghost_text](https://github.com/shugo/textbringer-ghost_text): [GhostText](https://github.com/fregante/GhostText)プラグイン
|
99
|
+
|
100
|
+
## ライセンス
|
101
|
+
|
102
|
+
[MIT License](http://opensource.org/licenses/MIT)の下でオープンソースとして利用可能です。
|
103
|
+
|
data/README.md
CHANGED
@@ -5,8 +5,10 @@
|
|
5
5
|
[](https://github.com/shugo/textbringer/actions?query=workflow%3Awindows)
|
6
6
|
[](https://github.com/shugo/textbringer/actions?query=workflow%3Amacos)
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
* [日本語版](README.ja.md)
|
9
|
+
|
10
|
+
Textbringer is an Emacs-like text editor written in Ruby.
|
11
|
+
It is extensible by Ruby instead of Lisp.
|
10
12
|
|
11
13
|
## Screenshot
|
12
14
|
|
@@ -30,7 +32,7 @@ Install ncursesw before installing curses.gem, on which textbringer depends.
|
|
30
32
|
|
31
33
|
## Usage
|
32
34
|
|
33
|
-
$
|
35
|
+
$ txtb
|
34
36
|
|
35
37
|
You can quit the editor by `Ctrl-x Ctrl-c`.
|
36
38
|
|
@@ -93,6 +95,13 @@ Add the following line to ~/.screenrc.
|
|
93
95
|
|
94
96
|
cjkwidth on
|
95
97
|
|
98
|
+
## Plugins
|
99
|
+
|
100
|
+
* [Mournmamil](https://github.com/shugo/mournmail): a mail user agent
|
101
|
+
* [MedicineShield](https://github.com/shugo/medicine_shield): a Mastodon client
|
102
|
+
* [textbringer-presentation](https://github.com/shugo/textbringer-presentation): a presentation tool
|
103
|
+
* [textbringer-ghost_text](https://github.com/shugo/textbringer-ghost_text): a [GhostText](https://github.com/fregante/GhostText) plugin
|
104
|
+
|
96
105
|
## Development
|
97
106
|
|
98
107
|
After checking out the repo, run `bundle install` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/exe/{textbringer → txtb}
RENAMED
@@ -19,13 +19,14 @@ def load_user_config(path)
|
|
19
19
|
end
|
20
20
|
|
21
21
|
unless STDIN.tty?
|
22
|
-
STDERR.puts("
|
22
|
+
STDERR.puts("txtb: standard input is not a tty")
|
23
23
|
exit 1
|
24
24
|
end
|
25
25
|
|
26
26
|
Controller.current = Controller.new
|
27
27
|
begin
|
28
28
|
Window.start do
|
29
|
+
$stdout = DefaultOutput.new
|
29
30
|
begin
|
30
31
|
load_user_config("~/.textbringer/init.rb")
|
31
32
|
Plugin.load_plugins
|
@@ -143,5 +143,20 @@ module Textbringer
|
|
143
143
|
File.dirname(Buffer.current.file_name))|
|
144
144
|
FileUtils.mkdir_p(dir_name)
|
145
145
|
end
|
146
|
+
|
147
|
+
define_command(:find_source, doc: "Open the source file.") do
|
148
|
+
|obj = read_object("Object or Class: ")|
|
149
|
+
klass = obj.is_a?(Module) ? obj : obj.class
|
150
|
+
method_name = klass.instance_methods(false).first
|
151
|
+
if method_name.nil?
|
152
|
+
raise EditorError, "Source not found"
|
153
|
+
end
|
154
|
+
method = klass.instance_method(method_name)
|
155
|
+
file_name = method.source_location.first
|
156
|
+
if !File.exist?(file_name)
|
157
|
+
raise EditorError, "Source not found"
|
158
|
+
end
|
159
|
+
find_file(method.source_location.first)
|
160
|
+
end
|
146
161
|
end
|
147
162
|
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
$".push("readline.rb")
|
2
|
+
require "rdoc/ri/driver"
|
3
|
+
|
1
4
|
module Textbringer
|
2
5
|
module Commands
|
3
6
|
HELP_RING = Ring.new
|
@@ -102,6 +105,44 @@ module Textbringer
|
|
102
105
|
push_help_command([:describe_key, key])
|
103
106
|
end
|
104
107
|
|
108
|
+
define_command(:describe_class,
|
109
|
+
doc: "Display the documentation of the class.") do
|
110
|
+
|name = read_expression("Describe class: ")|
|
111
|
+
show_help do |help|
|
112
|
+
old_stdout = $stdout
|
113
|
+
$stdout = StringIO.new
|
114
|
+
begin
|
115
|
+
rdoc = RDoc::RI::Driver.new(use_stdout: true,
|
116
|
+
formatter: RDoc::Markup::ToRdoc,
|
117
|
+
interactive: false)
|
118
|
+
rdoc.display_class(name)
|
119
|
+
help.insert($stdout.string)
|
120
|
+
ensure
|
121
|
+
$stdout = old_stdout
|
122
|
+
end
|
123
|
+
end
|
124
|
+
push_help_command([:describe_class, name])
|
125
|
+
end
|
126
|
+
|
127
|
+
define_command(:describe_method,
|
128
|
+
doc: "Display the documentation of the method.") do
|
129
|
+
|name = read_expression("Describe method: ")|
|
130
|
+
show_help do |help|
|
131
|
+
old_stdout = $stdout
|
132
|
+
$stdout = StringIO.new
|
133
|
+
begin
|
134
|
+
rdoc = RDoc::RI::Driver.new(use_stdout: true,
|
135
|
+
formatter: RDoc::Markup::ToRdoc,
|
136
|
+
interactive: false)
|
137
|
+
rdoc.display_method(name)
|
138
|
+
help.insert($stdout.string)
|
139
|
+
ensure
|
140
|
+
$stdout = old_stdout
|
141
|
+
end
|
142
|
+
end
|
143
|
+
push_help_command([:describe_method, name])
|
144
|
+
end
|
145
|
+
|
105
146
|
define_command(:help_go_back, doc: "Go back to the previous help.") do
|
106
147
|
if !HELP_RING.empty?
|
107
148
|
HELP_RING.rotate(1)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "stringio"
|
2
|
+
|
3
|
+
module Textbringer
|
4
|
+
class DefaultOutput
|
5
|
+
def write(*args)
|
6
|
+
Buffer.current.insert(args.join)
|
7
|
+
end
|
8
|
+
|
9
|
+
def flush
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(mid, ...)
|
13
|
+
buffer = StringIO.new
|
14
|
+
buffer.send(mid, ...)
|
15
|
+
write(buffer.string)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/textbringer/keymap.rb
CHANGED
@@ -210,6 +210,8 @@ module Textbringer
|
|
210
210
|
GLOBAL_MAP.define_key([:f1, "b"], :describe_bindings)
|
211
211
|
GLOBAL_MAP.define_key([:f1, "f"], :describe_command)
|
212
212
|
GLOBAL_MAP.define_key([:f1, "k"], :describe_key)
|
213
|
+
GLOBAL_MAP.define_key([:f1, "c"], :describe_class)
|
214
|
+
GLOBAL_MAP.define_key([:f1, "m"], :describe_method)
|
213
215
|
GLOBAL_MAP.define_key("\C-x#", :server_edit_done)
|
214
216
|
GLOBAL_MAP.define_key("\C-\\", :toggle_input_method)
|
215
217
|
GLOBAL_MAP.handle_undefined_key do |key|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Textbringer
|
2
2
|
CONFIG[:c_indent_level] = 4
|
3
|
-
CONFIG[:c_indent_tabs_mode] =
|
3
|
+
CONFIG[:c_indent_tabs_mode] = false
|
4
4
|
CONFIG[:c_continued_statement_offset] = 4
|
5
5
|
CONFIG[:c_case_label_offset] = -4
|
6
6
|
CONFIG[:c_label_offset] = -2
|
@@ -187,7 +187,7 @@ module Textbringer
|
|
187
187
|
if text.empty?
|
188
188
|
raise EditorError, "Empty token: (#{line},#{column}) #{$~.inspect}"
|
189
189
|
end
|
190
|
-
tokens.push([[line, column], token_name, text])
|
190
|
+
tokens.push([[line, column], token_name, CANONICAL_PUNCTUATORS[text]])
|
191
191
|
lf_count = text.count("\n")
|
192
192
|
if lf_count > 0
|
193
193
|
line += lf_count
|
@@ -269,7 +269,7 @@ module Textbringer
|
|
269
269
|
end
|
270
270
|
end
|
271
271
|
|
272
|
-
CANONICAL_PUNCTUATORS = Hash.new {
|
272
|
+
CANONICAL_PUNCTUATORS = Hash.new { _2 }
|
273
273
|
CANONICAL_PUNCTUATORS["<:"] = "["
|
274
274
|
CANONICAL_PUNCTUATORS[":>"] = "]"
|
275
275
|
CANONICAL_PUNCTUATORS["<%"] = "{"
|
data/lib/textbringer/utils.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require "rbconfig"
|
2
|
+
require "irb"
|
3
|
+
require "irb/completion"
|
2
4
|
|
3
5
|
module Textbringer
|
4
6
|
module Utils
|
@@ -164,7 +166,7 @@ module Textbringer
|
|
164
166
|
Window.echo_area.redisplay
|
165
167
|
Window.update
|
166
168
|
recursive_edit
|
167
|
-
s = Buffer.minibuffer.to_s
|
169
|
+
s = Buffer.minibuffer.to_s
|
168
170
|
if default && s.empty?
|
169
171
|
default
|
170
172
|
else
|
@@ -323,6 +325,18 @@ module Textbringer
|
|
323
325
|
end
|
324
326
|
end
|
325
327
|
|
328
|
+
def read_expression(prompt = "Expression: ")
|
329
|
+
f = ->(s) {
|
330
|
+
IRB::InputCompletor.retrieve_completion_data(s, bind: TOPLEVEL_BINDING).compact
|
331
|
+
}
|
332
|
+
read_from_minibuffer(prompt, completion_proc: f)
|
333
|
+
end
|
334
|
+
|
335
|
+
def read_object(prompt = "Object: ")
|
336
|
+
s = read_expression(prompt)
|
337
|
+
eval(s)
|
338
|
+
end
|
339
|
+
|
326
340
|
HOOKS = Hash.new { |h, k| h[k] = [] }
|
327
341
|
|
328
342
|
def add_hook(name, func = nil, &block)
|
data/lib/textbringer/version.rb
CHANGED
data/lib/textbringer.rb
CHANGED
data/textbringer.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.required_ruby_version = '>= 2.
|
22
|
+
spec.required_ruby_version = '>= 2.7'
|
23
23
|
|
24
24
|
spec.add_runtime_dependency "curses", ">= 1.2.7"
|
25
25
|
spec.add_runtime_dependency "unicode-display_width", ">= 1.1"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: textbringer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shugo Maeda
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -171,7 +171,7 @@ email:
|
|
171
171
|
executables:
|
172
172
|
- tbclient
|
173
173
|
- tbtags
|
174
|
-
-
|
174
|
+
- txtb
|
175
175
|
extensions: []
|
176
176
|
extra_rdoc_files: []
|
177
177
|
files:
|
@@ -184,13 +184,14 @@ files:
|
|
184
184
|
- CHANGES.md
|
185
185
|
- Gemfile
|
186
186
|
- LICENSE.txt
|
187
|
+
- README.ja.md
|
187
188
|
- README.md
|
188
189
|
- Rakefile
|
189
190
|
- bin/console
|
190
191
|
- bin/merge_mazegaki_dic
|
191
192
|
- exe/tbclient
|
192
193
|
- exe/tbtags
|
193
|
-
- exe/
|
194
|
+
- exe/txtb
|
194
195
|
- lib/textbringer.rb
|
195
196
|
- lib/textbringer/buffer.rb
|
196
197
|
- lib/textbringer/color.rb
|
@@ -212,6 +213,7 @@ files:
|
|
212
213
|
- lib/textbringer/commands/windows.rb
|
213
214
|
- lib/textbringer/config.rb
|
214
215
|
- lib/textbringer/controller.rb
|
216
|
+
- lib/textbringer/default_output.rb
|
215
217
|
- lib/textbringer/errors.rb
|
216
218
|
- lib/textbringer/face.rb
|
217
219
|
- lib/textbringer/faces/basic.rb
|
@@ -251,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
251
253
|
requirements:
|
252
254
|
- - ">="
|
253
255
|
- !ruby/object:Gem::Version
|
254
|
-
version: '2.
|
256
|
+
version: '2.7'
|
255
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
258
|
requirements:
|
257
259
|
- - ">="
|