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/TODO2.txt DELETED
@@ -1,118 +0,0 @@
1
- 1 [x] (1) buffered version of Listbox (2009-12-26) (x2010-01-18)
2
- - 1.1 [x] what form is celleditor using. check and fix (2010-01-04) (x2010-01-05) (x2010-01-07)
3
- - 1.2 [x] scrollpane scrollin till 18th row only  * Use downarrow to go down (2010-01-04) (x2010-01-05) (x2010-01-07)
4
- - 1.3 [x] testscrolllb.rb on enter cursor at pos 0 io 5th or so. Ok in test2.rb (2010-01-05) (x2010-01-18)
5
- 2 [x] buffered version of TextArea (2009-12-26) (x2010-01-19)
6
- - 2.1 [x] cursor position not updated when insert text  * just testing indentation (2009-12-27) (x2009-12-31)
7
- - 2.1.1 [x] we have to set main forms row and col from rbtextarea (2009-12-28) (x2009-12-31)
8
- - 2.1.2 [x] to factor in rscrollpane's coords, so cursor inside scr (2009-12-28) (x2009-12-31)
9
- - 2.3 [x] remove var oldcli since not using (2010-01-04) (x2010-01-07)
10
- 3 [x] rscrollpane needs on_enter and set_form_row etc (2009-12-26) (x2009-12-28)
11
- 4 [x] check how is cursor managed by rtabbedpane (2009-12-28) (x2009-12-29)
12
- - 4.1 [x] rtabbedpane does its own highlighting (2009-12-29) (x2009-12-29)
13
- 6 [x] make form.set_form_row which bubbles up row and colrather than directly setting row and col (2009-12-29) (x2009-12-31)
14
- 7 [x] (A) change addrowcol to percolate up too (2009-12-29) (x2010-01-05)
15
- 8 [x] (A) change direct references to form.row and col to call methods (2009-12-29) (x2010-02-18)
16
- 10 [x] @scrollpane needs to stop scrolling if no more data - actually it does, i had made the textarea large (2009-12-29) (x2009-12-29)
17
- 11 [x] (A) new textarea breaks test2.rb. see what on, no display  * display happens on focus/keypress in test2.rb  * display happens on up down arrow, not left right. check if repaint is called comparing old and new files  * Ack listbox is erasing or overwriting new textarea - very strange  * now buffered object write to main window, so window does not overwrite (2009-12-31) (x2010-01-03)
18
- - 11.1 [x] textarea: footer not showing (2010-01-01) (x2010-01-02)
19
- - 11.2 [x] textarea: some flag not updated on a s d f, not showing in testkeypress.rb (2010-01-01) (x2010-01-01)
20
- 12 [x] (A) review rwidget code regarding printing  * which window does textarea print on, is it transferred to main window  * now buffered object write to main window, so window does not overwrite (2010-01-03) (x2010-01-03)
21
- 13 [x] (A) review just print_title and border since they overwrite textarea (2010-01-03) (x2010-01-03)
22
- 14 [x] copy testwidget to textview and tv to old (2010-01-03) (x2010-01-03)
23
- 15 [x] buffered version of Table (2010-01-03) (x2010-01-19)
24
- 16 [x] (2) putting buffered objects in splitpane and testing (2010-01-03) (x2010-02-27)
25
- - 16.1 [x] testing textviews inside splitpane (2010-01-06) (x2010-01-13)
26
- - 16.1.1 [x] test various keys in splitpane with textview (2010-01-08) (x2010-01-13)
27
- - 16.2 [x] add oneTouchExpandable to +splitpane (2010-01-09) (x2010-02-27)
28
- - 16.3 [x] test splitpane with textareas (2010-01-13) (x2010-01-18)
29
- - 16.4 [x] test splitpane with one splitpane and 3 textviews (2010-01-13) (x2010-01-18)
30
- - 16.5 [x] test splitpane with scrollpane and textviews (2010-01-15) (x2010-01-18)
31
- 18 [x] (A) popups now showing one blak line below. need to adjust (2010-01-05) (x2010-01-06)
32
- 19 [x] make a scrollable form using Pad. Hint: scrollpane does that. (2010-01-06) (x2010-03-07)
33
- 20 [x] (A) investigate crash +splitpane, ht is ht/2-1 and you scroll C-n (2010-01-09) (x2010-01-11)
34
- - 20.1 [x] fixed for HORIZ, but do for VERT (2010-01-09) (x2010-01-11)
35
- 21 [x] test out tabbedpane, and compare code with scroll (newtesttabp.rb) (2010-01-10) (x2010-02-21)
36
- 22 [x] (A) sudden blank line in FC in splitpane see testsplittv.rb and tvv.rb  * that's due to top and left 0 by default in create_buffer (2010-01-11) (x2010-01-12)
37
- 23 [x] how to pass top left etc to widget so when it does a create_buffer those values are reached  * set_buffering does this (2010-01-12) (x2010-02-18)
38
- 24 [x] add parent attrib, pass parent in child() and first_component, add a method to pushup row and col adding roffset and coloffset at each level (2010-01-12) (x2010-01-13)
39
- 26 [x] Splitpane: Vert mode, comp 2 doesn't retain cursor when moving (2010-01-13) (x2010-01-13)
40
- 27 [x] (A) TextArea fix direct calls to form.row and form.col (2010-01-14) (x2010-01-14)
41
- 28 [x] (A) TextArea: borders get overwritten  * chomp was required when using << (2010-01-14) (x2010-01-14)
42
- 29 [x] what if we don't want to print borders, since that eats an extraline and col. Can we switch off and reclaim the line and col (2010-01-15) (x2010-02-18)
43
- 31 [x] move create_buffer to repaintin TA and TV and others, so that enduser does not have to bother. scroll and split can set internally  * All create_buffer calls moved to repaint. Maybe table pending (2010-01-16) (x2010-02-18)
44
- 37 [x] (B) test rtable in splitpane and scrollpanes  * done rtable in scrollpane (2010-01-18) (x2010-02-24)
45
- 38 [x] (B) test various widgets inside rtabbedpane (2010-01-19) (x2010-02-22)
46
- 41 [x] Textareas: C-a C-e does not repain which is good, but footer not updated (2010-01-23) (x2010-01-25)
47
- 42 [x] check where we are directly calling wmove and why (2010-01-23) (x2010-01-25)
48
- 43 [x] we need to pass actual highest form down as well as each components absolute coords so cursor display can happen quickly and accurately.  * RFED16 branch has absolute positioning (2010-01-23) (x2010-02-18)
49
- 44 [x] TextView: add more vi keys (2010-02-07) (x2010-02-24)
50
- 46 [x] RFED16 branch: Redo table as per new simple approach (2010-02-18) (x2010-02-19)
51
- 47 [x] RFED16 branch: Redo tabbedpane as per new simple approach (2010-02-18) (x2010-02-21)
52
- 49 [x] (A) Tabbing in top of tabbedpane gives funny staggered effect ?? (2010-02-21) (x2010-02-22)
53
- 50 [x] (A) Tabbedpane: scrolling not updating N and P (2010-02-21) (x2010-03-01)
54
- 51 [x] TabbedPane: add on the fly tabs in tabbedpane - what about second level (2010-02-21) (x2010-03-05)
55
- 53 [x] Splitpane needs multiplier for resizing panes (2010-02-24) (x2010-02-26)
56
- 54 [x] Scrollpane needs multiplier for scrolling (2010-02-24) (x2010-02-26)
57
- 55 [x] (1) keymapping: add symbols and test mapping externally (2010-02-27) (x2010-02-27)
58
- 56 [x] (A) Splitpane: add oneTouchExpandable to +splitpane (2010-02-27) (x2010-03-05)
59
- 57 [x] TabbedPane: can we directly add component (2010-02-27) (x2010-03-01)
60
- 60 [x] (A) Textview: should scroll horizontally (2010-02-28) (x2010-03-05)
61
- 62 [x] (A) TabbedPane: remove subheading, wastes space (2010-03-01) (x2010-03-02)
62
- 63 [x] (E) some means of editing a string at a location wiht option of C-c or Esc and default, take from commons1.rb (2010-03-05) (x2010-03-06)
63
- 64 [x] (F) TextArea and TextView Field Table etc: yanking and pasting globally (2010-03-05) (x2010-03-10)
64
- 65 [x] (F) textarea needs some undo more than just undelete_line  * http://rbcurse.tumblr.com/post/429578665/undo-in-text-widgets (2010-03-05) (x2010-03-12)
65
- 66 [x] (E) Text object should have ability to read in a text file with key (2010-03-05) (x2010-03-12)
66
- 70 [x] (E) rbgetstr: tab completion, as in filename completion etc (2010-03-06) (x2010-03-12)
67
- 71 [x] (D) Demo: using scrollform (2010-03-07) (x2010-03-16)
68
- 72 [ ] (F) TextView: keymaps. p 699 (2010-03-07)
69
- 73 [ ] (F) TextView: freezing an area horiz vertically (2010-03-07)
70
- 74 [x] General: move key bindings to bind_key so user can see what's bound (2010-03-07)
71
- 78 [x] (A) Undo: refactor undomanager and undohandler (2010-03-08) (x2010-03-10)
72
- 79 [x] (A) Demo: get sqlc.rb demo running (2010-03-09) (x2010-03-14)
73
- 80 [x] firehandler: can we combine consecutive ones into one, passing an array? (2010-03-09) (x2010-03-12)
74
- 81 [x] (F) Textview: multiple buffer version (2010-03-10) (x2010-03-12)
75
- 82 [x] (F) Textview: partial editable version (2010-03-10) (x2010-03-12)
76
- 83 [x] make error_message into a Variable, so app can attach it to a label if required (2010-03-11)
77
- 84 [x] (A) move some edit methods from textarea into module so we can call with diff bindings from textview editable (2010-03-12) (x2010-03-12)
78
- 85 [x] (F) how about getting ascii tables in here for sql stuff (2010-03-12)
79
- 87 [x] (E) MultiTextView: list buffers to do (2010-03-12) (x2010-03-15)
80
- 88 [x] (E) TextV+A, when printing a screenful, store actual maxlen for scrolling left (2010-03-12) (x2010-03-13)
81
- 91 [x] (B) tabbedpane: adding new tab dyn, not immediately shown (2010-03-14) (x2010-03-15)
82
- 94 [x] (F) MultiContainer: takes n objects, fills, one can cycle, just as in MultiTextView except that any component can be put. (2010-03-15) (x2010-03-15)
83
- 97 [x] (A) Scrollform : dont we need some indicators or bars (2010-03-17) (x2010-03-18)
84
- 98 [x] (A) SCrollFOrm: cursor not on first field to start with (2010-03-17) (x2010-03-18)
85
- 99 [ ] scrollform demo: add larger objects like textview and test (2010-03-18)
86
- 100 [x] (A) sqlm.rb finish this with multicontainer and table (2010-03-19) (x2010-03-19)
87
- 101 [x] Menu: simpler rewrite ?? (2010-03-20)
88
- 102 [x] (A) TabbedPane: rewrite (2011-09-21)
89
- 103 [x] Messagebox: rewrite (2011-09-21)
90
- 104 [x] (E) Gen: catching extended keys C-left, S-F10 (2011-09-21)
91
- 105 [x] (A) Window: combine array into existing constructor (2011-09-21)
92
- 106 [x] (A) gen: check if that buffering nonsense is still being used? (2011-09-21)
93
- 107 [ ] (F) find_file like microemacs (2011-09-21)
94
- 108 [ ] (F) color schemes (applying at form or app level) (2011-09-21)
95
- 109 [ ] (E) App: stack and flow to be objects so RESIZE can happen (2011-09-21)
96
- 110 [ ] Minor stuff (2011-09-21)
97
- 110.1 [ ] (O) Make event objects only if some listener exists (2010-03-08)
98
- 110.2 [ ] (F) how to map : bind w, 12j (to another key binding)  * if recogn as keys, then call handle_key on self with each key in array (2010-03-01)
99
- 110.3 [ ] (E) Text objects: execute ex commands ???  * printf '%cs/change this/to that/nwq' '%' | ex file.name (2010-03-05)
100
- 110.4 [ ] (E) TextView etal: store path so save can be done? (2010-03-12)
101
- 110.5 [ ] (E) table: yank one or more rows into kill ring as comma delim (2010-03-17)
102
- 110.6 [ ] Table needs multiplier for resizing cols (2010-02-24)
103
- 110.8 [ ] (O) maybe we should combine set_form_row and col since we call them one after another nowadays (2010-01-16)
104
- 110.11 [ ] should parent set scrollatrows for lb and tv and ta ? (2010-01-17)
105
- 110.12 [ ] a Box class = would that help? (2010-03-08)
106
- 111 [ ] (B) me: arrow down and up moves vertically not to next field (2011-09-21)
107
- 112 [ ] (E) app: add popup (2011-09-21)
108
- 113 [ ] (F) basic html view like alpine help with link, underline (2011-09-21)
109
- 115 [ ] (F) widgets shd add major keys to keylabel if present (2011-09-28)
110
- 116 [ ] (F) colormap can check for colorscheme before setting colors (2011-10-01)
111
- 117 [ ] make readme and homepage simple and clean like urwid (2011-10-01)
112
- 118 [x] return self from dsl_property and dsl_accessor (2011-10-02)
113
- 119 [x] PropertyVetoException to disallow change (2011-10-02)
114
- 120 [x] StatusWindow: 2 line bottom window for alert, confirm and status (2011-10-02)
115
- 121 [x] cleanup Widget and others, remove buffering nonsense (2011-10-02)
116
- 122 [x] Add valid_range to Field (2011-10-02)
117
- 123 [x] (A) Make listbox data more accessible from lb class (2011-10-02)
118
- 124 [x] look at sandy,ne,pygments source for ncurses syntax highlighting (2011-10-07)
data/examples/README.txt DELETED
@@ -1,67 +0,0 @@
1
-
2
- README
3
- ------
4
-
5
- ### For ruby 1.9.2, 2010-08-23 11:48
6
-
7
- Changes in 1.9.2 require the following changes:
8
- - $: no longer includes ".".
9
- Fixed 2 examples.
10
- - hash_update: cannot update hash during iteration
11
- Modified rwidget.rb and rtable.rb
12
-
13
- ### IMPORTANT
14
-
15
- 1. If you are trying out the examples from a folder that does not have
16
- write access (e.g. /opt/local/lib...), then you may have to run the
17
- examples, with "sudo", since a log file is created. Or else, you could
18
- copy the examples elsewhere, or change to location of the log file
19
- (view.log) before running.
20
-
21
- sudo ruby test2.rb
22
-
23
- Update: Added an environment variable named LOGDIR. So you may do:
24
-
25
- LOGDIR=~/ ruby test2.rb
26
-
27
- or just set LOGDIR
28
-
29
- export LOGDIR=~/tmp
30
-
31
- 2. Please change directory to the examples folder before executing, since
32
- some data files, or local programs may be loaded.
33
-
34
- ## sqlc.rb
35
-
36
- A sql client using tabbedpanes.
37
-
38
- This uses a file testd.db that can be downloaded (check file for
39
- location) or created using:
40
-
41
- sqlite3 testd.db < data.txt
42
-
43
- Enter an sql query in the textbox. Click Run.
44
-
45
- Or Press Enter on the name of a table in the tables listing. Its
46
- contents will be shown in a new tab in the tabbedpane.
47
-
48
- Or Press Space on a table. Its columns are shown below. Now select
49
- columns and then click Construct. Selected columns will be used to
50
- construct a query. Press Run to execute it.
51
-
52
- If you are inside a table, use Alt-TAb to exit.
53
-
54
- ## sqlm.rb
55
-
56
- Identical to sqlc.rb. This demo uses a multi-container for multiple
57
- resultsets instead of a tabbedpane.
58
-
59
- * * * * *
60
-
61
- Please check the examples with test*.rb - since they are updated.
62
- At the time of writing, viewtodo.rb may not be functional since I
63
- changed to structure of the yaml file.
64
-
65
- ## vim:tw=72:ai:formatoptions=tcqln:nocindent:
66
-
67
-
@@ -1,33 +0,0 @@
1
- require 'rbcurse/app'
2
- require 'rbcurse/rbasiclistbox'
3
-
4
- # just a simple test to ensure that rbasiclistbox is running inside a container.
5
- App.new do
6
- header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "Basic List Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
7
- message "Press F10 to escape from here"
8
-
9
- #list = %W{ bhikshu boddisattva avalokiteswara mu mun kwan paramita prajna samadhi sutra shakyamuni }
10
- list = File.open("data/brew.txt",'r').readlines
11
- list2 = File.open("data/gemlist.txt",'r').readlines
12
- lb = nil
13
- vimsplit :row => 1, :col => 0, :suppress_borders => false, :width => 60, :height => Ncurses.LINES-2, :weight => 0.4, :orientation => :VERTICAL do |s|
14
- lb = RubyCurses::BasicListbox.new nil, :list => list, :suppress_borders => false
15
- #lb = RubyCurses::BasicListbox.new nil, :list => list, :show_selector => true, :row_selected_symbol => "*", :suppress_borders => false
16
- #lb = RubyCurses::BasicListbox.new nil, :list => list
17
- #lb = list_box "A list", :list => list
18
- lb.show_selector = false
19
- #lb.row_selected_symbol = "*"
20
- #lb = list_box "A list", :list => list
21
-
22
- s.add lb, :FIRST
23
- #lb2= RubyCurses::BasicListbox.new nil, :list => list.shuffle, :justify => :center
24
- lb2 = basiclist :list => list2, :justify => :left, :suppress_borders => false
25
- s.add lb2, :SECOND
26
- label({:text => "checking overwrite from list", :row => 10, :col => 60})
27
- label({:text => "checking overwrite from list 1", :row => 11, :col => 60})
28
- end
29
- label({:text => "Press F4 and F5 to test popup, space or enter to select", :row => Ncurses.LINES-1, :col => 0})
30
-
31
- @form.bind_key(FFI::NCurses::KEY_F4) { row = lb.current_index+lb.row; col=lb.col+lb.current_value.length+1; ret = popuplist(%w[ andy berlioz strauss tchaiko matz beethoven], :row => row, :col => col, :title => "Names", :bgcolor => :blue, :color => :white) ; alert "got #{ret} "}
32
- @form.bind_key(FFI::NCurses::KEY_F5) { list = %x[ls].split("\n");ret = popuplist(list, :title => "Files"); alert "Got #{ret} #{list[ret]} " }
33
- end # app
data/examples/alpmenu.rb DELETED
@@ -1,42 +0,0 @@
1
- require 'rbcurse/app'
2
-
3
- App.new do
4
- #title "Demo of Menu - rbcurse"
5
- #subtitle "Hit F1 to quit, F2 for menubar toggle"
6
- header = app_header "rbcurse #{Rbcurse::VERSION}", :text_center => "Alpine Menu Demo", :text_right =>""
7
- #message_row(27)
8
-
9
- stack :margin_top => 10, :margin => 15 do
10
- #w = "Messages".length + 1
11
- w = 60
12
- menulink "&View Todo", :width => w, :description => "View TODO in sqlite" do |s|
13
- message "Pressed #{s.text} "
14
- require './viewtodo'; todo = ViewTodo::TodoApp.new; todo.run
15
- end
16
- blank
17
- menulink "&Edit Todo", :width => w, :description => "Edit TODO in CSV" do |s|
18
- message "Pressed #{s.text} "
19
- require './testtodo'; todo = TestTodo::TodoApp.new; todo.run
20
- end
21
- blank
22
- menulink "&Messages", :width => w, :description => "View messages in current folder" do |s|
23
- message "Pressed #{s.text} "
24
- load './menu1.rb'
25
- end
26
- blank
27
- menulink "&Compose", :width => w, :description => "Compose a mail" do |s|
28
- message "Pressed #{s.getvalue} "
29
- end
30
- blank
31
- menulink "Setup", :mnemonic => "?", :width => w, :description => "Configure Alpine options" do |s|
32
- message "Pressed #{s.text} "
33
- end
34
- blank
35
- menulink "&Quit", :width => w, :description => "Quit this application" do |s|
36
- quit
37
- end
38
- @form.bind(:ENTER) do |w|
39
- header.text_right = w.text
40
- end
41
- end # stack
42
- end # app
data/examples/app.rb DELETED
@@ -1,859 +0,0 @@
1
- =begin
2
- * Name: App
3
- * Description: Experimental Application class
4
- * Author: rkumar (arunachalesha)
5
- * file created 2010-09-04 22:10
6
- Todo:
7
- --------
8
- * License:
9
- Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
10
-
11
- =end
12
- #require 'rubygems'
13
- #require 'ncurses' # FFI
14
- require 'logger'
15
- require 'rbcurse'
16
-
17
- #include Ncurses
18
- include RubyCurses
19
- include RubyCurses::Utils
20
- module RubyCurses
21
- extend self
22
-
23
- # NOTE most of this has move to lib/rbcurse/app.rb
24
- #
25
- class Widget
26
- def changed *args, &block
27
- bind :CHANGED, *args, &block
28
- end
29
- def leave *args, &block
30
- bind :LEAVE, *args, &block
31
- end
32
- def enter *args, &block
33
- bind :ENTER, *args, &block
34
- end
35
- # actually we already have command() for buttons
36
- def click *args, &block
37
- bind :PRESS, *args, &block
38
- end
39
- end
40
- #class Listbox
41
- #def text
42
- #return get_content()[@current_index]
43
- #end
44
- #end
45
- class CheckBox
46
- # a little dicey XXX
47
- def text(*val)
48
- if val.empty?
49
- @value ? @onvalue : @offvalue
50
- else
51
- super
52
- end
53
- end
54
- end
55
- class App
56
- attr_reader :config
57
- attr_reader :form
58
- attr_reader :window
59
- attr_writer :quit_key
60
-
61
-
62
- # i should be able to pass window coords here in config
63
- # :title
64
- def initialize config={}, &block
65
- #$log.debug " inside constructor of APP #{config} "
66
- @config = config
67
- @app_row = @app_col = 0
68
- @stack = [] # stack's coordinates
69
- @flowstack = []
70
- @variables = {}
71
- # if we are creating child objects then we will not use outer form. this object will manage
72
- @current_object = []
73
- init_vars
74
- run &block
75
- end
76
- def init_vars
77
- @quit_key ||= KEY_F1
78
- # actually this should be maintained inside ncurses pack, so not loaded 2 times.
79
- # this way if we call an app from existing program, App won't start ncurses.
80
- unless $ncurses_started
81
- init_ncurses
82
- end
83
- unless $log
84
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
85
- $log.level = Logger::DEBUG
86
- colors = Ncurses.COLORS
87
- $log.debug "START #{colors} colors --------- #{$0}"
88
- end
89
- end
90
- def logger; return $log; end
91
- def close
92
- $log.debug " INSIDE CLOSE, #{@stop_ncurses_on_close} "
93
- @window.destroy if !@window.nil?
94
- $log.debug " INSIDE CLOSE, #{@stop_ncurses_on_close} "
95
- if @stop_ncurses_on_close
96
- VER::stop_ncurses
97
- $log.debug " CLOSING NCURSES"
98
- end
99
- #p $error_message.value unless $error_message.value.nil?
100
- $log.debug " CLOSING APP"
101
- #end
102
- end
103
- # not sure, but user shuld be able to trap keystrokes if he wants
104
- # but do i still call handle_key if he does, or give him total control.
105
- # But loop is already called by framework
106
- def loop &block
107
- @form.repaint
108
- @window.wrefresh
109
- Ncurses::Panel.update_panels
110
- while((ch = @window.getchar()) != @quit_key )
111
- str = keycode_tos ch
112
- @keyblock.call(str.gsub(/-/, "_").to_sym) if @keyblock
113
- $log.debug "#{ch} got (#{str})"
114
- yield ch if block # <<<----
115
- @form.handle_key ch
116
- @form.repaint
117
- @window.wrefresh
118
- end
119
- end
120
- # returns a symbol of the key pressed
121
- # e.g. :C_c for Ctrl-C
122
- # :Space, :bs, :M_d etc
123
- def keypress &block
124
- @keyblock = block
125
- end
126
- # updates a global var with text. Calling app has to set up a Variable with that name and attach to
127
- # a label so it can be printed.
128
- def message text
129
- @message.value = text
130
- end
131
- def message_row row
132
- @message_label.row = row
133
- end
134
- #
135
- # @group methods to create widgets easily
136
- #
137
- # process arguments based on datatype, perhaps making configuration
138
- # of some components easier for caller avoiding too much boiler plate code
139
- #
140
- # create a field
141
- def field *args, &block
142
- config = {}
143
- events = [ :CHANGED, :LEAVE, :ENTER, :CHANGE ]
144
- block_event = :CHANGED # LEAVE, ENTER, CHANGE
145
-
146
- args.each do |arg|
147
- case arg
148
- when Array
149
- #puts "row, col #{arg[0]} #{arg[1]} "
150
- # we can use r,c, w, h
151
- row, col, display_length = arg
152
- config[:row] = row
153
- config[:col] = col
154
- config[:display_length] = display_length if display_length
155
- when Hash
156
- config.merge!(arg)
157
- block_event = config.delete(:block_event){ block_event }
158
- raise "Invalid event. Use #{events}" unless events.include? block_event
159
- #puts "hash #{config}"
160
- when String
161
- title = arg
162
- config[:name] = title
163
- end
164
- end
165
- if @instack
166
- # most likely you won't have row and col. should we check or just go ahead
167
- col = @stack.last.margin
168
- config[:row] = @app_row
169
- config[:col] = col
170
- @app_row += 1
171
- end
172
- field = Field.new @form, config
173
- # shooz uses CHANGED, which is equivalent to our CHANGE. Our CHANGED means modified and exited
174
- if block
175
- field.bind(block_event, &block)
176
- end
177
- return field
178
- end
179
- #instance_eval &block if block_given?
180
- # or
181
- #@blk = block # for later execution using @blk.call()
182
- #colorlabel = Label.new @form, {'text' => "Select a color:", "row" => row, "col" => col, "color"=>"cyan", "mnemonic" => 'S'}
183
- #var = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => r, "col" => fc}
184
-
185
- def label *args
186
- block_event = nil
187
- config = {}
188
-
189
- args.each do |arg|
190
- case arg
191
- when Array
192
- row, col, display_length, height = arg
193
- config[:row] = row
194
- config[:col] = col
195
- config[:display_length] = display_length if display_length
196
- config[:height] = height || 1
197
- when Hash
198
- config.merge!(arg)
199
- when String
200
- config[:text] = arg
201
- end
202
- end
203
- config[:height] ||= 1
204
- if @instack
205
- # most likely you won't have row and col. should we check or just go ahead
206
- col = @stack.last.margin
207
- config[:row] = @app_row
208
- config[:col] = col
209
- @app_row += config[:height]
210
- end
211
- label = Label.new @form, config
212
- # shooz uses CHANGED, which is equivalent to our CHANGE. Our CHANGED means modified and exited
213
- return label
214
- end
215
- alias :text :label
216
- def button *args, &block
217
- config = {}
218
- events = [ :PRESS, :LEAVE, :ENTER ]
219
- block_event = :PRESS
220
-
221
- #process_args args, config, block_event, events
222
- args.each do |arg|
223
- case arg
224
- when Array
225
- #puts "row, col #{arg[0]} #{arg[1]} "
226
- # we can use r,c, w, h
227
- row, col, display_length, height = arg
228
- config[:row] = row
229
- config[:col] = col
230
- config[:display_length] = display_length if display_length
231
- config[:height] = height if height
232
- when Hash
233
- config.merge!(arg)
234
- block_event = config.delete(:block_event){ block_event }
235
- raise "Invalid event. Use #{events}" unless events.include? block_event
236
- #puts "hash #{config}"
237
- when String
238
- config[:text] = arg
239
- config[:name] = arg
240
- end
241
- end
242
- # flow gets precedence over stack
243
- _position(config)
244
- button = Button.new @form, config
245
- # shooz uses CHANGED, which is equivalent to our CHANGE. Our CHANGED means modified and exited
246
- if block
247
- button.bind(block_event, &block)
248
- end
249
- return button
250
- end
251
- #
252
- # create a list
253
- # Since we are mouseless, one can traverse without selection. So we have a different
254
- # way of selecting row/s and traversal. XXX this aspect of LB's has always troubled me hugely.
255
- def list_box *args, &block
256
- config = {}
257
- # TODO confirm events
258
- # listdataevent has interval added and interval removed, due to multiple
259
- # selection, we have to make that simple for user here.
260
- events = [ :LEAVE, :ENTER, :ENTER_ROW, :LEAVE_ROW, :LIST_DATA_EVENT ]
261
- # TODO how to do this so he gets selected row easily
262
- block_event = :ENTER_ROW
263
-
264
- # TODO abstract this into a new method so no copying
265
- args.each do |arg|
266
- case arg
267
- when Array
268
- #puts "row, col #{arg[0]} #{arg[1]} "
269
- # we can use r,c, w, h
270
- row, col, display_length, height = arg
271
- config[:row] = row
272
- config[:col] = col
273
- config[:display_length] = display_length if display_length
274
- config[:height] = height if height
275
- when Hash
276
- config.merge!(arg)
277
- block_event = config.delete(:block_event){ block_event }
278
- raise "Invalid event. Use #{events}" unless events.include? block_event
279
- #puts "hash #{config}"
280
- when String
281
- config[:name] = arg
282
- config[:title] = arg
283
- end
284
- end
285
- # naive defaults, since list could be large or have very long items
286
- # usually user will provide
287
- config[:height] ||= config[:list].length + 2
288
- if @current_object.empty?
289
- $log.debug "1 APP LB w: #{config[:width]} ,#{config[:name]} "
290
- config[:width] ||= @stack.last.width if @stack.last
291
- $log.debug "2 APP LB w: #{config[:width]} "
292
- config[:width] ||= longest_in_list(config[:list])+2
293
- $log.debug "3 APP LB w: #{config[:width]} "
294
- end
295
- # if no width given, expand to flows width XXX SHOULD BE NOT EXPAND ?
296
- #config[:width] ||= @stack.last.width if @stack.last
297
- #if config.has_key? :choose
298
- config[:default_values] = config.delete :choose
299
- # we make the default single unless specified
300
- config[:selection_mode] = :single unless config.has_key? :selection_mode
301
- if @current_object.empty?
302
- if @instack
303
- # most likely you won't have row and col. should we check or just go ahead
304
- col = @stack.last.margin
305
- config[:row] = @app_row
306
- config[:col] = col
307
- @app_row += config[:height] # this needs to take into account height of prev object
308
- end
309
- end
310
- useform = nil
311
- useform = @form if @current_object.empty?
312
- field = Listbox.new useform, config
313
- # shooz uses CHANGED, which is equivalent to our CHANGE. Our CHANGED means modified and exited
314
- if block
315
- # this way you can't pass params to the block
316
- field.bind(block_event, &block)
317
- end
318
- return field
319
- end
320
-
321
- # toggle button
322
- def toggle *args, &block
323
- config = {}
324
- # TODO confirm events
325
- events = [ :PRESS, :LEAVE, :ENTER ]
326
- block_event = :PRESS
327
- _process_args args, config, block_event, events
328
- config[:text] ||= longest_in_list2( [config[:onvalue], config[:offvalue]])
329
- #config[:onvalue] # needed for flow, we need a better way FIXME
330
- _position(config)
331
- toggle = ToggleButton.new @form, config
332
- if block
333
- toggle.bind(block_event, &block)
334
- end
335
- return toggle
336
- end
337
- # check button
338
- def check *args, &block
339
- config = {}
340
- # TODO confirm events
341
- events = [ :PRESS, :LEAVE, :ENTER ]
342
- block_event = :PRESS
343
- _process_args args, config, block_event, events
344
- _position(config)
345
- toggle = CheckBox.new @form, config
346
- if block
347
- toggle.bind(block_event, &block)
348
- end
349
- return toggle
350
- end
351
- # radio button
352
- def radio *args, &block
353
- config = {}
354
- # TODO confirm events
355
- events = [ :PRESS, :LEAVE, :ENTER ]
356
- block_event = :PRESS
357
- _process_args args, config, block_event, events
358
- a = config[:group]
359
- # FIXME we should check if user has set a varialbe in :variable.
360
- # we should create a variable, so he can use it if he wants.
361
- if @variables.has_key? a
362
- v = @variables[a]
363
- else
364
- v = Variable.new
365
- @variables[a] = v
366
- end
367
- config[:variable] = v
368
- config.delete(:group)
369
- _position(config)
370
- radio = RadioButton.new @form, config
371
- if block
372
- radio.bind(block_event, &block)
373
- end
374
- return radio
375
- end
376
- # editable text area
377
- def textarea *args, &block
378
- require 'rbcurse/rtextarea'
379
- config = {}
380
- # TODO confirm events many more
381
- events = [ :CHANGE, :LEAVE, :ENTER ]
382
- block_event = events[0]
383
- _process_args args, config, block_event, events
384
- config[:width] = config[:display_length] unless config.has_key? :width
385
- _position(config)
386
- # if no width given, expand to flows width
387
- config[:width] ||= @stack.last.width if @stack.last
388
- useform = nil
389
- useform = @form if @current_object.empty?
390
- w = TextArea.new useform, config
391
- if block
392
- w.bind(block_event, &block)
393
- end
394
- return w
395
- end
396
- # progress bar
397
- def progress *args, &block
398
- require 'rbcurse/rprogress'
399
- config = {}
400
- # TODO confirm events many more
401
- events = [ :CHANGE, :LEAVE, :ENTER ]
402
- block_event = nil
403
- _process_args args, config, block_event, events
404
- config[:width] = config[:display_length] || 10 unless config.has_key? :width
405
- _position(config)
406
- w = Progress.new @form, config
407
- #if block
408
- #w.bind(block_event, &block)
409
- #end
410
- return w
411
- end
412
-
413
- # table widget
414
- # @example
415
- # data = [["Roger",16,"SWI"], ["Phillip",1, "DEU"]]
416
- # colnames = ["Name", "Wins", "Place"]
417
- # t = table :width => 40, :height => 10, :columns => colnames, :data => data, :estimate_widths => true
418
- # other options are :column_widths => [12,4,12]
419
- # :size_to_fit => true
420
- def table *args, &block
421
- require 'rbcurse/rtable'
422
- config = {}
423
- # TODO confirm events many more
424
- events = [ :ENTER_ROW, :LEAVE, :ENTER ]
425
- block_event = events[0]
426
- _process_args args, config, block_event, events
427
- # if user is leaving out width, then we don't want it in config
428
- # else Widget will put a value of 10 as default, overriding what we've calculated
429
- if config.has_key? :display_length
430
- config[:width] = config[:display_length] unless config.has_key? :width
431
- end
432
- ext = config.delete :extended_keys
433
-
434
- model = nil
435
- _position(config)
436
- # if no width given, expand to flows width
437
- config[:width] ||= @stack.last.width if @stack.last
438
- w = Table.new @form, config
439
- if ext
440
- require 'rbcurse/extras/tableextended'
441
- # so we can increase and decrease column width using keys
442
- w.extend TableExtended
443
- w.bind_key(?w){ w.next_column }
444
- w.bind_key(?b){ w.previous_column }
445
- w.bind_key(?+) { w.increase_column }
446
- w.bind_key(?-) { w.decrease_column }
447
- w.bind_key([?d, ?d]) { w.table_model.delete_at w.current_index }
448
- w.bind_key(?u) { w.table_model.undo w.current_index}
449
- end
450
- if block
451
- w.bind(block_event, &block)
452
- end
453
- return w
454
- end
455
- # print a title on first row
456
- def title string, config={}
457
- ## TODO center it
458
- @window.printstring 1, 30, string, $normalcolor, 'reverse'
459
- end
460
- # print a sutitle on second row
461
- def subtitle string, config={}
462
- @window.printstring 2, 30, string, $datacolor, 'normal'
463
- end
464
- # menu bar
465
- def menubar &block
466
- require 'rbcurse/rmenu'
467
- RubyCurses::MenuBar.new &block
468
- end
469
-
470
- # creates a blank row
471
- def blank rows=1, config={}
472
- @app_row += rows
473
- end
474
- # displays a horizontal line
475
- # takes col (column to start from) from current stack
476
- # take row from app_row
477
- #
478
- # requires width to be passed in config, else defaults to 20
479
- # @example
480
- # hline :width => 55
481
- def hline config={}
482
- row = @app_row
483
- width = config[:width] || 20
484
- _position config
485
- col = config[:col] || 1
486
- @window.mvwhline( row, col, ACS_HLINE, width)
487
- @app_row += 1
488
- end
489
- def app_header title, config={}, &block
490
- require 'rbcurse/applicationheader'
491
- header = ApplicationHeader.new @form, title, config, &block
492
- end
493
- def dock labels, config={}, &block
494
- require 'rbcurse/keylabelprinter'
495
- klp = RubyCurses::KeyLabelPrinter.new @form, labels, config, &block
496
- end
497
- def link *args, &block
498
- require 'rbcurse/extras/rlink'
499
- config = {}
500
- events = [ :PRESS, :LEAVE, :ENTER ]
501
- block_event = :PRESS
502
- _process_args args, config, block_event, events
503
- _position(config)
504
- config[:text] ||= config.delete :title
505
- config[:highlight_foreground] = "yellow"
506
- config[:highlight_background] = "red"
507
- toggle = Link.new @form, config
508
- if block
509
- toggle.bind(block_event, toggle, &block)
510
- end
511
- return toggle
512
- end
513
- def menulink *args, &block
514
- require 'rbcurse/extras/rmenulink'
515
- config = {}
516
- events = [ :PRESS, :LEAVE, :ENTER ]
517
- block_event = :PRESS
518
- _process_args args, config, block_event, events
519
- _position(config)
520
- config[:text] ||= config.delete :title
521
- config[:highlight_foreground] = "yellow"
522
- config[:highlight_background] = "red"
523
- toggle = MenuLink.new @form, config
524
- if block
525
- toggle.bind(block_event, toggle, &block)
526
- end
527
- return toggle
528
- end
529
- def splitpane *args, &block
530
- require 'rbcurse/rsplitpane2'
531
- config = {}
532
- events = [ :PROPERTY_CHANGE, :LEAVE, :ENTER ]
533
- block_event = events[0]
534
- _process_args args, config, block_event, events
535
- _position(config)
536
- # if no width given, expand to flows width
537
- config[:width] ||= @stack.last.width if @stack.last
538
- config.delete :title
539
- useform = nil
540
- useform = @form if @current_object.empty?
541
-
542
- w = SplitPane.new useform, config
543
- #if block
544
- #w.bind(block_event, w, &block)
545
- #end
546
- if block_given?
547
- @current_object << w
548
- #instance_eval &block if block_given?
549
- yield w
550
- @current_object.pop
551
- end
552
- return w
553
- end
554
- def multisplit *args, &block
555
- require 'rbcurse/rmultisplit'
556
- config = {}
557
- events = [ :PROPERTY_CHANGE, :LEAVE, :ENTER ]
558
- block_event = events[0]
559
- _process_args args, config, block_event, events
560
- _position(config)
561
- # if no width given, expand to flows width
562
- config[:width] ||= @stack.last.width if @stack.last
563
- config.delete :title
564
- useform = nil
565
- useform = @form if @current_object.empty?
566
-
567
- w = MultiSplit.new useform, config
568
- #if block
569
- #w.bind(block_event, w, &block)
570
- #end
571
- if block_given?
572
- @current_object << w
573
- #instance_eval &block if block_given?
574
- yield w
575
- @current_object.pop
576
- end
577
- return w
578
- end
579
-
580
- # ADD new widget above this
581
-
582
- # @endgroup
583
-
584
- # @group positioning of components
585
-
586
- # line up vertically whatever comes in, ignoring r and c
587
- # margin_top to add to margin of existing stack (if embedded) such as extra spacing
588
- # margin to add to margin of existing stack, or window (0)
589
- Stack = Struct.new(:margin_top, :margin, :width)
590
- def stack config={}, &block
591
- @instack = true
592
- mt = config[:margin_top] || 1
593
- mr = config[:margin] || 0
594
- # must take into account margin
595
- defw = Ncurses.COLS - mr
596
- w = config[:width] || [50, defw].min
597
- s = Stack.new(mt, mr, w)
598
- @app_row += mt
599
- mr += @stack.last.margin if @stack.last
600
- #@stack << mr
601
- @stack << s
602
- instance_eval &block if block_given?
603
- @stack.pop
604
- @instack = false if @stack.empty?
605
- @app_row = 0 if @stack.empty?
606
- end
607
- # keep adding to right of previous and when no more space
608
- # move down and continue fitting in.
609
- # Useful for button positioning. Currently, we can use a second flow
610
- # to get another row.
611
- # TODO: move down when row filled
612
- # TODO: align right, center
613
- def flow config={}, &block
614
- @inflow = true
615
- mt = config[:margin_top] || 0
616
- @app_row += mt
617
- col = @flowstack.last || @stack.last.margin || @app_col
618
- col += config[:margin] || 0
619
- @flowstack << col
620
- @flowcol = col
621
- instance_eval &block if block_given?
622
- @flowstack.pop
623
- @inflow = false if @flowstack.empty?
624
- end
625
-
626
- private
627
- def quit
628
- throw(:close)
629
- end
630
- # Initialize curses
631
- def init_ncurses
632
- VER::start_ncurses # this is initializing colors via ColorMap.setup
633
- #$ncurses_started = true
634
- @stop_ncurses_on_close = true
635
- end
636
-
637
- # returns length of longest
638
- def longest_in_list list
639
- longest = list.inject(0) do |memo,word|
640
- memo >= word.length ? memo : word.length
641
- end
642
- longest
643
- end
644
- # returns longest item
645
- def longest_in_list2 list
646
- longest = list.inject(list[0]) do |memo,word|
647
- memo.length >= word.length ? memo : word
648
- end
649
- longest
650
- end
651
- def run &block
652
- begin
653
-
654
- # check if user has passed window coord in config, else root window
655
- @window = VER::Window.root_window
656
- catch(:close) do
657
- @form = Form.new @window
658
- @message = Variable.new
659
- @message.value = "Message Comes Here"
660
- @message_label = RubyCurses::Label.new @form, {:text_variable => @message, :name=>"message_label",:row => 24, :col => 1, :display_length => 60, :height => 1, :color => 'cyan'}
661
- $error_message.update_command { @message.set_value($error_message.value) }
662
- if block
663
- begin
664
- #yield(self, @window, @form)
665
- instance_eval &block if block_given?
666
- loop
667
- rescue => ex
668
- $log.debug( "APP.rb rescue reached ")
669
- $log.debug( ex) if ex
670
- $log.debug(ex.backtrace.join("\n")) if ex
671
- ensure
672
- close
673
- # putting it here allows it to be printed on screen, otherwise it was not showing at all.
674
- if ex
675
- puts "========== EXCEPTION =========="
676
- p ex
677
- puts "=========="
678
- puts(ex.backtrace.join("\n"))
679
- end
680
- end
681
- nil
682
- else
683
- #@close_on_terminate = true
684
- self
685
- end #if block
686
- end
687
- end
688
- end
689
- # TODO
690
- # process args, all widgets should call this
691
- def _process_args args, config, block_event, events
692
- args.each do |arg|
693
- case arg
694
- when Array
695
- # we can use r,c, w, h
696
- row, col, display_length, height = arg
697
- config[:row] = row
698
- config[:col] = col
699
- config[:display_length] = display_length if display_length
700
- config[:width] = display_length if display_length
701
- # width for most XXX ?
702
- config[:height] = height if height
703
- when Hash
704
- config.merge!(arg)
705
- if block_event
706
- block_event = config.delete(:block_event){ block_event }
707
- raise "Invalid event. Use #{events}" unless events.include? block_event
708
- end
709
- when String
710
- config[:name] = arg
711
- config[:title] = arg # some may not have title
712
- #config[:text] = arg # some may not have title
713
- end
714
- end
715
- end # _process
716
- # position object based on whether in a flow or stack.
717
- # @app_row is prepared for next object based on this objects ht
718
- def _position config
719
- unless @current_object.empty?
720
- $log.debug " WWWW returning from position #{@current_object.last} "
721
- return
722
- end
723
- if @inflow
724
- #col = @flowstack.last
725
- config[:row] = @app_row
726
- config[:col] = @flowcol
727
- $log.debug " YYYY config #{config} "
728
- @flowcol += config[:text].length + 5 # 5 came from buttons
729
- elsif @instack
730
- # most likely you won't have row and col. should we check or just go ahead
731
- col = @stack.last.margin
732
- config[:row] = @app_row
733
- config[:col] = col
734
- @app_row += config[:height] || 1
735
- # TODO need to allow stack to have its spacing, but we don't have an object as yet.
736
- end
737
- end
738
- end # class
739
- end # module
740
- if $0 == __FILE__
741
- include RubyCurses
742
- #app = App.new
743
- #window = app.window
744
- #window.printstring 2, 30, "Demo of Listbox - rbcurse", $normalcolor, 'reverse'
745
- #app.logger.info "beforegetch"
746
- #window.getch
747
- #app.close
748
- # this was the yield example, but now we've moved to instance eval
749
- App.new do
750
- @window.printstring 0, 30, "Demo of Listbox - rbcurse", $normalcolor, 'reverse'
751
- @window.printstring 1, 30, "Hit F1 to quit", $datacolor, 'normal'
752
- form = @form
753
- fname = "Search"
754
- r, c = 7, 30
755
- c += fname.length + 1
756
- #field1 = field( [r,c, 30], fname, :bgcolor => "cyan", :block_event => :CHANGE) do |fld|
757
- stack :margin_top => 2, :margin => 10 do
758
- lbl = label({:text => fname, :color=>'white',:bgcolor=>'red', :mnemonic=> 's'})
759
- field1 = field( [r,c, 30], fname, :bgcolor => "cyan",:block_event => :CHANGE) do |fld|
760
- message("You entered #{fld.getvalue}. To quit enter quit and tab out")
761
- if fld.getvalue == "quit"
762
- logger.info "you typed quit!"
763
- throw :close
764
- end
765
- end
766
- #field1.set_label Label.new @form, {:text => fname, :color=>'white',:bgcolor=>'red', :mnemonic=> 's'}
767
- field1.set_label( lbl )
768
- field1.enter do
769
- message "you entered this field"
770
- end
771
-
772
- stack :margin_top => 2, :margin => 0 do
773
- #label( [8, 30, 60],{:text => "A label", :color=>'white',:bgcolor=>'blue'} )
774
- end
775
-
776
- @bluelabel = label( [8, 30, 60],{:text => "B label", :color=>'white',:bgcolor=>'blue'} )
777
-
778
- stack :margin_top => 2, :margin => 0 do
779
- toggle :onvalue => " Toggle Down ", :offvalue => " Untoggle ", :mnemonic => 'T', :value => true
780
-
781
- toggle :onvalue => " On ", :offvalue => " Off ", :value => true do |e|
782
- alert "You pressed me #{e.state}"
783
- end
784
- check :text => "Check me!", :onvalue => "Checked", :offvalue => "Unchecked", :value => true do |e|
785
- # this works but long and complicated
786
- #@bluelabel.text = e.item.getvalue ? e.item.onvalue : e.item.offvalue
787
- @bluelabel.text = e.item.text
788
- end
789
- radio :text => "red", :value => "RED", :color => "red", :group => :colors
790
- radio :text => "green", :value => "GREEN", :color => "green", :group => :colors
791
- flow do
792
- button_row = 17
793
- ok_button = button( [button_row,30], "OK", {:mnemonic => 'O'}) do
794
- alert("About to dump data into log file!")
795
- message "Dumped data to log file"
796
- end
797
-
798
- # using ampersand to set mnemonic
799
- cancel_button = button( [button_row, 40], "&Cancel" ) do
800
- if confirm("Do your really want to quit?")== :YES
801
- #throw(:close);
802
- quit
803
- else
804
- message "Quit aborted"
805
- end
806
- end # cancel
807
- button "Don't know"
808
- end
809
- flow :margin_top => 2 do
810
- button "Another"
811
- button "Line"
812
- end
813
- stack :margin_top => 2, :margin => 0 do
814
- @pbar = progress :width => 20, :bgcolor => 'white', :color => 'red'
815
- @pbar1 = progress :width => 20, :style => :old
816
- end
817
- end
818
- end # stack
819
- # lets make another column
820
- stack :margin_top => 2, :margin => 70 do
821
- l = label "Column 2"
822
- f1 = field "afield", :bgcolor => 'white', :color => 'black'
823
- list_box "A list", :list => ["Square", "Oval", "Rectangle", "Somethinglarge"], :choose => ["Square"]
824
- lb = list_box "Another", :list => ["Square", "Oval", "Rectangle", "Somethinglarge"] do |list|
825
- #f1.set_buffer list.text
826
- #f1.text list.text
827
- f1.text = list.text
828
- l.text = list.text.upcase
829
- end
830
- t = textarea :height => 10 do |e|
831
- #@bluelabel.text = e.to_s.tr("\n",' ')
832
- @bluelabel.text = e.text.gsub("\n"," ")
833
- len = e.source.get_text.length
834
- len = len % 20 if len > 20
835
- $log.debug " PBAR len of text is #{len}: #{len/20.0} "
836
- @pbar.fraction(len/20.0)
837
- @pbar1.fraction(len/20.0)
838
- i = ((len/20.0)*100).to_i
839
- @pbar.text = "completed:#{i}"
840
- end
841
- t.leave do |c|
842
- @bluelabel.text = c.get_text.gsub("\n"," ")
843
- end
844
-
845
- end
846
-
847
- # Allow user to get the keys
848
- keypress do |key|
849
- if key == :C_c
850
- message "You tried to cancel"
851
- #throw :close
852
- quit
853
- else
854
- #app.message "You pressed #{key}, #{char} "
855
- message "You pressed #{key}"
856
- end
857
- end
858
- end
859
- end