rbcurse 1.2.0.pre → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  $LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
2
  require 'rubygems'
3
- require 'ncurses'
3
+ #require 'ncurses' # FFI
4
4
  require 'logger'
5
5
  require 'rbcurse'
6
6
  require 'rbcurse/rcombo'
@@ -475,50 +475,50 @@ module ViewTodo
475
475
  def make_popup table
476
476
  require 'rbcurse/rpopupmenu'
477
477
  tablemenu = RubyCurses::PopupMenu.new "Table"
478
- #tablemenu.add(item = RubyCurses::MenuItem.new("Open",'O'))
479
- tablemenu.add(item = RubyCurses::MenuItem.new("&Open"))
478
+ #tablemenu.add(item = RubyCurses::PMenuItem.new("Open",'O'))
479
+ tablemenu.add(item = RubyCurses::PMenuItem.new("&Open"))
480
480
 
481
481
  tablemenu.insert_separator 1
482
- #tablemenu.add(RubyCurses::MenuItem.new "New",'N')
482
+ #tablemenu.add(RubyCurses::PMenuItem.new "New",'N')
483
483
  tablemenu.add(@new_act)
484
- tablemenu.add(item = RubyCurses::MenuItem.new("&Save"))
484
+ tablemenu.add(item = RubyCurses::PMenuItem.new("&Save"))
485
485
  item.command() { @save_cmd.call }
486
486
 
487
- item=RubyCurses::MenuItem.new "Select"
487
+ item=RubyCurses::PMenuItem.new "Select"
488
488
  item.accelerator = "Ctrl-X"
489
489
  item.command() { table.toggle_row_selection() }
490
490
  #item.enabled = false
491
491
  tablemenu.add(item)
492
492
 
493
- item=RubyCurses::MenuItem.new "Clr Selection"
493
+ item=RubyCurses::PMenuItem.new "Clr Selection"
494
494
  item.accelerator = "Alt-e"
495
495
  item.command() { table.clear_selection() }
496
496
  item.enabled = table.selected_row_count > 0 ? true : false
497
497
  tablemenu.add(item)
498
498
 
499
- item=RubyCurses::MenuItem.new "Delete"
499
+ item=RubyCurses::PMenuItem.new "Delete"
500
500
  item.accelerator = "Alt-D"
501
501
  item.command() { @del_cmd.call }
502
502
  tablemenu.add(item)
503
503
 
504
- gotomenu = RubyCurses::Menu.new "&Goto"
504
+ gotomenu = RubyCurses::PMenu.new "&Goto"
505
505
 
506
- item = RubyCurses::MenuItem.new "Top"
506
+ item = RubyCurses::PMenuItem.new "Top"
507
507
  item.accelerator = "Alt-0"
508
508
  item.command() { table.goto_top }
509
509
  gotomenu.add(item)
510
510
 
511
- item = RubyCurses::MenuItem.new "Bottom"
511
+ item = RubyCurses::PMenuItem.new "Bottom"
512
512
  item.accelerator = "Alt-9"
513
513
  item.command() { table.goto_bottom }
514
514
  gotomenu.add(item)
515
515
 
516
- item = RubyCurses::MenuItem.new "Next Page"
516
+ item = RubyCurses::PMenuItem.new "Next Page"
517
517
  item.accelerator = "Ctrl-n"
518
518
  item.command() { table.scroll_forward }
519
519
  gotomenu.add(item)
520
520
 
521
- item = RubyCurses::MenuItem.new "Prev Page"
521
+ item = RubyCurses::PMenuItem.new "Prev Page"
522
522
  item.accelerator = "Ctrl-p"
523
523
  item.command() { table.scroll_backward }
524
524
  gotomenu.add(item)
@@ -365,7 +365,11 @@ module RubyCurses
365
365
  cmdline = str.split
366
366
  cmd = cmdline.shift #.to_sym
367
367
  if respond_to?(cmd, true)
368
- send cmd, *cmdline
368
+ if cmd == "close"
369
+ throw :close
370
+ else
371
+ send cmd, *cmdline
372
+ end
369
373
  else
