textbringer 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +8 -0
- data/README.ja.md +103 -0
- data/README.md +11 -2
- data/exe/txtb +1 -0
- 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 +2 -2
- data/lib/textbringer/utils.rb +14 -0
- data/lib/textbringer/version.rb +1 -1
- data/lib/textbringer.rb +1 -0
- metadata +4 -2
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,11 @@
|
|
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
|
+
|
1
9
|
## 1.2.0
|
2
10
|
|
3
11
|
* Drop Ruby 2.6 support.
|
data/README.ja.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# ![Textbringer](logo/logo.png)
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/textbringer.svg)](https://badge.fury.io/rb/textbringer)
|
4
|
+
[![ubuntu](https://github.com/shugo/textbringer/workflows/ubuntu/badge.svg)](https://github.com/shugo/textbringer/actions?query=workflow%3Aubuntu)
|
5
|
+
[![windows](https://github.com/shugo/textbringer/workflows/windows/badge.svg)](https://github.com/shugo/textbringer/actions?query=workflow%3Awindows)
|
6
|
+
[![macos](https://github.com/shugo/textbringer/workflows/macos/badge.svg)](https://github.com/shugo/textbringer/actions?query=workflow%3Amacos)
|
7
|
+
|
8
|
+
TextbringerはRubyで実装されたEmacsライクなテキストエディタです。
|
9
|
+
Lispの代りにRubyで拡張することができます。
|
10
|
+
|
11
|
+
## スクリーンショット
|
12
|
+
|
13
|
+
![Screenshot](screenshot.png)
|
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
|
[![windows](https://github.com/shugo/textbringer/workflows/windows/badge.svg)](https://github.com/shugo/textbringer/actions?query=workflow%3Awindows)
|
6
6
|
[![macos](https://github.com/shugo/textbringer/workflows/macos/badge.svg)](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
|
|
@@ -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/txtb
CHANGED
@@ -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
|
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
|
@@ -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
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
|
@@ -184,6 +184,7 @@ 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
|
@@ -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
|