vimamsa 0.1.10 → 0.1.12

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: bfc14cb231bc93909b4866e08cbd4503b4f4444527c0b65b4a9edb11d863faa0
4
- data.tar.gz: 7b63cdbff33cdcdbf7d6f5d025d8ec13a6f39a3ee937f716ec990bba743f3239
3
+ metadata.gz: 33b88d4f4c567a38c726a1eee1a408fb051a972a54afebfee29add1e81f7761d
4
+ data.tar.gz: '0366913aba4ccf3f687cbce63fec3815df7cf8c98ae1e00272be32d898f4ec48'
5
5
  SHA512:
6
- metadata.gz: 2176d7aaa01be873deb8687cf2b8d75044edba4ccfc3685cf334cae973c93e15ba6dc47d9667a9848209329b043f2ba8daf049f4340ddb130538584e17b5a5de
7
- data.tar.gz: afcdd6c30018dc971fc165d8ed6f63f5b2ccf109a167d0ec39cf03c150ac03d7765c4c0d83e3a6ceabaae74cf44f759144dbe5e2d9aee1b191182ca7fb622035
6
+ metadata.gz: 3eaa999737e313cfbfb1028031d60101c7c3fcbcfb30504991c4a7a350da374f0969502e13facf46cc69f63b60d576817fa86cbd87981be8988e7998fef119b7
7
+ data.tar.gz: 298335f27adce1d7164ea138908419db2b7d1192014ad780651779f36d1a384cde34e5196fa3cae021beaf178e551de08e92a81f03643dec476bbb01a2e1d566
data/README.md CHANGED
@@ -5,7 +5,7 @@ Vi/Vim -inspired experimental GUI-oriented text editor written with Ruby and GTK
5
5
 
6
6
  ## Requirements
7
7
  - Ruby 2.0+
8
- - GTK 3
8
+ - GTK 4
9
9
 
10
10
  ## Installation
11
11
 
@@ -16,14 +16,31 @@ sudo apt install ruby-dev
16
16
  sudo gem install vimamsa
17
17
  ```
18
18
 
19
- Run:
19
+ ### Other install options
20
+
21
+ Install from sources:
22
+
23
+ ```
24
+ git clone https://github.com/SamiSieranoja/vimamsa.git
25
+ cd vimamsa
26
+ gem build vimamsa.gemspec
27
+ sudo gem install --local vimamsa-0.1.*.gem
28
+
29
+ ```
30
+
31
+ Older version for GTK3:
32
+
33
+ sudo gem install vimamsa -v 0.1.10
34
+
35
+ ## Run
20
36
  ```
21
37
  vimamsa
22
38
  ```
23
39
 
24
- Packages for optional features:
40
+ Install packages for optional features:
25
41
  ```
26
42
  sudo apt install ack-grep clang-format
