rbcurse 1.4.0 → 1.4.1.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. data/NOTES +68 -0
  2. data/README.markdown +73 -330
  3. data/TODO2.txt +2 -2
  4. data/VERSION +1 -1
  5. data/examples/abasiclist.rb +8 -2
  6. data/examples/alpmenu.rb +1 -1
  7. data/examples/app.rb +1 -24
  8. data/examples/appdirtree.rb +1 -1
  9. data/examples/appemail.rb +8 -14
  10. data/examples/appemaillb.rb +2 -2
  11. data/examples/appgcompose.rb +7 -5
  12. data/examples/common/file.rb +40 -0
  13. data/examples/{rmail.rb → common/rmail.rb} +0 -0
  14. data/examples/data/README.markdown +9 -0
  15. data/examples/data/brew.txt +38 -0
  16. data/examples/data/color.2 +37 -0
  17. data/examples/data/gemlist.txt +60 -0
  18. data/examples/data/lotr.txt +12 -0
  19. data/examples/data/ports.txt +136 -0
  20. data/examples/data/tasks.txt +27 -0
  21. data/examples/{todocsv.csv → data/todocsv.csv} +0 -0
  22. data/examples/data/unix1.txt +21 -0
  23. data/examples/data/unix2.txt +11 -0
  24. data/examples/dbdemo.rb +49 -14
  25. data/examples/{appgmail.rb → deprecated/appgmail.rb} +1 -1
  26. data/examples/{splitp.rb → deprecated/splitp.rb} +0 -0
  27. data/examples/{testscrolllb.rb → deprecated/testscrolllb.rb} +0 -0
  28. data/examples/{testscrollp.rb → deprecated/testscrollp.rb} +0 -0
  29. data/examples/{testscrollta.rb → deprecated/testscrollta.rb} +0 -0
  30. data/examples/{testscrolltable.rb → deprecated/testscrolltable.rb} +0 -0
  31. data/examples/{testsplit.rb → deprecated/testsplit.rb} +0 -0
  32. data/examples/{testsplit2.rb → deprecated/testsplit2.rb} +0 -0
  33. data/examples/{testsplit3.rb → deprecated/testsplit3.rb} +0 -0
  34. data/examples/{testsplit3_1.rb → deprecated/testsplit3_1.rb} +0 -0
  35. data/examples/{testsplit3a.rb → deprecated/testsplit3a.rb} +0 -0
  36. data/examples/{testsplit3b.rb → deprecated/testsplit3b.rb} +0 -0
  37. data/examples/{testsplitta.rb → deprecated/testsplitta.rb} +0 -0
  38. data/examples/{testsplittv.rb → deprecated/testsplittv.rb} +0 -0
  39. data/examples/{testsplittvv.rb → deprecated/testsplittvv.rb} +0 -0
  40. data/examples/{testtpane.rb → deprecated/testtpane.rb} +0 -0
  41. data/examples/{testtpane2.rb → deprecated/testtpane2.rb} +0 -0
  42. data/examples/{testtpanetable.rb → deprecated/testtpanetable.rb} +0 -0
  43. data/examples/dirtree.rb +17 -7
  44. data/examples/experimental/resultsetdemo.rb +280 -0
  45. data/examples/experimental/testmform.rb +35 -0
  46. data/examples/{testscroller.rb → experimental/testscroller.rb} +1 -19
  47. data/examples/experimental/teststackflow.rb +111 -0
  48. data/examples/menu1.rb +1 -0
  49. data/examples/multispl.rb +4 -4
  50. data/examples/newmessagebox.rb +130 -0
  51. data/examples/newtabbedwindow.rb +100 -0
  52. data/examples/newtesttabp.rb +0 -3
  53. data/examples/qdfilechooser.rb +0 -3
  54. data/examples/rfe.rb +134 -18
  55. data/examples/rfe_renderer.rb +48 -2
  56. data/examples/sqlc.rb +2 -1
  57. data/examples/sqlm.rb +0 -2
  58. data/examples/table1.rb +1 -7
  59. data/examples/term2.rb +4 -1
  60. data/examples/test1.rb +0 -5
  61. data/examples/test2.rb +42 -31
  62. data/examples/testapp2.rb +8 -1
  63. data/examples/testchars.rb +0 -4
  64. data/examples/testcombo.rb +5 -9
  65. data/examples/testkeypress.rb +0 -3
  66. data/examples/testmenu.rb +0 -4
  67. data/examples/testmulticomp.rb +3 -5
  68. data/examples/testmulticontainer.rb +94 -0
  69. data/examples/testtable.rb +0 -5
  70. data/examples/testtabp.rb +16 -18
  71. data/examples/testtodo.rb +1 -5
  72. data/examples/testwsshortcuts.rb +64 -0
  73. data/examples/testwsshortcuts2.rb +126 -0
  74. data/examples/viewtodo.rb +1 -4
  75. data/lib/rbcurse.rb +1 -1
  76. data/lib/rbcurse/app.rb +92 -69
  77. data/lib/rbcurse/applicationheader.rb +46 -6
  78. data/lib/rbcurse/celleditor.rb +1 -9
  79. data/lib/rbcurse/comboboxcellrenderer.rb +0 -4
  80. data/lib/rbcurse/common/ansiparser.rb +117 -0
  81. data/{examples → lib/rbcurse/common}/appmethods.rb +25 -0
  82. data/lib/rbcurse/common/basestack.rb +407 -0
  83. data/lib/rbcurse/common/bordertitle.rb +41 -0
  84. data/lib/rbcurse/common/chunk.rb +177 -0
  85. data/lib/rbcurse/common/colorparser.rb +71 -0
  86. data/lib/rbcurse/common/keydefs.rb +30 -0
  87. data/lib/rbcurse/common/widgetshortcuts.rb +302 -0
  88. data/lib/rbcurse/deprecated/README.markdown +12 -0
  89. data/lib/rbcurse/{rscrollpane.rb → deprecated/rscrollpane.rb} +0 -0
  90. data/lib/rbcurse/{rsplitpane.rb → deprecated/rsplitpane.rb} +0 -0
  91. data/lib/rbcurse/{rsplitpane2.rb → deprecated/rsplitpane2.rb} +0 -0
  92. data/lib/rbcurse/{rviewport.rb → deprecated/rviewport.rb} +0 -0
  93. data/lib/rbcurse/experimental/README.markdown +14 -0
  94. data/lib/rbcurse/experimental/resultsettextview.rb +585 -0
  95. data/lib/rbcurse/experimental/stackflow.rb +478 -0
  96. data/lib/rbcurse/extras/bottomline.rb +85 -16
  97. data/lib/rbcurse/extras/box.rb +58 -0
  98. data/lib/rbcurse/extras/directorylist.rb +1 -1
  99. data/lib/rbcurse/extras/horizlist.rb +203 -0
  100. data/lib/rbcurse/extras/listselectable.rb +8 -0
  101. data/lib/rbcurse/extras/multiform.rb +330 -0
  102. data/lib/rbcurse/extras/multilinelabel.rb +142 -0
  103. data/lib/rbcurse/extras/newmessagebox.rb +328 -0
  104. data/lib/rbcurse/extras/newtabbedpane.rb +612 -0
  105. data/lib/rbcurse/extras/newtabbedwindow.rb +68 -0
  106. data/lib/rbcurse/extras/padreader.rb +189 -0
  107. data/lib/rbcurse/extras/rcomboedit.rb +256 -0
  108. data/lib/rbcurse/extras/resultsetbrowser.rb +281 -0
  109. data/lib/rbcurse/extras/statusline.rb +44 -6
  110. data/lib/rbcurse/extras/tabularwidget.rb +141 -104
  111. data/lib/rbcurse/extras/textpad.rb +516 -0
  112. data/lib/rbcurse/extras/viewer.rb +2 -0
  113. data/lib/rbcurse/io.rb +120 -3
  114. data/lib/rbcurse/listcellrenderer.rb +2 -1
  115. data/lib/rbcurse/listkeys.rb +1 -1
  116. data/lib/rbcurse/listscrollable.rb +72 -7
  117. data/lib/rbcurse/rbasiclistbox.rb +64 -12
  118. data/lib/rbcurse/rchangeevent.rb +0 -1
  119. data/lib/rbcurse/rcombo.rb +54 -59
  120. data/lib/rbcurse/rcommandwindow.rb +46 -10
  121. data/lib/rbcurse/rcontainer.rb +415 -0
  122. data/lib/rbcurse/rdialogs.rb +242 -165
  123. data/lib/rbcurse/rinputdataevent.rb +0 -1
  124. data/lib/rbcurse/rlistbox.rb +19 -9
  125. data/lib/rbcurse/rmessagebox.rb +1 -5
  126. data/lib/rbcurse/rmulticontainer.rb +64 -61
  127. data/lib/rbcurse/rmultitextview.rb +0 -2
  128. data/lib/rbcurse/rpopupmenu.rb +0 -2
  129. data/lib/rbcurse/rscrollform.rb +61 -12
  130. data/lib/rbcurse/rtabbedpane.rb +89 -73
  131. data/lib/rbcurse/rtabbedwindow.rb +53 -211
  132. data/lib/rbcurse/rtable.rb +0 -2
  133. data/lib/rbcurse/rtextarea.rb +14 -14
  134. data/lib/rbcurse/rtextview.rb +165 -50
  135. data/lib/rbcurse/rvimsplit.rb +15 -12
  136. data/lib/rbcurse/rwidget.rb +404 -150
  137. data/lib/rbcurse/table/tablecellrenderer.rb +1 -4
  138. data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -3
  139. data/lib/ver/ncurses.rb +1 -9
  140. data/lib/ver/rpad.rb +375 -0
  141. data/lib/ver/window.rb +262 -440
  142. metadata +73 -31
