vimamsa 0.1.9 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
data/lib/vimamsa/rbvma.rb CHANGED
@@ -1,8 +1,9 @@
1
- #require "gtksourceview4"
2
1
  require "date"
3
2
  require "fileutils"
4
- require "gtk3"
5
- require "gtksourceview4"
3
+
4
+ require "gtk4"
5
+ require "gtksourceview5"
6
+
6
7
  require "json"
7
8
  require "listen"
8
9
  require "pathname"
@@ -10,9 +11,11 @@ require "ripl"
10
11
  require "ripl/multi_line"
11
12
  require "shellwords"
12
13
  require "cgi"
13
-
14
+ require "uri"
14
15
  require "vimamsa/util"
16
+ # exit!
15
17
  require "vimamsa/main"
18
+ require "vimamsa/form_generator"
16
19
 
17
20
  require "vimamsa/actions"
18
21
  require "vimamsa/key_binding_tree"
@@ -3,7 +3,7 @@ def execute_search(input_str)
3
3
  $search = Search.new
4
4
  eval_str="execute_search(#{input_str.dump})"
5
5
  $macro.overwrite_current_action(eval_str)
6
- return $search.set(input_str, "simple", $buffer)
6
+ return $search.set(input_str, "simple", vma.buf)
7
7
  end
8
8
 
9
9
  def invoke_search()
@@ -44,6 +44,8 @@ class Search
44
44
  else
45
45
  return false
46
46
  end
47
+
48
+ return nil
47
49
  end
48
50
 
49
51
  def update_search()
@@ -54,7 +56,6 @@ class Search
54
56
  if startpos != nil
55
57
  @cur_search_i = @search_indexes.find_index(startpos)
56
58
  end
57
- # Ripl.start :binding => binding
58
59
  end
59
60
 
60
61
  def jump_to_next()
@@ -70,10 +70,10 @@ end
70
70
 
71
71
  def grep_cur_buffer(search_str, b = nil)
72
72
  debug "grep_cur_buffer(search_str)"
73
- lines = $buffer.split("\n")
73
+ lines = vma.buf.split("\n")
74
74
  r = Regexp.new(Regexp.escape(search_str), Regexp::IGNORECASE)
75
75
  fpath = ""
76
- fpath = $buffer.pathname.expand_path.to_s + ":" if $buffer.pathname
76
+ fpath = vma.buf.pathname.expand_path.to_s + ":" if vma.buf.pathname
77
77
  res_str = ""
78
78
 
79
79
  $grep_matches = []
@@ -84,7 +84,7 @@ def grep_cur_buffer(search_str, b = nil)
84
84
  $grep_matches << i + 1 # Lines start from index 1
85
85
  end
86
86
  }
87
- $grep_bufid = $buffers.current_buf
87
+ $grep_bufid = vma.buffers.current_buf
88
88
  b = create_new_file(nil, res_str)
89
89
  # set_current_buffer(buffer_i, update_history = true)
90
90
  # @current_buf = buffer_i
@@ -93,18 +93,18 @@ def grep_cur_buffer(search_str, b = nil)
93
93
  debug "GREP HANDLER:#{lineno}"
94
94
  jumpto = $grep_matches[lineno]
95
95
  if jumpto.class == Integer
96
- $buffers.set_current_buffer($grep_bufid, update_history = true)
96
+ vma.buffers.set_current_buffer($grep_bufid, update_history = true)
97
97
  buf.jump_to_line(jumpto)
98
98
  end
99
99
  }
100
100
  end
101
101
 
102
- def invoke_grep_search()
103
- start_minibuffer_cmd("", "", :grep_cur_buffer)
104
- end
102
+ # def invoke_grep_search()
103
+ # start_minibuffer_cmd("", "", :grep_cur_buffer)
104
+ # end
105
105
 
106
- def gui_one_input_action(title, field_label, button_title, callback,opt={})
107
- a = OneInputAction.new(nil, title, field_label, button_title, callback,opt)
106
+ def gui_one_input_action(title, field_label, button_title, callback, opt = {})
107
+ a = OneInputAction.new(nil, title, field_label, button_title, callback, opt)
108
108
  a.run