43
+ gem install ripl ripl-multi_line differ parallel listen rufo language_server-protocol
27
44
  ```
28
45
 
29
46
  For customization, edit ~/.vimamsa/custom.rb
data/custom_example.rb CHANGED
@@ -23,9 +23,18 @@ end
23
23
  def collect_c_header()
24
24
  # Matches e.g.:
25
25
  # static void funcname(parameters)
26
- s = buf.scan(/^(([\w]+\s*){1,3} \w+\((.|\n)+?\))/).collect { |x| x[0] + ";" }.join("\n")
26
+ s = buf.scan(/^(
27
+ ([\w\*\:&]+\s*){1,3}
28
+ [\*?\w\:&]+
29
+ \(
30
+ ([^\)]|\n)*?
31
+ \)
32
+ )
33
+ /x
34
+ ).collect { |x| x[0] + ";" }.join("\n")
27
35
  buf.insert_txt(s)
28
36
  end
37
+
29
38
  reg_act(:collect_c_header, proc { collect_c_header }, "Collect function definitions for c header file")
30
39
 
31
40
  # Extract all numbers from txt selection
@@ -38,6 +47,7 @@ def insert_lorem_ipsum()
38
47
 
39
48
  Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna felis sollicitudin mauris. Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis risus a elit. Etiam tempor. Ut ullamcorper, ligula eu tempor congue, eros est euismod turpis, id tincidunt sapien risus a quam. Maecenas fermentum consequat mi. Donec fermentum. Pellentesque malesuada nulla a mi. Duis sapien sem, aliquet nec, commodo eget, consequat quis, neque. Aliquam faucibus, elit ut dictum aliquet, felis nisl adipiscing sapien, sed malesuada diam lacus eget erat. Cras mollis scelerisque nunc. Nullam arcu. Aliquam consequat. Curabitur augue lorem, dapibus quis, laoreet et, pretium ac, nisi. Aenean magna nisl, mollis quis, molestie eu, feugiat in, orci. In hac habitasse platea dictumst."
40
49
 
50
+ # Insert to current position
41
51
  vma.buf.insert_txt(lorem_ipsum)
42
52
  end
43
53
 
data/demo.txt CHANGED
@@ -1,7 +1,8 @@
1
1
  ❙Demo❙
2
2
 
3
+
3
4
  ◼ General
4
- Links: press ⦁enter⦁ while cursor on
5
+ Links: press ⦁enter⦁ while text cursor on
5
6
  ⟦README.md⟧
6
7
 
7
8
  Extension .txt can be omitted:
@@ -22,4 +23,3 @@ Images work in .txt-files by drag&drop. (experimental)
22
23
 
23
24
 
24
25
 
25
-
data/exe/vimamsa CHANGED
@@ -1,16 +1,13 @@
1
- #!/usr/bin/ruby
1
+ #!/usr/bin/env ruby
2
2
  require "ripl/multi_line"
3
3
  require "tempfile"
4
4
  # Ripl.config[:multi_line_prompt] = ' > '
5
5
  require "pathname"
6
6
 
7
- ENV["GTK_THEME"] = "Adwaita:dark"
8
-
9
7
  selfpath = __FILE__
10
8
  selfpath = File.readlink(selfpath) if File.lstat(selfpath).symlink?
11
9
  scriptdir = File.expand_path(File.dirname(selfpath) + "/..")
12
10
 
13
-
14
11
  # If process is already running, open the parameter file in the running process and exit.
15
12
  listen_dir = File.expand_path("~/.vimamsa/listen")
16
13
  if File.exist?(listen_dir) and !ARGV[0].nil?
data/lib/vimamsa/ack.rb CHANGED
@@ -4,7 +4,7 @@ class FileContentSearch
4
4
  def self.start_gui()
5
5
  search_paths = vma.get_content_search_paths.join("<br/>")
6
6
 
7
- nfo = "<span size='x-large'>Search contents of text files</span>
7
+ nfo = "<span size='x-large'>Search contents of text files</span>
8
8
  Will search all .txt files in the following directories:
9
9
  #{search_paths}
10
10
 
@@ -13,34 +13,82 @@ Will search all .txt files in the following directories:
13
13
  </span>"
14
14
 
15
15
  callback = proc { |x| FileContentSearch.search_buffer(x) }
16
- gui_one_input_action(nfo, "Search:", "search", callback)
16
+ # gui_one_input_action(nfo, "Search:", "search", callback)
17
+
18
+ params = {}
19
+ params["inputs"] = {}
20
+ params["inputs"]["search"] = { :label => "Search:", :type => :entry }
21
+ params["inputs"]["extensions"] = { :label => "Limit to file extensions:", :type => :entry }
22
+ params["inputs"]["extensions"][:initial_text] = conf(:default_search_extensions).join(",")
23
+ params["inputs"]["btn1"] = { :label => "Search", :type => :button }
24
+ # callback = proc { |x| gui_replace_callback(x) }
25
+
26
+ params[:callback] = callback
27
+ PopupFormGenerator.new(params).run
17
28
  end
18
29
 
19
- def self.search_buffer(instr, b = nil)
30
+ def self.search_buffer(formdata, b = nil)
20
31
  # instr = Shellwords.escape(instr)
32
+
21
33
  fext = Set[".txt"]
34
+ # Include only word characters and dot
35
+ extstmp = formdata["extensions"].split(",").collect { |x| "." + x.gsub(/[^\w\.]/, "") }
36
+ fext = extstmp.to_set
37
+ if fext.empty?
38
+ return
39
+ end
40
+ instr = formdata["search"]
41
+
22
42
  dlist = []
23
43
  for d in vma.get_content_search_paths
24
44
  # Search for files with extension .txt and size < 200k
25
45
  dlist = dlist + Dir.glob("#{d}/**/*").select { |e| File.file?(e) and fext.include?(File.extname(e)) and File.size(e) < 200e3 }
26
46
  end
27
47
  bufstr = "Results:\n\n"
48
+ b = create_new_buffer(bufstr,"contentsearch")
49
+ lno = 1
50
+ @linep = {}
28
51
  for fp in dlist
29
- txt = read_file("",fp)
52
+ txt = read_file("", fp)
30
53
  ind = scan_indexes(txt, /#{instr}/i)
31
54
  if !ind.empty?
55
+ # bufstr << "#{fp}\n"
56
+ # buf.insert_txt("#{fp}\n", AFTER)
57
+ b.append("#{fp}\n")
58
+ lno += 1
59
+
32
60
  for x in ind
33
61
  starti = x - 30
34
62
  endi = x + 30
35
63
  starti = 0 if starti < 0
36
64
  endi = txt.size - 1 if endi >= txt.size
37
- bufstr << "#{fp}:c#{x} "
38
- bufstr << txt[starti..endi].gsub("\n"," ")
39
- bufstr << "\n"
65
+ b.append " "
66
+ b.append txt[starti..endi].gsub("\n", " ")
67
+ b.append "\n"
68
+ @linep[lno] = { :fname => fp, :ind => x }
69
+ lno += 1
40
70
  end
41
71
  end
42
72
  end
43
- create_new_file(nil, bufstr)
73
+
74
+ b.line_action_handler = proc { |lineno|
75
+ puts "SEARCH HANDLER:#{lineno}"
76
+ puts @linep[lineno]
77
+ lp = @linep[lineno]
78
+ if !lp.nil?
79
+ if lp.has_key?(:ind) and lp.has_key?(:fname)
80
+ jump_to_file(lp[:fname], lp[:ind], "c")
81
+ end
82
+ end
83
+
84
+ # jumpto = $grep_matches[lineno]
85
+ # if jumpto.class == Integer
86
+ # vma.buffers.set_current_buffer($grep_bufid, update_history = true)
87
+ # buf.jump_to_line(jumpto)
88
+ # end
89
+ }
90
+ # buf.insert_txt("\n")
91
+ # create_new_file(nil, bufstr)
44
92
  end
45
93
  end
46
94
 
@@ -70,7 +118,7 @@ def ack_buffer(instr, b = nil)
70
118
  bufstr += run_cmd("ack -Q --type-add=gd=.gd -ki --nohtml --nojs --nojson #{instr} #{path}")
71
119
  end
72
120
  if bufstr.size > 5
73
- create_new_file(nil, bufstr)
121
+ create_new_buffer(bufstr,"ack")
74
122
  else
75
123
  message("No results for input:#{instr}")
76
124
  end
@@ -49,6 +49,7 @@ def search_actions()
49
49
  l = []
50
50
  opt = { :title => "Search actions.", :desc => "Fuzzy search for actions. <up> or <down> to change selcted. <enter> to select current." }
51
51
  $select_keys = ["h", "l", "f", "d", "s", "a", "g", "z"]
52
+
52
53
  gui_select_update_window(l, $select_keys.collect { |x| x.upcase },
53
54
  "search_actions_select_callback",
54
55
  "search_actions_update_callback",
@@ -74,7 +75,6 @@ def search_actions_update_callback(search_str = "")
74
75
  end
75
76
  end
76
77
  # c_kbd = vma.kbd.act_bindings[mode_str][nfo[:action]]
77
- # Ripl.start :binding => binding
78
78
  item[:action] = act_id
79
79
  item[:str] = act_id.to_s
80
80
  if $actions[act_id].method_name != ""