rbcurse 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. data/README.markdown +3 -2
  2. data/VERSION +1 -1
  3. metadata +6 -103
  4. data/examples/README.txt +0 -67
  5. data/examples/abasiclist.rb +0 -33
  6. data/examples/alpmenu.rb +0 -42
  7. data/examples/app.rb +0 -859
  8. data/examples/app.sample +0 -17
  9. data/examples/appdirtree.rb +0 -74
  10. data/examples/appemail.rb +0 -191
  11. data/examples/appemaillb.rb +0 -308
  12. data/examples/appgcompose.rb +0 -315
  13. data/examples/atree.rb +0 -64
  14. data/examples/common/file.rb +0 -40
  15. data/examples/common/rmail.rb +0 -257
  16. data/examples/data.txt +0 -683
  17. data/examples/data/README.markdown +0 -9
  18. data/examples/data/brew.txt +0 -38
  19. data/examples/data/color.2 +0 -37
  20. data/examples/data/gemlist.txt +0 -60
  21. data/examples/data/lotr.txt +0 -12
  22. data/examples/data/ports.txt +0 -136
  23. data/examples/data/tasks.txt +0 -27
  24. data/examples/data/todocsv.csv +0 -28
  25. data/examples/data/unix1.txt +0 -21
  26. data/examples/data/unix2.txt +0 -11
  27. data/examples/dbdemo.rb +0 -495
  28. data/examples/deprecated/appgmail.rb +0 -952
  29. data/examples/deprecated/splitp.rb +0 -56
  30. data/examples/deprecated/testscrolllb.rb +0 -86
  31. data/examples/deprecated/testscrollp.rb +0 -88
  32. data/examples/deprecated/testscrollta.rb +0 -80
  33. data/examples/deprecated/testscrolltable.rb +0 -165
  34. data/examples/deprecated/testsplit.rb +0 -87
  35. data/examples/deprecated/testsplit2.rb +0 -123
  36. data/examples/deprecated/testsplit3.rb +0 -215
  37. data/examples/deprecated/testsplit3_1.rb +0 -244
  38. data/examples/deprecated/testsplit3a.rb +0 -215
  39. data/examples/deprecated/testsplit3b.rb +0 -237
  40. data/examples/deprecated/testsplitta.rb +0 -148
  41. data/examples/deprecated/testsplittv.rb +0 -142
  42. data/examples/deprecated/testsplittvv.rb +0 -144
  43. data/examples/deprecated/testtpane.rb +0 -215
  44. data/examples/deprecated/testtpane2.rb +0 -145
  45. data/examples/deprecated/testtpanetable.rb +0 -203
  46. data/examples/dirtree.rb +0 -88
  47. data/examples/experimental/resultsetdemo.rb +0 -280
  48. data/examples/experimental/testmform.rb +0 -35
  49. data/examples/experimental/testscroller.rb +0 -117
  50. data/examples/experimental/teststackflow.rb +0 -111
  51. data/examples/menu1.rb +0 -112
  52. data/examples/multispl.rb +0 -86
  53. data/examples/newmessagebox.rb +0 -131
  54. data/examples/newtabbedwindow.rb +0 -100
  55. data/examples/newtesttabp.rb +0 -121
  56. data/examples/qdfilechooser.rb +0 -68
  57. data/examples/rfe.rb +0 -1239
  58. data/examples/rfe_renderer.rb +0 -121
  59. data/examples/sqlc.rb +0 -454
  60. data/examples/sqlm.rb +0 -437
  61. data/examples/sqlt.rb +0 -408
  62. data/examples/status.txt +0 -68
  63. data/examples/table1.rb +0 -24
  64. data/examples/term2.rb +0 -84
  65. data/examples/test1.rb +0 -239
  66. data/examples/test2.rb +0 -674
  67. data/examples/testapp.rb +0 -44
  68. data/examples/testapp2.rb +0 -58
  69. data/examples/testchars.rb +0 -137
  70. data/examples/testcombo.rb +0 -91
  71. data/examples/testkeypress.rb +0 -66
  72. data/examples/testlistbox.rb +0 -113
  73. data/examples/testmenu.rb +0 -101
  74. data/examples/testmulticomp.rb +0 -70
  75. data/examples/testmulticontainer.rb +0 -94
  76. data/examples/testmultispl.rb +0 -199
  77. data/examples/testree.rb +0 -106
  78. data/examples/testtable.rb +0 -264
  79. data/examples/testtabp.rb +0 -107
  80. data/examples/testtodo.rb +0 -584
  81. data/examples/testvimsplit.rb +0 -112
  82. data/examples/testwsshortcuts.rb +0 -64
  83. data/examples/testwsshortcuts2.rb +0 -126
  84. data/examples/todo.db +0 -0
  85. data/examples/todo.yml +0 -191
  86. data/examples/viewtodo.rb +0 -574
  87. data/lib/rbcurse.rb +0 -8
  88. data/lib/rbcurse/deprecated/README.markdown +0 -12
  89. data/lib/rbcurse/deprecated/rpad.rb +0 -375
  90. data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
  91. data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
  92. data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
  93. data/lib/rbcurse/deprecated/rviewport.rb +0 -204
  94. data/lib/rbcurse/deprecated/widgets/mapper.rb +0 -130
  95. data/lib/rbcurse/deprecated/widgets/rmessagebox.rb +0 -348
  96. data/lib/rbcurse/deprecated/widgets/rtabbedpane.rb +0 -1158
  97. data/lib/rbcurse/deprecated/widgets/rtabbedwindow.rb +0 -167
  98. data/lib/rbcurse/deprecated/widgets/scrollable.rb +0 -301
  99. data/lib/rbcurse/deprecated/widgets/stdscrwindow.rb +0 -309
  100. data/lib/ver/keyboard2.rb +0 -170