data/examples/test2.rb CHANGED
@@ -14,14 +14,16 @@ require 'rbcurse/rtextarea'
14
14
  require 'rbcurse/rtextview'
15
15
  require 'rbcurse/rmenu'
16
16
  require 'rbcurse/rcombo'
17
+ require 'rbcurse/extras/rcomboedit'
17
18
  require 'rbcurse/listcellrenderer'
18
19
  require 'rbcurse/checkboxcellrenderer'
19
20
  require 'rbcurse/comboboxcellrenderer'
20
21
  require 'rbcurse/celleditor'
21
22
  require 'rbcurse/rlistbox'
22
- require 'rbcurse/rmessagebox'
23
+ require 'rbcurse/rbasiclistbox'
24
+ #require 'rbcurse/rmessagebox'
23
25
  require 'rbcurse/rtree'
24
- require './appmethods.rb'
26
+ require 'rbcurse/common/appmethods.rb'
25
27
  require 'rbcurse/extras/scrollbar'
26
28
  def help_text
27
29
  <<-eos
@@ -71,7 +73,7 @@ if $0 == __FILE__
71
73
  $log.debug "START #{colors} colors test2.rb --------- #{@window} "
72
74
  @form = Form.new @window
73
75
  title = (" "*30) + "Demo of some Ruby Curses Widgets - rbcurse " + Rbcurse::VERSION
