rbcurse 0.1.3 → 1.1.1

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 (74) hide show
  1. data/CHANGELOG +126 -0
  2. data/Manifest.txt +53 -20
  3. data/README.markdown +423 -0
  4. data/Rakefile +3 -1
  5. data/examples/keytest.rb +177 -0
  6. data/examples/mpad2.rb +156 -0
  7. data/examples/newtesttabp.rb +121 -0
  8. data/examples/rfe.rb +48 -10
  9. data/examples/rfe_renderer.rb +4 -4
  10. data/examples/rvimsplit.rb +376 -0
  11. data/examples/sqlc.rb +97 -106
  12. data/examples/sqlm.rb +446 -0
  13. data/examples/test1.rb +4 -4
  14. data/examples/test2.rb +12 -12
  15. data/examples/testchars.rb +140 -0
  16. data/examples/testkeypress.rb +9 -4
  17. data/examples/testmulticomp.rb +72 -0
  18. data/examples/testscroller.rb +136 -0
  19. data/examples/testscrolllb.rb +86 -0
  20. data/examples/testscrollp.rb +87 -0
  21. data/examples/testscrollta.rb +80 -0
  22. data/examples/testscrolltable.rb +166 -0
  23. data/examples/testsplit.rb +87 -0
  24. data/examples/testsplit2.rb +123 -0
  25. data/examples/testsplit3.rb +215 -0
  26. data/examples/testsplit3_1.rb +244 -0
  27. data/examples/testsplit3a.rb +215 -0
  28. data/examples/testsplit3b.rb +237 -0
  29. data/examples/testsplitta.rb +148 -0
  30. data/examples/testsplittv.rb +142 -0
  31. data/examples/testsplittvv.rb +144 -0
  32. data/examples/testtable.rb +1 -1
  33. data/examples/testtabp.rb +3 -2
  34. data/examples/testtestw.rb +69 -0
  35. data/examples/testtodo.rb +5 -3
  36. data/examples/testtpane.rb +203 -0
  37. data/examples/testtpane2.rb +145 -0
  38. data/examples/testtpanetable.rb +199 -0
  39. data/examples/viewtodo.rb +5 -3
  40. data/lib/rbcurse.rb +1 -1
  41. data/lib/rbcurse/celleditor.rb +2 -2
  42. data/lib/rbcurse/colormap.rb +5 -5
  43. data/lib/rbcurse/defaultlistselectionmodel.rb +3 -3
  44. data/lib/rbcurse/io.rb +663 -0
  45. data/lib/rbcurse/listeditable.rb +306 -0
  46. data/lib/rbcurse/listkeys.rb +15 -15
  47. data/lib/rbcurse/listscrollable.rb +168 -27
  48. data/lib/rbcurse/mapper.rb +35 -13
  49. data/lib/rbcurse/rchangeevent.rb +28 -0
  50. data/lib/rbcurse/rform.rb +845 -0
  51. data/lib/rbcurse/rlistbox.rb +144 -34
  52. data/lib/rbcurse/rmessagebox.rb +10 -5
  53. data/lib/rbcurse/rmulticontainer.rb +325 -0
  54. data/lib/rbcurse/rmultitextview.rb +306 -0
  55. data/lib/rbcurse/rscrollform.rb +369 -0
  56. data/lib/rbcurse/rscrollpane.rb +511 -0
  57. data/lib/rbcurse/rsplitpane.rb +820 -0
  58. data/lib/rbcurse/rtabbedpane.rb +737 -109
  59. data/lib/rbcurse/rtabbedwindow.rb +326 -0
  60. data/lib/rbcurse/rtable.rb +220 -64
  61. data/lib/rbcurse/rtextarea.rb +340 -181
  62. data/lib/rbcurse/rtextview.rb +237 -101
  63. data/lib/rbcurse/rviewport.rb +203 -0
  64. data/lib/rbcurse/rwidget.rb +919 -95
  65. data/lib/rbcurse/scrollable.rb +7 -7
  66. data/lib/rbcurse/selectable.rb +4 -4
  67. data/lib/rbcurse/table/tablecellrenderer.rb +3 -0
  68. data/lib/rbcurse/undomanager.rb +181 -0
  69. data/lib/rbcurse/vieditable.rb +100 -0
  70. data/lib/ver/window.rb +471 -21
  71. metadata +66 -22
  72. data/README.txt +0 -312
  73. data/examples/testd.db +0 -0
  74. data/examples/todocsv.csv +0 -28
