vimamsa 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82ad35212b7d75bfd5b702943ff3ed3180f7f1bd0b3912840e9ecfdf6126e467
4
- data.tar.gz: 8eff2ee35e1ecc2d791ff1fbf4a881e6aada9b38d35ce11e356b316b536bc642
3
+ metadata.gz: 7a71f8392835d7a5a3245366764eb79f6058ea3ded74cc1a308f021f950881ba
4
+ data.tar.gz: 590ea0409a43aabafe349cfcff0cb91712e2a269e334b3663b64f6b895ae666f
5
5
  SHA512:
6
- metadata.gz: 440d5d3b5b537fc9d3848d0f187df77dd045cde34643db356cd88ae5591e4e8c1c8596aac50f170ef7124dbd8784deddaff2d436f46dac0a8a180ccfeae4a9aa
7
- data.tar.gz: c058e9db468553e29f617186ea0d65d04014307b7797c5dad013b5b3738fab57c0f7a44e7401ae9606e88581ac4f557fad3665c6dc8f784781619a310c114b95
6
+ metadata.gz: 1bf328f8cbe0b69e85a9720790c8f4616e1996466ad65f6473cf1cff1173d78b9cec197145c653a5d33804571d383246492e593445da390cbe567fc6ccfbb24a
7
+ data.tar.gz: 799f836afc3c0e304cac07f44e1b5c96affa3f6b5775b4d654b43a81168f2ab14cb4ee1218a3345ae3189203520885fd6cc1de7ce48205e78386b060c700f8ca
@@ -1,5 +1,6 @@
1
1
  require "digest"
2
2
  require "tempfile"
3
+ require "fileutils"
3
4
  require "pathname"
4
5
  require "openssl"
5
6
  require "ripl/multi_line"
@@ -79,6 +80,13 @@ class Buffer < String
79
80
  # gui_set_current_buffer(@id)
80
81
  end
81
82
 
83
+ def set_executable
84
+ if File.exists?(@fname)
85
+ FileUtils.chmod("+x", @fname)
86
+ message("Set executable: #{@fname}")
87
+ end
88
+ end
89
+
82
90
  def detect_file_language
83
91
  @lang = nil
84
92
  @lang = "c" if @fname.match(/\.(c|h|cpp)$/)
@@ -451,7 +459,6 @@ class Buffer < String
451
459
  return if @edit_pos_history.empty?
452
460
  @edit_pos_history_i -= 1
453
461
  @edit_pos_history_i = @edit_pos_history.size - 1 if @edit_pos_history_i < 0
454
- # Ripl.start :binding => binding
455
462
  debug "@edit_pos_history_i=#{@edit_pos_history_i}"
456
463
  set_pos(@edit_pos_history[-@edit_pos_history_i])
457
464
  center_on_current_line
@@ -568,7 +575,6 @@ class Buffer < String
568
575
  ls = @line_ends[a] if a != nil
569
576
  # if a != nil and ls != @line_ends[a]
570
577
  # puts "NO MATCH @line_ends[a]"
571
- # Ripl.start :binding => binding
572
578
  # end
573
579
 
574
580
  if ls == nil
@@ -580,7 +586,6 @@ class Buffer < String
580
586
  end
581
587
 
582
588
  def get_line_end(pos)
583
- #Ripl.start :binding => binding
584
589
  return @line_ends.select { |x| x > pos }.min
585
590
  end
586
591
 
@@ -1328,9 +1333,9 @@ class Buffer < String
1328
1333
  calculate_line_and_column_pos
1329
1334
  end
1330
1335
 
1331
- def execute_current_line_in_terminal()
1336
+ def execute_current_line_in_terminal(autoclose = false)
1332
1337
  s = get_current_line
1333
- exec_in_terminal(s)
1338
+ exec_in_terminal(s, autoclose)
1334
1339
  end
1335
1340
 
1336
1341
  def insert_new_line()
@@ -1350,8 +1355,18 @@ class Buffer < String
1350
1355
  # Indent start of new line based on last line
1351
1356
  last_line = line(@lpos)
1352
1357
  m = /^( +)([^ ]+|$)/.match(last_line)
