rbcurse 1.4.1 → 1.5.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/CHANGELOG +31 -0
  2. data/README.markdown +69 -11
  3. data/VERSION +1 -1
  4. data/lib/rbcurse.rb +5 -5
  5. metadata +10 -198
  6. data/Makefile +0 -21
  7. data/Manifest.txt +0 -91
  8. data/TODO +0 -372
  9. data/TODO2.txt +0 -118
  10. data/examples/README.txt +0 -67
  11. data/examples/abasiclist.rb +0 -33
  12. data/examples/alpmenu.rb +0 -42
  13. data/examples/app.rb +0 -859
  14. data/examples/app.sample +0 -10
  15. data/examples/appdirtree.rb +0 -75
  16. data/examples/appemail.rb +0 -191
  17. data/examples/appemaillb.rb +0 -308
  18. data/examples/appgcompose.rb +0 -315
  19. data/examples/atree.rb +0 -64
  20. data/examples/common/file.rb +0 -40
  21. data/examples/common/rmail.rb +0 -257
  22. data/examples/data.txt +0 -683
  23. data/examples/data/README.markdown +0 -9
  24. data/examples/data/brew.txt +0 -38
  25. data/examples/data/color.2 +0 -37
  26. data/examples/data/gemlist.txt +0 -60
  27. data/examples/data/lotr.txt +0 -12
  28. data/examples/data/ports.txt +0 -136
  29. data/examples/data/tasks.txt +0 -27
  30. data/examples/data/todocsv.csv +0 -28
  31. data/examples/data/unix1.txt +0 -21
  32. data/examples/data/unix2.txt +0 -11
  33. data/examples/dbdemo.rb +0 -495
  34. data/examples/deprecated/appgmail.rb +0 -952
  35. data/examples/deprecated/splitp.rb +0 -56
  36. data/examples/deprecated/testscrolllb.rb +0 -86
  37. data/examples/deprecated/testscrollp.rb +0 -88
  38. data/examples/deprecated/testscrollta.rb +0 -80
  39. data/examples/deprecated/testscrolltable.rb +0 -165
  40. data/examples/deprecated/testsplit.rb +0 -87
  41. data/examples/deprecated/testsplit2.rb +0 -123
  42. data/examples/deprecated/testsplit3.rb +0 -215
  43. data/examples/deprecated/testsplit3_1.rb +0 -244
  44. data/examples/deprecated/testsplit3a.rb +0 -215
  45. data/examples/deprecated/testsplit3b.rb +0 -237
  46. data/examples/deprecated/testsplitta.rb +0 -148
  47. data/examples/deprecated/testsplittv.rb +0 -142
  48. data/examples/deprecated/testsplittvv.rb +0 -144
  49. data/examples/deprecated/testtpane.rb +0 -215
  50. data/examples/deprecated/testtpane2.rb +0 -145
  51. data/examples/deprecated/testtpanetable.rb +0 -203
  52. data/examples/dirtree.rb +0 -88
  53. data/examples/experimental/resultsetdemo.rb +0 -280
  54. data/examples/experimental/testmform.rb +0 -35
  55. data/examples/experimental/testscroller.rb +0 -117
  56. data/examples/experimental/teststackflow.rb +0 -111
  57. data/examples/menu1.rb +0 -112
  58. data/examples/multispl.rb +0 -86
  59. data/examples/newmessagebox.rb +0 -130
  60. data/examples/newtabbedwindow.rb +0 -100
  61. data/examples/newtesttabp.rb +0 -121
  62. data/examples/qdfilechooser.rb +0 -68
  63. data/examples/rfe.rb +0 -1195
  64. data/examples/rfe_renderer.rb +0 -121
  65. data/examples/sqlc.rb +0 -454
  66. data/examples/sqlm.rb +0 -437
  67. data/examples/sqlt.rb +0 -408
  68. data/examples/status.txt +0 -68
  69. data/examples/table1.rb +0 -24
  70. data/examples/term2.rb +0 -84
  71. data/examples/test1.rb +0 -239
  72. data/examples/test2.rb +0 -674
  73. data/examples/testapp.rb +0 -44
  74. data/examples/testapp2.rb +0 -58
  75. data/examples/testchars.rb +0 -137
  76. data/examples/testcombo.rb +0 -91
  77. data/examples/testkeypress.rb +0 -66
  78. data/examples/testlistbox.rb +0 -113
  79. data/examples/testmenu.rb +0 -101
  80. data/examples/testmulticomp.rb +0 -70
  81. data/examples/testmulticontainer.rb +0 -94
  82. data/examples/testmultispl.rb +0 -199
  83. data/examples/testree.rb +0 -106
  84. data/examples/testtable.rb +0 -263
  85. data/examples/testtabp.rb +0 -107
  86. data/examples/testtodo.rb +0 -584
  87. data/examples/testvimsplit.rb +0 -112
  88. data/examples/testwsshortcuts.rb +0 -64
  89. data/examples/testwsshortcuts2.rb +0 -126
  90. data/examples/todo.db +0 -0
  91. data/examples/todo.yml +0 -191
  92. data/examples/viewtodo.rb +0 -574
  93. data/lib/rbcurse/action.rb +0 -40
  94. data/lib/rbcurse/app.rb +0 -1374
  95. data/lib/rbcurse/applicationheader.rb +0 -102
  96. data/lib/rbcurse/celleditor.rb +0 -112
  97. data/lib/rbcurse/checkboxcellrenderer.rb +0 -57
  98. data/lib/rbcurse/colormap.rb +0 -159
  99. data/lib/rbcurse/comboboxcellrenderer.rb +0 -30
  100. data/lib/rbcurse/common/ansiparser.rb +0 -117
  101. data/lib/rbcurse/common/appmethods.rb +0 -112
  102. data/lib/rbcurse/common/basestack.rb +0 -407
  103. data/lib/rbcurse/common/bordertitle.rb +0 -41
  104. data/lib/rbcurse/common/chunk.rb +0 -177
  105. data/lib/rbcurse/common/colorparser.rb +0 -71
  106. data/lib/rbcurse/common/keydefs.rb +0 -30
  107. data/lib/rbcurse/common/widgetshortcuts.rb +0 -302
  108. data/lib/rbcurse/defaultlistselectionmodel.rb +0 -79
  109. data/lib/rbcurse/deprecated/README.markdown +0 -12
  110. data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
  111. data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
  112. data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
  113. data/lib/rbcurse/deprecated/rviewport.rb +0 -204
  114. data/lib/rbcurse/experimental/README.markdown +0 -14
  115. data/lib/rbcurse/experimental/resultsettextview.rb +0 -585
  116. data/lib/rbcurse/experimental/stackflow.rb +0 -478
  117. data/lib/rbcurse/extras/bottomline.rb +0 -1850
  118. data/lib/rbcurse/extras/box.rb +0 -58
  119. data/lib/rbcurse/extras/directorylist.rb +0 -467
  120. data/lib/rbcurse/extras/directorytree.rb +0 -69
  121. data/lib/rbcurse/extras/divider.rb +0 -310
  122. data/lib/rbcurse/extras/focusmanager.rb +0 -31
  123. data/lib/rbcurse/extras/horizlist.rb +0 -203
  124. data/lib/rbcurse/extras/listselectable.rb +0 -264
  125. data/lib/rbcurse/extras/masterdetail.rb +0 -166
  126. data/lib/rbcurse/extras/menutree.rb +0 -63
  127. data/lib/rbcurse/extras/multiform.rb +0 -330
  128. data/lib/rbcurse/extras/multilinelabel.rb +0 -142
  129. data/lib/rbcurse/extras/newmessagebox.rb +0 -328
  130. data/lib/rbcurse/extras/newtabbedpane.rb +0 -612
  131. data/lib/rbcurse/extras/newtabbedwindow.rb +0 -68
  132. data/lib/rbcurse/extras/padreader.rb +0 -189
  133. data/lib/rbcurse/extras/rcomboedit.rb +0 -256
  134. data/lib/rbcurse/extras/resultsetbrowser.rb +0 -281
  135. data/lib/rbcurse/extras/rlink.rb +0 -27
  136. data/lib/rbcurse/extras/rmenulink.rb +0 -21
  137. data/lib/rbcurse/extras/scrollbar.rb +0 -143
  138. data/lib/rbcurse/extras/statusline.rb +0 -94
  139. data/lib/rbcurse/extras/stdscrwindow.rb +0 -309
  140. data/lib/rbcurse/extras/tableextended.rb +0 -40
  141. data/lib/rbcurse/extras/tabular.rb +0 -264
  142. data/lib/rbcurse/extras/tabularwidget.rb +0 -1150
  143. data/lib/rbcurse/extras/textpad.rb +0 -516
  144. data/lib/rbcurse/extras/viewer.rb +0 -136
  145. data/lib/rbcurse/io.rb +0 -850
  146. data/lib/rbcurse/keylabelprinter.rb +0 -178
  147. data/lib/rbcurse/listcellrenderer.rb +0 -140
  148. data/lib/rbcurse/listeditable.rb +0 -310
  149. data/lib/rbcurse/listkeys.rb +0 -37
  150. data/lib/rbcurse/listscrollable.rb +0 -564
  151. data/lib/rbcurse/listselectable.rb +0 -142
  152. data/lib/rbcurse/mapper.rb +0 -130
  153. data/lib/rbcurse/orderedhash.rb +0 -77
  154. data/lib/rbcurse/ractionevent.rb +0 -67
  155. data/lib/rbcurse/rbasiclistbox.rb +0 -768
  156. data/lib/rbcurse/rchangeevent.rb +0 -27
  157. data/lib/rbcurse/rcombo.rb +0 -238
  158. data/lib/rbcurse/rcommandwindow.rb +0 -587
  159. data/lib/rbcurse/rcontainer.rb +0 -415
  160. data/lib/rbcurse/rdialogs.rb +0 -451
  161. data/lib/rbcurse/rinputdataevent.rb +0 -47
  162. data/lib/rbcurse/rlistbox.rb +0 -1196
  163. data/lib/rbcurse/rmenu.rb +0 -939
  164. data/lib/rbcurse/rmessagebox.rb +0 -348
  165. data/lib/rbcurse/rmulticontainer.rb +0 -304
  166. data/lib/rbcurse/rmultisplit.rb +0 -722
  167. data/lib/rbcurse/rmultitextview.rb +0 -306
  168. data/lib/rbcurse/rpopupmenu.rb +0 -755
  169. data/lib/rbcurse/rprogress.rb +0 -118
  170. data/lib/rbcurse/rscrollform.rb +0 -418
  171. data/lib/rbcurse/rtabbedpane.rb +0 -1158
  172. data/lib/rbcurse/rtabbedwindow.rb +0 -167
  173. data/lib/rbcurse/rtable.rb +0 -1718
  174. data/lib/rbcurse/rtextarea.rb +0 -920
  175. data/lib/rbcurse/rtextview.rb +0 -761
  176. data/lib/rbcurse/rtree.rb +0 -780
  177. data/lib/rbcurse/rvimsplit.rb +0 -763
  178. data/lib/rbcurse/rwidget.rb +0 -2915
  179. data/lib/rbcurse/scrollable.rb +0 -301
  180. data/lib/rbcurse/table/tablecellrenderer.rb +0 -86
  181. data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -98
  182. data/lib/rbcurse/tree/treecellrenderer.rb +0 -150
  183. data/lib/rbcurse/tree/treemodel.rb +0 -428
  184. data/lib/rbcurse/undomanager.rb +0 -188
  185. data/lib/rbcurse/vieditable.rb +0 -144
  186. data/lib/ver/keyboard.rb +0 -150
  187. data/lib/ver/keyboard2.rb +0 -170
  188. data/lib/ver/ncurses.rb +0 -218
  189. data/lib/ver/panel.rb +0 -162
  190. data/lib/ver/rpad.rb +0 -375
  191. data/lib/ver/window.rb +0 -882
  192. data/test/test_rbcurse.rb +0 -0