370
374
  alert "#{self.class} does not respond to #{cmd} "
371
375
  ret = false
@@ -1467,7 +1467,7 @@ module RubyCurses
1467
1467
  require 'rbcurse/rcommandwindow'
1468
1468
  ht = config[:height] || 15
1469
1469
  layout = { :height => ht, :width => Ncurses.COLS-1, :top => Ncurses.LINES-ht+1, :left => 0 }
1470
- rc = CommandWindow.new nil, :layout => layout, :box => true
1470
+ rc = CommandWindow.new nil, :layout => layout, :box => true, :title => config[:title]
1471
1471
  w = rc.window
1472
1472
  #rc.text "There was a quick brown fox who ran over the lazy dog and then went over the moon over and over again and again"
1473
1473
  rc.display_interactive(text) { |l|
@@ -281,7 +281,7 @@ module RubyCurses
281
281
  @repaint_required = true
282
282
  when 27, ?\C-c.getbyte(0)
283
283
  #editing_canceled @current_index if @cell_editing_allowed
284
- cancel_block # block
284
+ #cancel_block # block
285
285
  $multiplier = 0
286
286
  when @KEY_ASK_FIND_FORWARD
287
287
  # ask_search_forward
@@ -164,8 +164,8 @@ module RubyCurses
164
164
  # @param [Widget] component
165
165
  # @param [String] title
166
166
  def add component, title
167
- component.row = @row+@row_offset+1
168
- component.col = @col+@col_offset+1
167
+ component.row = @row+@row_offset+0 # changed 1 to 0 2011-09-14
168
+ component.col = @col+@col_offset+0 # changed 1 to 0 2011-09-14
169
169
  component.width = @width-2
170
170
  component.height = @height-2
171
171
  component.form = @form
@@ -13,6 +13,10 @@ NOTE : this program works but is one of the first programs and is untouched. It
13
13
  since its quite crappy.
14
14
  Also, we should move to Action classes as against just blokcs of code. And action class would have
15
15
  a user friendly string to identifiy the action, as well as a disabled option.
16
+
17
+ I am prefixing class names since they are same as those in rmenu and there's
18
+ some crashing happening when i first execcute rmenu in one app then rpopupmenu
19
+ in another.
16
20
 
17
21
  --------
18
22
  * Date: 2008-11-14 23:43
@@ -21,18 +25,18 @@ a user friendly string to identifiy the action, as well as a disabled option.
21
25
 
22
26
  =end
23
27
  require 'rubygems'
24
- require 'ncurses'
28
+ #require 'ncurses'
25
29
  require 'logger'
26
30
  require 'rbcurse'
27
31
  require 'rbcurse/action'
28
32
 
29
- include Ncurses
33
+ #include Ncurses # FFI 2011-09-8
30
34
  include RubyCurses
31
35
  module RubyCurses
32
36
  extend self
33
37
 
34
38
 
35
- class MenuSeparator
39
+ class PMenuSeparator
36
40
  attr_accessor :enabled
37
41
  attr_accessor :parent
38
42
  attr_accessor :row
@@ -55,7 +59,7 @@ module RubyCurses
55
59
  end
56
60
  end
57
61
  ##
58
- class MenuItem
62
+ class PMenuItem
59
63
  attr_accessor :parent
60
64
  # attr_accessor :window
61
65
  attr_accessor :row
@@ -90,16 +94,16 @@ module RubyCurses
90
94
  @args = args
91
95
  end
92
96
  def on_enter
93
- $log.debug ">>>on enter menuitem : #{@text} #{@row} #{@width} "
97
+ $log.debug ">>>on enter Pmenuitem : #{@text} #{@row} #{@width} "
94
98
  highlight
95
99
  end
96
100
  def on_leave
97
- $log.debug ">>>on leave menuitem : #{@text} "
101
+ $log.debug ">>>on leave Pmenuitem : #{@text} "
98
102
  highlight false
99
103
  end
100
104
  ## XXX it could be a menu again
101
105
  def fire
102
- $log.debug ">>>fire menuitem : #{@text} #{@command} "
106
+ $log.debug ">>>fire Pmenuitem : #{@text} #{@command} "
103
107
  @command.call self, *@args if !@command.nil?
104
108
  @parent.clear_menus
105
109
  return :CLOSE # added 2009-01-02 00:09 to close only actions, not submenus
@@ -143,7 +147,7 @@ module RubyCurses
143
147
  $log.debug "DESTRY menuitem #{@text}"
144
148
  end
145
149
  end
146
- class Menu < MenuItem
150
+ class PMenu < PMenuItem
147
151
  attr_accessor :parent
148
152
  attr_accessor :row
149
153
  attr_accessor :col
@@ -178,7 +182,7 @@ module RubyCurses
178
182
  # create a Menuitem given an Action
179
183
  # if menuitem.kind_of? RubyCurses::Action
180
184
  def create_action_component action
181
- m = MenuItem.new(action.name, action.mnemonic)
185
+ m = PMenuItem.new(action.name, action.mnemonic)
182
186
  m.command { action.call }
183
187
  m.accelerator = action.accelerator
184
188
  return m
@@ -199,10 +203,10 @@ module RubyCurses
199
203
  return self
200
204
  end
201
205
  def insert_separator ix
202
- @items.insert ix, MenuSeparator.new
206
+ @items.insert ix, PMenuSeparator.new
203
207
  end
204
208
  def add_separator
205
- @items << MenuSeparator.new
209
+ @items << PMenuSeparator.new
206
210
  end
207
211
  def get_item i
208
212
  @items[i]
@@ -220,7 +224,7 @@ module RubyCurses
220
224
  if @window.nil?
221
225
  #repaint
222
226
  create_window
223
- if !@parent.is_a? RubyCurses::MenuBar
227
+ if !@parent.is_a? RubyCurses::PMenuBar
224
228
  $log.debug " ADDING self to current menu: #{self}"
225
229
  # xxx highlight true
226
230
  @parent.current_menu << self
@@ -240,7 +244,7 @@ module RubyCurses
240
244
  def repaint # menu.repaint
241
245
  return if @items.nil? or @items.empty?
242
246
  $log.debug "menu repaint: #{@text} row #{@row} col #{@col} "
243
- if !@parent.is_a? RubyCurses::MenuBar
247
+ if !@parent.is_a? RubyCurses::PMenuBar
244
248
  @parent.window.printstring( @row, 0, "|%-*s>|" % [@width-1, @text], $reversecolor)
245
249
  # added 2009-01-23 00:49
246
250
  if !@mnemonic.nil?
@@ -307,7 +311,7 @@ module RubyCurses
307
311
  def on_enter # menu.on_enter
308
312
  $log.debug "menu onenter: #{@text} #{@row} #{@col} "
309
313
  # call parent method. XXX
310
- if @parent.is_a? RubyCurses::MenuBar
314
+ if @parent.is_a? RubyCurses::PMenuBar
311
315
  @parent.window.printstring( @row, @col, " %s " % @text, $datacolor)
312
316
  else
313
317
  highlight
@@ -316,7 +320,7 @@ module RubyCurses
316
320
  $log.debug "menu onenter: #{@text} calling window,show"
317
321
  @window.show
318
322
  select_item 0
319
- elsif @parent.is_a? RubyCurses::MenuBar and @parent.selected
323
+ elsif @parent.is_a? RubyCurses::PMenuBar and @parent.selected
320
324
  # only on the top level do we open a window if a previous one was opened
321
325
  $log.debug "menu onenter: #{@text} calling repaint CLASS: #{@parent.class}"
322
326
  # repaint
@@ -326,7 +330,7 @@ module RubyCurses
326
330
  def on_leave # menu.on_leave
327
331
  $log.debug "menu onleave: #{@text} #{@row} #{@col} "
328
332
  # call parent method. XXX
329
- if @parent.is_a? RubyCurses::MenuBar
333
+ if @parent.is_a? RubyCurses::PMenuBar
330
334
  @parent.window.printstring( @row, @col, " %s " % @text, $reversecolor)
331
335
  @window.hide if !@window.nil?
332
336
  else
@@ -391,7 +395,7 @@ module RubyCurses
391
395
  @visible = false
392
396
  panel = @window.panel
393
397
  Ncurses::Panel.del_panel(panel) if !panel.nil?
394
- @window.delwin if !@window.nil?
398
+ @window.delwin if !@window.nil? # FFI
395
399
  @items.each do |item|
396
400
  #next if item == :SEPARATOR
397
401
  item.destroy
@@ -399,7 +403,7 @@ module RubyCurses
399
403
  @window = nil
400
404
  end
401
405
  # menu LEFT, RIGHT, DOWN, UP, ENTER
402
- # item could be menuitem or another menu
406
+ # item could be Pmenuitem or another menu
403
407
  #
404
408
  def handle_key ch
405
409
  #if !@current_menu.empty?
@@ -421,11 +425,11 @@ module RubyCurses
421
425
  when KEY_ENTER, 10, 13, 32 # added 32 2008-11-28 23:50
422
426
  return cmenu.fire
423
427
  when KEY_LEFT
424
- if cmenu.parent.is_a? RubyCurses::Menu
428
+ if cmenu.parent.is_a? RubyCurses::PMenu
425
429
  $log.debug "LEFT IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}"
426
430
  $log.debug "left IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}"
427
431
  end
428
- if cmenu.parent.is_a? RubyCurses::Menu and !cmenu.parent.current_menu.empty?
432
+ if cmenu.parent.is_a? RubyCurses::PMenu and !cmenu.parent.current_menu.empty?
429
433
  $log.debug " ABOU TO DESTROY DUE TO LEFT"
430
434
  cmenu.parent.current_menu.pop
431
435
  @@menus.pop
@@ -436,11 +440,11 @@ module RubyCurses
436
440
  end
437
441
  when KEY_RIGHT
438
442
  $log.debug "RIGHTIN MENU : "
439
- if cmenu.parent.is_a? RubyCurses::Menu
443
+ if cmenu.parent.is_a? RubyCurses::PMenu
440
444
  $log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.parent.current_menu.length}"