1353
- debug m.inspect
1354
- c = c + " " * m[1].size if m
1358
+ if m
1359
+ c = c + " " * m[1].size if m
1360
+ end
1361
+
1362
+
1363
+ #if tab indent
1364
+ m = /^(\t+)([^\t]+|$)/.match(last_line)
1365
+ if m
1366
+ c = c + "\t" * m[1].size if m
1367
+ end
1368
+
1369
+ # debug m.inspect
1355
1370
  end
1356
1371
  if mode == BEFORE
1357
1372
  insert_pos = @pos
@@ -1494,7 +1509,13 @@ class Buffer < String
1494
1509
  return if !@visual_mode
1495
1510
 
1496
1511
  debug "COPY SELECTION"
1497
- set_clipboard(self[get_visual_mode_range])
1512
+ s = self[get_visual_mode_range]
1513
+ if x == :append
1514
+ puts "APPEND"
1515
+ s += "\n" + get_clipboard()
1516
+ end
1517
+
1518
+ set_clipboard(s)
1498
1519
  end_visual_mode
1499
1520
  return true
1500
1521
  end
@@ -1639,7 +1660,6 @@ class Buffer < String
1639
1660
  else
1640
1661
  savepath = buflist.get_last_dir
1641
1662
  end
1642
- # Ripl.start :binding => binding
1643
1663
  gui_file_saveas(savepath)
1644
1664
  # calls back to file_saveas
1645
1665
  end
@@ -1,16 +1,23 @@
1
1
  require "pty"
2
2
 
3
- def exec_in_terminal(cmd)
3
+ def exec_in_terminal(cmd, autoclose = false)
4
4
  # puts "CMD:#{cmd}"
5
5
 
6
6
  # global to prevent garbage collect unlink
7
7
  $initf = Tempfile.new("bashinit")
8
8
  # puts $initf.path
9
9
  $initf.write(cmd)
10
- $initf.write("rm #{$initf.path}\n")
11
- $initf.write("\nexec bash\n")
10
+ if autoclose
11
+ $initf.write("\nsleep 10; exit;\n")
12
+ $initf.write("rm #{$initf.path}\n")
13
+ else
14
+ $initf.write("rm #{$initf.path}\n")
15
+ $initf.write("\nexec bash\n")
16
+ end
12
17
  $initf.close
13
18
  # PTY.spawn("gnome-terminal", "--tab", "--", "bash", "-i", $initf.path, "-c", "exec bash")
19
+ # fork { exec "gnome-terminal", "--tab", "--", "bash", "-i", $initf.path, "-c", "exec bash" }
20
+ # Just another execution
14
21
  fork { exec "gnome-terminal", "--tab", "--", "bash", "-i", $initf.path, "-c", "exec bash" }
15
22
  end
16
23
 
@@ -26,7 +33,7 @@ end
26
33
 
27
34
  class Editor
28
35
  attr_reader :file_content_search_paths, :file_name_search_paths, :gui
29
- attr_accessor :converters, :fh, :paint_stack, :kbd
36
+ attr_accessor :converters, :fh, :paint_stack, :kbd
30
37
  #attr_writer :call_func, :update_highlight
31
38
 
32
39
  def initialize()
@@ -42,7 +49,6 @@ class Editor
42
49
  @converters = {}
43
50
  @paint_stack = []
44
51
  @_plugins = {}
45
-
46
52
  end
47
53
 
48
54
  def open_file_listener(added)
@@ -294,6 +300,10 @@ def system_clipboard_changed(clipboard_contents)
294
300
  $clipboard = $clipboard[-([$clipboard.size, max_clipboard_items].min)..-1]
295
301
  end
296
302
 
303
+ def get_clipboard()
304
+ return $clipboard[-1]
305
+ end
306
+
297
307
  def set_clipboard(s)
298
308
  if !(s.class <= String) or s.size == 0
299
309
  puts s.inspect
@@ -415,7 +425,7 @@ def minibuffer_new_char(c)
415
425
  end
416
426
 
417
427
  # def readchar_new_char(c)
418
- # $input_char_call_func.call(c)
428
+ # $input_char_call_func.call(c)
419
429
  # end
420
430
 
421
431
  def minibuffer_delete()
