Module: Nxxd::Nvim
- Defined in:
- lib/nxxd/nvim.rb
Class Attribute Summary collapse
-
.split ⇒ Object
Returns the value of attribute split.
Class Method Summary collapse
- .dump(a, m) ⇒ Object
- .dump!(a, m) ⇒ Object
- .dump_data(f, a = nil, m = nil) ⇒ Object
- .feed(a, range) ⇒ Object
- .pack(a, rarg, range) ⇒ Object
- .pack!(a, rarg, range) ⇒ Object
- .pipe(a, m, range) ⇒ Object
Class Attribute Details
.split ⇒ Object
Returns the value of attribute split.
25 26 27 |
# File 'lib/nxxd/nvim.rb', line 25 def split @split end |
Class Method Details
.dump(a, m) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/nxxd/nvim.rb', line 43 def dump a, m a = a.notempty? a ||= cur_buf_name File.open a do |f| dump_data f, a, m end $vim.get_current_buf.set_var "origfile", a end |
.dump!(a, m) ⇒ Object
52 53 54 55 56 |
# File 'lib/nxxd/nvim.rb', line 52 def dump! a, m a = a.notempty? a ||= cur_buf_name_exec pipe a, m, nil end |
.dump_data(f, a = nil, m = nil) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/nxxd/nvim.rb', line 79 def dump_data f, a = nil, m = nil (split_new m).tap { |sc| $vim.command sc } $vim.set_option filetype: "xxd", buftype: "nofile" $vim.get_current_buf.set_name "[hex: #{a}]" (Dump.new input: a).run f do |l| $vim.put [ l], "l", false, true end end |
.feed(a, range) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/nxxd/nvim.rb', line 142 def feed a, range popen a do |ro,re| r = Neovim::Lines.new $vim.get_current_buf, range Nxxd::Dump.reverse r, ro, consecutive: true ro.close_write $vim.command "#{range.last}" $vim.put [ ""], "l", true, true ro.each_line { |l| l.chomp! $vim.put [ l], "l", false, true } re.each_line { |l| l.chomp! $vim.put [ "# #{l}"], "l", false, true } end $?.success? or $vim.put [ "### Exit code: #{$?.exitstatus}"], "l", false, true end |
.pack(a, rarg, range) ⇒ Object
113 114 115 116 117 |
# File 'lib/nxxd/nvim.rb', line 113 def pack a, rarg, range pack_check a, rarg, range do |d| raise "File exists. Overwrite with '!'." if File.exist? d end end |
.pack!(a, rarg, range) ⇒ Object
119 120 121 |
# File 'lib/nxxd/nvim.rb', line 119 def pack! a, rarg, range pack_check a, rarg, range do || end end |
.pipe(a, m, range) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/nxxd/nvim.rb', line 58 def pipe a, m, range popen a do |ro,re| begin if range then # It would be nicer to write the lines as they are demanded. If # you have an idea how this could easily be done, feel free to # propose a patch. Putting this begin-end block into a Thread # didn't work. (Neovim::Lines.new $vim.get_current_buf, range).each { |l| ro.puts l } end ro.close_write end dump_data ro, a, m re.each_line { |l| l.chomp! $vim.put [ "# #{l}"], "l", false, true } end $?.success? or $vim.put [ "### Exit code: #{$?.exitstatus}"], "l", false, true end |