74
- Label.new @form, {'text' => title, "row" => 0, "col" => 0, :color => 'green', :bgcolor => 'black'}
76
+ Label.new @form, {'text' => title, :row => 0, :col => 0, :color => 'green', :bgcolor => 'black'}
75
77
  r = 1; fc = 12;
76
78
  mnemonics = %w[ n l r p]
77
79
  %w[ name line regex password].each_with_index do |w,i|
@@ -96,29 +98,25 @@ if $0 == __FILE__
96
98
  $results.value = "A variable"
97
99
  var = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => r, "col" => fc}
98
100
  r += 1
99
- mylist = ["Release gem","Bump version","Fix bugs","Make enhancements", "Brag on rubyforum"]
100
- 0.upto(100) { |v| mylist << "#{v} scrollable data" }
101
- $listdata = Variable.new mylist
102
- listb = Listbox.new @form do
101
+ mylist = File.open("data/tasks.txt",'r').readlines
102
+ #0.upto(100) { |v| mylist << "#{v} scrollable data" }
103
+ listb = BasicListbox.new @form do
103
104
  name "mylist"
104
105
  row r
105
106
  col 1
106
107
  width 40
107
108
  height 11
108
- # list mylist
109
- list_variable $listdata
109
+ list mylist
110
110
  #selection_mode :SINGLE