109
109
  return
110
110
  end
@@ -136,21 +136,21 @@ def invoke_replace()
136
136
  end
137
137
 
138
138
  def buf_replace(search_str, replace_str)
139
- if $buffer.visual_mode?
140
- r = $buffer.get_visual_mode_range
141
- txt = $buffer[r]
139
+ if vma.buf.visual_mode?
140
+ r = vma.buf.get_visual_mode_range
141
+ txt = vma.buf[r]
142
142
  txt.gsub!(search_str, replace_str)
143
- $buffer.replace_range(r, txt)
144
- $buffer.end_visual_mode
143
+ vma.buf.replace_range(r, txt)
144
+ vma.buf.end_visual_mode
145
145
  else
146
- repbuf = $buffer.to_s.clone
146
+ repbuf = vma.buf.to_s.clone
147
147
  repbuf.gsub!(search_str, replace_str)
148
- tmppos = $buffer.pos
149
- if repbuf == $buffer.to_s.clone
148
+ tmppos = vma.buf.pos
149
+ if repbuf == vma.buf.to_s.clone
150
150
  message("NO CHANGE. Replacing #{search_str} with #{replace_str}.")
151
151
  else
152
- $buffer.set_content(repbuf)
153
- $buffer.set_pos(tmppos)
152
+ vma.buf.set_content(repbuf)
153
+ vma.buf.set_pos(tmppos)
154
154
  message("Replacing #{search_str} with #{replace_str}.")
155
155
  end
156
156
  end
@@ -168,121 +168,48 @@ def buf_replace_string(instr)
168
168
  buf_replace(a[0], a[1])
169
169
  end
170
170
 
171
- # PopupFormGenerator.new().run
172
- class PopupFormGenerator
173
- def submit()
174
- ret = {}
175
- for id, entry in @vals
176
- ret[id] = entry.text
177
- end
178
- @callback.call(ret)
179
- @window.destroy
180
- end
181
-
182
- def initialize(params = nil)
183
- @window = Gtk::Window.new(:toplevel)
184
- # @window.screen = main_window.screen
185
- # @window.title = title
186
- # params = {}
187
- # params["inputs"] = {}
188
- # params["inputs"]["search"] = { :label => "Search", :type => :entry }
189
- # params["inputs"]["replace"] = { :label => "Replace", :type => :entry }
190
- # params["inputs"]["btn1"] = { :label => "Replace all", :type => :button }
191
- # params[:callback] = proc { |x| puts "====="; puts x.inspect; puts "=====" }
192
-
193
- @callback = params[:callback]
194
- @window.title = ""
195
-
196
- frame = Gtk::Frame.new()
197
- frame.margin = 8
198
- @window.add(frame)
199
-
200
- # @window.title = params["title"]
201
-
202
- # @callback = params["callback"]
203
-
204
- infolabel = Gtk::Label.new
205
- # infolabel.markup = params["title"]
206
-
207
- vbox = Gtk::Box.new(:vertical, 8)
208
- vbox.margin = 8
209
- frame.add(vbox)
210
-
211
- hbox = Gtk::Box.new(:horizontal, 8)
212
- # @window.add(hbox)
213
- @vals = {}
214
-
215
- for id, elem in params["inputs"]
216
- if elem[:type] == :button
217
- button = Gtk::Button.new(:label => elem[:label])
218
- hbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
219
- button.signal_connect "clicked" do
220
- submit
221
- end
222
- elsif elem[:type] == :entry
223
- label = Gtk::Label.new(elem[:label])
224
- entry = Gtk::Entry.new
225
- hbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
226
- hbox.pack_start(entry, :expand => false, :fill => false, :padding => 0)
227
- @vals[id] = entry
228
-
229
- entry.signal_connect("key_press_event") do |widget, event|
230
- if event.keyval == Gdk::Keyval::KEY_Return
231
- submit
232
- true
233
- elsif event.keyval == Gdk::Keyval::KEY_Escape
234
- @window.destroy
235
- true
236
- else
237
- false
238
- end
239
- end
240
- end
241
- end
242
-
243
- vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
244
-
245
- cancel_button = Gtk::Button.new(:label => "Cancel")
246
- cancel_button.signal_connect "clicked" do
247
- @window.destroy
171
+ module Gtk
172
+ class Frame
173
+ def margin=(a)
174
+ self.margin_bottom = a
175
+ self.margin_top = a
176
+ self.margin_end = a
177
+ self.margin_start = a
248
178
  end
