vimamsa 0.1.18 → 0.1.20

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.
@@ -119,6 +119,21 @@ class VSourceView < GtkSource::View
119
119
  end
120
120
  end
121
121
 
122
+ def focus_out()
123
+ set_cursor_color(:inactive)
124
+
125
+ # This does not seem to work: (TODO:why?)
126
+ # self.cursor_visible = false
127
+ end
128
+
129
+ def focus_in()
130
+ set_cursor_color(@ctype)
131
+ self.cursor_visible = false
132
+ self.cursor_visible = true
133
+ self.grab_focus
134
+ end
135
+
136
+
122
137
  def register_signals()
123
138
  check_controllers
124
139
 
@@ -581,33 +596,29 @@ class VSourceView < GtkSource::View
581
596
  end
582
597
 
583
598
  def draw_cursor
584
- # if @tt.nil?
585
- # @tt = buffer.create_tag("font_tag")
586
- # @tt.font = "Arial"
587
- # end
588
599
 
589
- sv = vma.gui.sw.child
600
+ sv = vma.gui.active_window[:sw].child
601
+ return if sv.nil?
602
+ if sv != self # if we are not the current buffer
603
+ sv.draw_cursor
604
+ return
605
+ end
606
+
590
607
  mode = vma.kbd.get_mode
591
608
  ctype = vma.kbd.get_cursor_type
592
609
  ctype = :visual if vma.buf.selection_active?
593
610
 
594
- vma.gui.remove_overlay_cursor
595
611
  if [:command, :replace, :browse].include?(ctype)
596
612
  set_cursor_color(ctype)
597
613
 
598
- sv.overwrite = true
599
- # sv.cursor_visible = true
600
- # sv.reset_cursor_blink
601
-
602
- # (Via trial and error) This combination is needed to make cursor visible:
603
- sv.cursor_visible = false
604
- sv.cursor_visible = true
605
-
606
- # sv.reset_cursor_blink
607
- Gtk::Settings.default.gtk_cursor_blink = false
608
- # Gtk::Settings.default.gtk_cursor_blink_time = 8000
609
- # vma.gui.sw.child.toggle_cursor_visible
610
- # vma.gui.sw.child.cursor_visible = true
614
+ if !self.overwrite?
615
+ self.overwrite = true
616
+
617
+ # (Via trial and error) This combination is needed to make cursor visible:
618
+ # TODO: determine why "self.cursor_visible = true" is not enough
619
+ self.cursor_visible = false
620
+ self.cursor_visible = true
621
+ end
611
622
  elsif ctype == :visual
612
623
  set_cursor_color(ctype)
613
624
  # debug "VISUAL MODE"
@@ -619,12 +630,11 @@ class VSourceView < GtkSource::View
619
630
  buffer.select_range(itr, itr2)
620
631
  elsif ctype == :insert
621
632
  set_cursor_color(ctype)
622
- sv.overwrite = false
623
- # sv.cursor_visible = false
624
- # sv.cursor_visible = true
633
+ self.overwrite = false
625
634
  debug "INSERT MODE"
626
635
  else # TODO
627
636
  end
637
+
628
638
  if [:insert, :command, :replace, :browse].include?(ctype)
629
639
  # Place cursor where it already is
630
640
  # Without this hack, the cursor doesn't always get drawn
@@ -632,5 +642,13 @@ class VSourceView < GtkSource::View
632
642
  itr = buffer.get_iter_at(:offset => pos)
633
643
  buffer.place_cursor(itr)
634
644
  end
635
- end
645
+
646
+ # Sometimes we lose focus and the cursor vanishes because of that
647
+ # TODO: determine why&when
648
+ if !self.has_focus?
649
+ self.grab_focus
650
+ self.cursor_visible = false
651
+ self.cursor_visible = true
652
+ end
653
+ end #end draw_cursor
636
654
  end