111
111
  show_selector true
112
- row_selected_symbol "[X] "
113
- row_unselected_symbol "[ ] "
114
- title "C-Space to select"
115
- title_attrib 'reverse'
116
- cell_editing_allowed true
112
+ #row_selected_symbol "*"
113
+ #row_unselected_symbol " "
114
+ selected_bgcolor :white
115
+ selected_color :blue
116
+ title "Todo List"
117
117
  end
118
118
  Scrollbar.new @form, :parent => listb # 2011-10-1 added
119
- #listb.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
120
- #$listdata.value.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
121
- listb.list_data_model.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net", "hi lisp", "hi clojure"
119
+ #listb.list_data_model.insert -1, "rake build", "rake release", "bump version", "fix bugs"
122
120
  col2 = 42
123
121
  texta = TextArea.new @form do
124
122
  name "mytext"
@@ -131,11 +129,13 @@ if $0 == __FILE__
131
129
  print_footer true
132
130
  bind(:CHANGE){|e| $message.value = e.to_s+" CP:"+e.source.curpos.to_s }
133
131
  end
134
- texta << "I expect to pass through this world but once." << "Any good therefore that I can do, or any kindness or abilities that I can show to any fellow creature, let me do it now."
135
- texta << "Let me not defer it or neglect it, for I shall not pass this way again."
136
- texta << " "
137
- texta << " F10 to exit. or click cancel button"
138
- texta << " Or alt-c"
132
+ lines = File.open("data/unix1.txt",'r').readlines
133
+ lines.each { |e| texta << e }
134
+ #texta << "I expect to pass through this world but once." << "Any good therefore that I can do, or any kindness or abilities that I can show to any fellow creature, let me do it now."
135
+ #texta << "Let me not defer it or neglect it, for I shall not pass this way again."
136
+ #texta << " "
137
+ #texta << " F10 to exit. or click cancel button"
138
+ #texta << " Or alt-c"
139
139
 
140
140
  col3 = 92
141
141
  treemodel = nil
@@ -212,7 +212,7 @@ if $0 == __FILE__
212
212
  editable false
213
213
  list %w[left right center]
214
214
  set_label Label.new @form, {'text' => "Align", 'color'=>'cyan','col'=>1, "mnemonic"=>"I"}
215
- list_config 'color' => 'yellow', 'bgcolor'=>'red', 'height' => 4
215
+ list_config :color => :yellow, :bgcolor=>:blue
216
216
  end
217
217
 
218
218
  list = ListDataModel.new( %w[white yellow cyan magenta red blue black])
@@ -220,7 +220,7 @@ if $0 == __FILE__
220
220
  list.bind(:ENTER_ROW) { |obj| $message.value = "ENTER_ROW :#{obj.current_index} : #{obj.selected_item} "; $log.debug " ENTER_ROW: #{$message.value} , #{obj}"; @form.widgets.each { |e| next unless e.is_a? Widget; e.color = obj.selected_item }; @mb.color = obj.selected_item }
221
221
 
222
222
  row += 1
223
- combo1 = ComboBox.new @form do
223
+ combo1 = ComboBoxEdit.new @form do
224
224
  name "combo1"
225
225
  row row
226
226
  col fc