441
445
  $log.debug "right IN MENU : #{cmenu.parent.class} len: #{cmenu.current_menu.length}"
442
446
  end
443
- if cmenu.parent.is_a? RubyCurses::Menu and !cmenu.parent.current_menu.empty?
447
+ if cmenu.parent.is_a? RubyCurses::PMenu and !cmenu.parent.current_menu.empty?
444
448
  $log.debug " ABOU TO DESTROY DUE TO RIGHT"
445
449
  cmenu.parent.current_menu.pop
446
450
  @@menus.pop
@@ -464,7 +468,7 @@ module RubyCurses
464
468
  if key == item.mnemonic.downcase
465
469
  cmenu.select_item ix # 2009-01-23 13:32 so focus moves to menu
466
470
  ret = item.fire
467
- return ret # 0 # 2009-01-23 00:43 menuitem returns CLOSE, menu 0
471
+ return ret # 0 # 2009-01-23 00:43 Pmenuitem returns CLOSE, menu 0
468
472
  end
469
473
  end
470
474
  return :UNHANDLED
@@ -479,7 +483,7 @@ module RubyCurses
479
483
  select_item 0
480
484
  end
481
485
  end
482
- class PopupMenu < Menu
486
+ class PopupMenu < PMenu
483
487
  def initialize text, &block