data/examples/status.txt DELETED
@@ -1,68 +0,0 @@
1
- PROGRAM STATUS
2
- ==============
3
- /// vim:ts=4:sw=4:tw=80:ai:formatoptions=tcqnl:
4
-
5
- I need to maintain the status of various test programs, what all is working and
6
- particularly what is not, after testing. That way after making changes if
7
- something is not working, i know whether it was a newly introduced issue or an
8
- existing issue that was not closed.
9
-
10
-
11
- testsplit3_1.rb ERROR
12
- 2010-02-08 20:47
13
- ERROR
14
- M-w works on left split to jump. C-a C-e etc working fine.
15
-
16
- [ ] TAB no longer working to go to right split. Tab puts me in the top left corner
17
- of current split.
18
-
19
- ------------
20
- testsplit3.rb
21
- 2010-02-08 20:49
22
- OK
23
-
24
- M-w working.
25
- Tab working to get to right side.
26
-
27
- ------------
28
- testsplit3a.rb ERROR
29
- 2010-02-08 20:53
30
- ERROR
31
-
32
- Display. Left top split shows NOTES instead of README. After cursor movement,
33
- it shows README.
34
- Middle separator not showing.
35
- Cursor off by -2, -1 in top left.
36
- TAB does not go to right split.
37
- M-w brings bottom tab to top!
38
- ------------
39
-
40
- testsplitta.rb
41
- 2010-02-08 21:00
42
- OKAY
43
-
44
- M-w
45
- Ca Ce
46
- M- M+ M=
47
- Cursor pos
48
-
49
- ------------
50
- testsplittv.rb
51
- 2010-02-08 21:37
52
- OKAY
53
-
54
- M-w
55
- Ca Ce
56
- + - =
57
- curpos
58
-
59
- ------------
60
- testsplittvv.rb
61
- 2010-02-08 21:39
62
- OKAY
63
-
64
- M-w
65
- Ca Ce
66
- + = -
67
- Cn Tab Cn
68
- ------------
data/examples/table1.rb DELETED
@@ -1,24 +0,0 @@
1
- require 'rbcurse/app'
2
-
3
- if $0 == __FILE__
4
- # NOTE try using the readonly tabular or tabular widget instead, see term2.rb
5
- App.new do
6
- @window.printstring 1, 30, "Demo of Table - rbcurse", $normalcolor, 'reverse'
7
- @window.printstring 2, 30, "Hit F1 to quit", $datacolor, 'normal'
8
- data = [["Roger Federer",16,"SWI"],
9
- ["Pete Sampras",14, "USA"],
10
- ["Roy Emerson", 12, "AUS"],
11
- ["Bjorn Borg", 11, "SWE"],
12
- ["Rod Laver", 11, "AUS"],
13
- ["Bill Tilden", 10, "USA"]]
14
- colnames = %w[ Player Wins Nation ]
15
- stack :margin_top => 3, :margin => 10 do
16
- # we leave out :width so it gets calculated by column_widths
17
- t = table :height => 10, :columns => colnames, :data => data, :column_widths => [15,5,10], :extended_keys => true
18
- # :estimate_widths => true
19
- # other options are :column_widths => [12,4,12]
20
- # :size_to_fit => true
21
-
22
- end
23
- end
24
- end
data/examples/term2.rb DELETED
@@ -1,84 +0,0 @@
1
- require 'rbcurse/app'
2
- require 'rbcurse/extras/tabular'
3
- require 'rbcurse/extras/scrollbar'
4
-
5
- App.new do
6
- header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "Tabular Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
7
- message "Press F10 to escape from here"
8
-
9
- stack :margin_top => 2, :margin => 5, :width => 30 do
10
- t = Tabular.new(['a', 'b'], [1, 2], [3, 4])
11
- list_box :list => t.render
12
- t = Tabular.new ['a', 'b']
13
- t << [1, 2]
14
- t << [3, 4]
15
- t << [4, 6]
16
- #list_box :list => t.to_s.split("\n")
17
- list_box :list => t.render
18
- end # stack
19
- r = `/bin/df -gh` # stock BSD df
20
- #r = `df -gh` # I've installed brew, the df (maybe coreutils gives an error due to g option"
21
-
22
- raise "df -gh not returning anything. correct command here. Try removing g option" if r == ""
23
- # on my system there are extra spaces so i need to remove them, or else
24
- # there'll be a mismatch between headers and columns
25
- r.gsub!("Mounted on", "Mounted_on")
26
- r.gsub!("map ", "map_")
27
- res = r.split("\n")
28
- heads = res.shift.split
29
- t = Tabular.new do |t|
30
- t.headings = heads
31
- #t.headings = 'First Name', 'Last Name', 'Email'
32
- #t << %w( TJ Holowaychuk tj@vision-media.ca )
33
- #t << %w( TJ Holowaychuk tj@vision-media.ca 1 2 3 )
34
- #t << %w( Bob Someone bob@vision-media.ca )
35
- #t << %w( Joe Whatever bob@vision-media.ca )
36
-
37
- #res.each { |e| t << e.split.flatten }
38
- res.each { |e| t.add_row e.split }
39
- end
40
-
41
- t = t.render
42
- wid = t[0].length + 2
43
- stack :margin_top => 2, :margin => 35, :width => wid do
44
- list_box :list => t, :title => '[df -gh]'
45
-
46
- r = `ls -l`
47
- res = r.split("\n")
48
-
49
- t = Tabular.new do
50
- # self.headings = 'Perm', 'Gr', 'User', 'U', 'Size', 'Mon', 'Date', 'Time', 'File' # changed 2011 dts
51
- self.headings = 'User', 'Size', 'Mon', 'Date', 'Time', 'File'
52
- res.each { |e|
53
- cols = e.split
54
- next if cols.count < 6
55
- cols = cols[3..-1]
56
- cols = cols[0..5] if cols.count > 6
57
- #cols[1] = cols[1].to_i
58
- add_row cols
59
- }
60
- column_width 1, 6
61
- align_column 1, :right
62
- #self.headings = 'First Name', 'Last Name', 'Email'
63
- #add_row ['Roald', 'Amundsen', 'ra@explorers.org']
64
- #add_row ['Francis', 'Drake', 'joe@ducks.com']
65
- #add_row ['Hsuan', 'Tsang', 'tsang@asia.org']
66
- #add_separator
67
- #add_row ['Ernest', 'Shackleton', 'jack@radio-schakc.org']
68
- #add_row ['Fa', 'Hsien', 'fa@sheen.net']
69
- #add_row ['Vasco', 'Da Gama', 'bob@vasco.org']
70
- #add_row ['David', 'Livingstone', 'jack@trolls.com']
71
- ##add_row ['Total', { :value => '3', :colspan => 2, :alignment => :right }]
72
- #align_column 1, :center
73
- #self.numbering = true
74
- end
75
- #lb = list_box :list => t.render2
76
- lb = textview :set_content => t.render, :height => 15, :title => '[ls -l]'
77
- lb.bind(:PRESS){|tae|
78
- alert "Pressed list on line #{tae.current_index} #{tae.word_under_cursor(nil, nil, "|")} "
79
- }
80
- Scrollbar.new @form, :parent => lb
81
- #make a textview that is vienabled by default.
82
- end
83
-
84
- end # app
data/examples/test1.rb DELETED
@@ -1,239 +0,0 @@
1
- # this is a test program, tests out messageboxes. type F1 to exit
2
- # 2008-12-17 22:13 tried out the listdatamodel
3
- # Certain terminals are not displaying background colors correctly.
4
- # TERM=screen does but does not show UNDERLINES.
5
- # TERM=xterm-color does but does not trap F1, f2 etc
6
- # TERM=xterm does not but other things are fine.
7
- #
8
- require 'logger'
9
- require 'rbcurse'
10
- require 'rbcurse/rmessagebox'
11
-
12
- if $0 == __FILE__
13
- # Initialize curses
14
- begin
15
- # XXX update with new color and kb
16
- VER::start_ncurses # this is initializing colors via ColorMap.setup
17
- $log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"rbc13.log")))
18
- $log.level = Logger::DEBUG
19
-
20
- # @window = VER::Window.root_window
21
-
22
-
23
- catch(:close) do
24
- choice = ARGV[0] && ARGV[0].to_i || 3
25
- $log.debug "START MESSAGE BOX TEST #{ARGV[0]}. choice==#{choice} ---------"
26
- # need to pass a form, not window.
27
- case choice
28
- when 1
29
- @mb = RubyCurses::MessageBox.new do
30
- title "Enter your name"
31
- message "Enter your name"
32
- type :list
33
- button_type :ok_cancel
34
- list %w[john tim lee wong rahul edward why chad andy]
35
- list_selection_mode :multiple
36
- default_values %w[ lee why ]
37
-
38
- default_button 0
39
- end
40
- when 2
41
- @mb = RubyCurses::MessageBox.new do
42
- title "Color selector"
43
- message "Select a color"
44
- type :custom
45
- button_type :custom
46
- buttons %w[&red &green &blue &yellow]
47
- underlines [0,0,0,0]
48
- default_button 0
49
- end
50
- when 3
51
- config = {}
52
- config["input_config"] = {}
53
- config["input_config"]["chars_allowed"]=/[^xzq]/
54
- config["input_config"]["valid_regex"]=/[A-Z][a-z]*/
55
- @mb = RubyCurses::MessageBox.new nil, config do
56
- title "Enter your name"
57
- #message "Enter your first name. You are not permitted to enter x z or q and must enter a capital first"
58
- message "Enter your first name. "
59
- type :input
60
- button_type :ok_cancel
61
- default_value "Rahul"
62
- end
63
- when 4
64
- @form = RubyCurses::Form.new nil
65
- field_list = []
66
- titlelabel = RubyCurses::Label.new @form, {'text' => 'User', 'row'=>3, 'col'=>4, 'color'=>'black', 'bgcolor'=>'white', 'mnemonic'=>'U'}
67
- field_list << titlelabel
68
- field = RubyCurses::Field.new @form do
69
- name "url"
70
- row 3
71
- col 10
72
- display_length 30
73
- # set_buffer "http://"
74
- set_label titlelabel
75
- end
76
- checkbutton = RubyCurses::CheckBox.new @form do
77
- # variable $results
78
- #value = true
79
- onvalue "Selected cb "
80
- offvalue "UNselected cb"
81
- color 'black'
82
- bgcolor 'white'
83
- text "No &frames"
84
- row 4
85
- col 4
86
- end
87
- field_list << field
88
- field_list << checkbutton
89
- checkbutton = RubyCurses::CheckBox.new @form do
90
- # variable $results
91
- value true
92
- color 'black'
93
- bgcolor 'white'
94
- text "Use &HTTP/1.0"
95
- row 5
96
- col 4
97
- end
98
- field_list << checkbutton
99
- checkbutton = RubyCurses::CheckBox.new @form do
100
- # variable $results
101
- color 'black'
102
- bgcolor 'white'
103
- text "Use &passive FTP"
104
- row 6
105
- col 4
106
- end
107
- field_list << checkbutton
108
- titlelabel = RubyCurses::Label.new @form, {'text' => 'Language', 'row'=>8, 'col'=>4, 'color'=>'black', 'bgcolor'=>'white'}
109
- field_list << titlelabel
110
- $radio = RubyCurses::Variable.new
111
- #$radio.update_command(colorlabel) {|tv, label| label.color tv.value}
112
- radio1 = RubyCurses::RadioButton.new @form do
113
- variable $radio
114
- text "rub&y"
115
- value "ruby"
116
- color "red"
117
- bgcolor 'white'
118
- row 9
119
- col 4
120
- end
121
- radio2 = RubyCurses::RadioButton.new @form do
122
- variable $radio
123
- text "python"
124
- value "py&thon"
125
- color "blue"
126
- bgcolor 'white'
127
- row 10
128
- col 4
129
- end
130
- field_list << radio1
131
- field_list << radio2
132
- field.bind(:ENTER) do |f|
133
- listconfig = {'bgcolor' => 'blue', 'color' => 'white'}
134
- url_list= RubyCurses::ListDataModel.new(%w[john tim lee wong rahul edward _why chad andy])
135
- pl = RubyCurses::PopupList.new do
136
- # title "Enter URL "
137
- row 4
138
- col 10
139
- width 30
140
- #list url_list
141
- list_data_model url_list
142
- list_selection_mode 'single'
143
- relative_to f
144
- list_config listconfig
145
- #default_values %w[ lee _why ]
146
- bind :PRESS do |index|
147
- field.set_buffer url_list[index]
148
- end
149
- end
150
- end
151
- @mb = RubyCurses::MessageBox.new @form do
152
- #title "Color selector"
153
- title "HTTP Configuration"
154
- # message "Enter your name"
155
- # type :custom
156
- # buttons %w[red green blue yellow]
157
- # underlines [0,0,0,0]
158
- # type :input
159
- # default_value "rahul"
160
- #type :field_list
161
- #field_list field_list
162
- button_type :ok
163
- default_button 0
164
- end
165
- when 5
166
- @form = RubyCurses::Form.new nil
167
- label = RubyCurses::Label.new @form, {'text' => 'File', 'row'=>3, 'col'=>4, 'color'=>'black', 'bgcolor'=>'white', 'mnemonic'=>'F'}
168
- field = RubyCurses::Field.new @form do
169
- name "file"
170
- row 3
171
- col 10
172
- display_length 40
173
- set_label label
174
- end
175
- flist = Dir.glob("*.*")
176
- listb = RubyCurses::Listbox.new @form do
177
- name "mylist"
178
- row 5
179
- col 10
180
- width 40
181
- height 10
182
- list flist
183
- title "File list"
184
- title_attrib 'bold'
185
- end
186
- #listb.list.bind(:ENTER_ROW) { field.set_buffer listb.selected_item }
187
- # if you find that cursor goes into listbox while typing, then
188
- # i've put set_form_row in listbox list_data_changed
189
- field.bind(:CHANGE) do |f|
190
- flist = Dir.glob(f.getvalue+"*")
191
- l = listb.list
192
- l.remove_all
193
- l.insert( 0, *flist) if flist
194
- end
195
- @mb = RubyCurses::MessageBox.new @form do
196
- title "Sample File Selector"
197
- type :override
198
- height 20
199
- width 60
200
- top 5
201
- left 20
202
- default_button 0
203
- button_type :ok_cancel
204
-
205
- end
206
- $log.debug "MBOX :selected #{listb.selected_item}"
207
- end
208
-
209
- $log.debug "MBOX :selected button index #{@mb.selected_index} "
210
- $log.debug "MBOX :input val #{@mb.input_value} "
211
- # $log.debug "row : #{@form.row} "
212
- # $log.debug "col : #{@form.col} "
213
- # $log.debug "Config : #{@form.config.inspect} "
214
- # @form.configure "row", 23
215
- # @form.configure "col", 83
216
- # $log.debug "row : #{@form.row} "
217
- # x = @form.row
218
- # @form.depth 21
219
- # @form.depth = 22
220
- # @form.depth 24
221
- # @form.depth = 25
222
- # $log.debug "col : #{@form.col} "
223
- # $log.debug "config : #{@form.config.inspect} "
224
- # $log.debug "row : #{@form.configure('row')} "
225
- #$log.debug "mrgods : #{@form.public_methods.sort.inspect}"
226
- #while((ch = @window.getchar()) != ?q )
227
- # @window.wrefresh
228
- #end
229
- end
230
- rescue => ex
231
- ensure
232
- @window.destroy unless @window.nil?
233
- VER::stop_ncurses
234
- p ex if ex
235
- p(ex.backtrace.join("\n")) if ex
236
- $log.debug( ex) if ex
237
- $log.debug(ex.backtrace.join("\n")) if ex
238
- end
239
- end
data/examples/test2.rb DELETED
@@ -1,674 +0,0 @@
1
- # This program tests out various widgets.
2
- # This is the old style of creating an application in which the user
3
- # has to start and stop ncurses. No shortcuts for widget constructors are available.
4
- #
5
- # The newer easier way is to use 'App' which manages the environment, and provides shortcuts
6
- # for all widgets. See app*.rb, alpmenu.rb, dbdemo.rb etc for samples.
7
- #
8
- # In case, you are running this in a directory that does not allow writing, set LOGDIR to
9
- # your home directory, or temp directory so a log file can be generated.
10
- #
11
- require 'logger'
12
- require 'rbcurse'
13
- require 'rbcurse/rtextarea'
14
- require 'rbcurse/rtextview'
15
- require 'rbcurse/rmenu'
16
- require 'rbcurse/rcombo'
17
- require 'rbcurse/extras/rcomboedit'
18
- require 'rbcurse/listcellrenderer'
19
- require 'rbcurse/checkboxcellrenderer'
20
- require 'rbcurse/comboboxcellrenderer'
21
- require 'rbcurse/celleditor'
22
- require 'rbcurse/rlistbox'
23
- require 'rbcurse/rbasiclistbox'
24
- #require 'rbcurse/rmessagebox'
25
- require 'rbcurse/rtree'
26
- require 'rbcurse/common/appmethods.rb'
27
- require 'rbcurse/extras/scrollbar'
28
- def help_text
29
- <<-eos
30
- TEST2 HELP
31
-
32
- This is some help text for test2.
33
-
34
- Alt-C/F10 - Exit application
35
- Alt-! - Drop to shell
36
- C-x c - Drop to shell
37
- C-x l - list of files
38
- C-x p - process list
39
- C-x d - disk usage list
40
- C-x s - Git status
41
- C-x d - Git diff
42
- C-x w - Git whatchanged
43
- Alt-x - Command mode (<tab> to see commands and select)
44
-
45
- Some commands for using bottom of screen as vim and emacs do.
46
- To add
47
-
48
- -----------------------------------------------------------------------
49
- eos
50
- end
51
- if $0 == __FILE__
52
-
53
- include RubyCurses
54
- include RubyCurses::Utils
55
-
56
- begin
57
- # Initialize curses
58
- VER::start_ncurses # this is initializing colors via ColorMap.setup
59
- path = File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")
60
- file = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)
61
- $log = Logger.new(path)
62
- $log.level = Logger::DEBUG
63
-
64
- @lookfeel = :classic # :dialog # or :classic
65
-
66
- @window = VER::Window.root_window
67
- # Initialize few color pairs
68
- # Create the window to be associated with the form
69
- # Un post form and free the memory
70
-
71
- catch(:close) do
72
- colors = Ncurses.COLORS
73
- $log.debug "START #{colors} colors test2.rb --------- #{@window} "
74
- @form = Form.new @window
75
- title = (" "*30) + "Demo of some Ruby Curses Widgets - rbcurse " + Rbcurse::VERSION
76
- Label.new @form, {'text' => title, :row => 0, :col => 0, :color => 'green', :bgcolor => 'black'}
77
- r = 1; fc = 12;
78
- mnemonics = %w[ n l r p]
79
- %w[ name line regex password].each_with_index do |w,i|
80
- field = Field.new @form do
81
- name w
82
- row r
83
- col fc
84
- display_length 30
85
- #set_buffer "abcd "
86
- set_label Label.new @form, {'text' => w, 'color'=>'cyan','mnemonic'=> mnemonics[i]}
87
- end
88
- r += 1
89
- end
90
-
91
- $message = Variable.new
92
- $message.value = "Message Comes Here"
93
- message_label = RubyCurses::Label.new @form, {'text_variable' => $message,
94
- "name"=>"message_label","row" => Ncurses.LINES-1, "col" => 1, "display_length" => 60,
95
- "height" => 2, 'color' => 'cyan'}
96
-
97
- $results = Variable.new
98
- $results.value = "A variable"
99
- var = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => r, "col" => fc}
100
- r += 1
101
- mylist = File.open("data/tasks.txt",'r').readlines
102
- #0.upto(100) { |v| mylist << "#{v} scrollable data" }
103
- listb = BasicListbox.new @form do
104
- name "mylist"
105
- row r
106
- col 1
107
- width 40
108
- height 11
109
- list mylist
110
- #selection_mode :SINGLE
111
- show_selector true
112
- #row_selected_symbol "*"
113
- #row_unselected_symbol " "
114
- selected_bgcolor :white
115
- selected_color :blue
116
- title "Todo List"
117
- end
118
- Scrollbar.new @form, :parent => listb # 2011-10-1 added
119
- #listb.list_data_model.insert -1, "rake build", "rake release", "bump version", "fix bugs"
120
- col2 = 42
121
- texta = TextArea.new @form do
122
- name "mytext"
123
- row 1
124
- col col2
125
- width 50
126
- height 14
127
- title "Editable box"
128
- #title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
129
- print_footer true
130
- bind(:CHANGE){|e| $message.value = e.to_s+" CP:"+e.source.curpos.to_s }
131
- end
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
-
140
- col3 = 92
141
- treemodel = nil
142
- atree = Tree.new @form, :title => "Tree", :row =>1, :col=>col3, :height => 14, :width => 15 do
143
- treemodel = root "ruby language" do
144
- branch "mri" do
145
- leaf "1.9.1"
146
- leaf "1.9.2"
147
- leaf "1.9.3"
148
- end
149
- branch "jruby" do
150
- leaf "1.5"
151
- leaf "a really long leaf"
152
-
153
- end
154
- branch "ree" do
155
- leaf "1.8"
156
- leaf "1.9"
157
- leaf "2.0"
158
- end
159
- end
160
- end
161
- root = treemodel.root
162
- atree.set_expanded_state root, true
163
- #listcb.cell_editor.component.form = @form
164
-
165
- w1 = Ncurses.COLS-col2-1
166
- @textview = TextView.new @form do
167
- name "myView"
168
- row 15
169
- col col2
170
- width w1
171
- height 11
172
- title "README.mark"
173
- #title_attrib 'bold'
174
- print_footer true
175
- footer_attrib 'bold'
176
- end
177
- content = File.open("../README.markdown","r").readlines
178
- @textview.set_content content #, :WRAP_WORD
179
- #@textview.top_row 21
180
-
181
- # just for demo, lets scroll the text view as we scroll this.
182
- listb.bind(:ENTER_ROW, @textview) { |alist, tview| tview.top_row alist.current_index
183
- pb = @form.by_name["pbar"]
184
- pb.visible true
185
- len = alist.current_index
186
- pb.fraction(len/100.0)
187
- i = ((len/100.0)*100).to_i
188
- i = 100 if i > 100
189
- pb.text = "completed:#{i}"
190
- }
191
- listb.bind(:LEAVE) {
192
- pb = @form.by_name["pbar"]
193
- pb.visible false
194
- r = pb.row
195
- c = pb.col
196
- @window.wmove(r,c); @window.wclrtoeol
197
- #@window.wrefresh
198
- }
199
-
200
- # just for demo, lets scroll the text view to the line you enter
201
- @form.by_name["line"].bind(:LEAVE, @textview) { |fld, tv| raise(FieldValidationException, "#{fld.getvalue.to_i} Outside range 1,200") if fld.getvalue.to_i >200; tv.top_row(fld.getvalue.to_i) }
202
- @form.by_name["regex"].bind(:LEAVE, @textview) { |fld, tv| tv.top_row(tv.find_first_match(fld.getvalue)) }
203
- @form.by_name["regex"].bind(:CHANGED) { |fld|
204
- $message.value = "REGEX CHANGED!!! #{fld.getvalue} " }
205
- row = 17
206
- col = 2
207
- align = ComboBox.new @form do
208
- name "combo"
209
- row row
210
- col fc
211
- display_length 10
212
- editable false
213
- list %w[left right center]
214
- set_label Label.new @form, {'text' => "Align", 'color'=>'cyan','col'=>1, "mnemonic"=>"I"}
215
- list_config :color => :yellow, :bgcolor=>:blue
216
- end
217
-
218
- list = ListDataModel.new( %w[white yellow cyan magenta red blue black])
219
- list.bind(:LIST_DATA_EVENT) { |lde| $message.value = lde.to_s; $log.debug " STA: #{$message.value} #{lde}"; }
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
-
222
- row += 1
223
- combo1 = ComboBoxEdit.new @form do
224
- name "combo1"
225
- row row
226
- col fc
227
- display_length 10
228
- editable true
229
- list_data_model list
230
- set_label Label.new @form, {'text' => "Edit Combo",'color'=>'cyan','col'=>1}
231
- list_config 'color' => 'white', 'bgcolor'=>'blue', 'max_visible_items' => 6, 'height' => 7
232
- end
233
- row += 1
234
- checkbutton = CheckBox.new @form do
235
- variable $results
236
- #value = true
237
- onvalue "Selected bold "
238
- offvalue "UNselected bold"
239
- text "Bold attribute "
240
- display_length 18 # helps when right aligning
241
- row row
242
- col col
243
- mnemonic 'B'
244
- end
245
- row += 1
246
- @cb_rev = Variable.new false # related to checkbox reverse
247
- cbb = @cb_rev
248
- checkbutton1 = CheckBox.new @form do
249
- variable cbb # $cb_rev
250
- #value = true
251
- onvalue "Selected reverse "
252
- offvalue "UNselected reverse"
253
- text "Reverse attribute "
254
- display_length 18
255
- row row
256
- col col
257
- mnemonic 'R'
258
- end
259
- row += 1
260
- togglebutton = ToggleButton.new @form do
261
- value true
262
- onvalue " Toggle Down "
263
- offvalue " Untoggle "
264
- row row
265
- col col
266
- mnemonic 'T'
267
- #underline 0
268
- end
269
- # a special case required since another form (combo popup also modifies)
270
- $message.update_command() { message_label.repaint }
271
-
272
- f = @form.by_name["line"]
273
- f.display_length(3).set_buffer(24).valid_range(1..200).
274
- maxlen(3).
275
- type(:integer)
276
-
277
- @form.by_name["name"].set_buffer( "Not focusable").
278
- set_focusable(false)
279
-
280
- @form.by_name["regex"].valid_regex(/^[A-Z][a-z]*/).
281
- set_buffer( "SYNOP").
282
- display_length(10).
283
- maxlen = 20
284
-
285
- @form.by_name["password"].set_buffer("").
286
- show('*').
287
- color('red').
288
- values(%w[scotty tiger secret pass qwerty]).
289
- null_allowed true
290
-
291
- # a form level event, whenever any widget is focussed, make the label red
292
- @form.bind(:ENTER) { |f| f.label && f.label.bgcolor = 'red' if f.respond_to? :label}
293
- @form.bind(:LEAVE) { |f| f.label && f.label.bgcolor = 'black' if f.respond_to? :label}
294
-
295
- row += 1
296
- colorlabel = Label.new @form, {'text' => "Select a color:", "row" => row, "col" => col,
297
- "color"=>"cyan", "mnemonic" => 'S'}
298
- $radio = Variable.new
299
- $radio.update_command(colorlabel) {|tv, label| label.color tv.value; }
300
- $radio.update_command() {|tv| message_label.color tv.value; align.bgcolor tv.value;
301
- combo1.bgcolor tv.value}
302
- $radio.update_command() {|tv| @form.widgets.each { |e| next unless e.is_a? Widget;
303
- e.bgcolor tv.value }; @mb.bgcolor = tv.value }
304
-
305
- # whenever updated set colorlabel and messagelabel to bold
306
- $results.update_command(colorlabel,checkbutton) {|tv, label, cb|
307
- attrs = cb.value ? 'bold' : 'normal'; label.attr(attrs); message_label.attr(attrs)}
308
-
309
- align.bind(:ENTER_ROW) {|fld| message_label.justify fld.getvalue}
310
-
311
- align.bind(:ENTER_ROW) {|fld|
312
- if fld.getvalue == 'right'
313
- checkbutton1.align_right true
314
- checkbutton.align_right true
315
- else
316
- checkbutton1.align_right false
317
- checkbutton.align_right false
318
- end
319
- }
320
-
321
- # whenever updated set colorlabel and messagelabel to reverse
322
- #@cb_rev.update_command(colorlabel,checkbutton1) {|tv, label, cb| attrs = cb.value ? 'reverse' : nil; label.attr(attrs); message_label.attr(attrs)}
323
- # changing nil to normal since PROP CHAN handler will not fire if nil being set.
324
- @cb_rev.update_command(colorlabel,checkbutton1) {|tv, label, cb|
325
- attrs = cb.value ? 'reverse' : 'normal'; label.attr(attrs); message_label.attr(attrs)}
326
-
327
- row += 1
328
- dlen = 10
329
- radio1 = RadioButton.new @form do
330
- variable $radio
331
- text "red"
332
- value "red"
333
- color "red"
334
- display_length dlen # helps when right aligning
335
- row row
336
- col col
337
- end
338
- radio11 = RadioButton.new @form do
339
- variable $radio
340
- text "c&yan"
341
- value "cyan"
342
- color "cyan"
343
- display_length dlen # helps when right aligning
344
- row row
345
- col col+24
346
- end
347
-
348
- row += 1
349
- radio2 = RadioButton.new @form do
350
- variable $radio
351
- text "&green"
352
- value "green"
353
- color "green"
354
- display_length dlen # helps when right aligning
355
- row row
356
- col col
357
- end
358
- radio22 = RadioButton.new @form do
359
- variable $radio
360
- text "magenta"
361
- value "magenta"
362
- color "magenta"
363
- display_length dlen # helps when right aligning
364
- row row
365
- col col+24
366
- end
367
- colorlabel.label_for radio1
368
- align.bind(:ENTER_ROW) {|fld|
369
- if fld.getvalue == 'right'
370
- radio1.align_right true
371
- radio2.align_right true
372
- radio11.align_right true
373
- radio22.align_right true
374
- else
375
- radio1.align_right false
376
- radio2.align_right false
377
- radio11.align_right false
378
- radio22.align_right false
379
- end
380
- }
381
-
382
- # instead of using frozen, I will use a PropertyVeto
383
- # to disallow changes to color itself
384
- veto = lambda { |e, name|
385
- if e.property_name == 'color'
386
- if e.newvalue != name
387
- raise PropertyVetoException.new("Cannot change this at all!", e)
388
- end
389
- elsif e.property_name == 'bgcolor'
390
- raise PropertyVetoException.new("Cannot change this!", e)
391
- end
392
- }
393
- [radio1, radio2, radio11, radio22].each { |r|
394
- r.bind(:PROPERTY_CHANGE) do |e| veto.call(e, r.text) end
395
- }
396
-
397
- #
398
- # define the menu
399
- #
400
- @mb = RubyCurses::MenuBar.new
401
- filemenu = RubyCurses::Menu.new "File"
402
- filemenu.add(item = RubyCurses::MenuItem.new("Open",'O'))
403
- item.command(@form) {|it, form| $message.value = "Open called on menu bar";
404
- require './qdfilechooser'
405
- fchooser = QDFileChooser.new
406
- option = fchooser.show_open_dialog
407
- $message.value = "File Selection #{option}, #{fchooser.get_selected_file}"
408
- if option == :OK
409
- filesel = fchooser.get_selected_file
410
- if !filesel.nil?
411
- texta.remove_all
412
- content = File.open(filesel,"r").readlines
413
- content.each do |line|
414
- texta << line
415
- end
416
- else
417
- alert "File name #{filesel} nil. Pls check code. "
418
- end
419
- end
420
- }
421
-
422
- filemenu.insert_separator 1
423
- filemenu.add(RubyCurses::MenuItem.new "New",'N')
424
- filemenu.add(item = RubyCurses::MenuItem.new("Save",'S'))
425
- item.command() do |it|
426
- filename = get_string("Please enter file to save in", 20, "t.t")
427
- $message.value = "file: #{filename}"
428
- filename ||= "tmpzzzz.tmp"
429
- str = texta.to_s
430
- File.open(filename, 'w') {|f| f.write(str) }
431
- $message.value = " written #{str.length} bytes to file: #{filename}"
432
- end
433
- filemenu.add(item = RubyCurses::MenuItem.new("Test",'T'))
434
- item.command(@form, texta) do |it, form, testa|
435
- $message.value = "Testing textarea"
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."
440
- testa.goto_start
441
- #testa.cursor_bol
442
- testa.handle_key ?\C-a.getbyte(0)
443
- str.each_char {|c| testa.putch(c)}
444
- testa.repaint
445
- 3.times { testa.handle_key KEY_DOWN }
446
- testa.handle_key ?\C-a.getbyte(0)
447
-
448
- str.each_char {|c| testa.putch(c)}
449
- $message.value = "Wrapping textarea"
450
- testa.repaint
451
- throw(:menubarclose)
452
- end
453
- filemenu.add(item = RubyCurses::MenuItem.new("Wrap",'W'))
454
- item.command(@form, texta) do |it, form, testa|
455
- #testa.goto_start
456
- testa.handle_key ?\C-a.getbyte(0)
457
- testa.wrap_para
458
- testa.repaint
459
- throw(:menubarclose)
460
- end
461
- filemenu.add(item = RubyCurses::MenuItem.new("Exit",'X'))
462
- item.command() {
463
- #throw(:menubarclose);
464
- throw(:close)
465
- }
466
- item = RubyCurses::CheckBoxMenuItem.new "Reverse"
467
- # item.onvalue="On"
468
- # item.offvalue="Off"
469
- #item.checkbox.text "Labelcb"
470
- #item.text="Labelcb"
471
- # in next line, an explicit repaint is required since label is on another form.
472
- item.command(colorlabel){|it, label| att = it.getvalue ? 'reverse' : 'normal'; label.attr(att); label.repaint}
473
- @status_line = status_line :row => Ncurses.LINES-2
474
- @status_line.command {
475
- "F1 Help | F2 Menu | F3 View | F4 Shell | F5 Sh | %20s" % [$message.value]
476
- }
477
- row += 1 #2
478
- ok_button = Button.new @form do
479
- text "OK"
480
- name "OK"
481
- row row
482
- col col
483
- #attr 'reverse'
484
- #highlight_background "white"
485
- #highlight_foreground "blue"
486
- mnemonic 'O'
487
- end
488
- ok_button.command() { |eve|
489
- alert("Hope you enjoyed this demo ", {'title' => "Hello", :bgcolor => :blue, :color => :white})
490
- sw = case @lookfeel
491
- when :dialog
492
- progress_dialog :color_pair => $reversecolor, :row_offset => 4, :col_offset => 5
493
- else
494
- status_window # at footer last 2 rows
495
- end
496
-
497
- sw.print "I am adding some stuff to list", "And testing out StatusWindow"
498
- sleep 1.0
499
- listb.list.insert 0, "hello ruby", "so long python", "farewell java", "RIP .Net"
500
- sw.printstring 1,1, "And some more now ..."
501
- sleep 0.5
502
- listb.list.insert 0, "get milk", "make beds", "clean shark pond","sell summer house"
503
- sleep 0.5
504
- sw.print "This was a test of Window", "we are almost done now ..."
505
- clock = %w[ | / - \ ]
506
- listb.list.each_with_index { |e, index| sw.print e, clock[index%4]; sleep 0.1 }
507
- sw.linger #@window
508
- }
509
-
510
- # using ampersand to set mnemonic
511
- cancel_button = Button.new @form do
512
- #variable $results
513
- text "&Cancel"
514
- row row
515
- col col + 10
516
- #attr 'reverse'
517
- #highlight_background "white"
518
- #highlight_foreground "blue"
519
- #surround_chars ['{ ',' }'] ## change the surround chars
520
- end
521
- cancel_button.command { |aeve|
522
- if @lookfeel == :dialog
523
- ret = confirm("Do your really want to quit?")
524
- else
525
- ret = confirm_window("Do your really want to quit?")
526
- end
527
- if ret == :YES
528
- throw(:close);
529
- else
530
- $message.value = "Quit aborted"
531
- end
532
- }
533
- #col += 22
534
- col += 15
535
- require 'rbcurse/rprogress'
536
- pbar = Progress.new @form, {:width => 20, :row => Ncurses.LINES-1, :col => Ncurses.COLS-20 ,
537
- :bgcolor => 'white', :color => 'red', :name => "pbar"}
538
- #len = 1
539
- #pbar.fraction(len/100.0)
540
- pbar.visible false
541
-
542
-
543
- filemenu.add(item)
544
- @mb.add(filemenu)
545
- editmenu = RubyCurses::Menu.new "Edit"
546
- item = RubyCurses::MenuItem.new "Cut"
547
- editmenu.add(item)
548
- item.accelerator = "Ctrl-X"
549
- item=RubyCurses::MenuItem.new "Copy"
550
- editmenu.add(item)
551
- item.accelerator = "Ctrl-C"
552
- item=RubyCurses::MenuItem.new "Paste"
553
- editmenu.add(item)
554
- item.accelerator = "Ctrl-V"
555
- @mb.add(editmenu)
556
- @mb.add(menu=RubyCurses::Menu.new("Others"))
557
- #item=RubyCurses::MenuItem.new "Save","S"
558
- item = RubyCurses::MenuItem.new "Options ..."
559
- item.command() do |it|
560
- require './testtabp'
561
- tp = TestTabbedPane.new
562
- tp.run
563
- $message.value=$config_hash.inspect
564
- $log.debug " returning with #{$config_hash}: #{$config_hash.inspect}"
565
- end
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)
576
- item = RubyCurses::MenuItem.new "Shell Command..."
577
- item.command { shell_output }
578
- menu.add(item)
579
- savemenu = RubyCurses::Menu.new "Shell"
580
- item = RubyCurses::MenuItem.new "Processes"
581
- item.command { run_command "ps -l" }
582
- savemenu.add(item)
583
- item = RubyCurses::MenuItem.new "Files"
584
- item.command { run_command "ls -l" }
585
- savemenu.add(item)
586
- item = RubyCurses::MenuItem.new "Disk"
587
- item.command { run_command "df -h" }
588
- savemenu.add(item)
589
- menu.add(savemenu)
590
-
591
- savemenu2 = RubyCurses::Menu.new "Git"
592
- item = RubyCurses::MenuItem.new "Status"
593
- item.command { run_command "git status" }
594
- savemenu2.add(item)
595
- item = RubyCurses::MenuItem.new "Diff"
596
- item.command { run_command "git diff" }
597
- savemenu2.add(item)
598
- item = RubyCurses::MenuItem.new "Name"
599
- item.command { run_command "git diff --name-status" }
600
- savemenu2.add(item)
601
- savemenu.add(savemenu2)
602
-
603
- @mb.toggle_key = FFI::NCurses::KEY_F2
604
- @form.set_menu_bar @mb
605
-
606
- # END
607
- @form.bind_key(FFI::NCurses::KEY_F3) {
608
- require 'rbcurse/extras/viewer'
609
- RubyCurses::Viewer.view(path || "rbc13.log", :close_key => KEY_RETURN, :title => "<Enter> to close")
610
- }
611
- @form.bind_key(FFI::NCurses::KEY_F4) { shell_output }
612
- @form.bind_key(FFI::NCurses::KEY_F5) { suspend }
613
- @form.bind_key([?\C-x,?c]) { suspend }
614
- @form.bind_key(?\M-!) { suspend }
615
- @form.bind_key([?\C-x,?l]) { run_command "ls -al" }
616
- @form.bind_key([?\C-x,?p]) { run_command "ps -l" }
617
- @form.bind_key([?\C-x,?d]) { run_command "df -h" }
618
- @form.bind_key([?\C-x,?d]) { run_command "git diff --name-status" }
619
- @form.bind_key([?\C-x, ?s]) { run_command "git status" }
620
- @form.bind_key([?\C-x,?w]) { run_command "git whatchanged" }
621
- @form.bind_key(FFI::NCurses::KEY_F1) { display_app_help help_text() }
622
- @form.repaint
623
- @window.wrefresh
624
- Ncurses::Panel.update_panels
625
-
626
- # the main loop
627
-
628
- while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
629
- break if ch == ?\C-q.getbyte(0)
630
- begin
631
- @form.handle_key(ch)
632
-
633
- rescue FieldValidationException => fve
634
- alert fve.to_s
635
-
636
- f = @form.get_current_field
637
- # lets restore the value
638
- if f.respond_to? :restore_original_value
639
- f.restore_original_value
640
- @form.repaint
641
- end
642
- $error_message.value = ""
643
- rescue => err
644
- $log.error( err) if err
645
- $log.error(err.backtrace.join("\n")) if err
646
- alert "Got an exception in test2: #{err} "
647
- $error_message.value = ""
648
- end
649
-
650
- # this should be avoided, we should not muffle the exception and set a variable
651
- # However, we have been doing that
652
- if $error_message.get_value != ""
653
- if @lookfeel == :dialog
654
- alert($error_message, {:bgcolor => :red, 'color' => 'yellow'}) if $error_message.get_value != ""
655
- else
656
- print_error_message $error_message, {:bgcolor => :red, :color => :yellow}
657
- end
658
- $error_message.value = ""
659
- end
660
-
661
- @window.wrefresh
662
- end # while loop
663
- end # catch
664
- rescue => ex
665
- ensure
666
- $log.debug " -==== EXCEPTION =====-"
667
- $log.debug( ex) if ex
668
- $log.debug(ex.backtrace.join("\n")) if ex
669
- @window.destroy if !@window.nil?
670
- VER::stop_ncurses
671
- puts ex if ex
672
- puts(ex.backtrace.join("\n")) if ex
673
- end
674
- end