@@ -433,9 +433,10 @@ if $0 == __FILE__
433
433
  filemenu.add(item = RubyCurses::MenuItem.new("Test",'T'))
434
434
  item.command(@form, texta) do |it, form, testa|
435
435
  $message.value = "Testing textarea"
436
- str = "Hello there good friends and fellow rubyists. Here is a textarea that I am testing out with"
437
- str << " some long data, to see how it acts, how the wrapping takes place. Sit back and enjoy the "
438
- str << " bugs as they crop up."
436
+ str = File.open("data/lotr.txt",'r').readlines.join
437
+ #str = "Hello there good friends and fellow rubyists. Here is a textarea that I am testing out with"
438
+ #str << " some long data, to see how it acts, how the wrapping takes place. Sit back and enjoy the "
439
+ #str << " bugs as they crop up."
439
440
  testa.goto_start
440
441
  #testa.cursor_bol
441
442
  testa.handle_key ?\C-a.getbyte(0)
@@ -471,7 +472,7 @@ if $0 == __FILE__
471
472
  item.command(colorlabel){|it, label| att = it.getvalue ? 'reverse' : 'normal'; label.attr(att); label.repaint}
472
473
  @status_line = status_line :row => Ncurses.LINES-2
473
474
  @status_line.command {
474
- "%-20s | F1 Help | F2 Menu | F3 View | F4 Shell | F5 Sh | %20s" % [Time.now, $message.value]
475
+ "F1 Help | F2 Menu | F3 View | F4 Shell | F5 Sh | %20s" % [$message.value]
475
476
  }
476
477
  row += 1 #2
477
478
  ok_button = Button.new @form do
@@ -485,7 +486,7 @@ if $0 == __FILE__
485
486
  mnemonic 'O'
486
487
  end
487
488
  ok_button.command() { |eve|
488
- #alert("Hope you enjoyed this demo ", {'title' => "Hello", :bgcolor => :blue, :color => :white})
489
+ alert("Hope you enjoyed this demo ", {'title' => "Hello", :bgcolor => :blue, :color => :white})
489
490
  sw = case @lookfeel
490
491
  when :dialog
491
492
  progress_dialog :color_pair => $reversecolor, :row_offset => 4, :col_offset => 5
@@ -563,6 +564,15 @@ if $0 == __FILE__
563
564
  $log.debug " returning with #{$config_hash}: #{$config_hash.inspect}"
564
565
  end
565
566
  menu.add(item)
567
+ item = RubyCurses::MenuItem.new "Options2 ..."
568
+ item.command() do |it|
569
+ require './newtabbedwindow'
570
+ tp = SetupTabbedPane.new
571
+ tp.run
572
+ $message.value=$config_hash.inspect
573
+ $log.debug " returning with #{$config_hash}: #{$config_hash.inspect}"
574
+ end
575
+ menu.add(item)
566
576
  item = RubyCurses::MenuItem.new "Shell Command..."
567
577
  item.command { shell_output }
568
578
  menu.add(item)
@@ -616,6 +626,7 @@ if $0 == __FILE__
616
626
  # the main loop
617
627
 
618
628
  while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
629
+ break if ch == ?\C-q.getbyte(0)
619
630
  begin
620
631
  @form.handle_key(ch)
621
632
 
@@ -630,8 +641,8 @@ if $0 == __FILE__
630
641
  end
631
642
  $error_message.value = ""
632
643
  rescue => err
633
- $log.debug( err) if err
634
- $log.debug(err.backtrace.join("\n")) if err
644
+ $log.error( err) if err
645
+ $log.error(err.backtrace.join("\n")) if err
635
646
  alert "Got an exception in test2: #{err} "
636
647
  $error_message.value = ""
637
648
  end
data/examples/testapp2.rb CHANGED
@@ -42,7 +42,14 @@ class Testy
42
42
  }
43
43
 
44
44
  end # stack