484
488
  @row_margin = 0
485
489
  @@row = 0
@@ -524,7 +528,7 @@ module RubyCurses
524
528
  @visible = false
525
529
  panel = @window.panel
526
530
  Ncurses::Panel.del_panel(panel) if !panel.nil?
527
- @window.delwin if !@window.nil?
531
+ @window.delwin if !@window.nil? # FFI
528
532
  @items.each do |item|
529
533
  item.destroy
530
534
  end
@@ -535,7 +539,7 @@ module RubyCurses
535
539
  # An application related menubar.
536
540
  # Currently, I am adding this to a form. But should this not be application specific ?
537
541
  # It should popup no matter which window you are on ?? XXX
538
- class MenuBar
542
+ class PMenuBar
539
543
  attr_reader :items
540
544
  attr_reader :window
541
545
  attr_reader :panel
@@ -704,7 +708,7 @@ module RubyCurses
704
708
  end
705
709
  end # menubar
706
710
 
707
- class CheckBoxMenuItem < MenuItem
711
+ class PCheckBoxMenuItem < PMenuItem
708
712
  attr_reader :checkbox
709
713
  def initialize text, mnemonic=nil, &block
710
714
  @checkbox = CheckBox.new nil
@@ -86,7 +86,8 @@ module RubyCurses
86
86
  @col_offset = @row_offset = 1