data/lib/vimamsa/gui.rb CHANGED
@@ -154,6 +154,7 @@ def gui_create_buffer(id)
154
154
  # provider.load(data: "textview { font-family: Arial; font-size: 12pt; }")
155
155
  view.style_context.add_provider(provider)
156
156
  view.wrap_mode = :char
157
+ view.set_tab_width(4) #TODO:add as setting
157
158
 
158
159
  $vmag.buffers[id] = view
159
160
  end
@@ -48,6 +48,7 @@ reg_act(:put_file_path_to_clipboard, proc { buf.put_file_path_to_clipboard }, "P
48
48
  # reg_act(:encrypt_file, proc{buf.set_encrypted},"Set current file to encrypt on save")
49
49
  reg_act(:encrypt_file, proc { encrypt_cur_buffer }, "Set current file to encrypt on save")
50
50
  reg_act(:set_unencrypted, proc { buf.set_unencrypted }, "Set current file to save unencrypted")
51
+ reg_act(:set_executable, proc { buf.set_executable }, "Set current file permissions to executable")
51
52
  reg_act(:close_all_buffers, proc { bufs.close_all_buffers() }, "Close all buffers")
52
53
  reg_act(:close_current_buffer, proc { bufs.close_current_buffer(true) }, "Close current buffer")
53
54
  reg_act(:comment_selection, proc { buf.comment_selection }, "")
@@ -89,7 +90,8 @@ reg_act :page_up, proc { page_up }
89
90
  reg_act :jump_to_start_of_buffer, proc { buf.jump(START_OF_BUFFER) }, "Jump to start of buffer"
90
91
  reg_act :jump_to_end_of_buffer, proc { buf.jump(END_OF_BUFFER) }, "Jump to end of buffer"
91
92
  reg_act(:auto_indent_buffer, proc { buf.indent }, "Auto format buffer")
92
- reg_act(:execute_current_line_in_terminal, proc { buf.execute_current_line_in_terminal }, "Execute current line in terminal")
93
+ reg_act(:execute_current_line_in_terminal, proc { buf.execute_current_line_in_terminal }, "Execute current line in terminalL")
94
+ reg_act(:execute_current_line_in_terminal_autoclose, proc { buf.execute_current_line_in_terminal(true) }, "Execute current line in terminal. Close after execution.")
93
95
  reg_act(:show_images, proc { hpt_scan_images() }, "Show images inserted with ⟦img:file.png⟧ syntax")
94
96
  reg_act(:delete_current_file, proc { bufs.delete_current_buffer() }, "Delete current file")
95
97
 
@@ -256,7 +258,7 @@ act_list_todo = {
256
258
  # Visual mode only:
257
259
  "V esc" => "buf.end_visual_mode",
258
260
  "V ctrl!" => "buf.end_visual_mode",
259
- "V y" => "buf.copy_active_selection",
261
+ "V y" => "buf.copy_active_selection(:foo)",
260
262
  "V g U" => "buf.transform_selection(:upcase)",
261
263
  "V g u" => "buf.transform_selection(:downcase)",
262
264
  "V g c" => "buf.transform_selection(:capitalize)",
@@ -189,7 +189,8 @@ default_keys = {
189
189
  # Visual mode only:
190
190
  "V esc" => "buf.end_visual_mode",
191
191
  "V ctrl!" => "buf.end_visual_mode",
192
- "V y" => "buf.copy_active_selection",
192
+ "V y" => "buf.copy_active_selection()",
193
+ "V a y" => "buf.copy_active_selection(:append)",
193
194
  "V g U" => "buf.transform_selection(:upcase)",
194
195
  "V g u" => "buf.transform_selection(:downcase)",
195
196
  "V g c" => "buf.transform_selection(:capitalize)",
@@ -1,3 +1,3 @@
1
1
  module Vimamsa
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/vimamsa.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib","ext"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.16"
23
+ spec.add_development_dependency "bundler", "~> 2.2.33"
24
24
  spec.add_development_dependency "rake", "~> 13.0"
25
25
 
26
26
  spec.add_runtime_dependency 'rufo', '~> 0.5'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vimamsa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sami Sieranoja
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-27 00:00:00.000000000 Z
11
+ date: 2022-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: 2.2.33
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: 2.2.33
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement