vimamsa 0.1.12 → 0.1.14

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: 33b88d4f4c567a38c726a1eee1a408fb051a972a54afebfee29add1e81f7761d
4
- data.tar.gz: '0366913aba4ccf3f687cbce63fec3815df7cf8c98ae1e00272be32d898f4ec48'
3
+ metadata.gz: 510c17ec3221823fe5e8c800b4146879c11f278b37a0ad807d57729210af6b3a
4
+ data.tar.gz: 211596938920f6a785830d9d516cd9c999b4c8f54a67610eaf971ce127c4b8e5
5
5
  SHA512:
6
- metadata.gz: 3eaa999737e313cfbfb1028031d60101c7c3fcbcfb30504991c4a7a350da374f0969502e13facf46cc69f63b60d576817fa86cbd87981be8988e7998fef119b7
7
- data.tar.gz: 298335f27adce1d7164ea138908419db2b7d1192014ad780651779f36d1a384cde34e5196fa3cae021beaf178e551de08e92a81f03643dec476bbb01a2e1d566
6
+ metadata.gz: '08b64e33fe9c031326ac005bf42da69f5e3ed9ce7ffe73d84a387ede95be8e37a44d0c57d6b5b62d3d2842b8de855dc6145e42cf4cd4a4eb8341cab33cb2b86d'
7
+ data.tar.gz: 3057288ea2ab7b13939a96282da7540287ebba518714b8aa2db7a285d9aff99e435142ab915d13d92684d229069388a0b52c86a971abad8acb817c5343ba2fff
data/custom_example.rb CHANGED
@@ -15,6 +15,11 @@
15
15
  # Open this file every time the program starts
16
16
  # setcnf :startup_file, "~/Documents/startup.txt"
17
17
 
18
+ # To enable LSP:
19
+ # conf(:custom_lsp)[:ruby] = {name: "solargraph", command:"solargraph stdio", type: "stdio"}
20
+ # conf(:custom_lsp)[:cpp] = {name: "clangd", command:"clangd-12 --offset-encoding=utf-8", type: "stdio"}
21
+
22
+
18
23
  def insert_date()
19
24
  # $buffer.insert_txt("#{DateTime.now().strftime("==========\n%Y-%m-%d")}\n")
20
25
  vma.buf.insert_txt("#{DateTime.now().strftime("%Y-%m-%d")}\n")
data/lib/vimamsa/ack.rb CHANGED
@@ -45,7 +45,7 @@ Will search all .txt files in the following directories:
45
45
  dlist = dlist + Dir.glob("#{d}/**/*").select { |e| File.file?(e) and fext.include?(File.extname(e)) and File.size(e) < 200e3 }
46
46
  end
47
47
  bufstr = "Results:\n\n"
48
- b = create_new_buffer(bufstr,"contentsearch")
48
+ b = create_new_buffer(bufstr, "contentsearch")
49
49
  lno = 1
50
50
  @linep = {}
51
51
  for fp in dlist
@@ -81,7 +81,6 @@ Will search all .txt files in the following directories:
81
81
  end
82
82
  end
83
83
 
84
- # jumpto = $grep_matches[lineno]
85
84
  # if jumpto.class == Integer
86
85
  # vma.buffers.set_current_buffer($grep_bufid, update_history = true)
87
86
  # buf.jump_to_line(jumpto)
@@ -111,14 +110,15 @@ Will search the following directories:
111
110
  gui_one_input_action(nfo, "Search:", "search", callback)
112
111
  end
113
112
 
114
- def ack_buffer(instr, b = nil)
115
- instr = Shellwords.escape(instr)
113
+ def ack_buffer(_instr, b = nil)
114
+ instr = Shellwords.escape(_instr)
116
115
  bufstr = ""
117
116
  for path in vma.get_content_search_paths
118
117
  bufstr += run_cmd("ack -Q --type-add=gd=.gd -ki --nohtml --nojs --nojson #{instr} #{path}")
119
118
  end
120
119
  if bufstr.size > 5
121
- create_new_buffer(bufstr,"ack")
120
+ b = create_new_buffer(bufstr, "ack")
121
+ Gui.highlight_match(b, _instr, color: cnf.match.highlight.color!)
122
122
  else
123
123
  message("No results for input:#{instr}")
124
124
  end
@@ -32,11 +32,14 @@ def missing_callfunc
32
32
  end
33
33
 
34
34
  #TODO: remove
35
- def call(id)
36
- call_action(id)
37
- end
35
+ # def call(id)
36
+ # call_action(id)
37
+ # end
38
+
39
+ $acth = []
38
40
 
39
41
  def call_action(id)
42
+ $acth << id
40
43
  a = $actions[id]
41
44
  if a
42
45
  a.method.call()
@@ -45,11 +48,15 @@ def call_action(id)
45
48
  end
46
49
  end
47
50
 
51
+ def last_action
52
+ return $acth[-1]
53
+ end
54
+
48
55
  def search_actions()
49
56
  l = []
50
- opt = { :title => "Search actions.", :desc => "Fuzzy search for actions. <up> or <down> to change selcted. <enter> to select current." }
57
+ opt = { :title => "Search for actions", :desc => "Fuzzy search for actions. <up> or <down> to change selcted. <enter> to select current." }
51
58
  $select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"]
52
-
59
+
53
60
  gui_select_update_window(l, $select_keys.collect { |x| x.upcase },
54
61
  "search_actions_select_callback",
55
62
  "search_actions_update_callback",
@@ -109,7 +116,7 @@ def search_actions_select_callback(search_str, idx)
109
116
  eval(acc)
110
117
  elsif acc.class == Symbol
111
118
  debug "Symbol"
112
- call(acc)
119
+ call_action(acc)
113
120
  end
114
121
  end
115
122
 
@@ -0,0 +1,82 @@
1
+ require "gstreamer"
2
+
3
+ class File
4
+ def self.exists?(fn)
5
+ File.exist?(fn)
6
+ end
7
+ end
8
+
9
+ # following the example gstreamer-4.2.0/sample/helloworld_e.rb
10
+ class Audio
11
+ @@playbin = nil
12
+
13
+ def self.stop
14
+ @@playbin.stop if !@@playbin.nil?
15
+ end
16
+
17
+ def self.play(fn)
18
+ playbin = @@playbin
19
+ if playbin.nil?
20
+ playbin = Gst::ElementFactory.make("playbin")
21
+ if playbin.nil?
22
+ puts "'playbin' gstreamer plugin missing"
23
+ return
24
+ end
25
+ else
26
+ if playbin.current_state == "playing"
27
+ playbin.stop # Stop previous play
28
+ end
29
+ end
30
+
31
+ # playbin.seek(10.0)
32
+
33
+ # playbin.volume
34
+ # playbin.volume=1.0
35
+ # playbin.stream_time
36
+ # playbin.current_state
37
+
38
+ # take the commandline argument and ensure that it is a uri
39
+ if Gst.valid_uri?(fn)
40
+ uri = fn
41
+ else
42
+ uri = Gst.filename_to_uri(fn)
43
+ end
44
+ playbin.uri = uri
45
+ @@playbin = playbin
46
+ $pb = playbin
47
+
48
+ bus = playbin.bus
49
+ bus.add_watch do |bus, message|
50
+ case message.type
51
+ when Gst::MessageType::EOS
52
+ puts "End-of-stream"
53
+ when Gst::MessageType::ERROR
54
+ error, debug = message.parse_error
55
+ puts "Debugging info: #{debug || "none"}"
56
+ puts "Error: #{error.message}"
57
+ end
58
+ true
59
+ end
60
+
61
+ message("Start playing audio: #{fn}")
62
+
63
+ # start play back and listed to events
64
+ playbin.play
65
+ playbin.seek_simple(Gst::Format::TIME, Gst::SeekFlags::NONE, 10.0)
66
+ end
67
+
68
+ def self.seek_forward(secs = 5.0)
69
+ return if @@playbin.nil?
70
+ if @@playbin.current_state == "playing"
71
+ duration = @@playbin.query_duration(Gst::Format::TIME)[1]
72
+ curpos = @@playbin.query_position(Gst::Format::TIME)[1]
73
+ newpos = curpos + secs * 1.0e9
74
+ newpos = 0.0 if newpos < 0
75
+ return if newpos > duration
76
+ @@playbin.seek_simple(Gst::Format::TIME, Gst::SeekFlags::FLUSH, newpos)
77
+ message("New audio pos: #{(newpos / 1.0e9).round(1)}/#{(duration / 1.0e9).round(1)}")
78
+ # $pb.query_position(Gst::Format::TIME)[1]/1.0e9
79
+ end
80
+ end
81
+ end
82
+