45
- #app.safe_loop
45
+ app.status_line :row => last_line()
46
+
47
+ # earlier style without end, everything had to be explicit but quite simple. Hard to edit since you
48
+ # could mess up by inserting inside
49
+ s="#[fg=green]testing chunks #[fg=yellow, bg=red, bold]yellow #[reverse] reverseme#[normal]normal#[bg = black]just yellow#[fg=blue],blue now #[underline] underlined text"
50
+ # revised, i know allow [end] so you can pop back to whatever was there before.
51
+ s="#[fg=green]testing chunks #[fg=yellow, bg=red, bold]yellow #[/end] back to green#[reverse]reverse#[end]#[bg=blue]blue bg #[end],back to green #[/end]plain#[underline] underlined text"
52
+ app.window.printstring_formatted 15,1, s, $datacolor, 'normal'
46
53
  end
47
54
  end
48
55
  end
@@ -1,8 +1,4 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'rubygems'
3
- #require 'ncurses' # FFI
4
1
  require 'logger'
5
- #require 'lib/ver/keyboard'
6
2
  require 'rbcurse'
7
3
  if $0 == __FILE__
8
4
  include RubyCurses
@@ -1,13 +1,11 @@
1
1
  #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'rubygems'
3
- #require 'ncurses' # FFI
4
2
  require 'logger'
5
3
  #require 'lib/rbcurse/mapper'
6
4
  #require 'lib/rbcurse/keylabelprinter'
7
5
  #require 'lib/rbcurse/commonio'
8
6
  #require 'lib/rbcurse/rwidget'
9
7
  #require 'lib/rbcurse/rform'
10
- require 'rbcurse/rcombo'
8
+ require 'rbcurse/extras/rcomboedit'
11
9
  if $0 == __FILE__
12
10
  include RubyCurses
13
11
 
@@ -23,13 +21,11 @@ if $0 == __FILE__
23
21
  # Un post form and free the memory
24
22
 
25
23
  catch(:close) do
26
- colors = Ncurses.COLORS
27
- $log.debug "START #{colors} colors ---------"
28
24
  @form = Form.new @window
29
25
  r = 1; c = 30;
30
26
  mylist = []
31
27
  0.upto(100) { |i| mylist << i.to_s }
32
- combo = ComboBox.new @form do
28
+ combo = ComboBoxEdit.new @form do
33
29
  name "combo"
34
30
  row r
35
31
  col c
@@ -56,7 +52,7 @@ if $0 == __FILE__
56
52
  list = ListDataModel.new( %w[spotty tiger secret pass torvalds qwerty quail toiletry])
57
53
  list.bind(:LIST_DATA_EVENT, name) { |lde,n| $results.value = lde.to_s[0,70]; $log.debug " STA: #{$results} #{lde}" }
58
54
  list.bind(:ENTER_ROW, name) { |obj,n| $results.value = "ENTER_ROW :#{obj.current_index} : #{obj.selected_item} "; $log.debug " ENTER_ROW: #{$results.value} , #{obj}" }
59
- ComboBox.new @form do
55
+ ComboBoxEdit.new @form do
60
56
  name name
61
57
  row r
62
58
  col 30
@@ -72,13 +68,13 @@ if $0 == __FILE__
72
68
  r+=2
73
69
  end
74
70
 
75
- @help = "Use UP and DOWN to navigate values, alt-DOWN for popup, TAB / BACKTAB between fields. F1-quit"
71
+ @help = "Use UP and DOWN to navigate values, alt-DOWN for popup, TAB / BACKTAB between fields. F10-quit"
76
72
  RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
77
73
 
78
74
  @form.repaint
79
75
  @window.wrefresh
80
76
  Ncurses::Panel.update_panels
81
- while((ch = @window.getchar()) != KEY_F1 )
77
+ while((ch = @window.getchar()) != KEY_F10 )
82
78
  @form.handle_key(ch)
83
79
  @window.wrefresh
84
80
  end
@@ -1,6 +1,3 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'rubygems'
3
- #require 'ncurses' # FFI
4
1
  require 'logger'
5
2
  require 'rbcurse'
6
3
  require 'rbcurse/rtextarea'