249
- hbox.pack_start(cancel_button, :expand => false, :fill => false, :padding => 0)
250
-
251
- return
252
179
  end
253
180
 
254
- def run
255
- if !@window.visible?
256
- @window.show_all
257
- else
258
- @window.destroy
181
+ class Box
182
+ def margin=(a)
183
+ self.margin_bottom = a
184
+ self.margin_top = a
185
+ self.margin_end = a
186
+ self.margin_start = a
259
187
  end
260
- @window
261
188
  end
262
189
  end
263
190
 
264
191
  class OneInputAction
265
192
  def initialize(main_window, title, field_label, button_title, callback, opt = {})
266
- @window = Gtk::Window.new(:toplevel)
193
+ @window = Gtk::Window.new()
267
194
  # @window.screen = main_window.screen
268
195
  # @window.title = title
269
196
  @window.title = ""
270
197
 
271
198
  frame = Gtk::Frame.new()
272
- frame.margin = 8
273
- @window.add(frame)
199
+ # frame.margin = 20
200
+ @window.set_child(frame)
274
201
 
275
202
  infolabel = Gtk::Label.new
276
203
  infolabel.markup = title
277
204
 
278
205
  vbox = Gtk::Box.new(:vertical, 8)
279
- vbox.margin = 8
280
- frame.add(vbox)
206
+ vbox.margin = 10
207
+ frame.set_child(vbox)
281
208
 
282
209
  hbox = Gtk::Box.new(:horizontal, 8)
283
210
  # @window.add(hbox)
284
- vbox.pack_start(infolabel, :expand => false, :fill => false, :padding => 0)
285
- vbox.pack_start(hbox, :expand => false, :fill => false, :padding => 0)
211
+ vbox.pack_end(infolabel, :expand => false, :fill => false, :padding => 0)
212
+ vbox.pack_end(hbox, :expand => false, :fill => false, :padding => 0)
286
213
 
287
214
  button = Gtk::Button.new(:label => button_title)
288
215
  cancel_button = Gtk::Button.new(:label => "Cancel")
@@ -304,12 +231,15 @@ class OneInputAction
304
231
  @window.destroy
305
232
  end
306
233
 
307
- @entry1.signal_connect("key_press_event") do |widget, event|
308
- if event.keyval == Gdk::Keyval::KEY_Return
234
+ press = Gtk::EventControllerKey.new
235
+ press.set_propagation_phase(Gtk::PropagationPhase::CAPTURE)
236
+ @window.add_controller(press)
237
+ press.signal_connect "key-pressed" do |gesture, keyval, keycode, y|
238
+ if keyval == Gdk::Keyval::KEY_Return
309
239
  callback.call(@entry1.text)
310
240
  @window.destroy
311
241
  true
312
- elsif event.keyval == Gdk::Keyval::KEY_Escape
242
+ elsif keyval == Gdk::Keyval::KEY_Escape
313
243
  @window.destroy
314
244
  true
315
245
  else
@@ -317,16 +247,16 @@ class OneInputAction
317
247
  end
318
248
  end
319
249
 
320
- hbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
321
- hbox.pack_start(@entry1, :expand => false, :fill => false, :padding => 0)
322
- hbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
323
- hbox.pack_start(cancel_button, :expand => false, :fill => false, :padding => 0)
250
+ hbox.pack_end(label, :expand => false, :fill => false, :padding => 0)
251
+ hbox.pack_end(@entry1, :expand => false, :fill => false, :padding => 0)
252
+ hbox.pack_end(button, :expand => false, :fill => false, :padding => 0)
253
+ hbox.pack_end(cancel_button, :expand => false, :fill => false, :padding => 0)
324
254
  return
