textbringer 0.1.9 → 0.2.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/CHANGES.md +4 -0
- data/lib/textbringer/buffer.rb +17 -7
- data/lib/textbringer/commands/misc.rb +1 -1
- data/lib/textbringer/commands/windows.rb +19 -5
- data/lib/textbringer/modes/completion_list_mode.rb +1 -1
- data/lib/textbringer/modes/help_mode.rb +1 -0
- data/lib/textbringer/utils.rb +1 -1
- data/lib/textbringer/version.rb +1 -1
- data/lib/textbringer/window.rb +43 -35
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb6561f5d595d683562f67d0553ef75b556b99b9
|
4
|
+
data.tar.gz: 9f7caf1348f813c52dd69654625e15dcd267e55e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21644b91f2a282c768345186da700628d221f4b177f5b8184d203029d8c0daa0e6b25ff82b93b1432f424e55fe81c144495c980dd56191113f24106c8ba92051
|
7
|
+
data.tar.gz: fb3bf64d60ba016956c87e3dc040aa3de4bcb12f78aa30362e15a015aa355c988c1cf67a635cea327775651ed0c81a251e922754c1f4cd9d07add6f3f5228528
|
data/CHANGES.md
CHANGED
data/lib/textbringer/buffer.rb
CHANGED
@@ -70,9 +70,13 @@ module Textbringer
|
|
70
70
|
@@detect_encoding_proc = f
|
71
71
|
end
|
72
72
|
|
73
|
+
def self.list
|
74
|
+
@@list.dup
|
75
|
+
end
|
76
|
+
|
73
77
|
def self.add(buffer)
|
74
78
|
@@table[buffer.name] = buffer
|
75
|
-
@@list.
|
79
|
+
@@list.push(buffer)
|
76
80
|
end
|
77
81
|
|
78
82
|
def self.current
|
@@ -82,7 +86,7 @@ module Textbringer
|
|
82
86
|
def self.current=(buffer)
|
83
87
|
if buffer && buffer.name && @@table.key?(buffer.name)
|
84
88
|
@@list.delete(buffer)
|
85
|
-
@@list.
|
89
|
+
@@list.unshift(buffer)
|
86
90
|
end
|
87
91
|
@@current = buffer
|
88
92
|
end
|
@@ -95,12 +99,18 @@ module Textbringer
|
|
95
99
|
@@global_mark_ring ||= Ring.new(CONFIG[:global_mark_ring_max])
|
96
100
|
end
|
97
101
|
|
102
|
+
def self.other(buffer = @@current)
|
103
|
+
@@list.find { |buf| buf != buffer } || Buffer.find_or_new("*scratch*")
|
104
|
+
end
|
105
|
+
|
98
106
|
def self.last
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
107
|
+
@@list.last
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.bury(buffer = @@current)
|
111
|
+
@@list.delete(buffer)
|
112
|
+
@@list.push(buffer)
|
113
|
+
@@current = @@list.first
|
104
114
|
end
|
105
115
|
|
106
116
|
def self.count
|
@@ -80,7 +80,7 @@ module Textbringer
|
|
80
80
|
def update_completions(xs)
|
81
81
|
if xs.size > 1
|
82
82
|
if COMPLETION[:original_buffer].nil?
|
83
|
-
COMPLETION[:completions_window] = Window.
|
83
|
+
COMPLETION[:completions_window] = Window.list.last
|
84
84
|
COMPLETION[:original_buffer] =
|
85
85
|
COMPLETION[:completions_window].buffer
|
86
86
|
end
|
@@ -82,6 +82,23 @@ module Textbringer
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
+
define_command(:bury_buffer, doc: <<~EOD) do
|
86
|
+
Put buffer at the end of the buffer list.
|
87
|
+
EOD
|
88
|
+
|buffer = Buffer.current|
|
89
|
+
if buffer.is_a?(String)
|
90
|
+
buffer = Buffer[buffer]
|
91
|
+
end
|
92
|
+
Buffer.bury(buffer)
|
93
|
+
Window.current.buffer = Buffer.current
|
94
|
+
end
|
95
|
+
|
96
|
+
define_command(:unbury_buffer, doc: <<~EOD) do
|
97
|
+
Switch to the last buffer in the buffer list.
|
98
|
+
EOD
|
99
|
+
switch_to_buffer(Buffer.last)
|
100
|
+
end
|
101
|
+
|
85
102
|
define_command(:kill_buffer, doc: "Kill buffer.") do
|
86
103
|
|buffer = read_buffer("Kill buffer: ", default: Buffer.current.name)|
|
87
104
|
if buffer.is_a?(String)
|
@@ -92,11 +109,8 @@ module Textbringer
|
|
92
109
|
message("Arioch! Arioch! Blood and souls for my Lord Arioch!")
|
93
110
|
end
|
94
111
|
buffer.kill
|
95
|
-
if Buffer.
|
96
|
-
|
97
|
-
switch_to_buffer(buffer)
|
98
|
-
elsif Buffer.current.nil?
|
99
|
-
switch_to_buffer(Buffer.last)
|
112
|
+
if Buffer.current.nil?
|
113
|
+
switch_to_buffer(Buffer.other)
|
100
114
|
end
|
101
115
|
end
|
102
116
|
end
|
@@ -5,7 +5,7 @@ module Textbringer
|
|
5
5
|
define_generic_command :choose_completion
|
6
6
|
|
7
7
|
COMPLETION_LIST_MODE_MAP = Keymap.new
|
8
|
-
COMPLETION_LIST_MODE_MAP.define_key("\
|
8
|
+
COMPLETION_LIST_MODE_MAP.define_key("\C-m", :choose_completion_command)
|
9
9
|
|
10
10
|
define_syntax :link, /^.+$/
|
11
11
|
|
@@ -10,6 +10,7 @@ module Textbringer
|
|
10
10
|
HELP_MODE_MAP.define_key("\C-c\C-b", :help_go_back)
|
11
11
|
HELP_MODE_MAP.define_key(?r, :help_go_forward)
|
12
12
|
HELP_MODE_MAP.define_key("\C-c\C-f", :help_go_forward)
|
13
|
+
HELP_MODE_MAP.define_key("q", :bury_buffer)
|
13
14
|
|
14
15
|
define_syntax :link, /
|
15
16
|
(?: ^\S*?:\d+$ ) |
|
data/lib/textbringer/utils.rb
CHANGED
@@ -160,7 +160,7 @@ module Textbringer
|
|
160
160
|
candidates.select { |i| i.start_with?(s) }
|
161
161
|
end
|
162
162
|
|
163
|
-
def read_buffer(prompt, default:
|
163
|
+
def read_buffer(prompt, default: Buffer.other.name)
|
164
164
|
f = ->(s) { complete_for_minibuffer(s, Buffer.names) }
|
165
165
|
read_from_minibuffer(prompt, completion_proc: f, default: default)
|
166
166
|
end
|
data/lib/textbringer/version.rb
CHANGED
data/lib/textbringer/window.rb
CHANGED
@@ -49,13 +49,17 @@ module Textbringer
|
|
49
49
|
end
|
50
50
|
|
51
51
|
@@started = false
|
52
|
-
@@
|
52
|
+
@@list = []
|
53
53
|
@@current = nil
|
54
54
|
@@echo_area = nil
|
55
55
|
@@has_colors = false
|
56
56
|
|
57
|
-
def self.
|
58
|
-
|
57
|
+
def self.list(include_echo_area: false)
|
58
|
+
if include_echo_area
|
59
|
+
@@list.dup
|
60
|
+
else
|
61
|
+
@@list.reject(&:echo_area?)
|
62
|
+
end
|
59
63
|
end
|
60
64
|
|
61
65
|
def self.current
|
@@ -64,7 +68,7 @@ module Textbringer
|
|
64
68
|
|
65
69
|
def self.current=(window)
|
66
70
|
if window.deleted?
|
67
|
-
window = @@
|
71
|
+
window = @@list.first
|
68
72
|
end
|
69
73
|
@@current.save_point if @@current && !@@current.deleted?
|
70
74
|
@@current = window
|
@@ -76,19 +80,19 @@ module Textbringer
|
|
76
80
|
if @@current.echo_area?
|
77
81
|
raise EditorError, "Can't delete the echo area"
|
78
82
|
end
|
79
|
-
if @@
|
83
|
+
if @@list.size == 2
|
80
84
|
raise EditorError, "Can't delete the sole window"
|
81
85
|
end
|
82
|
-
i = @@
|
86
|
+
i = @@list.index(@@current)
|
83
87
|
if i == 0
|
84
|
-
window = @@
|
88
|
+
window = @@list[1]
|
85
89
|
window.move(0, 0)
|
86
90
|
else
|
87
|
-
window = @@
|
91
|
+
window = @@list[i - 1]
|
88
92
|
end
|
89
93
|
window.resize(@@current.lines + window.lines, window.columns)
|
90
94
|
@@current.delete
|
91
|
-
@@
|
95
|
+
@@list.delete_at(i)
|
92
96
|
self.current = window
|
93
97
|
end
|
94
98
|
|
@@ -96,7 +100,7 @@ module Textbringer
|
|
96
100
|
if @@current.echo_area?
|
97
101
|
raise EditorError, "Can't expand the echo area to full screen"
|
98
102
|
end
|
99
|
-
@@
|
103
|
+
@@list.delete_if do |window|
|
100
104
|
if window.current? || window.echo_area?
|
101
105
|
false
|
102
106
|
else
|
@@ -109,10 +113,10 @@ module Textbringer
|
|
109
113
|
end
|
110
114
|
|
111
115
|
def self.other_window
|
112
|
-
i = @@
|
116
|
+
i = @@list.index(@@current)
|
113
117
|
begin
|
114
118
|
i += 1
|
115
|
-
window = @@
|
119
|
+
window = @@list[i % @@list.size]
|
116
120
|
end while !window.active?
|
117
121
|
self.current = window
|
118
122
|
end
|
@@ -161,20 +165,20 @@ module Textbringer
|
|
161
165
|
window =
|
162
166
|
Textbringer::Window.new(Window.lines - 1, Window.columns, 0, 0)
|
163
167
|
window.buffer = Buffer.new_buffer("*scratch*")
|
164
|
-
@@
|
168
|
+
@@list.push(window)
|
165
169
|
Window.current = window
|
166
170
|
@@echo_area = Textbringer::EchoArea.new(1, Window.columns,
|
167
171
|
Window.lines - 1, 0)
|
168
172
|
Buffer.minibuffer.keymap = MINIBUFFER_LOCAL_MAP
|
169
173
|
@@echo_area.buffer = Buffer.minibuffer
|
170
|
-
@@
|
174
|
+
@@list.push(@@echo_area)
|
171
175
|
@@started = true
|
172
176
|
yield
|
173
177
|
ensure
|
174
|
-
@@
|
175
|
-
win.
|
178
|
+
@@list.each do |win|
|
179
|
+
win.close
|
176
180
|
end
|
177
|
-
@@
|
181
|
+
@@list.clear
|
178
182
|
Curses.echo
|
179
183
|
Curses.noraw
|
180
184
|
Curses.nl
|
@@ -186,7 +190,7 @@ module Textbringer
|
|
186
190
|
def self.redisplay
|
187
191
|
return if Controller.current.executing_keyboard_macro?
|
188
192
|
return if Window.current.has_input?
|
189
|
-
@@
|
193
|
+
@@list.each do |window|
|
190
194
|
window.redisplay unless window.current?
|
191
195
|
end
|
192
196
|
current.redisplay
|
@@ -194,7 +198,7 @@ module Textbringer
|
|
194
198
|
end
|
195
199
|
|
196
200
|
def self.redraw
|
197
|
-
@@
|
201
|
+
@@list.each do |window|
|
198
202
|
window.redraw unless window.current?
|
199
203
|
end
|
200
204
|
current.redraw
|
@@ -214,7 +218,7 @@ module Textbringer
|
|
214
218
|
end
|
215
219
|
|
216
220
|
def self.resize
|
217
|
-
@@
|
221
|
+
@@list.delete_if do |window|
|
218
222
|
if !window.echo_area? &&
|
219
223
|
window.y > Window.lines - CONFIG[:window_min_height]
|
220
224
|
window.delete
|
@@ -223,9 +227,9 @@ module Textbringer
|
|
223
227
|
false
|
224
228
|
end
|
225
229
|
end
|
226
|
-
@@
|
230
|
+
@@list.each_with_index do |window, i|
|
227
231
|
unless window.echo_area?
|
228
|
-
if i < @@
|
232
|
+
if i < @@list.size - 2
|
229
233
|
window.resize(window.lines, Window.columns)
|
230
234
|
else
|
231
235
|
window.resize(Window.lines - 1 - window.y, Window.columns)
|
@@ -275,7 +279,7 @@ module Textbringer
|
|
275
279
|
def delete
|
276
280
|
unless @deleted
|
277
281
|
if current?
|
278
|
-
Window.current = @@
|
282
|
+
Window.current = @@list.first
|
279
283
|
end
|
280
284
|
delete_marks
|
281
285
|
@window.close
|
@@ -283,6 +287,10 @@ module Textbringer
|
|
283
287
|
end
|
284
288
|
end
|
285
289
|
|
290
|
+
def close
|
291
|
+
@window.close
|
292
|
+
end
|
293
|
+
|
286
294
|
def buffer=(buffer)
|
287
295
|
delete_marks
|
288
296
|
@buffer = buffer
|
@@ -571,23 +579,23 @@ module Textbringer
|
|
571
579
|
resize(new_lines, columns)
|
572
580
|
new_window = Window.new(old_lines - new_lines, columns, y + new_lines, x)
|
573
581
|
new_window.buffer = buffer
|
574
|
-
i = @@
|
575
|
-
@@
|
582
|
+
i = @@list.index(self)
|
583
|
+
@@list.insert(i + 1, new_window)
|
576
584
|
end
|
577
585
|
|
578
586
|
def enlarge(n)
|
579
587
|
if n > 0
|
580
588
|
max_height = Window.lines -
|
581
|
-
CONFIG[:window_min_height] * (@@
|
589
|
+
CONFIG[:window_min_height] * (@@list.size - 2) - 1
|
582
590
|
new_lines = [lines + n, max_height].min
|
583
591
|
needed_lines = new_lines - lines
|
584
592
|
resize(new_lines, columns)
|
585
|
-
i = @@
|
586
|
-
indices = (i + 1).upto(@@
|
593
|
+
i = @@list.index(self)
|
594
|
+
indices = (i + 1).upto(@@list.size - 2).to_a +
|
587
595
|
(i - 1).downto(0).to_a
|
588
596
|
indices.each do |j|
|
589
597
|
break if needed_lines == 0
|
590
|
-
window = @@
|
598
|
+
window = @@list[j]
|
591
599
|
extended_lines = [
|
592
600
|
window.lines - CONFIG[:window_min_height],
|
593
601
|
needed_lines
|
@@ -596,20 +604,20 @@ module Textbringer
|
|
596
604
|
needed_lines -= extended_lines
|
597
605
|
end
|
598
606
|
y = 0
|
599
|
-
@@
|
607
|
+
@@list.each do |win|
|
600
608
|
win.move(y, win.x)
|
601
609
|
y += win.lines
|
602
610
|
end
|
603
|
-
elsif n < 0 && @@
|
611
|
+
elsif n < 0 && @@list.size > 2
|
604
612
|
new_lines = [lines + n, CONFIG[:window_min_height]].max
|
605
613
|
diff = lines - new_lines
|
606
614
|
resize(new_lines, columns)
|
607
|
-
i = @@
|
608
|
-
if i < @@
|
609
|
-
window = @@
|
615
|
+
i = @@list.index(self)
|
616
|
+
if i < @@list.size - 2
|
617
|
+
window = @@list[i + 1]
|
610
618
|
window.move(window.y - diff, window.x)
|
611
619
|
else
|
612
|
-
window = @@
|
620
|
+
window = @@list[i - 1]
|
613
621
|
move(self.y + diff, self.x)
|
614
622
|
end
|
615
623
|
window.resize(window.lines + diff, window.columns)
|
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: 0.
|
4
|
+
version: 0.2.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: 2017-03-
|
11
|
+
date: 2017-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|