@@ -1,44 +0,0 @@
1
- require 'rbcurse/core/util/app'
2
-
3
- # this was a test to see how i could have a class and an app inside
4
- # and i could call methods in the class and have variables available
5
- # inside App.
6
- #
7
- # instance_eval inside stack and others was causing the issue putting everything in
8
- # App. However, i have to change the app, to use yield in order not to lose context
9
-
10
- class Testy
11
- attr_accessor :value
12
- def initialize val
13
- @value = val
14
- @my = "oldval"
15
- run
16
- end
17
- def amethod
18
- $log.debug "XXXX amethod called... " if $log.debug?
19
- alert " self #{self.class} amethod "
20
- @my = "hellothere"
21
- end
22
- def run
23
- puts @value
24
- app = App.new
25
- $log.debug " APP : value #{value}" if $log.debug?
26
- header = app.app_header "rbcurse #{Rbcurse::VERSION} " , :text_center => " #{@value} Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
27
- app.message "Press F10 to exit from here #{@value} "
28
-
29
- app.stack :margin_top => 2, :margin => 5, :width => 30 do |s|
30
- app.label "Hello: ", :attr => :reverse
31
- f=app.field "abc"
32
- #amethod()
33
- f.bind(:CHANGE) {
34
- amethod()
35
- app.message "now #{@my} "
36
- }
37
-
38
- end # stack
39
- app.safe_loop
40
- end
41
- end
42
- if __FILE__ == $PROGRAM_NAME
43
- Testy.new "FFI-NCURSES"
44
- end
@@ -1,58 +0,0 @@
1
- require 'rbcurse/core/util/app'
2
-
3
- ####
4
- # If you want to create an application which can run standaalong from terminal, or be passed
5
- # values from a previous form then this is one way you can do it.
6
- #
7
- # this was a test to see how i could have a class and an app inside
8
- # and i could call methods in the class and have variables available
9
- # inside App.
10
- #
11
- # instance_eval inside stack and others was causing the issue putting everything in
12
- # App. However, i have to change the app, to use yield in order not to lose context
13
-
14
- class Testy
15
- attr_accessor :value
16
- def initialize val
17
- @value = val
18
- @my = "oldval"
19
- run
20
- end
21
- # i will call this method from within the App block
22
- def amethod
23
- $log.debug "XXXX amethod called... " if $log.debug?
24
- #alert " self #{self.class} amethod "
25
- # we will access @my from insdie the block, we also access @f from here
26
- @my = "hellothere #{@f.getvalue} "
27
- end
28
- def run
29
-
30
- App.new do |app|
31
- $log.debug " APP : value #{value}" if $log.debug?
32
- header = app.app_header "rbcurse #{Rbcurse::VERSION} ", :text_center => " #{@value} Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
33
- app.message "Press F10 to exit from here #{@value} "
34
-
35
- app.stack :margin_top => 2, :margin => 5, :width => 30 do |s|
36
- app.label "Hello: ", :attr => :reverse
37
- @f=app.field "abc"
38
- #amethod()
39
- @f.bind(:CHANGE) {
40
- amethod()
41
- app.message "now #{@my} "
42
- }
43
-
44
- end # stack
45
- app.status_line :row => last_line()
46
-
47
- # earlier style without end, everything had to be explicit but quite simple. Hard to edit since you
48
- # could mess up by inserting inside
49
- s="#[fg=green]testing chunks #[fg=yellow, bg=red, bold]yellow #[reverse] reverseme#[normal]normal#[bg = black]just yellow#[fg=blue],blue now #[underline] underlined text"
50
- # revised, i know allow [end] so you can pop back to whatever was there before.
51
- s="#[fg=green]testing chunks #[fg=yellow, bg=red, bold]yellow #[/end] back to green#[reverse]reverse#[end]#[bg=blue]blue bg #[end],back to green #[/end]plain#[underline] underlined text"
52
- app.window.printstring_formatted 15,1, s, $datacolor, 'normal'
53
- end
54
- end
55
- end
56
- if __FILE__ == $PROGRAM_NAME
57
- Testy.new "SomeData"
58
- end
@@ -1,137 +0,0 @@
1
- require 'logger'
2
- require 'rbcurse'
3
- if $0 == __FILE__
4
- include RubyCurses
5
- include RubyCurses::Utils
6
-
7
- begin
8
- # Initialize curses
9
- VER::start_ncurses # this is initializing colors via ColorMap.setup
10
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
11
- $log.level = Logger::DEBUG
12
-
13
- @window = VER::Window.root_window
14
-
15
- catch(:close) do
16
- colors = Ncurses.COLORS
17
- @form = Form.new @window
18
- r = 1; c = 1;
19
- arr=[]; sarr=[]
20
-
21
- sarr << "ACS_BBSS"
22
- arr << FFI::NCurses::ACS_BBSS
23
- sarr << "ACS_BLOCK"
24
- arr << FFI::NCurses::ACS_BLOCK
25
- sarr << "ACS_BOARD"
26
- arr << FFI::NCurses::ACS_BOARD
27
- sarr << "ACS_BSBS"
28
- arr << FFI::NCurses::ACS_BSBS
29
- sarr << "ACS_BSSB"
30
- arr << FFI::NCurses::ACS_BSSB
31
- sarr << "ACS_BSSS"
32
- arr << FFI::NCurses::ACS_BSSS
33
- sarr << "ACS_BTEE"
34
- arr << FFI::NCurses::ACS_BTEE
35
- sarr << "ACS_BULLET"
36
- arr << FFI::NCurses::ACS_BULLET
37
- sarr << "ACS_CKBOARD"
38
- arr << FFI::NCurses::ACS_CKBOARD
39
- sarr << "ACS_DARROW"
40
- arr << FFI::NCurses::ACS_DARROW
41
- sarr << "ACS_DEGREE"
42
- arr << FFI::NCurses::ACS_DEGREE
43
- sarr << "ACS_DIAMOND"
44
- arr << FFI::NCurses::ACS_DIAMOND
45
- sarr << "ACS_GEQUAL"
46
- arr << FFI::NCurses::ACS_GEQUAL
47
- sarr << "ACS_HLINE"
48
- arr << FFI::NCurses::ACS_HLINE
49
- sarr << "ACS_LANTERN"
50
- arr << FFI::NCurses::ACS_LANTERN
51
- sarr << "ACS_LARROW"
52
- arr << FFI::NCurses::ACS_LARROW
53
- sarr << "ACS_LEQUAL"
54
- arr << FFI::NCurses::ACS_LEQUAL
55
- sarr << "ACS_LLCORNER"
56
- arr << FFI::NCurses::ACS_LLCORNER
57
- sarr << "ACS_LRCORNER"
58
- arr << FFI::NCurses::ACS_LRCORNER
59
- sarr << "ACS_LTEE"
60
- arr << FFI::NCurses::ACS_LTEE
61
- sarr << "ACS_NEQUAL"
62
- arr << FFI::NCurses::ACS_NEQUAL
63
- sarr << "ACS_PI"
64
- arr << FFI::NCurses::ACS_PI
65
- sarr << "ACS_PLMINUS"
66
- arr << FFI::NCurses::ACS_PLMINUS
67
- sarr << "ACS_PLUS"
68
- arr << FFI::NCurses::ACS_PLUS
69
- sarr << "ACS_RARROW"
70
- arr << FFI::NCurses::ACS_RARROW
71
- sarr << "ACS_RTEE"
72
- arr << FFI::NCurses::ACS_RTEE
73
- sarr << "ACS_S1"
74
- arr << FFI::NCurses::ACS_S1
75
- sarr << "ACS_S3"
76
- arr << FFI::NCurses::ACS_S3
77
- sarr << "ACS_S7"
78
- arr << FFI::NCurses::ACS_S7
79
- sarr << "ACS_S9"
80
- arr << FFI::NCurses::ACS_S9
81
- sarr << "ACS_SBBS"
82
- arr << FFI::NCurses::ACS_SBBS
83
- sarr << "ACS_SBSB"
84
- arr << FFI::NCurses::ACS_SBSB
85
- sarr << "ACS_SBSS"
86
- arr << FFI::NCurses::ACS_SBSS
87
- sarr << "ACS_SSBB"
88
- arr << FFI::NCurses::ACS_SSBB
89
- sarr << "ACS_SSBS"
90
- arr << FFI::NCurses::ACS_SSBS
91
- sarr << "ACS_SSSB"
92
- arr << FFI::NCurses::ACS_SSSB
93
- sarr << "ACS_SSSS"
94
- arr << FFI::NCurses::ACS_SSSS
95
- sarr << "ACS_STERLING"
96
- arr << FFI::NCurses::ACS_STERLING
97
- sarr << "ACS_TTEE"
98
- arr << FFI::NCurses::ACS_TTEE
99
- sarr << "ACS_UARROW"
100
- arr << FFI::NCurses::ACS_UARROW
101
- sarr << "ACS_ULCORNER"
102
- arr << FFI::NCurses::ACS_ULCORNER
103
- sarr << "ACS_URCORNER"
104
- arr << FFI::NCurses::ACS_URCORNER
105
- sarr << "ACS_VLINE"
106
- arr << FFI::NCurses::ACS_VLINE
107
-
108
- sarr.each_index { |i|
109
- @window.mvaddch r,c, arr[i]
110
- @window.mvprintw r,c+2,"%s", :string, sarr[i]
111
- r+=1
112
- if r == 25
113
- r = 1
114
- c+=25
115
- end
116
- }
117
-
118
- #@form.repaint
119
- @window.wrefresh
120
- Ncurses::Panel.update_panels
121
- while((ch = @window.getchar()) != ?q.getbyte(0) )
122
- break if ch == 32 || ch == 13
123
- str = keycode_tos ch
124
- @form.handle_key(ch)
125
- @window.wrefresh
126
- end
127
- end
128
- rescue => ex
129
- ensure
130
- @window.destroy if !@window.nil?
131
- VER::stop_ncurses
132
- p ex if ex
133
- p(ex.backtrace.join("\n")) if ex
134
- $log.debug( ex) if ex
135
- $log.debug(ex.backtrace.join("\n")) if ex
136
- end
137
- end
@@ -1,91 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'logger'
3
- #require 'lib/rbcurse/mapper'
4
- #require 'lib/rbcurse/core/widgets/keylabelprinter'
5
- #require 'lib/rbcurse/commonio'
6
- #require 'lib/rbcurse/core/widgets/rwidget'
7
- #require 'lib/rbcurse/rform'
8
- require 'rbcurse/extras/widgets/rcomboedit'
9
- if $0 == __FILE__
10
- include RubyCurses
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
- # Initialize few color pairs
20
- # Create the window to be associated with the form
21
- # Un post form and free the memory
22
-
23
- catch(:close) do
24
- @form = Form.new @window
25
- r = 1; c = 30;
26
- mylist = []
27
- 0.upto(100) { |i| mylist << i.to_s }
28
- combo = ComboBoxEdit.new @form do
29
- name "combo"
30
- row r
31
- col c
32
- bgcolor :magenta
33
- display_length 10
34
- editable false
35
- list mylist
36
- set_label Label.new @form, {'text' => "Non-edit Combo"}
37
- list_config 'color' => 'black', 'bgcolor'=>'magenta', 'max_visible_items' => 6
38
- end
39
- r+=1
40
- $results = Variable.new
41
- $results.value = "Event:"
42
- status = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => 22, "col" => 2}
43
- # since updated from another window, so explicit repaint required
44
- $results.update_command { status.repaint }
45
-
46
- v_positions = [:BELOW, :SAME, :CENTER, :CENTER, :ABOVE, :ABOVE]
47
- #h_positions = [:SAME, :LEFT, :RIGHT, :SAME, :SAME, :ABOVE]
48
- policies = [:NO_INSERT, :INSERT_AT_TOP, :INSERT_AT_BOTTOM,
49
- :INSERT_AT_CURRENT, :INSERT_BEFORE_CURRENT, :INSERT_AFTER_CURRENT]
50
- policies.each_with_index do |policy, ix|
51
- name="combo#{r}"
52
- list = ListDataModel.new( %w[spotty tiger secret pass torvalds qwerty quail toiletry])
53
- list.bind(:LIST_DATA_EVENT, name) { |lde,n| $results.value = lde.to_s[0,70]; $log.debug " STA: #{$results} #{lde}" }
54
- list.bind(:ENTER_ROW, name) { |obj,n| $results.value = "ENTER_ROW :#{obj.current_index} : #{obj.selected_item} "; $log.debug " ENTER_ROW: #{$results.value} , #{obj}" }
55
- ComboBoxEdit.new @form do
56
- name name
57
- row r
58
- col 30
59
- display_length 10
60
- bgcolor 'cyan'
61
- editable true
62
- #list %w[spotty tiger secret pass torvalds qwerty quail toiletry]
63
- list_data_model list
64
- insert_policy policy
65
- set_label Label.new @form, {'text' => "Combo: "+policy.to_s}
66
- list_config 'color' => 'white', 'bgcolor'=>'blue', 'valign' => v_positions[ix]
67
- end
68
- r+=2
69
- end
70
-
71
- @help = "Use UP and DOWN to navigate values, alt-DOWN for popup, TAB / BACKTAB between fields. F10-quit"
72
- RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
73
-
74
- @form.repaint
75
- @window.wrefresh
76
- Ncurses::Panel.update_panels
77
- while((ch = @window.getchar()) != KEY_F10 )
78
- @form.handle_key(ch)
79
- @window.wrefresh
80
- end
81
- end
82
- rescue => ex
83
- ensure
84
- @window.destroy if !@window.nil?
85
- VER::stop_ncurses
86
- p ex if ex
87
- p(ex.backtrace.join("\n")) if ex
88
- $log.debug( ex) if ex
89
- $log.debug(ex.backtrace.join("\n")) if ex
90
- end
91
- end
@@ -1,66 +0,0 @@
1
- require 'logger'
2
- require 'rbcurse'
3
- require 'rbcurse/core/widgets/rtextarea'
4
- #require 'rbcurse/oldrtextarea'
5
- if $0 == __FILE__
6
- include RubyCurses
7
- include RubyCurses::Utils
8
-
9
- begin
10
- # Initialize curses
11
- VER::start_ncurses # this is initializing colors via ColorMap.setup
12
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
13
-
14
- $log.level = Logger::DEBUG
15
-
16
- @window = VER::Window.root_window
17
-
18
- catch(:close) do
19
- colors = Ncurses.COLORS
20
- $log.debug "START #{colors} colors ---------"
21
- @form = Form.new @window
22
- r = 1; c = 30;
23
-
24
- texta = TextArea.new @form do
25
- name "mytext"
26
- row r
27
- col c
28
- width 60
29
- height 15
30
- editable false
31
- focusable false
32
- title "Keypresses"
33
- auto_scroll true
34
- title_attrib (Ncurses::A_REVERSE | Ncurses::A_BOLD)
35
- end
36
- help = "q to quit. Check keys. F1..10, C-a..z, Alt a-zA-Z0-9, C-left,rt, Sh-F5..10 .: #{$0}"
37
- help1 = "Press in quick succession: 1) M-[, w and (2) M-[, M-w. (3) M-Sh-O, w."
38
- RubyCurses::Label.new @form, {'text' => help, "row" => 21, "col" => 2, "color" => "yellow"}
39
- RubyCurses::Label.new @form, {'text' => help1, "row" => 22, "col" => 2, "color" => "green"}
40
-
41
- @form.repaint
42
- @window.wrefresh
43
- Ncurses::Panel.update_panels
44
- while((ch = @window.getchar()) != ?q.getbyte(0) )
45
- str = keycode_tos ch
46
- $log.debug "#{ch} got (#{str})"
47
- texta << "#{ch} got (#{str})"
48
- texta.repaint
49
- # 2010-01-01 16:00 not much point calling handle_key since textarea is not editable
50
- # and will return unhandled and thus NOT do a repaint. so we have to repaint anyway.
51
- #ret = @form.handle_key(ch)
52
- #$log.debug " form handlekey returned: #{ret} "
53
- @form.repaint
54
- @window.wrefresh
55
- end
56
- end
57
- rescue => ex
58
- ensure
59
- @window.destroy if !@window.nil?
60
- VER::stop_ncurses
61
- p ex if ex
62
- p(ex.backtrace.join("\n")) if ex
63
- $log.debug( ex) if ex
64
- $log.debug(ex.backtrace.join("\n")) if ex
65
- end
66
- end
@@ -1,113 +0,0 @@
1
- # this program tests out various widgets.
2
- #require 'ncurses' # FFI
3
- require 'logger'
4
- require 'rbcurse'
5
- require 'rbcurse/core/widgets/rwidget'
6
- #require 'rbcurse/core/include/listcellrenderer'
7
- #require 'rbcurse/extras/include/celleditor'
8
- require 'rbcurse/extras/widgets/rlistbox'
9
- require 'rbcurse/core/include/vieditable'
10
- require 'rbcurse/experimental/widgets/undomanager'
11
- #require 'rbcurse/deprecated/widgets/rmessagebox'
12
- class RubyCurses::Listbox
13
- # vieditable includes listeditable which
14
- # does bring in some functions which can crash program like x and X TODO
15
- # also, f overrides list f mapping. TODO
16
- include ViEditable
17
- end
18
- if $0 == __FILE__
19
- include RubyCurses
20
-
21
- begin
22
- # Initialize curses
23
- VER::start_ncurses # this is initializing colors via ColorMap.setup
24
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"rbc13.log")))
25
- $log.level = Logger::DEBUG
26
-
27
- @window = VER::Window.root_window
28
- $catch_alt_digits = true; # emacs like alt-1..9 numeric arguments
29
- # Initialize few color pairs
30
- # Create the window to be associated with the form
31
- # Un post form and free the memory
32
-
33
- catch(:close) do
34
- colors = Ncurses.COLORS
35
- $log.debug "START #{colors} colors testlistbox.rb --------- #{@window} "
36
- @form = Form.new @window
37
- @form.window.printstring 0, 30, "Demo of Listbox - rbcurse", $normalcolor, 'reverse'
38
- r = 1; fc = 1;
39
-
40
- $results = Variable.new
41
- $results.value = "A list with vim-like key bindings. Try j k gg G o O C dd u (undo) C-r (redo) f<char> w yy p P. Also try emacs's kill-ring save/yank/cycle using M-w C-y M-y. Also, C-u and M1..9 numeric arguments."
42
- var = RubyCurses::Label.new @form, {'text_variable' => $results, "row" => r+12, "col" => fc, "display_length" => 80, "height" => 5}
43
- r += 1
44
- mylist = []
45
- 0.upto(100) { |v| mylist << "#{v} scrollable data" }
46
- $listdata = Variable.new mylist
47
- listb = Listbox.new @form do
48
- name "mylist"
49
- row r
50
- col 1
51
- width 40
52
- height 11
53
- # list mylist
54
- list_variable $listdata
55
- #selection_mode :SINGLE
56
- show_selector true
57
- row_selected_symbol "[X] "
58
- row_unselected_symbol "[ ] "
59
- title "A long list"
60
- title_attrib 'reverse'
61
- cell_editing_allowed false
62
- end
63
- listb.one_key_selection = false # this allows us to map keys to methods
64
- listb.vieditable_init_listbox
65
- undom = SimpleUndo.new listb
66
-
67
- #listb.list.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
68
-
69
- # just for demo, lets scroll the text view as we scroll this.
70
- # listb.bind(:ENTER_ROW, @textview) { |alist, tview| tview.top_row alist.current_index }
71
-
72
- #list = ListDataModel.new( %w[spotty tiger panther jaguar leopard ocelot lion])
73
- #list.bind(:LIST_DATA_EVENT) { |lde| $message.value = lde.to_s; $log.debug " STA: #{$message.value} #{lde}" }
74
- #list.bind(:ENTER_ROW) { |obj| $message.value = "ENTER_ROW :#{obj.current_index} : #{obj.selected_item} "; $log.debug " ENTER_ROW: #{$message.value} , #{obj}" }
75
-
76
- # using ampersand to set mnemonic
77
- col = 1
78
- row = 20
79
- cancel_button = Button.new @form do
80
- #variable $results
81
- text "&Cancel"
82
- row row
83
- col col + 10
84
- #surround_chars ['{ ',' }'] ## change the surround chars
85
- end
86
- cancel_button.command { |form|
87
- if confirm("Do your really want to quit?")== :YES
88
- throw(:close);
89
- else
90
- $message.value = "Quit aborted"
91
- end
92
- }
93
-
94
-
95
- @form.repaint
96
- @window.wrefresh
97
- Ncurses::Panel.update_panels
98
- while((ch = @window.getchar()) != KEY_F1 )
99
- @form.handle_key(ch)
100
- #@form.repaint
101
- @window.wrefresh
102
- end
103
- end
104
- rescue => ex
105
- ensure
106
- @window.destroy if !@window.nil?
107
- VER::stop_ncurses
108
- p ex if ex
109
- p(ex.backtrace.join("\n")) if ex
110
- $log.debug( ex) if ex
111
- $log.debug(ex.backtrace.join("\n")) if ex
112
- end
113
- end