325
255
  end
326
256
 
327
257
  def run
328
258
  if !@window.visible?
329
- @window.show_all
259
+ @window.show
330
260
  else
331
261
  @window.destroy
332
262
  end
@@ -3,7 +3,7 @@ class Converter
3
3
  @obj = obj
4
4
  @type = type
5
5
  if id != nil
6
- $vma.reg_conv(self, id)
6
+ vma.reg_conv(self, id)
7
7
  end
8
8
  end
9
9
 
data/lib/vimamsa/util.rb CHANGED
@@ -1,12 +1,58 @@
1
1
 
2
+ class HSafe
3
+ def initialize(hash)
4
+ @h = hash
5
+ @a = []
6
+ end
7
+
8
+ def [](x)
9
+ @a << x
10
+ return self
11
+ end
12
+
13
+ def val
14
+ b = @a.reverse
15
+ hh = @h
16
+ while !b.empty?
17
+ x = b.pop
18
+ puts "x=#{x}"
19
+ pp b
20
+ ok = false
21
+ if hh.class == Hash or hh.class == Array
22
+ ok = true
23
+ else
24
+ if hh.methods.include?(:[])
25
+ ok = true
26
+ end
27
+ end
28
+ return nil if !ok
29
+ if hh[x].nil?
30
+ return nil
31
+ else
32
+ hh = hh[x]
33
+ end
34
+ end
35
+ return hh
36
+ end
37
+ end
38
+
39
+ # h= Hash.new
40
+ # h[2] = Hash.new
41
+ # h[2]["sdf"] = Hash.new
42
+ # h[2]["sdf"][:ll] = 2323
43
+ # pp HSafe.new(h)[2]["sdf"][:ll].val
44
+ # pp HSafe.new(h)[2]["sdf"][:llz].val
45
+ # pp HSafe.new(h)["SDFSDFD"]["sdf"][:llz].val
46
+
47
+
2
48
  # From https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
3
49
  # Cross-platform way of finding an executable in the $PATH.
4
50
  #
5
51
  # which('ruby') #=> /usr/bin/ruby
6
52
 
7
-
8
53
  # Execute proc after wait_time seconds after last .run call.
9
54
  # Used for image scaling after window resize
55
+
10
56
  class DelayExecutioner
11
57
  def initialize(wait_time, _proc)
12
58
  @wait_time = wait_time
@@ -1,3 +1,3 @@
1
1
  module Vimamsa
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.11"
3
3
  end
data/lib/vimamsa.rb CHANGED
@@ -1,17 +1,12 @@
1
1
  require "vimamsa/version"
2
2
 
3
- require "gtk3"
4
- require "gtksourceview4"
5
- test1 = Gtk::TextView.new
6
-
7
3
  require "vmaext"
8
4
 
9
5
  require "vimamsa/rbvma"
10
6
 
11
7
  module Vimamsa
12
- # Your code goes here...
13
8
  def self.test
14
- puts "Vimamsa test"
9
+ puts "Vimamsa c-extension test"
15
10
  puts srn_dst("foobar", "baz")
16
11
  end
17
12
  end
@@ -8,6 +8,9 @@
8
8
  </_description>
9
9
 
10
10
  <color name="heading" value="#CF6A4C"/>
11
+ <style name="selection" foreground="#ffffff" background="#10bd8e"/>
12
+
13
+
11
14
  <style foreground="#AE81FF" name="def:boolean"/>
12
15
  <style foreground="#AE81FF" name="def:number"/>
13
16
  <style foreground="#E6DB74" name="def:string"/>
data/vimamsa.gemspec CHANGED
@@ -20,20 +20,20 @@ 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", "~> 2.2.33"
23
+ spec.add_development_dependency "bundler", "~> 2.4.21"
24
24
  spec.add_development_dependency "rake", "~> 13.0"
25
25
 