@@ -46,8 +46,9 @@ reg_act(:create_new_file, "create_new_file", "Create new file", { :group => :fil
46
46
  reg_act(:backup_all_buffers, proc { backup_all_buffers }, "Backup all buffers", { :group => :file })
47
47
  reg_act(:e_move_forward_char, "e_move_forward_char", "", { :group => [:move, :basic] })
48
48
  reg_act(:e_move_backward_char, "e_move_backward_char", "", { :group => [:move, :basic] })
49
- reg_act(:history_switch_backwards, "history_switch_backwards", "", { :group => :file })
50
- reg_act(:history_switch_forwards, "history_switch_forwards", "", { :group => :file })
49
+ # reg_act(:history_switch_backwards, proc{bufs.history_switch_backwards}, "", { :group => :file })
50
+ reg_act(:history_switch_backwards, proc{bufs.history_switch(-1)}, "", { :group => :file })
51
+ reg_act(:history_switch_forwards, proc{bufs.history_switch(+1)}, "", { :group => :file })
51
52
  reg_act(:center_on_current_line, "center_on_current_line", "", { :group => :view })
52
53
  reg_act(:run_last_macro, proc { vma.macro.run_last_macro }, "Run last recorded or executed macro", { :group => :macro })
53
54
  reg_act(:jump_to_next_edit, "jump_to_next_edit", "")
@@ -169,11 +170,14 @@ act_list = {
169
170
  :search_actions => { :proc => proc { vma.actions.gui_search },
170
171
  :desc => "Search actions", :group => :search },
171
172
 
173
+ :edit_customrb => { :proc => proc { jump_to_file("~/.config/vimamsa/custom.rb") },
174
+ :desc => "Customize (edit custom.rb)", :group => :search },
175
+
172
176
  :toggle_active_window => { :proc => proc { vma.gui.toggle_active_window },
173
- :desc => "Toggle active window", :group => :search },
177
+ :desc => "Switch active column in two column mode", :group => :search },
174
178
 
175
179
  :toggle_two_column => { :proc => proc { vma.gui.toggle_two_column },
176
- :desc => "Set two column mode", :group => :search },
180
+ :desc => "Toggle two column mode", :group => :search },
177
181
 
178
182
  :content_search => { :proc => proc { FileContentSearch.start_gui },
179
183
  :desc => "Search content of files", :group => :search },
@@ -188,15 +192,14 @@ act_list = {
188
192
  :desc => "Output SHA256 hex digest of curent buffer" },
189
193
 
190
194
  :start_autocomplete => { :proc => proc { vma.buf.view.start_autocomplete },
191
- :desc => "Start autocomplete" },
192
-
193
- :show_autocomplete => { :proc => proc {
194
- # vma.buf.view.signal_emit("show-completion")
195
- # vma.buf.view.show_completion
196
- vma.buf.view.show_completions
197
- },
198
- :desc => "Show autocomplete" },
199
-
195
+ :desc => "Start autocomplete" },
196
+
197
+ :show_autocomplete => { :proc => proc {
198
+ # vma.buf.view.signal_emit("show-completion")
199
+ # vma.buf.view.show_completion
200
+ vma.buf.view.show_completions
201
+ },
202
+ :desc => "Show autocomplete" },
200
203
 
201
204
  }
202
205
 
@@ -18,8 +18,6 @@
18
18
  # 'I ctrl-a'=> 'vma.buf.jump(BEGINNING_OF_LINE)',
19
19
  #
20
20
 
21
- setcnf :indent_based_on_last_line, true
22
- setcnf :extensions_to_open, [".txt", ".h", ".c", ".cpp", ".hpp", ".rb", ".inc", ".php", ".sh", ".m", ".gd", ".js"]
23
21
 
24
22
  class State
25
23
  attr_accessor :key_name, :eval_rule, :children, :action, :label, :major_modes, :level, :cursor_type
@@ -18,6 +18,7 @@ cnf.mode.visual.cursor.background = "#bc6040"
18
18
  cnf.mode.replace.cursor.background = "#fc0331"
19
19
  cnf.mode.browse.cursor.background = "#f803fc"
20
20
  cnf.mode.insert.cursor.background = "#ffffff"
21
+ cnf.mode.inactive.cursor.background = "#777777"
21
22
 
22
23
  def _insert_move(op)
23
24
  if op == :pagedown
@@ -100,9 +101,7 @@ bindkey "VC h", :e_move_backward_char
100
101
  bindkey "C , , .", :backup_all_buffers
101
102
  bindkey "C z ", :start_browse_mode
102
103
  bindkey "B h", :history_switch_backwards
103
- # bindkey "B h", [:browse_file_backwards, proc { vma.kbd.to_previous_mode; call_action(:history_switch_backwards); }, "Browse previous file"]
104
104
  bindkey "B l", :history_switch_forwards
105
- #bindkey 'B z', :center_on_current_line
106
105
  bindkey "B z", "center_on_current_line();call_action(:exit_browse_mode)"
107
106
  bindkey "B enter || B return || B esc || B j || B ctrl!", :exit_browse_mode
108
107
  bindkey "B s", :page_up