87
87
 
88
88
  super
89
- @_events.push(*[:TABLE_TRAVERSAL_EVENT,:TABLE_EDITING_EVENT])
89
+ # added LIST event since bombing when selecting a row in table 2011-09-8 FFI
90
+ @_events.push(*[:TABLE_TRAVERSAL_EVENT,:TABLE_EDITING_EVENT, :LIST_SELECTION_EVENT])
90
91
  init_vars
91
92
  install_list_keys
92
93
  install_keys_bindings
@@ -497,6 +497,7 @@ module RubyCurses
497
497
  def sanitize content #:nodoc:
498
498
  if content.is_a? String
499
499
  content.chomp!
500
+ content = content.encode("ASCII-8BIT", :invalid => :replace, :undef => :replace, :replace => "?")
500
501
  content.gsub!(/\t/, ' ') # don't display tab
501
502
  content.gsub!(/[^[:print:]]/, '') # don't display non print characters
502
503
  else
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbcurse
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: true
5
- segments:
6
- - 1
7
- - 2
8
- - 0
9
- - pre
10
- version: 1.2.0.pre
4
+ prerelease:
5
+ version: 1.2.0
11
6
  platform: ruby
12
7
  authors:
13
8
  - Rahul Kumar
@@ -15,11 +10,10 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-11-20 00:00:00 +05:30
19
- default_executable:
13
+ date: 2011-09-14 00:00:00 Z
20
14
  dependencies: []
21
15
 
22
- description: Ruby curses widgets for easy application development on text terminals (ruby 1.9, 1.8)
16
+ description: Ruby curses/ncurses widgets for easy application development on text terminals (ruby 1.9, 1.8)
23
17
  email: sentinel1879@gmail.com
24
18
  executables: []
25
19
 
@@ -41,9 +35,11 @@ files:
41
35
  - examples/README.txt
42
36
  - examples/abasiclist.rb
43
37
  - examples/alpmenu.rb
38
+ - examples/app.rb
44
39
  - examples/appdirtree.rb
45
40
  - examples/appemail.rb
46
41
  - examples/appemaillb.rb
42
+ - examples/appgcompose.rb
47
43
  - examples/appgmail.rb
48
44
  - examples/atree.rb
49
45
  - examples/data.txt
@@ -65,6 +61,8 @@ files:
65
61
  - examples/term2.rb
66
62
  - examples/test1.rb
67
63
  - examples/test2.rb
64
+ - examples/testapp.rb
65
+ - examples/testapp2.rb
68
66
  - examples/testchars.rb
69
67
  - examples/testcombo.rb
70
68
  - examples/testkeypress.rb
@@ -172,25 +170,12 @@ files:
172
170
  - lib/ver/ncurses.rb
173
171
  - lib/ver/window.rb
174
172
  - test/test_rbcurse.rb
175
- - examples/app.rb
176
- - examples/appcombo.rb
177
- - examples/appgcompose.rb
178
- - examples/cdir/testmultispl.rb
179
- - examples/focusmanager.rb
180
- - examples/imap.rb
181
- - examples/s.rb
182
- - examples/scrollbar.rb
183
- - examples/term.rb
184
- - examples/testapp.rb
185
- - examples/testapp2.rb
186
- - examples/testgmail.rb
187
- has_rdoc: true
188
173
  homepage: http://rbcurse.rubyforge.org/
