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
@@ -1,87 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'rubygems'
3
- #require 'ncurses' # FFI
4
- require 'logger'
5
- require 'rbcurse'
6
- require 'rbcurse/rsplitpane'
7
- #require 'rbcurse/rtestwidget'
8
- #
9
- ## this sample creates a single scrollpane, and allows you to change orientation
10
- ##+ and move divider around using - + and =.
11
- #
12
- if $0 == __FILE__
13
- include RubyCurses
14
- include RubyCurses::Utils
15
-
16
- begin
17
- # Initialize curses
18
- VER::start_ncurses # this is initializing colors via ColorMap.setup
19
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
20
- $log.level = Logger::DEBUG
21
-
22
- @window = VER::Window.root_window
23
-
24
- catch(:close) do
25
- colors = Ncurses.COLORS
26
- @form = Form.new @window
27
- r = 3; c = 7; ht = 18
28
- # filler just to see that we are covering correct space and not wasting lines or cols
29
- filler = "*" * 88
30
- (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
31
-
32
-
33
- @help = "q to quit. v h - + = : #{$0} . Check logger too"
34
- RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
35
-
36
- $message = Variable.new
37
- $message.value = "Message Comes Here"
38
- message_label = RubyCurses::Label.new @form, {'text_variable' => $message, "name"=>"message_label","row" => ht+r+2, "col" => 1, "display_length" => 60, "height" => 2, 'color' => 'cyan'}
39
- $message.update_command() { message_label.repaint } # why ?
40
-
41
- splitp = SplitPane.new @form do
42
- name "mypane"
43
- row r
44
- col c
45
- width 70
46
- height ht
47
- # focusable false
48
- #orientation :VERTICAL_SPLIT
49
- end
50
- splitp.bind(:PROPERTY_CHANGE){|e| $message.value = e.to_s }
51
-
52
- @form.repaint
53
- @window.wrefresh
54
- Ncurses::Panel.update_panels
55
- while((ch = @window.getchar()) != ?q.getbyte(0) )
56
- str = keycode_tos ch
57
- case ch
58
- when ?v.getbyte(0)
59
- splitp.orientation(:VERTICAL_SPLIT)
60
- splitp.reset_to_preferred_sizes
61
- when ?h.getbyte(0)
62
- splitp.orientation(:HORIZONTAL_SPLIT)
63
- splitp.reset_to_preferred_sizes
64
- when ?-.getbyte(0)
65
- splitp.set_divider_location(splitp.divider_location-1)
66
- when ?+.getbyte(0)
67
- splitp.set_divider_location(splitp.divider_location+1)
68
- when ?=.getbyte(0)
69
- splitp.set_resize_weight(0.50)
70
- end
71
- #splitp.get_buffer().wclear
72
- #splitp << "#{ch} got (#{str})"
73
- splitp.repaint # since the above keys are not being handled inside
74
- @form.handle_key(ch)
75
- @window.wrefresh
76
- end
77
- end
78
- rescue => ex
79
- ensure
80
- @window.destroy if !@window.nil?
81
- VER::stop_ncurses
82
- p ex if ex
83
- p(ex.backtrace.join("\n")) if ex
84
- $log.debug( ex) if ex
85
- $log.debug(ex.backtrace.join("\n")) if ex
86
- end
87
- end
@@ -1,123 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'rubygems'
3
- #require 'ncurses' # FFI
4
- require 'logger'
5
- require 'rbcurse'
6
- require 'rbcurse/rsplitpane'
7
- #require 'rbcurse/rtestwidget'
8
- if $0 == __FILE__
9
- include RubyCurses
10
- include RubyCurses::Utils
11
-
12
- begin
13
- # Initialize curses
14
- VER::start_ncurses # this is initializing colors via ColorMap.setup
15
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
16
- $log.level = Logger::DEBUG
17
-
18
- @window = VER::Window.root_window
19
-
20
- catch(:close) do
21
- colors = Ncurses.COLORS
22
- @form = Form.new @window
23
- r = 3; c = 5; ht = 18; w = 70
24
- # filler just to see that we are covering correct space and not wasting lines or cols
25
- filler = "*" * 88
26
- # (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
27
-
28
-
29
- @help = "q to quit. v for vertical split, h - horizontal. -/+/= to resize split. : #{$0}"
30
- RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
31
- splitp = SplitPane.new @form do
32
- name "mainpane"
33
- row r
34
- col c
35
- width w
36
- height ht
37
- #focusable false
38
- #orientation :VERTICAL_SPLIT
39
- orientation :HORIZONTAL_SPLIT
40
- #set_resize_weight 0.60
41
- end
42
- # note that splitc has no form. so focus has to be managed XXX
43
- splitc = SplitPane.new nil do
44
- name "FC"
45
- #row r
46
- #col c
47
-
48
- ## earlier commented now bombing
49
- #width w-4 # 30
50
- #height ht/2-1
51
-
52
- #focusable false
53
- #orientation :HORIZONTAL_SPLIT
54
- orientation :VERTICAL_SPLIT
55
- border_color $promptcolor
56
- border_attrib Ncurses::A_NORMAL
57
- end
58
- splitc2 = SplitPane.new nil do
59
- name "2C"
60
- #
61
- ## not present earlier now bombing
62
- #width w-4
63
- #height ht/2-1
64
-
65
- orientation :VERTICAL_SPLIT
66
- border_color $promptcolor
67
- border_attrib Ncurses::A_REVERSE
68
- end
69
- splitp.first_component(splitc)
70
- splitp.second_component(splitc2)
71
- splitc.preferred_width w/2
72
- splitc.preferred_height ht/2-2
73
- splitc.set_resize_weight 0.50
74
- splitc2.min_width 15
75
- splitc2.min_height 5
76
- splitc.min_width 12
77
- splitc.min_height 6
78
- ret = splitp.reset_to_preferred_sizes
79
- splitp.set_resize_weight(0.50) if ret == :ERROR
80
-
81
- @form.repaint
82
- @window.wrefresh
83
- Ncurses::Panel.update_panels
84
- while((ch = @window.getchar()) != ?q.getbyte(0) )
85
- str = keycode_tos ch
86
- case ch
87
- when ?v.getbyte(0)
88
- $log.debug " ORIENTATION VERTICAL"
89
- splitp.orientation(:VERTICAL_SPLIT)
90
- splitp.reset_to_preferred_sizes
91
- when ?h.getbyte(0)
92
- $log.debug " ORIENTATION HORIZ"
93
- splitp.orientation(:HORIZONTAL_SPLIT)
94
- splitp.reset_to_preferred_sizes
95
- when ?-.getbyte(0)
96
- $log.debug " KEY PRESS -"
97
- splitp.set_divider_location(splitp.divider_location-1)
98
- when ?+.getbyte(0)
99
- $log.debug " KEY PRESS +"
100
- splitp.set_divider_location(splitp.divider_location+1)
101
- when ?=.getbyte(0)
102
- $log.debug " KEY PRESS ="
103
- splitp.set_resize_weight(0.50)
104
- end
105
- #splitp.get_buffer().wclear
106
- #splitp << "#{ch} got (#{str})"
107
- # splitp.repaint
108
- # splitp.buffer_to_screen
109
- @form.repaint
110
- @form.handle_key(ch)
111
- @window.wrefresh
112
- end
113
- end
114
- rescue => ex
115
- ensure
116
- @window.destroy if !@window.nil?
117
- VER::stop_ncurses
118
- p ex if ex
119
- p(ex.backtrace.join("\n")) if ex
120
- $log.debug( ex) if ex
121
- $log.debug(ex.backtrace.join("\n")) if ex
122
- end
123
- end
@@ -1,215 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- #*******************************************************#
3
- # testsplit3.rb #
4
- # written by Rahul Kumar #
5
- # January 14, 2010 #
6
- # #
7
- # test textview, split and textarea inside splitpane #
8
- # #
9
- #
10
- # /----+---------------\
11
- # | | |
12
- # | 1 | |
13
- # +----+ 3 |
14
- # | 2 | |
15
- # | | |
16
- # \----+---------------/
17
- #
18
- # Please note, this is *not* the ideal way of placing a textview directly inside a
19
- # splitpane, unless you size it so that the entire TV is visible inside
20
- # the splitpane. If the TV is too large, you won't be able to scroll down to the
21
- # bottom-most portion using TV's inbuilt scrolling (C-n C-p). This is *not* a bug.
22
- # TV does not know you've put it inside a small SPLP.
23
- #
24
- # The ideal way is to put a TV inside a scrollpane, and put the scrollpane inside
25
- # a SPLP just like all frames on the internet do. That is the subject of the next example.
26
- #
27
- #
28
- # Released under ruby license. See #
29
- # http://www.ruby-lang.org/en/LICENSE.txt #
30
- # Copyright 2010, Rahul Kumar #
31
- #*******************************************************#
32
- require 'rubygems'
33
- #require 'ncurses' # FFI
34
- require 'logger'
35
- require 'rbcurse'
36
- require 'rbcurse/rsplitpane'
37
- require 'rbcurse/rtextarea'
38
- require 'rbcurse/rtextview'
39
- require 'rbcurse/rlistbox'
40
- if $0 == __FILE__
41
- include RubyCurses
42
- include RubyCurses::Utils
43
-
44
- begin
45
- # Initialize curses
46
- VER::start_ncurses # this is initializing colors via ColorMap.setup
47
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
48
- $log.level = Logger::DEBUG
49
-
50
- @window = VER::Window.root_window
51
-
52
- catch(:close) do
53
- colors = Ncurses.COLORS
54
- @form = Form.new @window
55
- @form.name = "Form::MAINFORM"
56
- $log.debug " MAIN FORM #{@form} #{$0} "
57
- r = 3; c = 5; ht = 18; w = 90
58
- # r = 0; c = 0; ht = 20; w = 100
59
-
60
-
61
- @help = "F1 to quit. -/+/= to resize outer split, M-, M+, M= for inner split: #{$0}"
62
- RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r+2, "col" => 2, "color" => "yellow"}
63
-
64
- outer = SplitPane.new @form do
65
- name "mainpane"
66
- row r
67
- col c
68
- width w
69
- height ht
70
- #focusable false
71
- orientation :VERTICAL_SPLIT
72
- #orientation :HORIZONTAL_SPLIT
73
- #set_resize_weight 0.60
74
- border_color $promptcolor
75
- end
76
- # note that splitleft has no form. so focus has to be managed XXX
77
- splitleft = SplitPane.new nil do
78
- name "C1-leftpane"
79
- #row r
80
- #col c
81
-
82
- ## earlier commented now bombing
83
- #width w/2 # 30
84
- #height ht-2 #/2-1
85
-
86
- #focusable false
87
- orientation :HORIZONTAL_SPLIT
88
- #orientation :VERTICAL_SPLIT
89
- border_color $promptcolor
90
- border_attrib Ncurses::A_NORMAL
91
- end
92
- ta1 = TextArea.new nil do
93
- name "myTextArea-right"
94
- #row 0
95
- #col 0
96
- width w/2-2
97
- #height (ht/2)-1
98
- height ht
99
- title "README.md"
100
- title_attrib 'bold'
101
- print_footer true
102
- footer_attrib 'bold'
103
- #should_create_buffer true
104
- end
105
-
106
- t1 = TextView.new nil do
107
- name "myView-left-first"
108
- #row 0
109
- #col 0
110
- #width w-2
111
- #height ht
112
- height (ht/2)-1
113
- width w/2 #-1
114
- title "README.md"
115
- title_attrib 'bold'
116
- print_footer true
117
- footer_attrib 'bold'
118
- #should_create_buffer true
119
- end
120
- content = File.open("../README.markdown","r").readlines
121
- t1.set_content content #, :WRAP_WORD
122
-
123
- # to see lower border i need to set height to ht/2 -2 in both cases, but that
124
- # crashes ruby when i reduce height by 1.
125
- t2 = TextView.new nil do
126
- name "myView2-left-second"
127
- #row 0
128
- #col 0
129
- width w/2
130
- #height ht
131
- height (ht/2)-1
132
- title "NOTES"
133
- title_attrib 'bold'
134
- print_footer true
135
- footer_attrib 'bold'
136
- #should_create_buffer true
137
- end
138
- content = File.open("../NOTES","r").readlines
139
- t2.set_content content #, :WRAP_WORD
140
-
141
- # the outer compo needs child set first else cursor does not reach up from
142
- # lower levels. Is the connection broken ?
143
- outer.first_component(splitleft)
144
- outer.second_component(ta1)
145
- splitleft.first_component(t1)
146
- splitleft.second_component(t2)
147
- t1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
148
- t1.preferred_height((ht/2)-1) ## this messes things up when we change orientation
149
- #t1.set_resize_weight 0.50
150
- t2.min_width 15
151
- t2.min_height 5
152
- t1.min_width 12
153
- t1.min_height 5
154
- ret = splitleft.reset_to_preferred_sizes
155
- splitleft.set_resize_weight(0.50) if ret == :ERROR
156
-
157
- splitleft.preferred_width w/2
158
- splitleft.preferred_height ht/2-2
159
- #splitleft.set_resize_weight 0.50
160
- ta1.min_width 10
161
- ta1.min_height 5
162
- splitleft.min_width 12
163
- splitleft.min_height 6
164
- ret = outer.reset_to_preferred_sizes
165
- outer.set_resize_weight(0.50) if ret == :ERROR
166
-
167
- File.open("../README.markdown","r") do |file|
168
- while (line = file.gets)
169
- ta1 << line.chomp
170
- end
171
- end
172
-
173
- @form.repaint
174
- @window.wrefresh
175
- Ncurses::Panel.update_panels
176
- while((ch = @window.getchar()) != KEY_F1 )
177
- str = keycode_tos ch
178
- case ch
179
- #when ?v.getbyte(0)
180
- #$log.debug " ORIENTATION VERTICAL"
181
- #outer.orientation(:VERTICAL_SPLIT)
182
- #outer.reset_to_preferred_sizes
183
- #when ?h.getbyte(0)
184
- #$log.debug " ORIENTATION HORIZ"
185
- #outer.orientation(:HORIZONTAL_SPLIT)
186
- #outer.reset_to_preferred_sizes
187
- when ?-.getbyte(0)
188
- $log.debug " KEY PRESS -"
189
- outer.set_divider_location(outer.divider_location-1)
190
- when ?+.getbyte(0)
191
- $log.debug " KEY PRESS +"
192
- outer.set_divider_location(outer.divider_location+1)
193
- when ?=.getbyte(0)
194
- $log.debug " KEY PRESS ="
195
- outer.set_resize_weight(0.50)
196
- end
197
- #outer.get_buffer().wclear
198
- #outer << "#{ch} got (#{str})"
199
- # outer.repaint
200
- # outer.buffer_to_screen
201
- @form.repaint
202
- @form.handle_key(ch)
203
- @window.wrefresh
204
- end
205
- end
206
- rescue => ex
207
- ensure
208
- @window.destroy if !@window.nil?
209
- VER::stop_ncurses
210
- p ex if ex
211
- p(ex.backtrace.join("\n")) if ex
212
- $log.debug( ex) if ex
213
- $log.debug(ex.backtrace.join("\n")) if ex
214
- end
215
- end
@@ -1,244 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- #*******************************************************#
3
- # testsplit3.rb #
4
- # written by Rahul Kumar #
5
- # January 14, 2010 #
6
- # #
7
- # test textview, split and textarea inside splitpane #
8
- # #
9
- #
10
- # /---------|----------\
11
- # | | |
12
- # | 1 | 3 |
13
- # +---------|----------|
14
- # | 2 | 4 |
15
- # | | |
16
- # \---------|----------/
17
- #
18
- #
19
- # Released under ruby license. See #
20
- # http://www.ruby-lang.org/en/LICENSE.txt #
21
- # Copyright 2010, Rahul Kumar #
22
- #*******************************************************#
23
- require 'rubygems'
24
- #require 'ncurses' # FFI
25
- require 'logger'
26
- require 'rbcurse'
27
- require 'rbcurse/rsplitpane'
28
- require 'rbcurse/rtextarea'
29
- require 'rbcurse/rtextview'
30
- require 'rbcurse/rlistbox'
31
- if $0 == __FILE__
32
- include RubyCurses
33
- include RubyCurses::Utils
34
-
35
- begin
36
- # Initialize curses
37
- VER::start_ncurses # this is initializing colors via ColorMap.setup
38
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
39
- $log.level = Logger::DEBUG
40
- show_caret_flag = true
41
-
42
- @window = VER::Window.root_window
43
-
44
- catch(:close) do
45
- colors = Ncurses.COLORS
46
- @form = Form.new @window
47
- @form.name = "Form::MAINFORM"
48
- r = 1; c = 3; ht = 18; w = 70
49
- r = 3; c = 7; ht = 24; w = 100
50
-
51
-
52
- @help = "F1 to quit. -/+/= to resize outer split, M-, M+, M= for inner split: #{$0}"
53
- RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
54
-
55
- outer = SplitPane.new @form do
56
- name "mainpane"
57
- row r
58
- col c
59
- width w
60
- height ht
61
- #focusable false
62
- orientation :VERTICAL_SPLIT
63
- #orientation :HORIZONTAL_SPLIT
64
- #set_resize_weight 0.60
65
- end
66
- # note that splitleft has no form. so focus has to be managed XXX
67
- splitleft = SplitPane.new nil do
68
- name "C1-left"
69
- #row r
70
- #col c
71
-
72
- ## earlier commented now bombing
73
- width w/2 # 30
74
- height ht #/2-1
75
-
76
- #focusable false
77
- orientation :HORIZONTAL_SPLIT
78
- #orientation :VERTICAL_SPLIT
79
- border_color $promptcolor
80
- border_attrib Ncurses::A_NORMAL
81
- end
82
- splitrt = SplitPane.new nil do
83
- name "C1-rt"
84
- #row r
85
- #col c
86
-
87
- ## earlier commented now bombing
88
- width w/2 # 30
89
- height ht #/2-1
90
-
91
- #focusable false
92
- orientation :HORIZONTAL_SPLIT
93
- #orientation :VERTICAL_SPLIT
94
- border_color $promptcolor
95
- border_attrib Ncurses::A_NORMAL
96
- end
97
- ta1 = TextArea.new nil do
98
- name "myTextArea1-left-bot"
99
- #row 0
100
- #col 0
101
- width w/2-2
102
- height (ht/2)-1
103
- #height ht
104
- title "README.mark"
105
- title_attrib 'bold'
106
- print_footer true
107
- footer_attrib 'bold'
108
- end
109
- #ta1.show_caret=show_caret_flag
110
- ta2 = TextArea.new nil do
111
- name "myTextArea2-right-bot"
112
- #row 0
113
- #col 0
114
- width w/2-2
115
- height (ht/2)-1
116
- #height ht
117
- title "Scratch Pad"
118
- title_attrib 'reverse'
119
- print_footer true
120
- footer_attrib 'bold'
121
- end
122
- #ta2.show_caret=show_caret_flag
123
-
124
- t1 = TextView.new nil do
125
- name "myView-right-top"
126
- #row 0
127
- #col 0
128
- #width w-2
129
- height ht
130
- #height (ht/2)-1
131
- width w/2-1
132
- title "README.md"
133
- title_attrib 'bold'
134
- print_footer true
135
- footer_attrib 'bold'
136
- end
137
- #t1.show_caret=show_caret_flag
138
- content = File.open("../README.markdown","r").readlines
139
- t1.set_content content #, :WRAP_WORD
140
-
141
- # to see lower border i need to set height to ht/2 -2 in both cases, but that
142
- # crashes ruby when i reduce height by 1.
143
- t2 = TextView.new nil do
144
- name "myView2-left-top"
145
- #row 0
146
- #col 0
147
- width w/2-1
148
- height ht
149
- #height (ht/2)-1
150
- title "NOTES"
151
- title_attrib 'bold'
152
- print_footer true
153
- footer_attrib 'bold'
154
- end
155
- #t2.show_caret=show_caret_flag
156
- content = File.open("../NOTES","r").readlines
157
- t2.set_content content #, :WRAP_WORD
158
-
159
- # the outer compo needs child set first else cursor does not reach up from
160
- # lower levels. Is the connection broken ?
161
- outer.first_component(splitleft)
162
- outer.second_component(splitrt)
163
- splitleft.first_component(t2)
164
- splitleft.second_component(ta1)
165
- splitrt.first_component(t1)
166
- splitrt.second_component(ta2)
167
- t2.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
168
- t2.preferred_height((ht/2)-1) ## this messes things up when we change orientation
169
- t1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
170
- t1.preferred_height((ht/2)-1) ## this messes things up when we change orientation
171
- #t1.set_resize_weight 0.50
172
- t2.min_width 15
173
- t2.min_height 5
174
- t1.min_width 12
175
- t1.min_height 5
176
- ta1.min_width 10
177
- ta1.min_height 5
178
- ta2.min_width 10
179
- ta2.min_height 5
180
- ret = splitleft.reset_to_preferred_sizes
181
- splitleft.set_resize_weight(0.50) if ret == :ERROR
182
- ret = splitrt.reset_to_preferred_sizes
183
- splitrt.set_resize_weight(0.50) if ret == :ERROR
184
-
185
- splitleft.preferred_width w/2
186
- splitleft.preferred_height ht/2-2
187
- splitleft.min_width 12
188
- splitleft.min_height 6
189
- splitrt.preferred_width w/2
190
- splitrt.preferred_height ht/2-2
191
- splitrt.min_width 12
192
- splitrt.min_height 6
193
- ret = outer.reset_to_preferred_sizes
194
- outer.set_resize_weight(0.50) if ret == :ERROR
195
-
196
- File.open("../README.markdown","r") do |file|
197
- while (line = file.gets)
198
- ta1 << line.chomp
199
- end
200
- end
201
-
202
- @form.repaint
203
- @window.wrefresh
204
- Ncurses::Panel.update_panels
205
- while((ch = @window.getchar()) != KEY_F1 )
206
- str = keycode_tos ch
207
- #case ch
208
- #when ?v.getbyte(0)
209
- #$log.debug " ORIENTATION VERTICAL"
210
- #outer.orientation(:VERTICAL_SPLIT)
211
- #outer.reset_to_preferred_sizes
212
- #when ?h.getbyte(0)
213
- #$log.debug " ORIENTATION HORIZ"
214
- #outer.orientation(:HORIZONTAL_SPLIT)
215
- #outer.reset_to_preferred_sizes
216
- #when ?-.getbyte(0)
217
- #$log.debug " KEY PRESS -"
218
- #outer.set_divider_location(outer.divider_location-1)
219
- #when ?+.getbyte(0)
220
- #$log.debug " KEY PRESS +"
221
- #outer.set_divider_location(outer.divider_location+1)
222
- #when ?=.getbyte(0)
223
- #$log.debug " KEY PRESS ="
224
- #outer.set_resize_weight(0.50)
225
- #end
226
- #outer.get_buffer().wclear
227
- #outer << "#{ch} got (#{str})"
228
- # outer.repaint
229
- # outer.buffer_to_screen
230
- @form.repaint
231
- @form.handle_key(ch)
232
- @window.wrefresh
233
- end
234
- end
235
- rescue => ex
236
- ensure
237
- @window.destroy if !@window.nil?
238
- VER::stop_ncurses
239
- p ex if ex
240
- p(ex.backtrace.join("\n")) if ex
241
- $log.debug( ex) if ex
242
- $log.debug(ex.backtrace.join("\n")) if ex
243
- end
244
- end