ribhu 0.0.4 → 0.0.5
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.
- data/bin/ribhu +42 -17
- data/ribhu.gemspec +1 -1
- metadata +4 -4
data/bin/ribhu
CHANGED
@@ -87,18 +87,41 @@ def my_help_text
|
|
87
87
|
eos
|
88
88
|
end
|
89
89
|
|
90
|
+
def convert_man_to_ansi file
|
91
|
+
lines = file.split "\n"
|
92
|
+
l = nil
|
93
|
+
lines.each_with_index do |line, ix|
|
94
|
+
# convert underlined words to yellow or one color, these are usually params
|
95
|
+
line.gsub!(/((_[^ ])+)/,'[4;33m\1[0m')
|
96
|
+
line.gsub!(/_/,'')
|
97
|
+
# convert bold words to red or one color, these are usually headers and other words
|
98
|
+
l= line.gsub(/(([^ ][^ ])+)/,'[1;31m\1[0m').gsub(/[^ ]/,'').gsub(//,'')
|
99
|
+
lines[ix] = l
|
100
|
+
end
|
101
|
+
lines
|
102
|
+
end
|
90
103
|
##
|
91
104
|
# display the ridoc for given word (class or method or part)
|
92
105
|
def display_text word
|
93
106
|
w = @form.by_name["tv"];
|
94
|
-
lines =
|
107
|
+
lines = get_data word
|
108
|
+
#file = `ri -f bs #{word}`
|
109
|
+
#lines = convert_man_to_ansi file
|
95
110
|
return if lines.nil? || lines.size == 0
|
96
111
|
# ansi can have overflow
|
97
|
-
|
112
|
+
w.add_content(lines, :content_type => :ansi, :title => word)
|
98
113
|
$visited << word unless $visited.index(word)
|
99
|
-
w.add_content(lines, :title => word)
|
114
|
+
#w.add_content(lines, :title => word)
|
100
115
|
w.buffer_last
|
101
116
|
end
|
117
|
+
## retrieve data in ansi format.
|
118
|
+
# NOTE that ri returns <t>CLEAR</tt> without the 0. So rbcurse-core does not catch that
|
119
|
+
# it expects a zero there. So i've replaced [[m with [[0m.
|
120
|
+
# @param String class or method name to fetch ri info for
|
121
|
+
# @ returns Array of lines, containing ansi format data
|
122
|
+
def get_data str
|
123
|
+
lines = `ri -f ansi #{str} 2>&1`.gsub('[m','[0m').split("\n")
|
124
|
+
end
|
102
125
|
|
103
126
|
##
|
104
127
|
# prompt user for a class name and show ri doc for same, can be method too
|
@@ -107,7 +130,8 @@ def ask_classes
|
|
107
130
|
format="rdoc"
|
108
131
|
str = get_string_with_history("Enter a class name: ")
|
109
132
|
if str && str != ""
|
110
|
-
lines = `ri -f #{format} #{str}`.split("\n")
|
133
|
+
#lines = `ri -f #{format} #{str}`.split("\n")
|
134
|
+
lines = get_data str
|
111
135
|
if lines.size == 0
|
112
136
|
alert "Nothing came through for #{str}"
|
113
137
|
## Nothing returned, lets see if we can match something from the class list
|
@@ -118,7 +142,8 @@ def ask_classes
|
|
118
142
|
ix = popuplist(values)
|
119
143
|
if ix
|
120
144
|
str = values[ix]
|
121
|
-
lines = `ri -f #{format} #{str}`.split("\n")
|
145
|
+
#lines = `ri -f #{format} #{str}`.split("\n")
|
146
|
+
lines = get_data str
|
122
147
|
end
|
123
148
|
else
|
124
149
|
alert "Nothing came through for #{str}"
|
@@ -131,13 +156,14 @@ def ask_classes
|
|
131
156
|
ix = popuplist(lines)
|
132
157
|
if ix
|
133
158
|
str = lines[ix]
|
134
|
-
lines = `ri -f #{format} #{str}`.split("\n")
|
159
|
+
#lines = `ri -f #{format} #{str}`.split("\n")
|
160
|
+
lines = get_data str
|
135
161
|
end
|
136
162
|
end
|
137
163
|
return if lines.size == 0
|
138
164
|
w = @form.by_name["tv"];
|
139
|
-
|
140
|
-
w.add_content(lines, :title => str)
|
165
|
+
w.add_content(lines, :content_type => :ansi, :title => str)
|
166
|
+
#w.add_content(lines, :title => str)
|
141
167
|
w.buffer_last
|
142
168
|
set_focus_on str
|
143
169
|
end
|
@@ -178,7 +204,8 @@ end
|
|
178
204
|
def try_ri arr
|
179
205
|
_text = nil
|
180
206
|
arr.each do |w|
|
181
|
-
_text = `ri -f rdoc #{w} 2>&1`.split("\n")
|
207
|
+
#_text = `ri -f rdoc #{w} 2>&1`.split("\n")
|
208
|
+
_text = get_data w
|
182
209
|
if _text.first.index("Nothing known about")
|
183
210
|
else
|
184
211
|
break
|
@@ -257,7 +284,7 @@ if true
|
|
257
284
|
popup_history
|
258
285
|
end
|
259
286
|
|
260
|
-
header = app_header "0.0.
|
287
|
+
header = app_header "0.0.5", :text_center => "ri Documentation Browser", :text_right =>"" #, :color => :black, :bgcolor => :white #, :attr => :bold
|
261
288
|
# this is the old style of printing something directly on the window.
|
262
289
|
# The new style is to use a header
|
263
290
|
#@form.window.printstring 0, 30, "ri documentation browser", $normalcolor, BOLD
|
@@ -265,9 +292,6 @@ if true
|
|
265
292
|
|
266
293
|
# this is the old style of using a label at the screen bottom, you can use the status_line
|
267
294
|
|
268
|
-
v = "Q quit, F1 Help, ? Bindings, f<char>, /, Alt-c, ENTER on Class or Method"
|
269
|
-
#var = RubyCurses::Label.new @form, { :text => v, :row => FFI::NCurses.LINES-2,
|
270
|
-
#:col => fc, :display_length => 100}
|
271
295
|
$message = Variable.new
|
272
296
|
$message.value = "Message Comes Here"
|
273
297
|
@status_line = status_line :row => Ncurses.LINES-1
|
@@ -314,7 +338,7 @@ if true
|
|
314
338
|
end
|
315
339
|
|
316
340
|
tv = RubyCurses::TextView.new @form, :row => r, :col => w+1, :height => h, :width => FFI::NCurses.COLS-w-1,
|
317
|
-
:name => "tv", :title => "Press Enter on
|
341
|
+
:name => "tv", :title => "Press Enter on Class"
|
318
342
|
tv.set_content ["Press Enter on list to view ri information in this area.",
|
319
343
|
"Press ENTER on method name to see details"]
|
320
344
|
require 'rbcurse/core/include/multibuffer'
|
@@ -345,12 +369,13 @@ if true
|
|
345
369
|
if tt.index("::")
|
346
370
|
ix = tt.index("::")
|
347
371
|
tt = tt[0,ix]
|
348
|
-
_text = `ri -f
|
372
|
+
#_text = `ri -f ansi #{tt}::#{w} 2>&1`.gsub('[m','[0m').split("\n")
|
373
|
+
_text = get_data "#{tt}::#{w}"
|
349
374
|
end
|
350
375
|
end
|
351
376
|
if _text && _text.size != 0
|
352
|
-
|
353
|
-
view(_text)
|
377
|
+
view(_text, :content_type => :ansi)
|
378
|
+
#view(_text)
|
354
379
|
end
|
355
380
|
end
|
356
381
|
}
|
data/ribhu.gemspec
CHANGED
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "ribhu"
|
8
|
-
spec.version = "0.0.
|
8
|
+
spec.version = "0.0.5"
|
9
9
|
spec.authors = ["Rahul Kumar"]
|
10
10
|
spec.email = ["sentinel1879@gmail.com"]
|
11
11
|
spec.description = %q{ri documentation browser using ncurses}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ribhu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
89
|
version: '0'
|
90
90
|
segments:
|
91
91
|
- 0
|
92
|
-
hash: -
|
92
|
+
hash: -1291920242593968261
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
98
|
version: '0'
|
99
99
|
segments:
|
100
100
|
- 0
|
101
|
-
hash: -
|
101
|
+
hash: -1291920242593968261
|
102
102
|
requirements: []
|
103
103
|
rubyforge_project:
|
104
104
|
rubygems_version: 1.8.25
|