ribhu 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +8 -1
  2. data/bin/ribhu +39 -9
  3. data/lib/ribhu/version.rb +1 -1
  4. metadata +3 -3
data/README.md CHANGED
@@ -8,7 +8,14 @@ You may press Enter on a class to see its documention. Pressing ENTER over a met
8
8
  fetch its details.
9
9
 
10
10
  You may mark classes with an upper case alphabet (vim style) and access them directly using single-quote.
11
- Several classes have been bookmarked such as Array, String, Hash, File.
11
+ Several classes have been bookmarked such as Array, String, Hash, File. You may place more in a file named "~/.ribhu.conf" in the form:
12
+
13
+ $bookmark[:Z] = "Zlib"
14
+
15
+ A list of visited classes is also maintained and can be accessed and selected from. You may prepopulate it
16
+ from the conf file as:
17
+
18
+ $visited.concat %w{Abbrev GC ARGF}
12
19
 
13
20
  Pressing Alt-c and type in any class or method or portion. If `ri` does not return data or returns
14
21
  choices, a popup will allows selection of choices.
data/bin/ribhu CHANGED
@@ -59,6 +59,11 @@ def my_help_text
59
59
  Entering 'Str' returns nothing from ri, so you have to select from classes
60
60
  starting with 'Str'.
61
61
 
62
+ Press Alt-D to get a popup of visited classes, from which you may select.
63
+
64
+ '?' displays all key binding for current object. 'Q' and 'C-q' quit.
65
+ In any popups, try 'C-q' to quit.
66
+
62
67
  =========================================================================
63
68
  Bookmarks
64
69
 
@@ -90,6 +95,7 @@ def display_text word
90
95
  return if lines.nil? || lines.size == 0
91
96
  # ansi can have overflow
92
97
  #w.add_content(lines, :content_type => :ansi, :title => word)
98
+ $visited << word unless $visited.index(word)
93
99
  w.add_content(lines, :title => word)
94
100
  w.buffer_last
95
101
  end
@@ -116,6 +122,7 @@ def ask_classes
116
122
  end
117
123
  else
118
124
  alert "Nothing came through for #{str}"
125
+ $message.value = "Nothing came through for #{str}"
119
126
  end
120
127
  elsif lines.first.index(".#{str} not found")
121
128
  ## we are returned something with some choices, lets prompt user with choices
@@ -132,6 +139,7 @@ def ask_classes
132
139
  #w.add_content(lines, :content_type => :ansi, :title => str)
133
140
  w.add_content(lines, :title => str)
134
141
  w.buffer_last
142
+ set_focus_on str
135
143
  end
136
144
  end
137
145
 
@@ -154,7 +162,7 @@ def ask_bookmark
154
162
  # set focus to that in the left list
155
163
  set_focus_on str
156
164
  else
157
- #alert "No bookmark for #{ch}"
165
+ $message.value = "No bookmark for #{ch}. Use m to create."
158
166
  ## No bookmark, jumping to first char
159
167
  listb = @form.by_name["mylist"];
160
168
  listb.set_selection_for_char ch
@@ -178,6 +186,13 @@ def try_ri arr
178
186
  end
179
187
  _text
180
188
  end
189
+ def popup_history
190
+ return if $visited.size == 0
191
+ ix = popuplist($visited, :title => " History ", :bgcolor => :blue, :color => :white)
192
+ if ix
193
+ display_text $visited[ix]
194
+ end
195
+ end
181
196
 
182
197
 
183
198
  #if $0 == __FILE__
@@ -187,9 +202,11 @@ if true
187
202
  begin
188
203
  # Initialize curses
189
204
  VER::start_ncurses # this is initializing colors via ColorMap.setup
190
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
205
+ logfilename = File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")
206
+ $log = Logger.new(logfilename)
191
207
  $log.level = Logger::DEBUG
192
208
 
209
+ $visited = []
193
210
  $bookmarks = {
194
211
  :A => "Array",
195
212
  :C => "Class",
@@ -198,10 +215,13 @@ if true
198
215
  :H => "Hash",
199
216
  :I => "IO",
200
217
  :K => "Kernel",
201
- :R => "RubyCurses",
202
- :L => "RubyCurses::Link",
203
218
  :S => "String"
204
219
  }
220
+ config = File.expand_path("~/.ribhu.conf")
221
+ # read up any bookmarks or visited classes, they get added to the existing data
222
+ if File.exists? config
223
+ load config
224
+ end
205
225
 
206
226
 
207
227
  @window = VER::Window.root_window
@@ -220,19 +240,29 @@ if true
220
240
  @form.bind_key(?', 'select bookmark') do
221
241
  ask_bookmark
222
242
  end
243
+ @form.bind_key(?\M-d, 'View history') do
244
+ popup_history
245
+ end
223
246
 
247
+ header = app_header "0.0.2", :text_center => "ri Documentation Browser", :text_right =>"" #, :color => :black, :bgcolor => :white #, :attr => :bold
224
248
  # this is the old style of printing something directly on the window.
225
249
  # The new style is to use a header
226
- @form.window.printstring 0, 30, "ri documentation browser", $normalcolor, BOLD
250
+ #@form.window.printstring 0, 30, "ri documentation browser", $normalcolor, BOLD
227
251
  r = 1; fc = 1;
228
252
 
229
253
  # this is the old style of using a label at the screen bottom, you can use the status_line
230
254
 
231
255
  v = "Q quit, F1 Help, ? Bindings, f<char>, /, Alt-c, ENTER on Class or Method"
232
- var = RubyCurses::Label.new @form, { :text => v, :row => FFI::NCurses.LINES-2,
233
- :col => fc, :display_length => 100}
256
+ #var = RubyCurses::Label.new @form, { :text => v, :row => FFI::NCurses.LINES-2,
257
+ #:col => fc, :display_length => 100}
258
+ $message = Variable.new
259
+ $message.value = "Message Comes Here"
260
+ @status_line = status_line :row => Ncurses.LINES-1
261
+ @status_line.command {
262
+ "F1 Help | Q Quit | ? Keys | M-c Classes | M-d History | %20s" % [$message.value]
263
+ }
234
264
 
235
- h = FFI::NCurses.LINES-3
265
+ h = FFI::NCurses.LINES-2
236
266
  mylist = `ri -l `.split("\n")
237
267
  w = 25
238
268
 
@@ -317,7 +347,7 @@ if true
317
347
  @window.wrefresh
318
348
  Ncurses::Panel.update_panels
319
349
  while((ch = @window.getchar()) != KEY_F10 )
320
- break if ch == ?Q.ord
350
+ break if ch == ?Q.ord || ch == ?\C-q.getbyte(0)
321
351
  @form.handle_key(ch)
322
352
  @window.wrefresh
323
353
  end
data/lib/ribhu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ribhu
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -91,7 +91,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  segments:
93
93
  - 0
94
- hash: 2856289681820087894
94
+ hash: -1996546408870180195
95
95
  required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  version: '0'
101
101
  segments:
102
102
  - 0
103
- hash: 2856289681820087894
103
+ hash: -1996546408870180195
104
104
  requirements: []
105
105
  rubyforge_project:
106
106
  rubygems_version: 1.8.25