data/examples/testmenu.rb CHANGED
@@ -1,7 +1,3 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- # this program tests out various widgets.
3
- require 'rubygems'
4
- #require 'ncurses' # FFI
5
1
  require 'logger'
6
2
  require 'rbcurse'
7
3
  #require 'lib/rbcurse/rform'
@@ -1,6 +1,3 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'rubygems'
3
- #require 'ncurses' # FFI
4
1
  require 'logger'
5
2
  require 'rbcurse'
6
3
  require 'rbcurse/rmulticontainer'
@@ -46,13 +43,14 @@ if $0 == __FILE__
46
43
  texta << "Hello World"
47
44
  ctr += 1
48
45
  end
49
- @help = "F1 to quit. M-a to open new component. M-: for menu #{$0} "
46
+ @help = "F10 to quit. M-a to open new component. M-: for menu #{$0} "
50
47
  RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
51
48
 
52
49
  @form.repaint
53
50
  @window.wrefresh
54
51
  Ncurses::Panel.update_panels
55
- while((ch = @window.getchar()) != KEY_F1 )
52
+ while((ch = @window.getchar()) != KEY_F10 )
53
+ break if ch == ?\C-q.getbyte(0)
56
54
  str = keycode_tos ch
57
55
  $log.debug "#{ch} got (#{str})"
58
56
  @form.handle_key ch
@@ -0,0 +1,94 @@
1
+ ##
2
+ # This tests both multicontainer and container
3
+ #
4
+ require 'logger'
5
+ require 'rbcurse'
6
+ require 'rbcurse/rmulticontainer'
7
+ require 'rbcurse/rcontainer'
8
+ require 'rbcurse/rtextarea'
9
+ if $0 == __FILE__
10
+ include RubyCurses
11
+ include RubyCurses::Utils
12
+
13
+ begin
14
+ # Initialize curses
15
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
16
+ $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
17
+ $log.level = Logger::DEBUG
18
+
19
+ @window = VER::Window.root_window
20
+
21
+ catch(:close) do
22
+ colors = Ncurses.COLORS
23
+ $log.debug "START #{colors} colors --------- testmulticomp"
24
+ @form = Form.new @window
25
+ @ctr = 1
26
+ r = 1; c = 30;
27
+
28
+ mc = MultiContainer.new @form do
29
+ name "multic"
30
+ row r
31
+ col c
32
+ width 60
33
+ height 15
34
+ title "Multicontainer"
35
+ end
36
+ ctr = 1
37
+
38
+ c1 = Container.new
39
+ mc.add c1, "A form"
40
+ f1 = Field.new nil do
41
+ name "name"
42
+ text "rahul"
43
+ row 1
44
+ col 10
45
+ label " Name: "
46
+ end
47
+ f2 = Field.new nil, :name => "email", :text => "me@somebody.com", :label => "Email: "
48
+ c1.add( f1, f2)
49
+
50
+ c3 = TextArea.new
51
+ mc.add c3, "Edit Me"
52
+ c2 = Container.new
53
+ mc.add c2, "Another form"
54
+ attrib = 'underline'
55
+ f3 = Field.new do
56
+ name "language"
57
+ text "ruby"
58
+ row 1
59
+ col 10
60
+ label "Language: "
61
+ attr attrib
62
+ end
63
+ f4 = Field.new nil, :name => "version", :text => "1.9.2", :row => 2, :col => 10,
64
+ :label => " Version: ", :attr => attrib
65
+ c2.add( f3, f4)
66
+
67
+ @help = "F10 to quit. M-a to open new component. M-: for menu #{$0} "
68
+ RubyCurses::Label.new @form, {:text => @help, :row => last_line(), :col => 2,
69
+ :color => 'yellow', :bgcolor => 'red'}
70
+ f5 = Field.new @form, :name => "version2", :text => "1.9.2", :row => 20, :col => c, :bgcolor => 'blue',
71
+ :label => "Version: ", :label_color_pair => get_color($datacolor, 'green', 'black')
72
+
73
+ @form.repaint
74
+ @window.wrefresh
75
+ Ncurses::Panel.update_panels
76
+ while((ch = @window.getchar()) != KEY_F10 )
77
+ break if ch == ?\C-q.getbyte(0)
78
+ str = keycode_tos ch
79
+ $log.debug "#{ch} got (#{str})"
80
+ @form.handle_key ch
81
+ @form.repaint
82
+ @window.wrefresh
83
+ end
84
+ end
85
+ rescue => ex
86
+ ensure
87
+ @window.destroy if !@window.nil?
88
+ VER::stop_ncurses
89
+ p ex if ex
90
+ p(ex.backtrace.join("\n")) if ex
91
+ $log.debug( ex) if ex
92
+ $log.debug(ex.backtrace.join("\n")) if ex
93
+ end
94
+ end
@@ -1,8 +1,3 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'rubygems'
3
- #require 'ncurses' # FFI
4
- require 'logger'
5
- #require 'ver/keyboard'
6
1
  require 'rbcurse'
