kang 0.0.3 → 0.1.0alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +19 -0
- data/History.txt +12 -0
- data/bin/kang +1 -3
- data/lib/kang/controller.rb +58 -0
- data/lib/kang/data.rb +140 -0
- data/lib/kang/offset_data.rb +32 -0
- data/lib/kang/version.rb +2 -2
- data/lib/kang/view.rb +141 -0
- data/lib/kang.rb +4 -201
- metadata +20 -8
data/COPYING
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 Tony Doan <tdoan@tdoan.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/History.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
== 0.0.1 2009-01-07
|
2
|
+
|
3
|
+
* Initial release
|
4
|
+
|
5
|
+
== 0.0.2 2011-06-21
|
6
|
+
|
7
|
+
* Port from wx to gtk2
|
8
|
+
|
9
|
+
== 0.0.3 2011-08-07
|
10
|
+
|
11
|
+
* Fix bug where match highlighting would not start until the match text was edited for the first time.
|
12
|
+
* Changed background color of highlighted text tog gray to make the cursor more visible.
|
data/bin/kang
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Kang
|
2
|
+
class Controller
|
3
|
+
def initialize
|
4
|
+
reg_text = "RegEx here"
|
5
|
+
match_text = "Match Text Here"
|
6
|
+
@data = Data.new(reg_text,match_text)
|
7
|
+
@view = View.new(self,@data)
|
8
|
+
@view.start
|
9
|
+
end
|
10
|
+
|
11
|
+
def key_up_match(view,event,match_string)
|
12
|
+
#@view.update_status("")
|
13
|
+
@data.match_string = match_string
|
14
|
+
#key_up
|
15
|
+
@view.repaint
|
16
|
+
end
|
17
|
+
|
18
|
+
def key_up_reg(view,event,text)
|
19
|
+
#@view.update_status("")
|
20
|
+
@data.regex_string = text
|
21
|
+
#key_up
|
22
|
+
@view.repaint
|
23
|
+
end
|
24
|
+
|
25
|
+
def multiline_click(view,event)
|
26
|
+
@data.multiline=view.active?
|
27
|
+
#@view.toggle_multiline(view.active?)
|
28
|
+
@view.repaint
|
29
|
+
end
|
30
|
+
|
31
|
+
def spin_change(value)
|
32
|
+
@data.line_number = value
|
33
|
+
#@view.update_tag
|
34
|
+
@view.repaint
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def key_up
|
39
|
+
unless @data.regex_valid?
|
40
|
+
@view.remove_tag
|
41
|
+
@view.update_status("Invalid Regex")
|
42
|
+
else
|
43
|
+
count = @data.match_group_count ? @data.match_group_count : "no"
|
44
|
+
message = "Matched with #{@data.match_group_count} grouping"
|
45
|
+
message += "s" if @data.match_group_count and @data.match_group_count > 1
|
46
|
+
@view.update_status(message)
|
47
|
+
if @data.match?
|
48
|
+
@view.update_tag(@data.match_begin,@data.match_end)
|
49
|
+
else
|
50
|
+
@view.remove_tag
|
51
|
+
@view.update_status("no match")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
@view.update_match_groups(@data.matches)
|
55
|
+
@view.update_spin_count
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/kang/data.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'kang/offset_data'
|
2
|
+
|
3
|
+
module Kang
|
4
|
+
class Data
|
5
|
+
attr_accessor :line_number,:match_string,:regex_string
|
6
|
+
|
7
|
+
def initialize(reg_text="",match_text="")
|
8
|
+
self.match_string = match_text
|
9
|
+
self.regex_string = reg_text
|
10
|
+
@line_number=1
|
11
|
+
@multiline=false
|
12
|
+
update_match
|
13
|
+
end
|
14
|
+
|
15
|
+
def match_string=(match_string)
|
16
|
+
@match_string = match_string
|
17
|
+
update_match
|
18
|
+
end
|
19
|
+
|
20
|
+
def regex_string=(regex_string)
|
21
|
+
@regex_string = regex_string
|
22
|
+
begin
|
23
|
+
@re = Regexp.new(@regex_string)
|
24
|
+
update_match
|
25
|
+
rescue RegexpError
|
26
|
+
@re = nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def multiline=(multiline)
|
31
|
+
if multiline
|
32
|
+
@multiline = true
|
33
|
+
else
|
34
|
+
@multiline = false
|
35
|
+
end
|
36
|
+
update_match
|
37
|
+
end
|
38
|
+
|
39
|
+
def multiline
|
40
|
+
@multiline
|
41
|
+
end
|
42
|
+
|
43
|
+
def match
|
44
|
+
@match
|
45
|
+
end
|
46
|
+
|
47
|
+
def line_number=(line_number)
|
48
|
+
if (self.num_lines) and (line_number > 0) and (line_number <= self.num_lines)
|
49
|
+
@line_number = line_number
|
50
|
+
update_match
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def num_lines
|
55
|
+
#if (defined? @line_matches) and @multiline
|
56
|
+
#@line_matches.size - 1 #line_match is padded with a leading nil to deal with 0 offset
|
57
|
+
#else
|
58
|
+
#nil
|
59
|
+
#end
|
60
|
+
@match_string.scan(/^.*$/).size
|
61
|
+
end
|
62
|
+
|
63
|
+
def line(line_num)
|
64
|
+
@line_matches[line_num][0]
|
65
|
+
end
|
66
|
+
|
67
|
+
def regex_valid?
|
68
|
+
@re.nil? ? false : true
|
69
|
+
end
|
70
|
+
|
71
|
+
def match?
|
72
|
+
@match ? true : false
|
73
|
+
end
|
74
|
+
|
75
|
+
def match_begin
|
76
|
+
if @match
|
77
|
+
@match.begin(0)
|
78
|
+
else
|
79
|
+
nil
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def match_end
|
84
|
+
if @match
|
85
|
+
@match.end(0)
|
86
|
+
else
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def match_group_count
|
92
|
+
if @match
|
93
|
+
@match.length
|
94
|
+
else
|
95
|
+
nil
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def matches
|
100
|
+
if @match and (@match.length > 1)
|
101
|
+
if @match.names and @match.names.size>0
|
102
|
+
names = @match.names.unshift("0")
|
103
|
+
else
|
104
|
+
names = Range.new(0,@match.length-1).to_a.collect{|o| o.to_s}
|
105
|
+
end
|
106
|
+
return names.zip(@match.to_a)
|
107
|
+
else
|
108
|
+
[]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
private
|
113
|
+
|
114
|
+
def update_match
|
115
|
+
if @re
|
116
|
+
if @multiline
|
117
|
+
@line_matches = [nil]
|
118
|
+
@match_string.scan(/^.*$/) {|m| @line_matches << $~}
|
119
|
+
@line_number = 1 if @line_number > self.num_lines
|
120
|
+
line_match = @line_matches[@line_number]
|
121
|
+
@match = @re.match(@line_matches[@line_number][0])
|
122
|
+
@match = OffSetMatchData.new(line_match.begin(0), @match) if @match
|
123
|
+
else
|
124
|
+
@match = @re.match(@match_string)
|
125
|
+
end
|
126
|
+
else
|
127
|
+
@match = nil
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def update_regexp(re_string)
|
132
|
+
begin
|
133
|
+
@re = Regexp.new(re_string)
|
134
|
+
rescue RegexpError
|
135
|
+
@re = nil
|
136
|
+
end
|
137
|
+
update_match
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Kang
|
2
|
+
class OffSetMatchData
|
3
|
+
def initialize(offset,match_data)
|
4
|
+
@offset = offset
|
5
|
+
@match_data = match_data
|
6
|
+
end
|
7
|
+
|
8
|
+
def begin(i)
|
9
|
+
@match_data.begin(i) + @offset
|
10
|
+
end
|
11
|
+
|
12
|
+
def end(i)
|
13
|
+
@match_data.end(i) + @offset
|
14
|
+
end
|
15
|
+
|
16
|
+
def length
|
17
|
+
@match_data.length
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](x)
|
21
|
+
@match_data[x]
|
22
|
+
end
|
23
|
+
|
24
|
+
def names
|
25
|
+
@match_data.names
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_a
|
29
|
+
@match_data.to_a
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/kang/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module Kang
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
2
|
+
VERSION = "0.1.0alpha"
|
3
|
+
end
|
data/lib/kang/view.rb
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
module Kang
|
2
|
+
class View
|
3
|
+
def initialize(controller,data)
|
4
|
+
reg_text=data.regex_string
|
5
|
+
match_text=data.match_string
|
6
|
+
@controller = controller
|
7
|
+
@data = data
|
8
|
+
@window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
|
9
|
+
@window.set_title "Kang"
|
10
|
+
@window.border_width = 10
|
11
|
+
@window.set_size_request(600, 400)
|
12
|
+
@window.signal_connect('delete_event') { Gtk.main_quit }
|
13
|
+
|
14
|
+
wintop = Gtk::ScrolledWindow.new
|
15
|
+
wintop.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS)
|
16
|
+
|
17
|
+
winbottom = Gtk::ScrolledWindow.new
|
18
|
+
winbottom.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS)
|
19
|
+
|
20
|
+
winright = Gtk::ScrolledWindow.new
|
21
|
+
winright.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
|
22
|
+
|
23
|
+
@statusbar = Gtk::Statusbar.new
|
24
|
+
@statusbar.push(0,"")
|
25
|
+
|
26
|
+
@regview = Gtk::TextView.new
|
27
|
+
@regview.buffer.text = reg_text
|
28
|
+
|
29
|
+
@matchview = Gtk::TextView.new
|
30
|
+
@matchview.buffer.text = match_text
|
31
|
+
|
32
|
+
@matchview.buffer.create_tag("colors",{ "foreground" => "green", "background" => "gray" })
|
33
|
+
|
34
|
+
wintop.add(@regview)
|
35
|
+
winbottom.add(@matchview)
|
36
|
+
|
37
|
+
@list_store = Gtk::ListStore.new(String, String)
|
38
|
+
treeview = Gtk::TreeView.new(@list_store)
|
39
|
+
column0 = Gtk::TreeViewColumn.new("Match",Gtk::CellRendererText.new, {:text => 0})
|
40
|
+
column1 = Gtk::TreeViewColumn.new("Match",Gtk::CellRendererText.new, {:text => 1})
|
41
|
+
treeview.append_column(column0)
|
42
|
+
treeview.append_column(column1)
|
43
|
+
treeview.selection.mode = Gtk::SELECTION_NONE
|
44
|
+
treeview.set_size_request(200,-1)
|
45
|
+
winright.add(treeview)
|
46
|
+
#winright.set_size_request(200,-1)
|
47
|
+
|
48
|
+
vpaned = Gtk::VPaned.new
|
49
|
+
vpaned.add1(wintop)
|
50
|
+
vpaned.add2(winbottom)
|
51
|
+
vpaned.set_size_request(400,400)
|
52
|
+
hpaned = Gtk::HPaned.new
|
53
|
+
hpaned.pack1(vpaned,true,false)
|
54
|
+
hpaned.pack2(winright,true,false)
|
55
|
+
hpaned.set_size_request(100,-1)
|
56
|
+
vbox = Gtk::VBox.new(false,0)
|
57
|
+
vbox.pack_start(hpaned,true,true,0)
|
58
|
+
@multiline = Gtk::CheckButton.new("multiline")
|
59
|
+
vbox.pack_start(@multiline,false,false,0)
|
60
|
+
@spinbutton = Gtk::SpinButton.new(1, 1, 1)
|
61
|
+
@spinbutton.sensitive=false
|
62
|
+
vbox.pack_start(@spinbutton,false,false,0)
|
63
|
+
vbox.pack_start(@statusbar,false,false,0)
|
64
|
+
@window.add(vbox)
|
65
|
+
|
66
|
+
@regview.signal_connect("key-release-event") {|view,event| @controller.key_up_reg(view,event,view.buffer.text)}
|
67
|
+
@matchview.signal_connect("key-release-event") {|view,event| @controller.key_up_match(view,event,view.buffer.text)}
|
68
|
+
@multiline.signal_connect("clicked") {|view,event| @controller.multiline_click(view,event)}
|
69
|
+
@spinbutton.signal_connect("value-changed") {|button| @controller.spin_change(button.value.to_i)}
|
70
|
+
end
|
71
|
+
|
72
|
+
def start
|
73
|
+
@window.show_all
|
74
|
+
begin
|
75
|
+
Gtk.main
|
76
|
+
rescue SystemExit, Interrupt
|
77
|
+
exit(0)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def repaint
|
82
|
+
update_status
|
83
|
+
update_spin_count
|
84
|
+
update_match_groups
|
85
|
+
update_tag if @data.match
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
def update_tag
|
90
|
+
remove_tag
|
91
|
+
tag_begin = @data.match_begin
|
92
|
+
tag_end = @data.match_end
|
93
|
+
b = @matchview.buffer.get_iter_at_offset(tag_begin)
|
94
|
+
e = @matchview.buffer.get_iter_at_offset(tag_end)
|
95
|
+
@matchview.buffer.apply_tag("colors",b,e)
|
96
|
+
end
|
97
|
+
|
98
|
+
def update_status
|
99
|
+
unless @data.regex_valid?
|
100
|
+
remove_tag
|
101
|
+
message = "Invalid Regex"
|
102
|
+
else
|
103
|
+
count = @data.match_group_count ? @data.match_group_count : "no"
|
104
|
+
message = "Matched with #{@data.match_group_count} grouping"
|
105
|
+
message += "s" if @data.match_group_count and @data.match_group_count > 1
|
106
|
+
if @data.match?
|
107
|
+
update_tag #(@data.match_begin,@data.match_end)
|
108
|
+
else
|
109
|
+
remove_tag
|
110
|
+
message = "no match"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
@statusbar.pop(0)
|
114
|
+
@statusbar.push(0,message)
|
115
|
+
end
|
116
|
+
|
117
|
+
def update_match_groups
|
118
|
+
@list_store.clear
|
119
|
+
@data.matches.each{|m| iter = @list_store.append; iter[0]=m[0];iter[1]=m[1]}
|
120
|
+
end
|
121
|
+
|
122
|
+
def remove_tag
|
123
|
+
buffer = @matchview.buffer
|
124
|
+
bstart = buffer.get_iter_at_offset(0)
|
125
|
+
bend = buffer.get_iter_at_offset(buffer.text.size)
|
126
|
+
@matchview.buffer.remove_tag("colors",bstart,bend)
|
127
|
+
end
|
128
|
+
|
129
|
+
def update_spin_count
|
130
|
+
@spinbutton.sensitive = @data.multiline
|
131
|
+
if @data.multiline
|
132
|
+
@spinbutton.set_range(1, @data.num_lines)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def toggle_multiline(active)
|
137
|
+
update_spin_count
|
138
|
+
@spinbutton.sensitive = active
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/lib/kang.rb
CHANGED
@@ -15,210 +15,13 @@
|
|
15
15
|
#
|
16
16
|
$:.unshift(File.dirname(__FILE__)) unless
|
17
17
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
18
|
-
|
18
|
+
require "kang/controller"
|
19
|
+
require "kang/view"
|
20
|
+
require "kang/data"
|
21
|
+
require "rubygems"
|
19
22
|
begin
|
20
23
|
require 'gtk2'
|
21
24
|
rescue LoadError => ex
|
22
25
|
$stderr.puts("This is a GUI application that requires the gtk2 gem be installed, which in turn requires that GTK2 be installed.")
|
23
26
|
exit(-1)
|
24
27
|
end
|
25
|
-
|
26
|
-
module Kang
|
27
|
-
class Data
|
28
|
-
def initialize(reg_text="",match_text="")
|
29
|
-
update_regexp(reg_text)
|
30
|
-
update_match_string(match_text)
|
31
|
-
end
|
32
|
-
|
33
|
-
def update_match_string(match_string)
|
34
|
-
@match_string = match_string
|
35
|
-
update_match
|
36
|
-
end
|
37
|
-
|
38
|
-
def update_match
|
39
|
-
if @re
|
40
|
-
@match = @re.match(@match_string)
|
41
|
-
else
|
42
|
-
@match = nil
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def match_group_count
|
47
|
-
if @match
|
48
|
-
@match.length
|
49
|
-
else
|
50
|
-
nil
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def update_regexp(re_string)
|
55
|
-
begin
|
56
|
-
@re = Regexp.new(re_string)
|
57
|
-
rescue RegexpError
|
58
|
-
@re = nil
|
59
|
-
end
|
60
|
-
update_match
|
61
|
-
end
|
62
|
-
|
63
|
-
def regexp_valid?
|
64
|
-
@re.nil? ? false : true
|
65
|
-
end
|
66
|
-
|
67
|
-
def match?
|
68
|
-
@match ? true : false
|
69
|
-
end
|
70
|
-
|
71
|
-
def match_begin
|
72
|
-
if @match
|
73
|
-
@match.begin(0)
|
74
|
-
else
|
75
|
-
nil
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def match_end
|
80
|
-
if @match
|
81
|
-
@match.end(0)
|
82
|
-
else
|
83
|
-
nil
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def matches
|
88
|
-
if @match and (@match.length > 1)
|
89
|
-
@match.to_a
|
90
|
-
else
|
91
|
-
[]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
class Controller
|
97
|
-
def initialize
|
98
|
-
reg_text = "RegExp here"
|
99
|
-
match_text = "Match Text Here"
|
100
|
-
@view = View.new(self,reg_text,match_text)
|
101
|
-
@data = Data.new(reg_text,match_text)
|
102
|
-
@view.start
|
103
|
-
end
|
104
|
-
|
105
|
-
def key_up_match(view,event,match_string)
|
106
|
-
@view.update_status("")
|
107
|
-
@data.update_match_string(match_string)
|
108
|
-
key_up
|
109
|
-
end
|
110
|
-
|
111
|
-
def key_up_reg(view,event,text)
|
112
|
-
@view.update_status("")
|
113
|
-
@data.update_regexp(text)
|
114
|
-
key_up
|
115
|
-
end
|
116
|
-
|
117
|
-
private
|
118
|
-
def key_up
|
119
|
-
unless @data.regexp_valid?
|
120
|
-
@view.remove_tag
|
121
|
-
@view.update_status("Invalid Regexp")
|
122
|
-
else
|
123
|
-
count = @data.match_group_count ? @data.match_group_count : "no"
|
124
|
-
message = "Matched with #{@data.match_group_count} grouping"
|
125
|
-
message += "s" if @data.match_group_count and @data.match_group_count > 1
|
126
|
-
@view.update_status(message)
|
127
|
-
if @data.match?
|
128
|
-
@view.update_tag(@data.match_begin,@data.match_end)
|
129
|
-
else
|
130
|
-
@view.remove_tag
|
131
|
-
@view.update_status("no match")
|
132
|
-
end
|
133
|
-
end
|
134
|
-
@view.update_match_groups(@data.matches)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
class View
|
139
|
-
def initialize(controller,reg_text="",match_text="")
|
140
|
-
@controller = controller
|
141
|
-
@window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
|
142
|
-
@window.set_title "Kang"
|
143
|
-
@window.border_width = 10
|
144
|
-
@window.set_size_request(600, 400)
|
145
|
-
@window.signal_connect('delete_event') { Gtk.main_quit }
|
146
|
-
|
147
|
-
wintop = Gtk::ScrolledWindow.new
|
148
|
-
wintop.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS)
|
149
|
-
|
150
|
-
winbottom = Gtk::ScrolledWindow.new
|
151
|
-
winbottom.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS)
|
152
|
-
|
153
|
-
@statusbar = Gtk::Statusbar.new
|
154
|
-
@statusbar.push(0,"")
|
155
|
-
|
156
|
-
@regview = Gtk::TextView.new
|
157
|
-
@regview.buffer.text = reg_text
|
158
|
-
|
159
|
-
@matchview = Gtk::TextView.new
|
160
|
-
@matchview.buffer.text = match_text
|
161
|
-
|
162
|
-
@matchview.buffer.create_tag("colors",{ "foreground" => "green", "background" => "gray" })
|
163
|
-
|
164
|
-
wintop.add(@regview)
|
165
|
-
winbottom.add(@matchview)
|
166
|
-
|
167
|
-
@list_store = Gtk::ListStore.new(Integer, String)
|
168
|
-
treeview = Gtk::TreeView.new(@list_store)
|
169
|
-
column0 = Gtk::TreeViewColumn.new("#",Gtk::CellRendererText.new, {:text => 0})
|
170
|
-
column1 = Gtk::TreeViewColumn.new("Match",Gtk::CellRendererText.new, {:text => 1})
|
171
|
-
treeview.append_column(column0)
|
172
|
-
treeview.append_column(column1)
|
173
|
-
treeview.selection.mode = Gtk::SELECTION_NONE
|
174
|
-
|
175
|
-
vpaned = Gtk::VPaned.new
|
176
|
-
vpaned.add1(wintop)
|
177
|
-
vpaned.add2(winbottom)
|
178
|
-
vpaned.set_size_request(400,400)
|
179
|
-
hpaned = Gtk::HPaned.new
|
180
|
-
hpaned.add1(vpaned)
|
181
|
-
hpaned.add2(treeview)
|
182
|
-
vbox = Gtk::VBox.new(false,0)
|
183
|
-
vbox.pack_start(hpaned,true,true,0)
|
184
|
-
vbox.pack_start(@statusbar,false,false,0)
|
185
|
-
@window.add(vbox)
|
186
|
-
|
187
|
-
@regview.signal_connect("key-release-event") {|view,event| @controller.key_up_reg(view,event,view.buffer.text)}
|
188
|
-
@matchview.signal_connect("key-release-event") {|view,event| @controller.key_up_match(view,event,view.buffer.text)}
|
189
|
-
end
|
190
|
-
|
191
|
-
def start
|
192
|
-
@window.show_all
|
193
|
-
begin
|
194
|
-
Gtk.main
|
195
|
-
rescue SystemExit, Interrupt
|
196
|
-
exit(0)
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
def update_tag(tag_begin,tag_end)
|
201
|
-
remove_tag
|
202
|
-
b = @matchview.buffer.get_iter_at_offset(tag_begin)
|
203
|
-
e = @matchview.buffer.get_iter_at_offset(tag_end)
|
204
|
-
@matchview.buffer.apply_tag("colors",b,e)
|
205
|
-
end
|
206
|
-
|
207
|
-
def update_status(message)
|
208
|
-
@statusbar.pop(0)
|
209
|
-
@statusbar.push(0,message)
|
210
|
-
end
|
211
|
-
|
212
|
-
def update_match_groups(groups)
|
213
|
-
@list_store.clear
|
214
|
-
groups.each_with_index{|item,i| iter = @list_store.append; iter[0]=i;iter[1]=item}
|
215
|
-
end
|
216
|
-
|
217
|
-
def remove_tag
|
218
|
-
buffer = @matchview.buffer
|
219
|
-
bstart = buffer.get_iter_at_offset(0)
|
220
|
-
bend = buffer.get_iter_at_offset(buffer.text.size)
|
221
|
-
@matchview.buffer.remove_tag("colors",bstart,bend)
|
222
|
-
end
|
223
|
-
end
|
224
|
-
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0alpha
|
5
|
+
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tony Doan
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-08-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gtk2
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
description: The Ruby Regex Debugger. Put your regex in the top pane, and your match
|
26
31
|
text in the bottom pane. Kang will highlight the match text that matches and show
|
27
32
|
you any match groups you have created down the right hand side.
|
@@ -33,7 +38,13 @@ extra_rdoc_files: []
|
|
33
38
|
files:
|
34
39
|
- lib/kang.rb
|
35
40
|
- lib/kang/cli.rb
|
41
|
+
- lib/kang/controller.rb
|
42
|
+
- lib/kang/data.rb
|
43
|
+
- lib/kang/offset_data.rb
|
36
44
|
- lib/kang/version.rb
|
45
|
+
- lib/kang/view.rb
|
46
|
+
- COPYING
|
47
|
+
- History.txt
|
37
48
|
- bin/kang
|
38
49
|
homepage: http://github.com/tdoan/kang
|
39
50
|
licenses: []
|
@@ -50,13 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
62
|
none: false
|
52
63
|
requirements:
|
53
|
-
- - ! '
|
64
|
+
- - ! '>'
|
54
65
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
66
|
+
version: 1.3.1
|
56
67
|
requirements: []
|
57
68
|
rubyforge_project:
|
58
|
-
rubygems_version: 1.8.
|
69
|
+
rubygems_version: 1.8.23
|
59
70
|
signing_key:
|
60
71
|
specification_version: 3
|
61
72
|
summary: A visual regex debugger
|
62
73
|
test_files: []
|
74
|
+
has_rdoc: false
|