189
174
  licenses: []
190
175
 
191
176
  post_install_message:
192
- rdoc_options:
193
- - --charset=UTF-8
177
+ rdoc_options: []
178
+
194
179
  require_paths:
195
180
  - lib
196
181
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -198,91 +183,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
198
183
  requirements:
199
184
  - - ">="
200
185
  - !ruby/object:Gem::Version
201
- segments:
202
- - 0
203
186
  version: "0"
204
187
  required_rubygems_version: !ruby/object:Gem::Requirement
205
188
  none: false
206
189
  requirements:
207
- - - ">"
190
+ - - ">="
208
191
  - !ruby/object:Gem::Version
209
- segments:
210
- - 1
211
- - 3
212
- - 1
213
- version: 1.3.1
192
+ version: "0"
214
193
  requirements: []
215
194
 
216
195
  rubyforge_project: rbcurse
217
- rubygems_version: 1.3.7
196
+ rubygems_version: 1.8.8
218
197
  signing_key:
219
198
  specification_version: 3
220
- summary: Ruby ncurses Toolkit
221
- test_files:
222
- - test/test_rbcurse.rb
223
- - examples/abasiclist.rb
224
- - examples/alpmenu.rb
225
- - examples/app.rb
226
- - examples/appcombo.rb
227
- - examples/appdirtree.rb
228
- - examples/appemail.rb
229
- - examples/appemaillb.rb
230
- - examples/appgcompose.rb
231
- - examples/appgmail.rb
232
- - examples/atree.rb
233
- - examples/cdir/testmultispl.rb
234
- - examples/dirtree.rb
235
- - examples/focusmanager.rb
236
- - examples/imap.rb
237
- - examples/keytest.rb
238
- - examples/menu1.rb
239
- - examples/mpad2.rb
240
- - examples/multispl.rb
241
- - examples/newtesttabp.rb
242
- - examples/qdfilechooser.rb
243
- - examples/rfe.rb
244
- - examples/rfe_renderer.rb
245
- - examples/rmail.rb
246
- - examples/s.rb
247
- - examples/scrollbar.rb
248
- - examples/splitp.rb
249
- - examples/sqlc.rb
250
- - examples/sqlm.rb
251
- - examples/table1.rb
252
- - examples/term.rb
253
- - examples/term2.rb
254
- - examples/test1.rb
255
- - examples/test2.rb
256
- - examples/testapp.rb
257
- - examples/testapp2.rb
258
- - examples/testchars.rb
259
- - examples/testcombo.rb
260
- - examples/testgmail.rb
261
- - examples/testkeypress.rb
262
- - examples/testlistbox.rb
263
- - examples/testmenu.rb
264
- - examples/testmulticomp.rb
265
- - examples/testmultispl.rb
266
- - examples/testree.rb
267
- - examples/testscroller.rb
268
- - examples/testscrolllb.rb
269
- - examples/testscrollp.rb
270
- - examples/testscrollta.rb
271
- - examples/testscrolltable.rb
272
- - examples/testsplit.rb
273
- - examples/testsplit2.rb
274
- - examples/testsplit3.rb
275
- - examples/testsplit3_1.rb
276
- - examples/testsplit3a.rb
277
- - examples/testsplit3b.rb
278
- - examples/testsplitta.rb
279
- - examples/testsplittv.rb
280
- - examples/testsplittvv.rb
281
- - examples/testtable.rb
282
- - examples/testtabp.rb
283
- - examples/testtodo.rb
284
- - examples/testtpane.rb
285
- - examples/testtpane2.rb
286
- - examples/testtpanetable.rb
287
- - examples/testvimsplit.rb
288
- - examples/viewtodo.rb
199
+ summary: Ruby ncurses Toolkit using ffi since v1.2.3
200
+ test_files: []
201
+