7
2
  require 'rbcurse/rcombo'
8
3
  require 'rbcurse/rtable'
data/examples/testtabp.rb CHANGED
@@ -1,8 +1,3 @@
1
- # this is a test program, tests out tabbed panes. type F1 to exit
2
- #
3
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
4
- require 'rubygems'
5
- #require 'ncurses' # FFI
6
1
  require 'logger'
7
2
  require 'rbcurse'
8
3
  #require 'rbcurse/rtabbedpane'
@@ -16,15 +11,16 @@ class TestTabbedPane
16
11
  def run
17
12
  $config_hash ||= Variable.new Hash.new
18
13
  #configvar.update_command(){ |v| $config_hash[v.source()] = v.value }
19
- @tp = RubyCurses::TabbedWindow.new nil do
20
- height 12
21
- width 50
14
+ @tw = RubyCurses::TabbedWindow.new nil do
15
+ height 18
16
+ width 60
22
17
  row 5
23
- col 10
18
+ col 20
24
19
  button_type :ok
25
20
  end
26
- @tab1 = @tp.add_tab "&Language"
27
- f1 = @tab1.form
21
+ @tp = @tw.tabbed_pane
22
+ @tab1 = @tw.add_tab "&Language"
23
+ f1 = @tp.form @tab1
28
24
  #$radio = Variable.new
29
25
  radio1 = RadioButton.new f1 do
30
26
  #variable $radio
@@ -56,9 +52,10 @@ class TestTabbedPane
56
52
  row 6
57
53
  col 2
58
54
  end
59
- @tab2 = @tp.add_tab "&Settings"
60
- f2 = @tab2.form
61
- r = 3
55
+ @tab2 = @tw.add_tab "&Settings"
56
+ #f2 = @tab2.form
57
+ f2 = @tp.form @tab2
58
+ r = 2
62
59
  butts = [ "Use &HTTP/1.0", "Use &frames", "&Use SSL" ]
63
60
  bcodes = %w[ HTTP, FRAMES, SSL ]
64
61
  butts.each_with_index do |t, i|
@@ -70,8 +67,9 @@ class TestTabbedPane
70
67
  col 4
71
68
  end
72
69
  end
73
- @tab3 = @tp.add_tab "&Editors"
74
- f3 = @tab3.form
70
+ @tab3 = @tw.add_tab "&Editors"
71
+ #f3 = @tab3.form
72
+ f3 = @tp.form @tab3
75
73
  butts = %w[ &Vim E&macs &Jed &Other ]
76
74
  bcodes = %w[ VIM EMACS JED OTHER]
77
75
  row = 3
@@ -85,8 +83,8 @@ class TestTabbedPane
85
83
  end
86
84
  row +=1
87
85
  end
88
- @tp.show
89
- @tp.handle_keys
86
+ @tw.show
87
+ @tw.handle_keys
90
88
  end
91
89
  end
92
90
  if $0 == __FILE__