26
- spec.add_runtime_dependency 'rufo', '~> 0.5'
26
+ spec.add_runtime_dependency 'rufo', '~> 0.16.2'
27
27
 
28
- spec.add_runtime_dependency 'ripl', '~> 0.7'
28
+ spec.add_runtime_dependency 'ripl', '~> 0.7.1'
29
29
  spec.add_runtime_dependency 'ripl-multi_line', '~> 0.3.1'
30
- spec.add_runtime_dependency 'gdk3', '~> 3.4'
31
- spec.add_runtime_dependency 'gtk3', '~> 3.4'
32
- spec.add_runtime_dependency 'differ', '~> 0.1'
33
- spec.add_runtime_dependency 'gtksourceview3', '~> 3.4'
34
- # spec.add_runtime_dependency 'gtksourceview4'
35
- spec.add_runtime_dependency 'parallel', '~> 1.14'
36
- spec.add_runtime_dependency 'listen', '~> 3.4'
30
+ spec.add_runtime_dependency 'gdk4', '~> 4.2.0'
31
+ spec.add_runtime_dependency 'gtk4', '~> 4.2.0'
32
+ spec.add_runtime_dependency 'differ', '~> 0.1.2'
33
+ spec.add_runtime_dependency 'gtksourceview5', '~> 4.2.0'
34
+ spec.add_runtime_dependency 'parallel', '~> 1.14' #TODO: update?
35
+ spec.add_runtime_dependency 'listen', '~> 3.4' #TODO: update?
36
+
37
37
 
38
38
  spec.extensions = ["ext/vmaext/extconf.rb"]
39
39
  spec.licenses = ['GPL-3.0+']
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.9
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sami Sieranoja
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-15 00:00:00.000000000 Z
11
+ date: 2023-10-20 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: 2.2.33
19
+ version: 2.4.21
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: 2.2.33
26
+ version: 2.4.21
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.5'
47
+ version: 0.16.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.5'
54
+ version: 0.16.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ripl
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.7'
61
+ version: 0.7.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0.7'
68
+ version: 0.7.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: ripl-multi_line
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -81,61 +81,61 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.3.1
83
83
  - !ruby/object:Gem::Dependency
84
- name: gdk3
84
+ name: gdk4
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.4'
89
+ version: 4.2.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '3.4'
96
+ version: 4.2.0
97
97
  - !ruby/object:Gem::Dependency
98
- name: gtk3
98
+ name: gtk4
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.4'
103
+ version: 4.2.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.4'
110
+ version: 4.2.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: differ
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0.1'
117
+ version: 0.1.2
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0.1'
124
+ version: 0.1.2
125
125
  - !ruby/object:Gem::Dependency
126
- name: gtksourceview3
126
+ name: gtksourceview5
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '3.4'
131
+ version: 4.2.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '3.4'
138
+ version: 4.2.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: parallel
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -202,6 +202,7 @@ files:
202
202
  - lib/vimamsa/file_finder.rb
203
203
  - lib/vimamsa/file_history.rb
204
204
  - lib/vimamsa/file_manager.rb
205
+ - lib/vimamsa/form_generator.rb
205
206
  - lib/vimamsa/gui.rb
206
207
  - lib/vimamsa/gui_image.rb
207
208
  - lib/vimamsa/gui_menu.rb
@@ -212,6 +213,7 @@ files:
212
213
  - lib/vimamsa/key_actions.rb
213
214
  - lib/vimamsa/key_binding_tree.rb
214
215
  - lib/vimamsa/key_bindings_vimlike.rb
216
+ - lib/vimamsa/langservp.rb
215
217
  - lib/vimamsa/macro.rb
216
218
  - lib/vimamsa/main.rb
217
219
  - lib/vimamsa/rbvma.rb
@@ -245,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
245
247
  - !ruby/object:Gem::Version
246
248
  version: '0'
247
249
  requirements: []
248
- rubygems_version: 3.1.2
250
+ rubygems_version: 3.4.20
249
251
  signing_key:
250
252
  specification_version: 4
251
253
  summary: Vimamsa