vimamsa 0.1.14 → 0.1.16
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/custom_example.rb +9 -2
- data/lib/vimamsa/actions.rb +1 -2
- data/lib/vimamsa/buffer.rb +79 -31
- data/lib/vimamsa/buffer_changetext.rb +18 -1
- data/lib/vimamsa/buffer_list.rb +126 -139
- data/lib/vimamsa/buffer_manager.rb +34 -23
- data/lib/vimamsa/clipboard.rb +1 -0
- data/lib/vimamsa/conf.rb +6 -0
- data/lib/vimamsa/constants.rb +0 -10
- data/lib/vimamsa/debug.rb +5 -0
- data/lib/vimamsa/editor.rb +17 -7
- data/lib/vimamsa/file_history.rb +0 -8
- data/lib/vimamsa/file_manager.rb +6 -3
- data/lib/vimamsa/gui.rb +105 -55
- data/lib/vimamsa/gui_dialog.rb +1 -1
- data/lib/vimamsa/gui_menu.rb +7 -1
- data/lib/vimamsa/gui_sourceview.rb +58 -18
- data/lib/vimamsa/gui_sourceview_autocomplete.rb +141 -0
- data/lib/vimamsa/gui_text.rb +32 -2
- data/lib/vimamsa/hyper_plain_text.rb +11 -0
- data/lib/vimamsa/key_actions.rb +29 -10
- data/lib/vimamsa/key_binding_tree.rb +84 -14
- data/lib/vimamsa/key_bindings_vimlike.rb +44 -23
- data/lib/vimamsa/langservp.rb +23 -3
- data/lib/vimamsa/main.rb +4 -0
- data/lib/vimamsa/rbvma.rb +2 -0
- data/lib/vimamsa/search_replace.rb +35 -27
- data/lib/vimamsa/terminal.rb +12 -0
- data/lib/vimamsa/util.rb +40 -2
- data/lib/vimamsa/version.rb +1 -1
- data/vimamsa.gemspec +3 -2
- metadata +8 -7
data/lib/vimamsa/buffer_list.rb
CHANGED
@@ -2,7 +2,7 @@ def save_buffer_list()
|
|
2
2
|
message("Save buffer list")
|
3
3
|
buffn = get_dot_path("buffers.txt")
|
4
4
|
f = File.open(buffn, "w")
|
5
|
-
bufstr = vma.buffers.collect { |buf| buf.fname }.inspect
|
5
|
+
bufstr = vma.buffers.list.collect { |buf| buf.fname }.inspect
|
6
6
|
f.write(bufstr)
|
7
7
|
f.close()
|
8
8
|
end
|
@@ -19,74 +19,93 @@ def load_buffer_list()
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
class BufferList
|
22
|
+
class BufferList
|
23
23
|
attr_reader :current_buf, :last_dir, :last_file, :buffer_history
|
24
|
+
attr_accessor :list
|
24
25
|
|
25
26
|
def initialize()
|
26
27
|
@last_dir = File.expand_path(".")
|
27
28
|
@buffer_history = []
|
28
29
|
super
|
29
30
|
@current_buf = 0
|
31
|
+
@list = []
|
32
|
+
@h = {}
|
33
|
+
reset_navigation
|
30
34
|
end
|
31
35
|
|
32
36
|
# lastdir = File.expand_path(".") if lastdir.nil?
|
33
37
|
def <<(_buf)
|
34
|
-
super
|
35
38
|
vma.buf = _buf
|
36
|
-
|
37
|
-
|
38
|
-
@recent_ind = 0
|
39
|
+
self.add(_buf)
|
40
|
+
|
39
41
|
$hook.call(:change_buffer, vma.buf)
|
40
|
-
vma.gui.set_current_buffer(vma.buf.id)
|
41
|
-
#
|
42
|
-
vma.buf.view.set_cursor_pos(vma.buf.pos)
|
42
|
+
vma.gui.set_current_buffer(vma.buf.id) #TODO: handle elswhere?
|
43
|
+
# vma.buf.view.set_cursor_pos(vma.buf.pos) #TODO: handle elswhere?
|
43
44
|
update_last_dir(_buf)
|
44
45
|
end
|
45
46
|
|
46
47
|
def add(_buf)
|
47
|
-
|
48
|
-
@
|
48
|
+
@buffer_history << _buf.id
|
49
|
+
# @navigation_idx = _buf.id #TODO:??
|
50
|
+
@list << _buf
|
51
|
+
@h[_buf.id] = _buf
|
49
52
|
end
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
#NOTE: unused. enable?
|
55
|
+
# def switch()
|
56
|
+
# debug "SWITCH BUF. bufsize:#{self.size}, curbuf: #{@current_buf}"
|
57
|
+
# @current_buf += 1
|
58
|
+
# @current_buf = 0 if @current_buf >= self.size
|
59
|
+
# m = method("switch")
|
60
|
+
# set_last_command({ method: m, params: [] })
|
61
|
+
# set_current_buffer(@current_buf)
|
62
|
+
# end
|
63
|
+
|
64
|
+
def slist
|
65
|
+
# TODO: implement using heap/priorityque
|
66
|
+
@list.sort_by! { |x| x.access_time }
|
58
67
|
end
|
59
68
|
|
60
69
|
def get_last_visited_id
|
61
|
-
last_buf =
|
62
|
-
|
70
|
+
last_buf = nil
|
71
|
+
for i in 0..(slist.size - 1)
|
72
|
+
next if slist[i].is_active?
|
73
|
+
last_buf = slist[i].id
|
74
|
+
end
|
75
|
+
return last_buf
|
63
76
|
end
|
64
77
|
|
65
78
|
def switch_to_last_buf()
|
66
79
|
debug "SWITCH TO LAST BUF:"
|
67
|
-
debug @buffer_history
|
68
|
-
last_buf = @buffer_history[-2]
|
69
|
-
|
70
|
-
|
80
|
+
# debug @buffer_history
|
81
|
+
# last_buf = @buffer_history[-2]
|
82
|
+
|
83
|
+
last_buf = slist[-2]
|
84
|
+
if !last_buf.nil?
|
85
|
+
set_current_buffer(last_buf.id)
|
71
86
|
end
|
72
87
|
end
|
73
88
|
|
89
|
+
def size
|
90
|
+
return @list.size
|
91
|
+
end
|
92
|
+
|
74
93
|
def get_buffer_by_filename(fname)
|
75
94
|
#TODO: check using stat/inode? http://ruby-doc.org/core-1.9.3/File/Stat.html#method-i-ino
|
76
|
-
|
77
|
-
return
|
95
|
+
b = @list.find { |b| b.fname == fname }
|
96
|
+
return b.id unless b.nil?
|
97
|
+
return nil
|
78
98
|
end
|
79
99
|
|
80
100
|
def get_buffer_by_id(id)
|
81
|
-
|
82
|
-
return buf_idx
|
101
|
+
return @h[id]
|
83
102
|
end
|
84
103
|
|
85
104
|
def add_buf_to_history(buf_idx)
|
86
|
-
if
|
105
|
+
if @list.include?(buf_idx)
|
87
106
|
@buffer_history << @buf_idx
|
88
|
-
@
|
89
|
-
compact_buf_history()
|
107
|
+
@navigation_idx = 0
|
108
|
+
# compact_buf_history()
|
90
109
|
else
|
91
110
|
debug "buffer_list, no such id:#{buf_idx}"
|
92
111
|
return
|
@@ -94,52 +113,40 @@ class BufferList < Array
|
|
94
113
|
end
|
95
114
|
|
96
115
|
def add_current_buf_to_history()
|
97
|
-
@
|
98
|
-
@buffer_history << @current_buf
|
99
|
-
compact_buf_history()
|
116
|
+
@h[@current_buf].update_access_time
|
100
117
|
end
|
101
118
|
|
102
|
-
def set_current_buffer_by_id(
|
103
|
-
idx = get_buffer_by_id(buf_id)
|
104
|
-
if idx.nil?
|
105
|
-
debug "IDX=nil"
|
106
|
-
return
|
107
|
-
end
|
119
|
+
def set_current_buffer_by_id(idx, update_history = true)
|
108
120
|
set_current_buffer(idx, update_history)
|
109
121
|
end
|
110
122
|
|
111
|
-
def set_current_buffer(
|
112
|
-
|
113
|
-
|
114
|
-
if !vma.buf.nil? and vma.kbd.
|
123
|
+
def set_current_buffer(idx, update_history = true)
|
124
|
+
# Set update_history = false if we are only browsing
|
125
|
+
|
126
|
+
if !vma.buf.nil? and vma.kbd.get_scope != :editor
|
115
127
|
# Save keyboard mode status of old buffer when switching buffer
|
116
128
|
vma.buf.mode_stack = vma.kbd.default_mode_stack.clone
|
117
129
|
end
|
118
|
-
|
119
|
-
|
130
|
+
return if !@h[idx]
|
131
|
+
vma.buf = bu = @h[idx]
|
120
132
|
update_last_dir(vma.buf)
|
121
|
-
@current_buf =
|
122
|
-
debug "SWITCH
|
123
|
-
fpath = vma.buf.fname
|
124
|
-
if fpath and fpath.size > 50
|
125
|
-
fpath = fpath[-50..-1]
|
126
|
-
end
|
133
|
+
@current_buf = idx
|
134
|
+
debug "SWITCH BUF. bufsize:#{@list.size}, curbuf: #{@current_buf}"
|
127
135
|
|
128
|
-
if update_history
|
129
|
-
add_current_buf_to_history
|
130
|
-
end
|
131
136
|
vma.hook.call(:change_buffer, vma.buf)
|
132
|
-
vma.buf.set_active # TODO
|
133
137
|
|
134
|
-
|
138
|
+
bu.set_active # TODO
|
139
|
+
bu.update_access_time if update_history
|
140
|
+
vma.gui.set_current_buffer(idx)
|
135
141
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
142
|
+
#TODO: delete?
|
143
|
+
# if !vma.buf.mode_stack.nil? and vma.kbd.get_scope != :editor #TODO
|
144
|
+
# debug "set kbd mode stack #{vma.buf.mode_stack} #{vma.buf.id}", 2
|
145
|
+
# Reload previously saved keyboard mode status
|
146
|
+
# vma.kbd.set_mode_stack(vma.buf.mode_stack.clone) #TODO:needed?
|
147
|
+
# vma.kbd.set_mode_stack([vma.buf.default_mode])
|
148
|
+
# end
|
149
|
+
# vma.kbd.set_mode_to_default if vma.kbd.get_scope != :editor
|
143
150
|
|
144
151
|
gui_set_window_title(vma.buf.title, vma.buf.subtitle)
|
145
152
|
|
@@ -169,100 +176,80 @@ class BufferList < Array
|
|
169
176
|
return @last_dir
|
170
177
|
end
|
171
178
|
|
172
|
-
def
|
173
|
-
|
174
|
-
@buffer_history.reverse.each { |x| bufs << x if !b[x] && x < self.size; b[x] = true }
|
175
|
-
return bufs
|
179
|
+
def reset_navigation
|
180
|
+
@navigation_idx = 0
|
176
181
|
end
|
177
182
|
|
178
|
-
def history_switch_backwards
|
179
|
-
|
180
|
-
@
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
set_current_buffer(bufid, false)
|
183
|
+
def history_switch_backwards
|
184
|
+
@navigation_idx += 1
|
185
|
+
@navigation_idx = 0 if @navigation_idx >= list.size
|
186
|
+
b = slist[-1 - @navigation_idx]
|
187
|
+
debug "IND:#{@navigation_idx} RECENT:#{slist.collect { |x| x.fname }.join(" ")}"
|
188
|
+
set_current_buffer(b.id, false)
|
185
189
|
end
|
186
190
|
|
187
191
|
def history_switch_forwards()
|
188
|
-
|
189
|
-
@
|
190
|
-
|
191
|
-
|
192
|
-
debug "IND:#{@
|
193
|
-
set_current_buffer(
|
192
|
+
@navigation_idx -= 1
|
193
|
+
@navigation_idx = list.size - 1 if @navigation_idx < 0
|
194
|
+
|
195
|
+
b = slist[-1 - @navigation_idx]
|
196
|
+
debug "IND:#{@navigation_idx} RECENT:#{slist.collect { |x| x.fname }.join(" ")}"
|
197
|
+
set_current_buffer(b.id, false)
|
194
198
|
end
|
195
199
|
|
196
|
-
def
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
200
|
+
def get_last_non_active_buffer
|
201
|
+
for bu in slist.reverse
|
202
|
+
return bu.id if !bu.is_active?
|
203
|
+
end
|
204
|
+
return nil
|
201
205
|
end
|
202
206
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
return if
|
207
|
-
return if @current_buf == buffer_i
|
207
|
+
def close_buffer(idx, from_recent = false, auto_open: true)
|
208
|
+
return if idx.nil?
|
209
|
+
bu = @h[idx]
|
210
|
+
return if bu.nil?
|
208
211
|
|
209
|
-
bufname =
|
212
|
+
bufname = bu.basename
|
210
213
|
message("Closed buffer #{bufname}")
|
211
214
|
|
212
|
-
|
213
|
-
@
|
214
|
-
end
|
215
|
-
|
216
|
-
def close_buffer(buffer_i, from_recent = false)
|
217
|
-
return if buffer_i.nil?
|
218
|
-
return if self.size <= buffer_i
|
215
|
+
@list.delete(@h[idx])
|
216
|
+
@h.delete(idx)
|
219
217
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
self.slice!(buffer_i)
|
227
|
-
@buffer_history = @buffer_history.collect { |x| r = x; r = x - 1 if x > buffer_i; r = nil if x == buffer_i; r }.compact
|
228
|
-
|
229
|
-
if @current_buf == buffer_i
|
230
|
-
if from_recent
|
231
|
-
@current_buf = jump_to_buf
|
232
|
-
else
|
233
|
-
# Find last edited buffer that is not already open
|
234
|
-
@current_buf = @buffer_history.filter { |x| !vma.gui.is_buffer_open(self[x].id) }.last
|
218
|
+
if auto_open
|
219
|
+
@current_buf = get_last_non_active_buffer
|
220
|
+
if @list.size == 0 or @current_buf.nil?
|
221
|
+
bu = Buffer.new("\n")
|
222
|
+
add(bu)
|
223
|
+
@current_buf = bu.id
|
235
224
|
end
|
225
|
+
set_current_buffer(@current_buf, false)
|
236
226
|
end
|
237
|
-
if self.size == 0 or @current_buf.nil?
|
238
|
-
self << Buffer.new("\n")
|
239
|
-
@current_buf = 0
|
240
|
-
else
|
241
|
-
@current_buf = 0 if @current_buf >= self.size
|
242
|
-
end
|
243
|
-
set_current_buffer(@current_buf, false)
|
244
227
|
end
|
245
228
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
if self.size == 1
|
250
|
-
close_buffer(0)
|
251
|
-
break
|
252
|
-
else
|
253
|
-
close_buffer(0)
|
254
|
-
end
|
255
|
-
end
|
256
|
-
# self << Buffer.new("\n")
|
229
|
+
# Close buffer in the background
|
230
|
+
def close_other_buffer(idx)
|
231
|
+
close_buffer(idx, auto_open: false)
|
257
232
|
end
|
258
233
|
|
234
|
+
#TODO
|
235
|
+
# def close_all_buffers()
|
236
|
+
# message("Closing all buffers")
|
237
|
+
# while @list.size > 0
|
238
|
+
# if self.size == 1
|
239
|
+
# close_buffer(0)
|
240
|
+
# break
|
241
|
+
# else
|
242
|
+
# close_buffer(0)
|
243
|
+
# end
|
244
|
+
# end
|
245
|
+
# # self << Buffer.new("\n")
|
246
|
+
# end
|
247
|
+
|
259
248
|
def close_scrap_buffers()
|
260
|
-
|
261
|
-
|
262
|
-
if !
|
263
|
-
close_buffer(
|
264
|
-
else
|
265
|
-
i += 1
|
249
|
+
l = @list.clone
|
250
|
+
for bu in l
|
251
|
+
if !bu.pathname
|
252
|
+
close_buffer(bu.id)
|
266
253
|
end
|
267
254
|
end
|
268
255
|
end
|
@@ -273,7 +260,7 @@ class BufferList < Array
|
|
273
260
|
|
274
261
|
def delete_current_buffer(from_recent = false)
|
275
262
|
fn = buf.fname
|
276
|
-
close_buffer(@current_buf
|
263
|
+
close_buffer(@current_buf)
|
277
264
|
#TODO: confirm with user, "Do you want to delete file X"
|
278
265
|
if is_existing_file(fn)
|
279
266
|
message("Deleting file: #{fn}")
|
@@ -28,28 +28,26 @@ class BufferManager
|
|
28
28
|
l = @buf.lpos - @header.size
|
29
29
|
return nil if l < 0
|
30
30
|
bufid = @line_to_id[l]
|
31
|
-
|
32
|
-
return buf_i
|
31
|
+
return bufid
|
33
32
|
end
|
34
33
|
|
35
34
|
def close_selected
|
36
|
-
|
37
|
-
|
35
|
+
idx = buf_of_current_line()
|
36
|
+
r = @buf.current_line_range
|
37
|
+
Gui.hilight_range(@buf, r, color: "#666666ff")
|
38
|
+
if idx.nil?
|
38
39
|
message("buf already closed")
|
39
40
|
return
|
40
41
|
end
|
41
|
-
vma.buffers.close_other_buffer(
|
42
|
+
vma.buffers.close_other_buffer(idx)
|
42
43
|
end
|
43
44
|
|
44
45
|
def select_line
|
45
|
-
|
46
|
-
return if
|
46
|
+
idx = buf_of_current_line()
|
47
|
+
return if idx.nil?
|
47
48
|
|
48
|
-
|
49
|
-
vma.buffers.
|
50
|
-
|
51
|
-
bid = vma.buffers.get_buffer_by_id(@buf.id)
|
52
|
-
vma.buffers.close_other_buffer(bid)
|
49
|
+
vma.buffers.set_current_buffer(idx)
|
50
|
+
vma.buffers.close_other_buffer(@buf.id)
|
53
51
|
@@cur = nil
|
54
52
|
end
|
55
53
|
|
@@ -70,21 +68,34 @@ class BufferManager
|
|
70
68
|
s << "\n"
|
71
69
|
i = 0
|
72
70
|
jump_to_line = 0
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
lastdir = nil
|
72
|
+
bh = {}
|
73
|
+
for b in vma.buffers.list
|
74
|
+
if !b.fname.nil?
|
75
|
+
bname = File.basename(b.fname)
|
76
|
+
dname = File.dirname(b.dirname)
|
77
|
+
else
|
78
|
+
bname = b.list_str
|
79
|
+
dname = "*"
|
77
80
|
end
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
+
bh[dname] ||= []
|
82
|
+
bh[dname] << {bname: bname, buf: b}
|
83
|
+
end
|
84
|
+
for k in bh.keys.sort
|
85
|
+
d = tilde_path(k)
|
86
|
+
s << "📂#{d}:\n" # Note: to close?: 📁
|
81
87
|
i += 1
|
88
|
+
for bnfo in bh[k].sort_by{|x|x[:bname]}
|
89
|
+
s << "╰─#{bnfo[:bname]}\n"
|
90
|
+
|
91
|
+
@line_to_id[i] = bnfo[:buf].id
|
92
|
+
jump_to_line = i if bnfo[:buf].id == vma.buf.id # current file
|
93
|
+
i += 1
|
94
|
+
end
|
82
95
|
end
|
83
|
-
|
84
|
-
|
85
|
-
|
96
|
+
|
86
97
|
if @buf.nil?
|
87
|
-
@buf = create_new_buffer(s,"bufmgr")
|
98
|
+
@buf = create_new_buffer(s, "bufmgr")
|
88
99
|
@buf.default_mode = :buf_mgr
|
89
100
|
@buf.module = self
|
90
101
|
@buf.active_kbd_mode = :buf_mgr
|
data/lib/vimamsa/clipboard.rb
CHANGED
data/lib/vimamsa/conf.rb
CHANGED
data/lib/vimamsa/constants.rb
CHANGED
@@ -15,8 +15,6 @@ CURRENT_CHAR_FORWARD = 2005
|
|
15
15
|
CURRENT_CHAR_BACKWARD = 2006
|
16
16
|
START_OF_BUFFER = 2007
|
17
17
|
END_OF_BUFFER = 2008
|
18
|
-
BACKWARD = 2009
|
19
|
-
FORWARD = 2010
|
20
18
|
END_OF_LINE = 2011
|
21
19
|
BEGINNING_OF_LINE = 2012
|
22
20
|
WORD_START = 2013
|
@@ -30,14 +28,6 @@ REPLACE = 3002
|
|
30
28
|
KEY_PRESS = 6
|
31
29
|
KEY_RELEASE = 7 # QEvent::KeyRelease
|
32
30
|
|
33
|
-
# http://qt-project.org/doc/qt-5.0/qtcore/qt.html#KeyboardModifier-enum
|
34
|
-
ALTMODIFIER = 0x08000000
|
35
|
-
NOMODIFIER = 0x00000000 # No modifier key is pressed.
|
36
|
-
SHIFTMODIFIER = 0x02000000 # A Shift key on the keyboard is pressed.
|
37
|
-
CONTROLMODIFIER = 0x04000000 # A Ctrl key on the keyboard is pressed.
|
38
|
-
ALTMODIFIER = 0x08000000 # An Alt key on the keyboard is pressed.
|
39
|
-
METAMODIFIER = 0x10000000 # A Meta key on the keyboard is pressed.
|
40
|
-
KEYPADMODIFIER = 0x20000000 # A keypad button is pressed.
|
41
31
|
|
42
32
|
|
43
33
|
|
data/lib/vimamsa/debug.rb
CHANGED
data/lib/vimamsa/editor.rb
CHANGED
@@ -5,6 +5,7 @@ def handle_drag_and_drop(fname)
|
|
5
5
|
buf.handle_drag_and_drop(fname)
|
6
6
|
end
|
7
7
|
|
8
|
+
|
8
9
|
class Editor
|
9
10
|
attr_reader :file_content_search_paths, :file_name_search_paths, :gui, :hook, :macro
|
10
11
|
attr_accessor :converters, :fh, :paint_stack, :kbd, :langsrv, :register, :cur_register, :clipboard
|
@@ -68,6 +69,11 @@ class Editor
|
|
68
69
|
$search = Search.new
|
69
70
|
register_plugin(:Search, $search)
|
70
71
|
|
72
|
+
# build_key_bindings_tree
|
73
|
+
@kbd = KeyBindingTree.new()
|
74
|
+
$kbd = @kbd
|
75
|
+
require "vimamsa/key_bindings_vimlike"
|
76
|
+
|
71
77
|
$buffers = BufferList.new
|
72
78
|
$minibuffer = Buffer.new(">", "")
|
73
79
|
@langsrv = {}
|
@@ -75,10 +81,7 @@ class Editor
|
|
75
81
|
require "vimamsa/text_transforms"
|
76
82
|
|
77
83
|
debug "ARGV: " + ARGV.inspect
|
78
|
-
|
79
|
-
@kbd = KeyBindingTree.new()
|
80
|
-
$kbd = @kbd
|
81
|
-
require "vimamsa/key_bindings_vimlike"
|
84
|
+
|
82
85
|
sleep(0.03)
|
83
86
|
|
84
87
|
BufferManager.init
|
@@ -121,8 +124,9 @@ class Editor
|
|
121
124
|
|
122
125
|
Grep.init
|
123
126
|
FileManager.init
|
127
|
+
Autocomplete.init
|
124
128
|
|
125
|
-
if
|
129
|
+
if cnf.lsp.enabled?
|
126
130
|
require "vimamsa/langservp"
|
127
131
|
require "vimamsa/audio" # TODO:config
|
128
132
|
@langsrv["ruby"] = LangSrv.new("ruby")
|
@@ -444,7 +448,7 @@ def minibuffer_delete()
|
|
444
448
|
end
|
445
449
|
|
446
450
|
def error(str)
|
447
|
-
|
451
|
+
show_caller
|
448
452
|
debug "#{caller[0]} ERROR: #{str}", 2
|
449
453
|
end
|
450
454
|
|
@@ -487,7 +491,7 @@ GUESS_ENCODING_ORDER = [
|
|
487
491
|
]
|
488
492
|
|
489
493
|
def create_new_file(filename = nil, file_contents = "\n")
|
490
|
-
buffer = Buffer.new(file_contents)
|
494
|
+
buffer = Buffer.new(file_contents, filename)
|
491
495
|
|
492
496
|
debug "NEW FILE CREATED: #{buffer.id}"
|
493
497
|
vma.buffers.add(buffer)
|
@@ -580,6 +584,12 @@ def open_new_file(filename, file_contents = "")
|
|
580
584
|
if !is_path_writable(filename)
|
581
585
|
message("Path #{filename} cannot be written to")
|
582
586
|
return false
|
587
|
+
elsif !File.exist?(filename)
|
588
|
+
message("File #{filename} does not exist")
|
589
|
+
return false
|
590
|
+
elsif !file_is_text_file(filename)
|
591
|
+
message("File #{filename} does not contain text")
|
592
|
+
return false
|
583
593
|
end
|
584
594
|
message "New file opened: #{filename}"
|
585
595
|
fname = filename
|
data/lib/vimamsa/file_history.rb
CHANGED
@@ -4,9 +4,6 @@ class FileHistory
|
|
4
4
|
attr_accessor :history
|
5
5
|
|
6
6
|
def initialize()
|
7
|
-
# puts self.method("update")
|
8
|
-
# x = self.method("update")
|
9
|
-
# x.call("ASFASF")
|
10
7
|
|
11
8
|
vma.hook.register(:change_buffer, self.method("update"))
|
12
9
|
vma.hook.register(:shutdown, self.method("save"))
|
@@ -17,9 +14,6 @@ class FileHistory
|
|
17
14
|
$search_list = []
|
18
15
|
end
|
19
16
|
|
20
|
-
# def self.init()
|
21
|
-
# end
|
22
|
-
|
23
17
|
def update(buf)
|
24
18
|
debug "FileHistory.update(buf=#{buf.fname})"
|
25
19
|
return if !buf.fname
|
@@ -30,8 +24,6 @@ class FileHistory
|
|
30
24
|
@history[buf.fname] += 1
|
31
25
|
end
|
32
26
|
debug @history
|
33
|
-
|
34
|
-
# puts "FileHistory.update(buf=#{buf})"
|
35
27
|
end
|
36
28
|
|
37
29
|
def save()
|
data/lib/vimamsa/file_manager.rb
CHANGED
@@ -18,7 +18,7 @@ class FileManager
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.init()
|
21
|
-
reg_act(:start_file_selector, proc { FileManager.new.run; vma.kbd.set_mode(:file_exp);
|
21
|
+
reg_act(:start_file_selector, proc { FileManager.new.run; vma.kbd.set_mode(:file_exp); }, "File selector")
|
22
22
|
|
23
23
|
reg_act(:fexp_chdir_parent, proc { FileManager.chdir_parent }, "File selector")
|
24
24
|
reg_act(:fexp_select, proc { buf.module.select_line }, "")
|
@@ -86,7 +86,7 @@ class FileManager
|
|
86
86
|
# Thread.new {
|
87
87
|
for fn in @cut_files
|
88
88
|
FileUtils.move(fn, @ld)
|
89
|
-
|
89
|
+
debug "FileUtils.move(#{fn}, #{@ld})"
|
90
90
|
end
|
91
91
|
elsif !@copied_files.empty?
|
92
92
|
for fn in @copied_files
|
@@ -263,8 +263,11 @@ class FileManager
|
|
263
263
|
# elsif vma.can_open_extension?(fn)
|
264
264
|
# jump_to_file(fn)
|
265
265
|
elsif file_is_text_file(fn)
|
266
|
-
bufs.close_current_buffer
|
266
|
+
# bufs.close_current_buffer
|
267
267
|
jump_to_file(fn)
|
268
|
+
# vma.buffers.set_current_buffer(idx)
|
269
|
+
vma.buffers.close_other_buffer(@buf.id)
|
270
|
+
|
268
271
|
else
|
269
272
|
open_with_default_program(fn)
|
270
273
|
end
|