@@ -0,0 +1,148 @@
1
+ #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
+ ##*******************************************************#
3
+ # testsplittv.rb #
4
+ # written by Rahul Kumar #
5
+ # January 06, 2010 #
6
+ # #
7
+ # test textview inside scrollpane #
8
+ # #
9
+ # Released under ruby license. See #
10
+ # http://www.ruby-lang.org/en/LICENSE.txt #
11
+ # Copyright 2010, Rahul Kumar #
12
+ #*******************************************************#
13
+ require 'rubygems'
14
+ require 'ncurses'
15
+ require 'logger'
16
+ require 'rbcurse'
17
+ require 'rbcurse/rsplitpane'
18
+ require 'rbcurse/rtextarea'
19
+ require 'rbcurse/rmultitextview'
20
+ require 'rbcurse/undomanager'
21
+
22
+ ## This sample creates a single scrollpane,
23
+ ##+ and embeds a textarea inside it
24
+ ##+ and allows you to change orientation
25
+ ##+ and move divider around using - + and =.
26
+ #
27
+ if $0 == __FILE__
28
+ include RubyCurses
29
+ include RubyCurses::Utils
30
+
31
+ begin
32
+ # Initialize curses
33
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
34
+ $log = Logger.new("v#{$0}.log")
35
+ $log.level = Logger::DEBUG
36
+
37
+ @window = VER::Window.root_window
38
+
39
+ catch(:close) do
40
+ colors = Ncurses.COLORS
41
+ @form = Form.new @window
42
+ $log.debug " FORM #{@form} "
43
+ r = 1; c = 7; ht = 20; w = 50
44
+ #r = 1; c = 3; ht = 24; w = 70
45
+ # filler just to see that we are covering correct space and not wasting lines or cols
46
+ # filler = "*" * 88
47
+ # (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
48
+
49
+
50
+ @help = "F1 to quit. M- M+ M= v h C-n C-p M-w (alt-w) : #{$0} . Check #{$0}.log too"
51
+ RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
52
+
53
+ splitp = SplitPane.new @form do
54
+ name "mypane"
55
+ row r
56
+ col c
57
+ width w
58
+ height ht
59
+ #focusable false
60
+ #orientation :VERTICAL_SPLIT
61
+ end
62
+
63
+ ## typically height should be ht or at least more than ht/2, but i've kept it at
64
+ ## ht/2-1 to see the footer, and because it was crashing with this.
65
+ t1 = TextArea.new do
66
+ name "myView"
67
+ #row 0
68
+ #col 0
69
+ width w-2
70
+ height (ht/2)-1
71
+ title "README.md"
72
+ title_attrib 'bold'
73
+ print_footer true
74
+ footer_attrib 'bold'
75
+ end
76
+
77
+ t2 = TextArea.new do
78
+ name "myView2"
79
+ #row 0
80
+ #col 0
81
+ width w-2
82
+ height ht/2
83
+ #height (ht/2)-1
84
+ title "NOTES"
85
+ title_attrib 'bold'
86
+ print_footer true
87
+ footer_attrib 'bold'
88
+ end
89
+
90
+ splitp.first_component(t1)
91
+ splitp.second_component(t2)
92
+ t1.preferred_width w-4 #/2 ## should pertain more to horizontal orientation
93
+ t1.preferred_height (ht/2)-1 ## this messes things up when we change orientation
94
+ #t1.set_resize_weight 0.50
95
+ t2.min_width 15
96
+ t2.min_height 5
97
+ t1.min_width 12
98
+ t1.min_height 5
99
+ ret = splitp.reset_to_preferred_sizes
100
+ ## if an error is returned you should check what's wrong since you
101
+ ## could still get a blank screen, if your comps area is smaller than
102
+ ## pane, or other conditions. the log will point out various possible errors.
103
+ splitp.set_resize_weight(0.50) if ret == :ERROR
104
+ File.open("../README.markdown","r") do |file|
105
+ while (line = file.gets)
106
+ t1 << line.chomp
107
+ end
108
+ end
109
+ File.open("../NOTES","r") do |file|
110
+ while (line = file.gets)
111
+ t2 << line.chomp
112
+ end
113
+ end
114
+ undom = SimpleUndo.new t1
115
+ undo2 = SimpleUndo.new t2
116
+
117
+ @form.repaint
118
+ @window.wrefresh
119
+ Ncurses::Panel.update_panels
120
+ while((ch = @window.getchar()) != KEY_F1 )
121
+ #str = keycode_tos ch
122
+ case ch
123
+ when ?\M-v.getbyte(0)
124
+ splitp.orientation(:VERTICAL_SPLIT)
125
+ splitp.set_resize_weight(0.50)
126
+ when ?\M-h.getbyte(0)
127
+ splitp.orientation(:HORIZONTAL_SPLIT)
128
+ splitp.set_resize_weight(0.50)
129
+ end
130
+ #splitp.get_buffer().wclear
131
+ #splitp << "#{ch} got (#{str})"
132
+ #splitp.repaint
133
+ #splitp.buffer_to_screen
134
+ @form.repaint
135
+ @form.handle_key(ch)
136
+ @window.wrefresh
137
+ end
138
+ end
139
+ rescue => ex
140
+ ensure
141
+ @window.destroy if !@window.nil?
142
+ VER::stop_ncurses
143
+ p ex if ex
144
+ p(ex.backtrace.join("\n")) if ex
145
+ $log.debug( ex) if ex
146
+ $log.debug(ex.backtrace.join("\n")) if ex
147
+ end
148
+ end
@@ -0,0 +1,142 @@
1
+ #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
+ ##*******************************************************#
3
+ # testsplittv.rb #
4
+ # written by Rahul Kumar #
5
+ # January 06, 2010 #
6
+ # #
7
+ # test textview inside scrollpane #
8
+ # #
9
+ # Released under ruby license. See #
10
+ # http://www.ruby-lang.org/en/LICENSE.txt #
11
+ # Copyright 2010, Rahul Kumar #
12
+ #*******************************************************#
13
+ require 'rubygems'
14
+ require 'ncurses'
15
+ require 'logger'
16
+ require 'rbcurse'
17
+ require 'rbcurse/rsplitpane'
18
+ require 'rbcurse/rtextview'
19
+
20
+ ## This sample creates a single scrollpane,
21
+ ##+ and embeds a textarea inside it
22
+ ##+ and allows you to change orientation
23
+ ##+ and move divider around using - + and =.
24
+ #
25
+ if $0 == __FILE__
26
+ include RubyCurses
27
+ include RubyCurses::Utils
28
+
29
+ begin
30
+ # Initialize curses
31
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
32
+ $log = Logger.new("v#{$0}.log")
33
+ $log.level = Logger::DEBUG
34
+
35
+ @window = VER::Window.root_window
36
+
37
+ catch(:close) do
38
+ colors = Ncurses.COLORS
39
+ @form = Form.new @window
40
+ $log.debug " FORM #{@form} "
41
+ r = 1; c = 3; ht = 24; w = 70
42
+ # filler just to see that we are covering correct space and not wasting lines or cols
43
+ # filler = "*" * 88
44
+ # (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
45
+
46
+
47
+ @help = "F1 to quit. - + = v h C-n C-p M-w (alt-w) : #{$0} . Check #{$0}.log too"
48
+ RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
49
+
50
+ splitp = SplitPane.new @form do
51
+ name "mypane"
52
+ row r
53
+ col c
54
+ width w
55
+ height ht
56
+ #focusable false
57
+ #orientation :VERTICAL_SPLIT
58
+ end
59
+ t1 = TextView.new nil do
60
+ name "myView"
61
+ #row 0
62
+ #col 0
63
+ width w-2
64
+ height (ht/2)-1
65
+ title "README.md"
66
+ title_attrib 'bold'
67
+ print_footer true
68
+ footer_attrib 'bold'
69
+ end
70
+ content = File.open("../README.markdown","r").readlines
71
+ t1.set_content content #, :WRAP_WORD
72
+
73
+ # to see lower border i need to set height to ht/2 -2 in both cases, but that
74
+ # crashes ruby when i reduce height by 1.
75
+ t2 = TextView.new nil do
76
+ name "myView2"
77
+ #row 0
78
+ #col 0
79
+ width w-2
80
+ #height ht
81
+ height (ht/2)-1
82
+ title "NOTES"
83
+ title_attrib 'bold'
84
+ print_footer true
85
+ footer_attrib 'bold'
86
+ end
87
+ content = File.open("../NOTES","r").readlines
88
+ t2.set_content content #, :WRAP_WORD
89
+
90
+ splitp.first_component(t1)
91
+ splitp.second_component(t2)
92
+ t1.preferred_width w-4 #/2 ## should pertain more to horizontal orientation
93
+ t1.preferred_height (ht/2)-1 ## this messes things up when we change orientation
94
+ #t1.set_resize_weight 0.50
95
+ t2.min_width 15
96
+ t2.min_height 5
97
+ t1.min_width 12
98
+ t1.min_height 8
99
+ ret = splitp.reset_to_preferred_sizes
100
+ ## if an error is returned you should check what's wrong since you
101
+ ## could still get a blank screen, if your comps area is smaller than
102
+ ## pane, or other conditions. the log will point out various possible errors.
103
+ splitp.set_resize_weight(0.50) if ret == :ERROR
104
+
105
+ @form.repaint
106
+ @window.wrefresh
107
+ Ncurses::Panel.update_panels
108
+ while((ch = @window.getchar()) != KEY_F1 )
109
+ str = keycode_tos ch
110
+ case ch
111
+ when ?v.getbyte(0)
112
+ splitp.orientation(:VERTICAL_SPLIT)
113
+ splitp.set_resize_weight(0.50)
114
+ when ?h.getbyte(0)
115
+ splitp.orientation(:HORIZONTAL_SPLIT)
116
+ splitp.set_resize_weight(0.50)
117
+ when ?-.getbyte(0)
118
+ splitp.set_divider_location(splitp.divider_location-1)
119
+ when ?+.getbyte(0)
120
+ splitp.set_divider_location(splitp.divider_location+1)
121
+ when ?=.getbyte(0)
122
+ splitp.set_resize_weight(0.50)
123
+ end
124
+ #splitp.get_buffer().wclear
125
+ #splitp << "#{ch} got (#{str})"
126
+ #splitp.repaint
127
+ #splitp.buffer_to_screen
128
+ @form.repaint
129
+ @form.handle_key(ch)
130
+ @window.wrefresh
131
+ end
132
+ end
133
+ rescue => ex
134
+ ensure
135
+ @window.destroy if !@window.nil?
136
+ VER::stop_ncurses
137
+ p ex if ex
138
+ p(ex.backtrace.join("\n")) if ex
139
+ $log.debug( ex) if ex
140
+ $log.debug(ex.backtrace.join("\n")) if ex
141
+ end
142
+ end
@@ -0,0 +1,144 @@
1
+ #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
+ #*******************************************************#
3
+ # testsplittv.rb #
4
+ # written by Rahul Kumar #
5
+ # January 06, 2010 #
6
+ # #
7
+ # test textview inside splitpane #
8
+ # Startup is vertical split #
9
+ # #
10
+ # Released under ruby license. See #
11
+ # http://www.ruby-lang.org/en/LICENSE.txt #
12
+ # Copyright 2010, Rahul Kumar #
13
+ #*******************************************************#
14
+ require 'rubygems'
15
+ require 'ncurses'
16
+ require 'logger'
17
+ require 'rbcurse'
18
+ require 'rbcurse/rsplitpane'
19
+ require 'rbcurse/rtextview'
20
+
21
+ ## This sample creates a single scrollpane,
22
+ ##+ and embeds a textarea inside it
23
+ ##+ and allows you to change orientation
24
+ ##+ and move divider around using - + and =.
25
+ #
26
+ if $0 == __FILE__
27
+ include RubyCurses
28
+ include RubyCurses::Utils
29
+
30
+ begin
31
+ # Initialize curses
32
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
33
+ $log = Logger.new("v#{$0}.log")
34
+ $log.level = Logger::DEBUG
35
+
36
+ @window = VER::Window.root_window
37
+
38
+ catch(:close) do
39
+ colors = Ncurses.COLORS
40
+ @form = Form.new @window
41
+ r = 1; c = 3; ht = 24; w = 70
42
+ # filler just to see that we are covering correct space and not wasting lines or cols
43
+ # filler = "*" * 88
44
+ # (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
45
+
46
+
47
+ @help = "q to quit. - + = v h C-n C-p M-w (alt-w) : #{$0} . Check #{$0}.log too"
48
+ RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
49
+
50
+ splitp = SplitPane.new @form do
51
+ name "mypane"
52
+ row r
53
+ col c
54
+ width w
55
+ height ht
56
+ #focusable false
57
+ orientation :VERTICAL_SPLIT
58
+ end
59
+ t1 = TextView.new nil do
60
+ name "myView"
61
+ #row 0
62
+ #col 0
63
+ #width w-2
64
+ height ht
65
+ #height (ht/2)-1
66
+ width w/2-1
67
+ title "README.md"
68
+ title_attrib 'bold'
69
+ print_footer true
70
+ footer_attrib 'bold'
71
+ end
72
+ content = File.open("../README.markdown","r").readlines
73
+ t1.set_content content #, :WRAP_WORD
74
+
75
+ # to see lower border i need to set height to ht/2 -2 in both cases, but that
76
+ # crashes ruby when i reduce height by 1.
77
+ t2 = TextView.new nil do
78
+ name "myView2"
79
+ #row 0
80
+ #col 0
81
+ width w/2-1
82
+ height ht
83
+ #height (ht/2)-1
84
+ title "NOTES"
85
+ title_attrib 'bold'
86
+ print_footer true
87
+ footer_attrib 'bold'
88
+ end
89
+ content = File.open("../NOTES","r").readlines
90
+ t2.set_content content #, :WRAP_WORD
91
+
92
+ splitp.first_component(t1)
93
+ splitp.second_component(t2)
94
+ t1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
95
+ #t1.preferred_height (ht/2)-1 ## this messes things up when we change orientation
96
+ t1.preferred_height ht ## this messes things up when we change orientation
97
+ #t1.set_resize_weight 0.50
98
+ t2.min_width 15
99
+ t2.min_height 5
100
+ t1.min_width 12
101
+ t1.min_height 8
102
+ ret = splitp.reset_to_preferred_sizes
103
+ splitp.set_resize_weight(0.50) if ret == :ERROR
104
+
105
+ @form.repaint
106
+ @window.wrefresh
107
+ Ncurses::Panel.update_panels
108
+ while((ch = @window.getchar()) != ?q.getbyte(0) )
109
+ str = keycode_tos ch
110
+ case ch
111
+ when ?v.getbyte(0)
112
+ splitp.orientation(:VERTICAL_SPLIT)
113
+ splitp.set_resize_weight(0.50)
114
+ when ?h.getbyte(0)
115
+ splitp.orientation(:HORIZONTAL_SPLIT)
116
+ splitp.set_resize_weight(0.50)
117
+ when ?-.getbyte(0)
118
+ ret = splitp.set_divider_location(splitp.divider_location-1)
119
+ next if ret == :ERROR
120
+ when ?+.getbyte(0)
121
+ ret = splitp.set_divider_location(splitp.divider_location+1)
122
+ next if ret == :ERROR
123
+ when ?=.getbyte(0)
124
+ splitp.set_resize_weight(0.50)
125
+ end
126
+ #splitp.get_buffer().wclear
127
+ #splitp << "#{ch} got (#{str})"
128
+ #splitp.repaint
129
+ #splitp.buffer_to_screen
130
+ @form.repaint
131
+ @form.handle_key(ch)
132
+ @window.wrefresh
133
+ end
134
+ end
135
+ rescue => ex
136
+ ensure
137
+ @window.destroy if !@window.nil?
138
+ VER::stop_ncurses
139
+ p ex if ex
140
+ p(ex.backtrace.join("\n")) if ex
141
+ $log.debug( ex) if ex
142
+ $log.debug(ex.backtrace.join("\n")) if ex
143
+ end
144
+ end
@@ -231,7 +231,7 @@ if $0 == __FILE__
231
231
  @form.repaint
232
232
  @window.wrefresh
233
233
  Ncurses::Panel.update_panels
234
- while((ch = @window.getchar()) != ?\C-q )
234
+ while((ch = @window.getchar()) != ?\C-q.getbyte(0) )
235
235
  colcount = tcm.column_count-1
236
236
  s = keycode_tos ch
237
237
  keylabel.text = "Pressed #{ch} , #{s}"
@@ -5,7 +5,8 @@ require 'rubygems'
5
5
  require 'ncurses'
6
6
  require 'logger'
7
7
  require 'rbcurse'
8
- require 'rbcurse/rtabbedpane'
8
+ #require 'rbcurse/rtabbedpane'
9
+ require 'rbcurse/rtabbedwindow'
9
10
 
10
11
  class TestTabbedPane
11
12
  def initialize
@@ -15,7 +16,7 @@ class TestTabbedPane
15
16
  def run
16
17
  $config_hash ||= Variable.new Hash.new
17
18
  #configvar.update_command(){ |v| $config_hash[v.source()] = v.value }
18
- @tp = RubyCurses::TabbedPane.new nil do
19
+ @tp = RubyCurses::TabbedWindow.new nil do
19
20
  height 12
20
21
  width 50
21
22
  row 5