vimamsa 0.1.23 → 0.1.24
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/.dockerignore +32 -0
- data/Dockerfile +45 -0
- data/custom_example.rb +37 -11
- data/docker_cmd.sh +7 -0
- data/exe/run_tests.rb +23 -0
- data/lib/vimamsa/actions.rb +8 -0
- data/lib/vimamsa/buffer.rb +38 -47
- data/lib/vimamsa/buffer_changetext.rb +49 -12
- data/lib/vimamsa/buffer_list.rb +2 -28
- data/lib/vimamsa/conf.rb +30 -0
- data/lib/vimamsa/diff_buffer.rb +80 -32
- data/lib/vimamsa/editor.rb +54 -67
- data/lib/vimamsa/file_finder.rb +6 -2
- data/lib/vimamsa/gui.rb +247 -63
- data/lib/vimamsa/gui_file_panel.rb +1 -0
- data/lib/vimamsa/gui_func_panel.rb +127 -0
- data/lib/vimamsa/gui_menu.rb +42 -0
- data/lib/vimamsa/gui_select_window.rb +17 -6
- data/lib/vimamsa/gui_settings.rb +344 -13
- data/lib/vimamsa/gui_sourceview.rb +116 -2
- data/lib/vimamsa/gui_text.rb +0 -22
- data/lib/vimamsa/hyper_plain_text.rb +1 -0
- data/lib/vimamsa/key_actions.rb +30 -29
- data/lib/vimamsa/key_binding_tree.rb +85 -3
- data/lib/vimamsa/key_bindings_vimlike.rb +4 -0
- data/lib/vimamsa/langservp.rb +161 -7
- data/lib/vimamsa/macro.rb +54 -7
- data/lib/vimamsa/rbvma.rb +2 -0
- data/lib/vimamsa/test_framework.rb +137 -0
- data/lib/vimamsa/version.rb +1 -1
- data/modules/calculator/calculator.rb +318 -0
- data/modules/calculator/calculator_info.rb +3 -0
- data/modules/terminal/terminal.rb +140 -0
- data/modules/terminal/terminal_info.rb +3 -0
- data/run_tests.rb +89 -0
- data/styles/dark.xml +1 -1
- data/styles/molokai_edit.xml +2 -2
- data/tests/key_bindings.rb +2 -0
- data/tests/test_basic_editing.rb +86 -0
- data/tests/test_copy_paste.rb +88 -0
- data/tests/test_key_bindings.rb +152 -0
- data/tests/test_module_interface.rb +98 -0
- data/tests/test_undo.rb +201 -0
- data/vimamsa.gemspec +6 -5
- metadata +46 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1c5be10ed2f57f72fe6aa73549680f6617b88149350b2afde434be82bfbe0a8
|
|
4
|
+
data.tar.gz: 941e4c0ddd0359306b91f1f8ebd3d3c91e156847e04c8ffd5ebd4ba7dbf27880
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b161ee9c95585324ee772fb6c28bd148d8846bde5aec0a70117af51895ca82f7e179968d1b7dd05269b24f8e4a78f7a61de09db48c75531e252e6a07bb412bbd
|
|
7
|
+
data.tar.gz: f5b553a83eef33c833ca5fc0ef01da4b3c5004f2c44df8d1298940d61dd28ddc8863828249568c88feac0d611538a533d90ee914a61e4ddf499538eacae228ef
|
data/.dockerignore
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Let the container generate its own lockfile during bundle install
|
|
2
|
+
Gemfile.lock
|
|
3
|
+
|
|
4
|
+
# Compiled artifacts — rebuilt by bundle install
|
|
5
|
+
*.gem
|
|
6
|
+
*.o
|
|
7
|
+
*.so
|
|
8
|
+
ext/vmaext/Makefile
|
|
9
|
+
ext/vmaext/mkmf.log
|
|
10
|
+
|
|
11
|
+
# Autosave files
|
|
12
|
+
*_vma_autosave
|
|
13
|
+
|
|
14
|
+
# Reports and logs
|
|
15
|
+
test_report.txt
|
|
16
|
+
llm_report.txt
|
|
17
|
+
lsp-log.txt
|
|
18
|
+
|
|
19
|
+
# Bug/scratch notes
|
|
20
|
+
bug*.txt
|
|
21
|
+
*.txtf
|
|
22
|
+
|
|
23
|
+
# Media
|
|
24
|
+
*.mp3
|
|
25
|
+
*.wav
|
|
26
|
+
*.png
|
|
27
|
+
|
|
28
|
+
# Performance traces
|
|
29
|
+
perf*.svg
|
|
30
|
+
perf.data*
|
|
31
|
+
|
|
32
|
+
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Vimamsa test container
|
|
2
|
+
#
|
|
3
|
+
# Runs the full test suite headlessly via xvfb.
|
|
4
|
+
#
|
|
5
|
+
# Build: docker build -t vimamsa-test .
|
|
6
|
+
# Run: docker run --rm vimamsa-test
|
|
7
|
+
#
|
|
8
|
+
# Ruby version matches development environment (see Makefile in project root).
|
|
9
|
+
|
|
10
|
+
FROM ruby:3.1-slim
|
|
11
|
+
|
|
12
|
+
ENV DEBIAN_FRONTEND=noninteractive
|
|
13
|
+
|
|
14
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
15
|
+
build-essential \
|
|
16
|
+
ruby-dev \
|
|
17
|
+
git \
|
|
18
|
+
pkg-config \
|
|
19
|
+
libgtk-4-dev \
|
|
20
|
+
libgtksourceview-5-dev \
|
|
21
|
+
libgstreamer1.0-dev \
|
|
22
|
+
libgstreamer-plugins-base1.0-dev \
|
|
23
|
+
libvte-2.91-gtk4-dev \
|
|
24
|
+
xvfb \
|
|
25
|
+
xauth \
|
|
26
|
+
libssl-dev
|
|
27
|
+
|
|
28
|
+
WORKDIR /app
|
|
29
|
+
|
|
30
|
+
# COPY .git/ .git/
|
|
31
|
+
# COPY vimamsa.gemspec Gemfile ./
|
|
32
|
+
# COPY lib/vimamsa/version.rb lib/vimamsa/
|
|
33
|
+
# COPY ext/vmaext/ ext/vmaext/
|
|
34
|
+
|
|
35
|
+
RUN gem install bundler -v '~> 2.4'
|
|
36
|
+
|
|
37
|
+
RUN echo "alias ll='ls -ltrh'" >> ~/.bashrc
|
|
38
|
+
ARG CACHE_BUST=1
|
|
39
|
+
RUN git clone https://github.com/SamiSieranoja/vimamsa.git && cd vimamsa && gem build vimamsa.gemspec && gem install vimamsa-0.1.*.gem
|
|
40
|
+
RUN cp /usr/local/bundle/gems/vimamsa-0.1.23/ext/vmaext/vmaext.so vimamsa/lib/
|
|
41
|
+
|
|
42
|
+
WORKDIR /app/vimamsa
|
|
43
|
+
CMD ["bash", "-c", "xvfb-run -a ruby run_tests.rb 2>&1"]
|
|
44
|
+
|
|
45
|
+
|
data/custom_example.rb
CHANGED
|
@@ -14,19 +14,9 @@
|
|
|
14
14
|
# setcnf :tab_width, 4
|
|
15
15
|
|
|
16
16
|
# Open this file every time the program starts
|
|
17
|
-
|
|
17
|
+
cnf.startup_file = "~/Documents/startup.txt"
|
|
18
18
|
|
|
19
|
-
# To enable LSP:
|
|
20
|
-
# cnf.lsp.enabled = true
|
|
21
|
-
# cnf.lsp.server.solargraph = { name: "solargraph", command: "solargraph stdio", type: "stdio" }
|
|
22
|
-
# cnf.lsp.server.solargraph.languages = ["ruby"]
|
|
23
19
|
|
|
24
|
-
# cnf.lsp.server.clangd = { name: "clangd", command: "clangd-12 --offset-encoding=utf-8", type: "stdio" }
|
|
25
|
-
# cnf.lsp.server.clangd.languages = ["c", "cpp"]
|
|
26
|
-
|
|
27
|
-
# Uncomment this if you don't want to see the state trail of previous action
|
|
28
|
-
# on top right corner:
|
|
29
|
-
# cnf.kbd.show_prev_action = false
|
|
30
20
|
|
|
31
21
|
|
|
32
22
|
|
|
@@ -35,6 +25,9 @@ def insert_date()
|
|
|
35
25
|
vma.buf.insert_txt("#{DateTime.now().strftime("%Y-%m-%d")}\n")
|
|
36
26
|
end
|
|
37
27
|
|
|
28
|
+
bindkey "C , i d", proc { insert_date }
|
|
29
|
+
|
|
30
|
+
|
|
38
31
|
def collect_c_header()
|
|
39
32
|
# Matches e.g.:
|
|
40
33
|
# static void funcname(parameters)
|
|
@@ -69,4 +62,37 @@ end
|
|
|
69
62
|
# Find with action search ([C] , , s)
|
|
70
63
|
reg_act(:insert_lorem_ipsum, proc { insert_lorem_ipsum }, "Insert lorem ipsum")
|
|
71
64
|
|
|
65
|
+
def open_mtg(urlpref = nil)
|
|
66
|
+
require "uri"
|
|
67
|
+
l = vma.buf.get_current_line.strip
|
|
68
|
+
m = l.match(/[^;!]+/)
|
|
69
|
+
if m
|
|
70
|
+
cardname = m[0].strip
|
|
71
|
+
# cardname = "Omnath, locus of mana"
|
|
72
|
+
u = URI.encode_www_form_component(cardname)
|
|
73
|
+
url = "https://gatherer.wizards.com/Pages/Card/Details.aspx?name=#{u}"
|
|
74
|
+
if !urlpref.nil?
|
|
75
|
+
url = urlpref + u
|
|
76
|
+
end
|
|
77
|
+
open_url(url)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# reg_act(:open_mtg, proc { open_mtg }, "open mtg card info")
|
|
82
|
+
# bindkey "C , , m", :open_mtg
|
|
83
|
+
# Restless Cottage
|
|
84
|
+
# https://duckduckgo.com/?ia=web&origin=funnel_home_website&t=h_&q=
|
|
85
|
+
|
|
86
|
+
# Primitive support for LSP (not well tested)
|
|
87
|
+
# To enable LSP:
|
|
88
|
+
# cnf.lsp.enabled = true
|
|
89
|
+
# cnf.lsp.server.solargraph = { name: "solargraph", command: "solargraph stdio", type: "stdio" }
|
|
90
|
+
# cnf.lsp.server.solargraph.languages = ["ruby"]
|
|
91
|
+
|
|
92
|
+
# cnf.lsp.server.clangd = { name: "clangd", command: "clangd-12 --offset-encoding=utf-8", type: "stdio" }
|
|
93
|
+
# cnf.lsp.server.clangd.languages = ["c", "cpp"]
|
|
94
|
+
|
|
95
|
+
# Uncomment this if you don't want to see the state trail of previous action
|
|
96
|
+
# on top right corner:
|
|
97
|
+
# cnf.kbd.show_prev_action = false
|
|
72
98
|
|
data/docker_cmd.sh
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
gem build vimamsa.gemspec
|
|
2
|
+
sudo gem install --local vimamsa-0.1.*.gem
|
|
3
|
+
cp /usr/local/bundle/gems/vimamsa-0.1.23/ext/vmaext/vmaext.so .
|
|
4
|
+
cp /usr/local/bundle/gems/vimamsa-0.1.23/ext/vmaext/vmaext.so lib/
|
|
5
|
+
# xvfb-run -a bundle exec ruby exe/run_tests.rb --test tests/test_basic_editing.rb
|
|
6
|
+
xvfb-run -a bundle exec ruby run_tests.rb
|
|
7
|
+
|
data/exe/run_tests.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
require "ripl/multi_line"
|
|
3
|
+
require "tempfile"
|
|
4
|
+
require "pathname"
|
|
5
|
+
|
|
6
|
+
ENV["GTK_THEME"] = "Adwaita:light"
|
|
7
|
+
|
|
8
|
+
selfpath = __FILE__
|
|
9
|
+
selfpath = File.readlink(selfpath) if File.lstat(selfpath).symlink?
|
|
10
|
+
scriptdir = File.expand_path(File.dirname(selfpath) + "/..")
|
|
11
|
+
|
|
12
|
+
$LOAD_PATH.unshift(File.expand_path("lib"))
|
|
13
|
+
$LOAD_PATH.unshift(File.expand_path("ext"))
|
|
14
|
+
begin
|
|
15
|
+
gem_spec = Gem::Specification.find_by_name("vimamsa")
|
|
16
|
+
$LOAD_PATH.unshift(File.join(gem_spec.gem_dir, "ext", "vmaext")) if gem_spec
|
|
17
|
+
rescue Gem::MissingSpecError
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
require "vimamsa"
|
|
21
|
+
$vmag = VMAgui.new()
|
|
22
|
+
$vmag.run
|
|
23
|
+
|
data/lib/vimamsa/actions.rb
CHANGED
|
@@ -10,6 +10,10 @@ class Action
|
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
+
def unreg_act(id)
|
|
14
|
+
vma.actions.unregister(id)
|
|
15
|
+
end
|
|
16
|
+
|
|
13
17
|
def reg_act(id, callfunc, name = "", opt = {})
|
|
14
18
|
if callfunc.class == Proc
|
|
15
19
|
a = Action.new(id, name, callfunc, opt)
|
|
@@ -43,6 +47,10 @@ class ActionList
|
|
|
43
47
|
@actions[id] = obj
|
|
44
48
|
end
|
|
45
49
|
|
|
50
|
+
def unregister(id)
|
|
51
|
+
@actions.delete(id)
|
|
52
|
+
end
|
|
53
|
+
|
|
46
54
|
def include?(act)
|
|
47
55
|
return @actions.has_key?(act)
|
|
48
56
|
end
|
data/lib/vimamsa/buffer.rb
CHANGED
|
@@ -5,10 +5,6 @@ require "pathname"
|
|
|
5
5
|
require "openssl"
|
|
6
6
|
require "ripl/multi_line"
|
|
7
7
|
|
|
8
|
-
$buffer_history = []
|
|
9
|
-
|
|
10
|
-
$update_highlight = false
|
|
11
|
-
|
|
12
8
|
$ifuncon = false
|
|
13
9
|
|
|
14
10
|
class Buffer < String
|
|
@@ -348,6 +344,7 @@ class Buffer < String
|
|
|
348
344
|
@crypt = crypt
|
|
349
345
|
@encrypted_str = encrypted
|
|
350
346
|
set_filename(filename)
|
|
347
|
+
gui_set_buffer_contents(@id, self.to_s)
|
|
351
348
|
end
|
|
352
349
|
|
|
353
350
|
def sanitycheck_btree()
|
|
@@ -410,7 +407,10 @@ class Buffer < String
|
|
|
410
407
|
@need_redraw = 1
|
|
411
408
|
@call_func = nil
|
|
412
409
|
@deltas = []
|
|
413
|
-
@edit_history = []
|
|
410
|
+
@edit_history = [] # Array of groups: [[delta, ...], ...]
|
|
411
|
+
@current_group = [] # In-progress undo group
|
|
412
|
+
@last_delta_time = nil
|
|
413
|
+
@macro_group_active = false
|
|
414
414
|
@redo_stack = []
|
|
415
415
|
@edit_pos_history = []
|
|
416
416
|
@edit_pos_history_i = 0
|
|
@@ -530,7 +530,6 @@ class Buffer < String
|
|
|
530
530
|
# sanity_check_line_ends #TODO: enable with debug mode
|
|
531
531
|
#highlight_c()
|
|
532
532
|
|
|
533
|
-
$update_highlight = true
|
|
534
533
|
@update_highlight = true
|
|
535
534
|
|
|
536
535
|
return delta
|
|
@@ -563,36 +562,39 @@ class Buffer < String
|
|
|
563
562
|
end
|
|
564
563
|
end
|
|
565
564
|
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
if last_delta[1] == DELETE
|
|
573
|
-
d = [last_delta[0], INSERT, 0, last_delta[3]]
|
|
574
|
-
run_delta(d)
|
|
575
|
-
elsif last_delta[1] == INSERT
|
|
576
|
-
d = [last_delta[0], DELETE, last_delta[3].size]
|
|
577
|
-
run_delta(d)
|
|
578
|
-
else
|
|
579
|
-
return #TODO: assert?
|
|
565
|
+
# Flush @current_group into @edit_history and start a new group.
|
|
566
|
+
# Called on mode changes, macro boundaries, and time threshold.
|
|
567
|
+
def new_undo_group
|
|
568
|
+
if @current_group.any?
|
|
569
|
+
@edit_history << @current_group
|
|
570
|
+
@current_group = []
|
|
580
571
|
end
|
|
581
|
-
|
|
582
|
-
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
def apply_inverse_delta(d)
|
|
575
|
+
if d[1] == DELETE
|
|
576
|
+
run_delta([d[0], INSERT, 0, d[3]])
|
|
577
|
+
elsif d[1] == INSERT
|
|
578
|
+
run_delta([d[0], DELETE, d[3].size])
|
|
579
|
+
end
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
def undo()
|
|
583
|
+
new_undo_group # flush any in-progress group first
|
|
584
|
+
return if @edit_history.empty?
|
|
585
|
+
group = @edit_history.pop
|
|
586
|
+
@redo_stack << group
|
|
587
|
+
group.reverse_each { |d| apply_inverse_delta(d) }
|
|
588
|
+
set_pos(group.first[0])
|
|
583
589
|
calculate_line_and_column_pos
|
|
584
590
|
end
|
|
585
591
|
|
|
586
592
|
def redo()
|
|
587
|
-
return if
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
run_delta(redo_delta)
|
|
593
|
-
@edit_history << redo_delta
|
|
594
|
-
set_pos(redo_delta[0])
|
|
595
|
-
#recalc_line_ends #TODO: optimize?
|
|
593
|
+
return if @redo_stack.empty?
|
|
594
|
+
group = @redo_stack.pop
|
|
595
|
+
group.each { |d| run_delta(d) }
|
|
596
|
+
@edit_history << group
|
|
597
|
+
set_pos(group.last[0])
|
|
596
598
|
calculate_line_and_column_pos
|
|
597
599
|
end
|
|
598
600
|
|
|
@@ -1133,6 +1135,9 @@ class Buffer < String
|
|
|
1133
1135
|
elsif linep != nil
|
|
1134
1136
|
wtype = :linepointer
|
|
1135
1137
|
word = linep
|
|
1138
|
+
elsif (bare_linep = resolve_bare_file_line_pointer(word))
|
|
1139
|
+
wtype = :linepointer
|
|
1140
|
+
word = bare_linep
|
|
1136
1141
|
elsif m = word.match(/⟦help:(.*)⟧/)
|
|
1137
1142
|
return [m[1], :help]
|
|
1138
1143
|
else
|
|
@@ -1294,7 +1299,6 @@ class Buffer < String
|
|
|
1294
1299
|
end
|
|
1295
1300
|
|
|
1296
1301
|
def end_selection()
|
|
1297
|
-
puts("END SELECTION")
|
|
1298
1302
|
# @selection_start = nil
|
|
1299
1303
|
@selection_active = false
|
|
1300
1304
|
@visual_mode = false
|
|
@@ -1305,7 +1309,7 @@ class Buffer < String
|
|
|
1305
1309
|
def start_selection()
|
|
1306
1310
|
@selection_start = @pos
|
|
1307
1311
|
@selection_active = true
|
|
1308
|
-
@visual_mode = true
|
|
1312
|
+
@visual_mode = true #TODO: change use of @visual_mode into @selection_active
|
|
1309
1313
|
end
|
|
1310
1314
|
|
|
1311
1315
|
# Start selection if not already started
|
|
@@ -1441,10 +1445,6 @@ class Buffer < String
|
|
|
1441
1445
|
|
|
1442
1446
|
def get_visual_mode_range2()
|
|
1443
1447
|
r = get_visual_mode_range
|
|
1444
|
-
if r.begin > r.end
|
|
1445
|
-
debug "r.begin > r.end"
|
|
1446
|
-
require "pry";binding.pry
|
|
1447
|
-
end
|
|
1448
1448
|
return [r.begin, r.end]
|
|
1449
1449
|
end
|
|
1450
1450
|
|
|
@@ -1459,7 +1459,7 @@ class Buffer < String
|
|
|
1459
1459
|
end
|
|
1460
1460
|
|
|
1461
1461
|
def get_visual_mode_range()
|
|
1462
|
-
_start = @selection_start
|
|
1462
|
+
_start = @selection_start || @pos
|
|
1463
1463
|
_end = @pos
|
|
1464
1464
|
_start, _end = _end, _start if _start > _end
|
|
1465
1465
|
return _start..(_end)
|
|
@@ -1721,15 +1721,6 @@ class Buffer < String
|
|
|
1721
1721
|
end
|
|
1722
1722
|
end
|
|
1723
1723
|
|
|
1724
|
-
#TODO: function not used
|
|
1725
|
-
def write_to_file(savepath, s)
|
|
1726
|
-
if is_path_writable(savepath)
|
|
1727
|
-
IO.write(savepath, self.to_s)
|
|
1728
|
-
else
|
|
1729
|
-
message("PATH NOT WRITABLE: #{savepath}")
|
|
1730
|
-
end
|
|
1731
|
-
end
|
|
1732
|
-
|
|
1733
1724
|
def is_path_writable(fpath)
|
|
1734
1725
|
r = false
|
|
1735
1726
|
if fpath.class == String
|
|
@@ -22,7 +22,14 @@ class Buffer < String
|
|
|
22
22
|
else
|
|
23
23
|
@deltas << delta
|
|
24
24
|
end
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
unless @macro_group_active
|
|
27
|
+
if @last_delta_time && (Time.now - @last_delta_time) > cnf.undo.group_threshold!
|
|
28
|
+
new_undo_group
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
@current_group << delta
|
|
32
|
+
@last_delta_time = Time.now
|
|
26
33
|
if self[-1] != "\n"
|
|
27
34
|
add_delta([self.size, INSERT, 1, "\n"], true)
|
|
28
35
|
end
|
|
@@ -81,18 +88,18 @@ class Buffer < String
|
|
|
81
88
|
@clipboard_paste_running = true
|
|
82
89
|
Thread.new {
|
|
83
90
|
text = `xclip -selection c -o`
|
|
84
|
-
paste_finish(text, at, register)
|
|
91
|
+
GLib::Idle.add { paste_finish(text, at, register); false }
|
|
85
92
|
}
|
|
86
93
|
return nil
|
|
87
94
|
end
|
|
88
95
|
|
|
89
96
|
# Start asynchronous read of system clipboard
|
|
90
|
-
def paste_start(at, register)
|
|
97
|
+
def paste_start(at, register, overwrite: false)
|
|
91
98
|
@clipboard_paste_running = true
|
|
92
99
|
|
|
93
|
-
if true or running_wayland? and !GLib::Version::or_later?(2, 79, 0)
|
|
94
|
-
return paste_start_xclip(at, register)
|
|
95
|
-
end
|
|
100
|
+
# if true or running_wayland? and !GLib::Version::or_later?(2, 79, 0)
|
|
101
|
+
# return paste_start_xclip(at, register)
|
|
102
|
+
# end
|
|
96
103
|
|
|
97
104
|
clipboard = vma.gui.window.display.clipboard
|
|
98
105
|
clipboard.read_text_async do |_clipboard, result|
|
|
@@ -101,13 +108,13 @@ class Buffer < String
|
|
|
101
108
|
rescue Gio::IOError::NotSupported
|
|
102
109
|
debug Gio::IOError::NotSupported
|
|
103
110
|
else
|
|
104
|
-
paste_finish(text, at, register)
|
|
111
|
+
paste_finish(text, at, register, overwrite: overwrite)
|
|
105
112
|
end
|
|
106
113
|
end
|
|
107
114
|
return nil
|
|
108
115
|
end
|
|
109
116
|
|
|
110
|
-
def paste_finish(text, at, register)
|
|
117
|
+
def paste_finish(text, at, register, overwrite: false)
|
|
111
118
|
debug "PASTE: #{text}"
|
|
112
119
|
|
|
113
120
|
# If we did not put this text to clipboard
|
|
@@ -121,9 +128,25 @@ class Buffer < String
|
|
|
121
128
|
|
|
122
129
|
return if text == ""
|
|
123
130
|
|
|
124
|
-
|
|
131
|
+
cursor_at_start = cnf.paste.cursor_at_start!
|
|
132
|
+
|
|
133
|
+
if overwrite && !@paste_lines
|
|
134
|
+
# Delete as many chars forward as we are about to insert, stopping before newline
|
|
135
|
+
line_end = current_line_range.last - 1 # position of last char before \n
|
|
136
|
+
n = [text.size, [line_end - @pos + 1, 0].max].min
|
|
137
|
+
add_delta([@pos, DELETE, n], true) if n > 0
|
|
138
|
+
insert_txt_at(text, @pos)
|
|
139
|
+
set_pos(cursor_at_start ? @pos : @pos + text.size - 1)
|
|
140
|
+
elsif @paste_lines
|
|
125
141
|
debug "PASTE LINES"
|
|
126
|
-
|
|
142
|
+
if at == BEFORE
|
|
143
|
+
l = current_line_range()
|
|
144
|
+
insert_txt_at(text, l.begin)
|
|
145
|
+
set_pos(l.begin)
|
|
146
|
+
else
|
|
147
|
+
put_to_new_next_line(text)
|
|
148
|
+
set_pos(@pos) if cursor_at_start
|
|
149
|
+
end
|
|
127
150
|
else
|
|
128
151
|
debug "PASTE !LINES"
|
|
129
152
|
if at_end_of_buffer? or at_end_of_line? or at == BEFORE
|
|
@@ -132,13 +155,23 @@ class Buffer < String
|
|
|
132
155
|
pos = @pos + 1
|
|
133
156
|
end
|
|
134
157
|
insert_txt_at(text, pos)
|
|
135
|
-
set_pos(pos + text.size)
|
|
158
|
+
set_pos(cursor_at_start ? pos : pos + text.size)
|
|
136
159
|
end
|
|
137
160
|
set_pos(@pos)
|
|
138
161
|
vma.buf.view.after_action # redraw
|
|
139
162
|
@clipboard_paste_running = false
|
|
140
163
|
end
|
|
141
164
|
|
|
165
|
+
def paste_over(at = AFTER, register = nil)
|
|
166
|
+
if vma.macro.running_macro
|
|
167
|
+
text = vma.clipboard.get()
|
|
168
|
+
paste_finish(text, at, register, overwrite: true)
|
|
169
|
+
else
|
|
170
|
+
paste_start(at, register, overwrite: true)
|
|
171
|
+
end
|
|
172
|
+
return true
|
|
173
|
+
end
|
|
174
|
+
|
|
142
175
|
def paste(at = AFTER, register = nil)
|
|
143
176
|
# Macro's don't work with asynchronous call using GTK
|
|
144
177
|
# TODO: implement as synchronous?
|
|
@@ -206,7 +239,11 @@ class Buffer < String
|
|
|
206
239
|
(startpos, endpos) = get_visual_mode_range2
|
|
207
240
|
delete_range(startpos, endpos, x)
|
|
208
241
|
@pos = [@pos, @selection_start].min
|
|
209
|
-
|
|
242
|
+
if vma.kbd.get_mode == :visual
|
|
243
|
+
end_visual_mode
|
|
244
|
+
else
|
|
245
|
+
end_selection
|
|
246
|
+
end
|
|
210
247
|
#return
|
|
211
248
|
|
|
212
249
|
# Delete current char
|
data/lib/vimamsa/buffer_list.rb
CHANGED
|
@@ -20,12 +20,11 @@ def load_buffer_list()
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
class BufferList
|
|
23
|
-
attr_reader :current_buf, :last_dir, :last_file
|
|
23
|
+
attr_reader :current_buf, :last_dir, :last_file
|
|
24
24
|
attr_accessor :list
|
|
25
25
|
|
|
26
26
|
def initialize()
|
|
27
27
|
@last_dir = File.expand_path(".")
|
|
28
|
-
@buffer_history = []
|
|
29
28
|
super
|
|
30
29
|
@current_buf = 0
|
|
31
30
|
@list = []
|
|
@@ -46,22 +45,10 @@ class BufferList
|
|
|
46
45
|
end
|
|
47
46
|
|
|
48
47
|
def add(_buf)
|
|
49
|
-
@buffer_history << _buf.id
|
|
50
|
-
# @navigation_idx = _buf.id #TODO:??
|
|
51
48
|
@list << _buf
|
|
52
49
|
@h[_buf.id] = _buf
|
|
53
50
|
end
|
|
54
51
|
|
|
55
|
-
#NOTE: unused. enable?
|
|
56
|
-
# def switch()
|
|
57
|
-
# debug "SWITCH BUF. bufsize:#{self.size}, curbuf: #{@current_buf}"
|
|
58
|
-
# @current_buf += 1
|
|
59
|
-
# @current_buf = 0 if @current_buf >= self.size
|
|
60
|
-
# m = method("switch")
|
|
61
|
-
# set_last_command({ method: m, params: [] })
|
|
62
|
-
# set_current_buffer(@current_buf)
|
|
63
|
-
# end
|
|
64
|
-
|
|
65
52
|
def slist
|
|
66
53
|
# TODO: implement using heap/priorityque
|
|
67
54
|
@list.sort_by! { |x| x.access_time }
|
|
@@ -91,9 +78,6 @@ class BufferList
|
|
|
91
78
|
|
|
92
79
|
def switch_to_last_buf()
|
|
93
80
|
debug "SWITCH TO LAST BUF:"
|
|
94
|
-
# debug @buffer_history
|
|
95
|
-
# last_buf = @buffer_history[-2]
|
|
96
|
-
|
|
97
81
|
last_buf = slist[-2]
|
|
98
82
|
if !last_buf.nil?
|
|
99
83
|
set_current_buffer(last_buf.id)
|
|
@@ -115,17 +99,6 @@ class BufferList
|
|
|
115
99
|
return @h[id]
|
|
116
100
|
end
|
|
117
101
|
|
|
118
|
-
def add_buf_to_history(buf_idx)
|
|
119
|
-
if @list.include?(buf_idx)
|
|
120
|
-
@buffer_history << @buf_idx
|
|
121
|
-
@navigation_idx = 0
|
|
122
|
-
# compact_buf_history()
|
|
123
|
-
else
|
|
124
|
-
debug "buffer_list, no such id:#{buf_idx}"
|
|
125
|
-
return
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
102
|
def add_current_buf_to_history()
|
|
130
103
|
@h[@current_buf].update_access_time
|
|
131
104
|
end
|
|
@@ -154,6 +127,7 @@ class BufferList
|
|
|
154
127
|
reset_navigation if update_history
|
|
155
128
|
vma.gui.set_current_buffer(idx)
|
|
156
129
|
vma.gui.file_panel_refresh
|
|
130
|
+
vma.gui.func_panel_refresh
|
|
157
131
|
|
|
158
132
|
#TODO: delete?
|
|
159
133
|
# if !vma.buf.mode_stack.nil? and vma.kbd.get_scope != :editor #TODO
|
data/lib/vimamsa/conf.rb
CHANGED
|
@@ -103,6 +103,28 @@ def cnf()
|
|
|
103
103
|
return $vimamsa_conf
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
+
# Read a config value by key path array.
|
|
107
|
+
# Uses the cnf accessor chain so key types match cnf.xxx! reads.
|
|
108
|
+
# Example:
|
|
109
|
+
# cnf_get([:tab, :width]) # => 2
|
|
110
|
+
# cnf_get([:style_scheme]) # => "molokai_edit"
|
|
111
|
+
def cnf_get(key)
|
|
112
|
+
obj = cnf
|
|
113
|
+
key[0..-2].each { |k| obj = obj.public_send(k) }
|
|
114
|
+
obj.public_send(:"#{key.last}!")
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Write a config value by key path array.
|
|
118
|
+
# Uses the cnf accessor chain so the value is readable via cnf.xxx!
|
|
119
|
+
# Example:
|
|
120
|
+
# cnf_set([:tab, :width], 4)
|
|
121
|
+
# cnf_set([:style_scheme], "soviet_cockpit")
|
|
122
|
+
def cnf_set(key, val)
|
|
123
|
+
obj = cnf
|
|
124
|
+
key[0..-2].each { |k| obj = obj.public_send(k) }
|
|
125
|
+
obj.public_send(:"#{key.last}=", val)
|
|
126
|
+
end
|
|
127
|
+
|
|
106
128
|
cnf.indent_based_on_last_line = true
|
|
107
129
|
cnf.extensions_to_open = [".txt", ".h", ".c", ".cpp", ".hpp", ".rb", ".inc", ".php", ".sh", ".m", ".gd", ".js", ".py"]
|
|
108
130
|
cnf.default_search_extensions = ["txt", "rb"]
|
|
@@ -131,4 +153,12 @@ cnf.startup_file=false
|
|
|
131
153
|
|
|
132
154
|
cnf.macro.animation_delay = 0.02
|
|
133
155
|
|
|
156
|
+
cnf.undo.group_threshold = 1.8 # seconds of inactivity before starting a new undo group
|
|
157
|
+
|
|
158
|
+
cnf.paste.cursor_at_start = false
|
|
159
|
+
|
|
160
|
+
cnf.style_scheme = "molokai_edit"
|
|
161
|
+
cnf.color_contrast = 1.0
|
|
162
|
+
cnf.color_brightness = 0.0
|
|
163
|
+
|
|
134
164
|
|