@@ -52,7 +52,7 @@ class LangSrv
52
52
  @id = 0
53
53
 
54
54
  wf = []
55
- for c in conf(:workspace_folders)
55
+ for c in cnf.workspace_folders!
56
56
  wf << LSP::Interface::WorkspaceFolder.new(uri: c[:uri], name: c[:name])
57
57
  end
58
58
  debug "WORKSPACE FOLDERS", 2
@@ -157,7 +157,6 @@ class LangSrv
157
157
  @writer.write(id: id, params: a, method: "textDocument/definition")
158
158
  r = wait_for_response(id)
159
159
  return nil if r.nil?
160
- # Ripl.start :binding => binding
161
160
  pp r
162
161
  line = HSafe.new(r)[:result][0][:range][:start][:line].val
163
162
  uri = HSafe.new(r)[:result][0][:uri].val
data/lib/vimamsa/macro.rb CHANGED
@@ -165,7 +165,7 @@ class Macro
165
165
  m = @recorded_macros[name]
166
166
  return if !(m.kind_of?(Array) and m.any?)
167
167
  contents = m.join(";")
168
- dot_dir = File.expand_path("~/.vimamsa")
168
+ dot_dir = File.expand_path("~/.config/.vimamsa")
169
169
  Dir.mkdir(dot_dir) unless File.exist?(dot_dir)
170
170
  save_fn = "#{dot_dir}/macro_#{name}.rb"
171
171
 
@@ -30,5 +30,8 @@ Converter.new(lambda { |x|
30
30
  x + "\n" + nums.join("+") + "=#{sum}"
31
31
  }, :lambda, :sum_of_numbers)
32
32
 
33
- c = Converter.new(lambda { |x| x.scan(/[\w\.]+@[\w\.]+/).join("\n") }, :lambda, :get_emails)
33
+ Converter.new(lambda { |x| x.scan(/[\w\.]+@[\w\.]+/).join("\n") }, :lambda, :get_emails)
34
+
35
+ # Eval selection as ruby code
36
+ Converter.new(lambda { |x| b = "eval failed"; begin; b = eval(x, TOPLEVEL_BINDING); rescue; end; "#{x}\n#{b}\n" }, :lambda, :eval)
34
37
 
@@ -1,3 +1,3 @@
1
1
  module Vimamsa
2
- VERSION = "0.1.18"
2
+ VERSION = "0.1.20"
3
3
  end
data/lib/vimamsa.rb CHANGED
@@ -2,6 +2,9 @@ require "vimamsa/version"
2
2
 
3
3
  require "vmaext"
4
4
 
5
+ $:.unshift File.expand_path(File.dirname(__FILE__)+"/../ext/stridx")
6
+ require "stridx"
7
+
5
8
  require "vimamsa/rbvma"
6
9
 
7
10
  module Vimamsa
data/vimamsa.gemspec CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(refcode|spec|features)/})
18
18
  end
19
+ # spec.files = Dir["{ext}/**/*"]
20
+
19
21
  spec.bindir = "exe"
20
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
23
  spec.require_paths = ["lib","ext"]
@@ -36,10 +38,9 @@ Gem::Specification.new do |spec|
36
38
  spec.add_runtime_dependency 'differ', '~> 0.1.2'
37
39
  spec.add_runtime_dependency 'parallel', '~> 1.14' #TODO: update?
38
40
  spec.add_runtime_dependency 'listen', '~> 3.4' #TODO: update?
41
+ spec.add_runtime_dependency 'StrIdx', '~> 0.1.1'
39
42
  spec.add_runtime_dependency 'language_server-protocol', '~> 3.17.0.3'
40
43
 
41
44
  spec.extensions = ["ext/vmaext/extconf.rb"]
42
45
  spec.licenses = ['GPL-3.0+']
43
- # FileList["ext/**/extconf.rb"]
44
-
45
46
  end
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.18
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sami Sieranoja
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-17 00:00:00.000000000 Z
11
+ date: 2024-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -192,6 +192,20 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: '3.4'
195
+ - !ruby/object:Gem::Dependency
196
+ name: StrIdx
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: 0.1.1
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: 0.1.1
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: language_server-protocol
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -217,7 +231,6 @@ extensions:
217
231
  extra_rdoc_files: []
218
232
  files:
219
233
  - ".gitignore"
220
- - ".vma_project"
221
234
  - Gemfile
222
235
  - README.md
223
236
  - Rakefile
data/.vma_project DELETED
File without changes