rbcurse 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/NOTES CHANGED
@@ -1638,3 +1638,17 @@ complex splits. Or perhaps a way of giving preferred size, so it can
1638
1638
  expand fully in one direction.
1639
1639
 
1640
1640
  * * * * * * * *
1641
+
1642
+ Subject: ffi-ncurses ?
1643
+ ----------------------
1644
+ Date: 2010-08-30 12:37
1645
+
1646
+ there is some talk of ncurses installation which is hindering people
1647
+ from using rbcurse.
1648
+
1649
+ Perhaps we should try moving to ffi-ncurses after all. I heard it was
1650
+ slow. Is there some way of making it optional, whether a user wishes to
1651
+ use ffi or ruby-ncurses. For example, i read that mutt can be compiled
1652
+ for ncurses or slang.
1653
+
1654
+ * * * * * * * *
data/README.markdown CHANGED
@@ -15,9 +15,11 @@ test2.rb works - i always give it a quick run after making changes. All the test
15
15
 
16
16
  * <http://totalrecall.wordpress.com> - always has some status posted.
17
17
 
18
- * Notes on rbcurse - <http://rbcurse.tumblr.com/>
18
+ * <http://rdoc.info/github/rkumar/rbcurse/master> - rdoc
19
19
 
20
- * rbcurse on rubyforge: <http://rbcurse.rubyforge.org/> - Occassionally updated.
20
+ * Notes/thoughts/ideas on rbcurse - <http://rbcurse.tumblr.com/>
21
+
22
+ * rbcurse on rubyforge: <http://rbcurse.rubyforge.org/> - Occasionally updated.
21
23
 
22
24
  * See changes on (not updated often)
23
25
  <http://github.com/rkumar/rbcurse/tree/master/CHANGELOG>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.4
1
+ 1.1.5
@@ -0,0 +1,150 @@
1
+ $LOAD_PATH << "/Users/rahul/work/projects/rbcurse/lib"
2
+ require 'rubygems'
3
+ require 'ncurses'
4
+ require 'logger'
5
+ require 'rbcurse'
6
+ require 'rbcurse/rmultisplit'
7
+ require 'rbcurse/rlistbox'
8
+ #
9
+ ## this sample creates a multisplitpane with n objects
10
+ ##+ and move divider around using - + and =.
11
+ #
12
+ if $0 == __FILE__
13
+ include RubyCurses
14
+ include RubyCurses::Utils
15
+
16
+ begin
17
+ # Initialize curses
18
+ VER::start_ncurses # this is initializing colors via ColorMap.setup
19
+ $log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"view.log")))
20
+
21
+ $log.level = Logger::DEBUG
22
+
23
+ @window = VER::Window.root_window
24
+
25
+ catch(:close) do
26
+ colors = Ncurses.COLORS
27
+ @form = Form.new @window
28
+ r = 3; c = 7; ht = 18
29
+ # filler just to see that we are covering correct space and not wasting lines or cols
30
+ filler = "*" * 88
31
+ (ht+2).times(){|i| @form.window.printstring(i,r, filler, $datacolor) }
32
+
33
+
34
+ @help = "q to quit. v h - + = : #{$0} . Check logger too"
35
+ RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r, "col" => 2, "color" => "yellow"}
36
+
37
+ $message = Variable.new
38
+ $message.value = "Message Comes Here"
39
+ message_label = RubyCurses::Label.new @form, {'text_variable' => $message, "name"=>"message_label","row" => ht+r+2, "col" => 1, "display_length" => 60, "height" => 2, 'color' => 'cyan'}
40
+ $message.update_command() { message_label.repaint } # why ?
41
+
42
+ splitp = MultiSplit.new @form do
43
+ name "mypane"
44
+ row r
45
+ col c
46
+ width 70
47
+ height ht
48
+ split_count 3
49
+ unlimited true
50
+ # focusable false
51
+ orientation :VERTICAL_SPLIT
52
+ end
53
+ splitp.bind(:PROPERTY_CHANGE){|e| $message.value = e.to_s }
54
+
55
+ lists = []
56
+ mylist = Dir.glob('*')
57
+ listb = Listbox.new @form do
58
+ name "mylist"
59
+ list mylist
60
+ title "A short list"
61
+ title_attrib 'reverse'
62
+ end
63
+ listb.one_key_selection = false
64
+ splitp.add listb
65
+ listb.bind_key(13) {
66
+ #@status_row.text = "Selected #{tablelist.get_content()[tablelist.current_index]}"
67
+ table = "#{listb.get_content()[listb.current_index]}"
68
+ ##table = table[0] if table.class==Array ## 1.9 ???
69
+ mylist = nil
70
+ if File.directory? table
71
+ d = Dir.new(table)
72
+ mylist = d.entries
73
+ end
74
+ if lists.empty?
75
+ listb = Listbox.new @form do
76
+ name "mylist"
77
+ list mylist
78
+ title table
79
+ title_attrib 'reverse'
80
+ end
81
+ splitp.add listb
82
+ lists << listb
83
+ else
84
+ l = lists.first
85
+ l.list_data_model.remove_all
86
+ l.list_data_model.insert 0, mylist
87
+ end
88
+ }
89
+
90
+ @form.repaint
91
+ @window.wrefresh
92
+ Ncurses::Panel.update_panels
93
+ counter = 0
94
+ while((ch = @window.getchar()) != ?q.getbyte(0) )
95
+ str = keycode_tos ch
96
+ case ch
97
+ when ?a.getbyte(0)
98
+ return
99
+ r = 0
100
+ mylist = []
101
+ counter.upto(counter+100) { |v| mylist << "#{v} scrollable data" }
102
+ counter+=100;
103
+ $listdata = Variable.new mylist
104
+ listb = Listbox.new @form do
105
+ name "mylist"
106
+ # list mylist
107
+ list_variable $listdata
108
+ selection_mode :SINGLE
109
+ #show_selector true
110
+ #row_selected_symbol "[X] "
111
+ #row_unselected_symbol "[ ] "
112
+ title "A short list"
113
+ title_attrib 'reverse'
114
+ #cell_editing_allowed true
115
+ end
116
+ #listb.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
117
+ #$listdata.value.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net"
118
+ #listb.list_data_model.insert 55, "hello ruby", "so long python", "farewell java", "RIP .Net", "hi lisp", "hi clojure"
119
+ splitp.add listb
120
+ when ?V.getbyte(0)
121
+ splitp.orientation(:VERTICAL_SPLIT)
122
+ #splitp.reset_to_preferred_sizes
123
+ when ?H.getbyte(0)
124
+ splitp.orientation(:HORIZONTAL_SPLIT)
125
+ #splitp.reset_to_preferred_sizes
126
+ when ?-.getbyte(0)
127
+ #splitp.set_divider_location(splitp.divider_location-1)
128
+ when ?+.getbyte(0)
129
+ #splitp.set_divider_location(splitp.divider_location+1)
130
+ when ?=.getbyte(0)
131
+ #splitp.set_resize_weight(0.50)
132
+ end
133
+ #splitp.get_buffer().wclear
134
+ #splitp << "#{ch} got (#{str})"
135
+ splitp.repaint # since the above keys are not being handled inside
136
+ @form.handle_key(ch)
137
+ @window.wrefresh
138
+ end
139
+ end
140
+ rescue => ex
141
+ ensure
142
+ @window.destroy if !@window.nil?
143
+ VER::stop_ncurses
144
+ p ex if ex
145
+ p(ex.backtrace.join("\n")) if ex
146
+ $log.debug( ex) if ex
147
+ $log.debug(ex.backtrace.join("\n")) if ex
148
+ end
149
+ end
150
+
data/examples/keytest.rb CHANGED
@@ -5,15 +5,16 @@ require 'logger'
5
5
  require 'rbcurse'
6
6
  #require 'lib/ver/ncurses'
7
7
  #require 'lib/ver/window'
8
- require 'lib/rbcurse/rwidget'
9
- require 'lib/ver/keyboard2'
10
- #require 'lib/rbcurse/mapper'
8
+ require 'rbcurse/rwidget'
9
+ require 'ver/keyboard2'
10
+ require 'rbcurse/mapper'
11
11
 
12
12
  # Using mapper with keyboard2 which gives numeric keys
13
13
  # The error messages are not so pretty, otherwise its okay... error messages need a little work
14
14
  # Use C-q or q to quit
15
15
  ## C-s starts a new mode :cx, 'i' gets back to normal
16
16
  #include Ncurses
17
+ # NOTE: this test was created only to test upcoming 1.9 key change and how to handle it.
17
18
 
18
19
 
19
20
  def printstr(pad, r,c,string, color, att = Ncurses::A_NORMAL)
@@ -62,7 +62,7 @@ if $0 == __FILE__
62
62
  undom = SimpleUndo.new @textview
63
63
  #@textview.show_caret=true
64
64
 
65
- @help = "F1 to quit. #{$0} TextView inside scrollpane. M-n M-p M-h M-l M-< M->, e to open file, : for menu""
65
+ @help = "F1 to quit. #{$0} TextView inside scrollpane. M-n M-p M-h M-l M-< M->, e to open file, : for menu"
66
66
  RubyCurses::Label.new @form, {'text' => @help, "row" => ht+r+1, "col" => 2, "color" => "yellow"}
67
67
 
68
68
  @form.repaint
@@ -145,7 +145,7 @@ if $0 == __FILE__
145
145
  splitleft.first_component(t1)
146
146
  splitleft.second_component(t2)
147
147
  t1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
148
- t1.preferred_height (ht/2)-1 ## this messes things up when we change orientation
148
+ t1.preferred_height((ht/2)-1) ## this messes things up when we change orientation
149
149
  #t1.set_resize_weight 0.50
150
150
  t2.min_width 15
151
151
  t2.min_height 5
@@ -165,9 +165,9 @@ if $0 == __FILE__
165
165
  splitrt.first_component(t1)
166
166
  splitrt.second_component(ta2)
167
167
  t2.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
168
- t2.preferred_height (ht/2)-1 ## this messes things up when we change orientation
168
+ t2.preferred_height((ht/2)-1) ## this messes things up when we change orientation
169
169
  t1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
170
- t1.preferred_height (ht/2)-1 ## this messes things up when we change orientation
170
+ t1.preferred_height((ht/2)-1) ## this messes things up when we change orientation
171
171
  #t1.set_resize_weight 0.50
172
172
  t2.min_width 15
173
173
  t2.min_height 5
@@ -137,7 +137,7 @@ if $0 == __FILE__
137
137
  leftscroll1.cascade_changes = true
138
138
  leftscroll2.cascade_changes = true
139
139
  #leftscroll1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
140
- leftscroll1.preferred_height (ht/2)-4 ## this messes things up when we change orientation
140
+ leftscroll1.preferred_height((ht/2)-4) ## this messes things up when we change orientation
141
141
  # the outer compo needs child set first else cursor does not reach up from
142
142
  # lower levels. Is the connection broken ?
143
143
  outer.first_component(splitleft)
@@ -158,7 +158,7 @@ if $0 == __FILE__
158
158
  #width 46
159
159
  end
160
160
  #scroll1.preferred_width w/2 #/2 ## should pertain more to horizontal orientation
161
- scroll1.preferred_height (ht/2)-4 ## this messes things up when we change orientation
161
+ scroll1.preferred_height ht/2-4 ## this messes things up when we change orientation
162
162
  # the outer compo needs child set first else cursor does not reach up from
163
163
  # lower levels. Is the connection broken ?
164
164
  outer.first_component(splitleft)
@@ -90,7 +90,7 @@ if $0 == __FILE__
90
90
  splitp.first_component(t1)
91
91
  splitp.second_component(t2)
92
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
93
+ t1.preferred_height((ht/2)-1) ## this messes things up when we change orientation
94
94
  #t1.set_resize_weight 0.50
95
95
  t2.min_width 15
96
96
  t2.min_height 5
@@ -90,7 +90,7 @@ if $0 == __FILE__
90
90
  splitp.first_component(t1)
91
91
  splitp.second_component(t2)
92
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
93
+ t1.preferred_height ht/2-1 ## this messes things up when we change orientation
94
94
  #t1.set_resize_weight 0.50
95
95
  t2.min_width 15
96
96
  t2.min_height 5
@@ -12,7 +12,7 @@
12
12
 
13
13
  # this is a test program, tests out tabbed panes. type F1 to exit
14
14
  #
15
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
15
+ $LOAD_PATH << "/Users/rahul/work/projects/rbcurse/lib/"
16
16
  require 'rubygems'
17
17
  require 'ncurses'
18
18
  require 'logger'
@@ -41,6 +41,8 @@ class TestTabbedPane
41
41
  end
42
42
  @tab1 = @tp.add_tab "&Table"
43
43
  f1 = @tab1.form
44
+ f1 = @tp.form @tab1
45
+ raise "form f1 nil" unless f1
44
46
  $log.debug " TABLE FORM #{f1} "
45
47
 
46
48
  data = [["Pathetique",3,"Tchaikovsky",3.21, true, "WIP"],
@@ -127,7 +129,8 @@ class TestTabbedPane
127
129
  end
128
130
 
129
131
  @tab2 = @tp.add_tab "&ScrollTable"
130
- f2 = @tab2.form
132
+ #f2 = @tab2.form
133
+ f2 = @tp.form @tab2
131
134
  scroll = ScrollPane.new f2 do
132
135
  name "myScroller"
133
136
  row 4
@@ -26,6 +26,8 @@ require 'ncurses'
26
26
  require 'logger'
27
27
  require 'rbcurse'
28
28
 
29
+ KEY_TAB = 9
30
+ KEY_BTAB = 353
29
31
  include Ncurses
30
32
  include RubyCurses
31
33
  module RubyCurses
data/rbcurse.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rbcurse}
8
- s.version = "1.1.4"
8
+ s.version = "1.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rahul Kumar"]
12
- s.date = %q{2010-08-30}
12
+ s.date = %q{2010-09-04}
13
13
  s.default_executable = %q{rbcurse}
14
14
  s.description = %q{Ruby curses widgets for easy application development on text terminals (ruby 1.9, 1.8)}
15
15
  s.email = %q{sentinel.2001@gmx.com}
@@ -66,7 +66,6 @@ Gem::Specification.new do |s|
66
66
  "examples/testsplittvv.rb",
67
67
  "examples/testtable.rb",
68
68
  "examples/testtabp.rb",
69
- "examples/testtestw.rb",
70
69
  "examples/testtodo.rb",
71
70
  "examples/testtpane.rb",
72
71
  "examples/testtpane2.rb",
@@ -134,6 +133,7 @@ Gem::Specification.new do |s|
134
133
  s.summary = %q{Ruby Curses Toolkit}
135
134
  s.test_files = [
136
135
  "test/test_rbcurse.rb",
136
+ "examples/cdir/testmultispl.rb",
137
137
  "examples/keytest.rb",
138
138
  "examples/mpad2.rb",
139
139
  "examples/newtesttabp.rb",
@@ -167,7 +167,6 @@ Gem::Specification.new do |s|
167
167
  "examples/testsplittvv.rb",
168
168
  "examples/testtable.rb",
169
169
  "examples/testtabp.rb",
170
- "examples/testtestw.rb",
171
170
  "examples/testtodo.rb",
172
171
  "examples/testtpane.rb",
173
172
  "examples/testtpane2.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 4
9
- version: 1.1.4
8
+ - 5
9
+ version: 1.1.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rahul Kumar
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-30 00:00:00 +05:30
17
+ date: 2010-09-04 00:00:00 +05:30
18
18
  default_executable: rbcurse
19
19
  dependencies: []
20
20
 
@@ -75,7 +75,6 @@ files:
75
75
  - examples/testsplittvv.rb
76
76
  - examples/testtable.rb
77
77
  - examples/testtabp.rb
78
- - examples/testtestw.rb
79
78
  - examples/testtodo.rb
80
79
  - examples/testtpane.rb
81
80
  - examples/testtpane2.rb
@@ -135,6 +134,7 @@ files:
135
134
  - lib/ver/window.rb
136
135
  - rbcurse.gemspec
137
136
  - test/test_rbcurse.rb
137
+ - examples/cdir/testmultispl.rb
138
138
  - examples/todo.rb
139
139
  has_rdoc: true
140
140
  homepage: http://rbcurse.rubyforge.org/
@@ -170,6 +170,7 @@ specification_version: 3
170
170
  summary: Ruby Curses Toolkit
171
171
  test_files:
172
172
  - test/test_rbcurse.rb
173
+ - examples/cdir/testmultispl.rb
173
174
  - examples/keytest.rb
174
175
  - examples/mpad2.rb
175
176
  - examples/newtesttabp.rb
@@ -203,7 +204,6 @@ test_files:
203
204
  - examples/testsplittvv.rb
204
205
  - examples/testtable.rb
205
206
  - examples/testtabp.rb
206
- - examples/testtestw.rb
207
207
  - examples/testtodo.rb
208
208
  - examples/testtpane.rb
209
209
  - examples/testtpane2.rb
@@ -1,69 +0,0 @@
1
- #$LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'rubygems'
3
- require 'ncurses'
4
- require 'logger'
5
- #require 'lib/ver/keyboard'
6
- require 'rbcurse'
7
- require 'rbcurse/rtestwidget'
8
- if $0 == __FILE__
9
- include RubyCurses
10
- include RubyCurses::Utils
11
-
12
- begin
13
- # Initialize curses
14
- VER::start_ncurses # this is initializing colors via ColorMap.setup
15
- $log = Logger.new((File.join(ENV["LOGDIR"] || "./" ,"view.log")))
16
- $log.level = Logger::DEBUG
17
-
18
- @window = VER::Window.root_window
19
-
20
- catch(:close) do
21
- colors = Ncurses.COLORS
22
- @form = Form.new @window
23
- r = 1; c = 30; w = 40
24
- ht = 10
25
- # print filler stars
26
- filler = "*" * (w+2)
27
- (ht+3).times(){|i| @form.window.printstring(i,c-1, filler, $datacolor) }
28
-
29
- # strangely, first displays textview, then puts the fillers over it.
30
- # then after a keypress, again refreshes textview.
31
-
32
-
33
- @textview = TestWidget.new @form do
34
- name "myView"
35
- row r
36
- col c
37
- width w
38
- height ht
39
- title "README.txt"
40
- title_attrib 'bold'
41
- print_footer true
42
- footer_attrib 'bold'
43
- end
44
- content = File.open("../README.txt","r").readlines
45
- @textview.set_content content #, :WRAP_WORD
46
-
47
- @help = "q to quit. This is a test of testWidget which uses a pad/buffer."
48
- RubyCurses::Label.new @form, {'text' => @help, "row" => 21, "col" => 2, "color" => "yellow"}
49
-
50
- @form.repaint
51
- @window.wrefresh
52
- Ncurses::Panel.update_panels
53
- while((ch = @window.getchar()) != ?q.getbyte(0) )
54
- str = keycode_tos ch
55
- @form.handle_key(ch)
56
- @form.repaint
57
- @window.wrefresh
58
- end
59
- end
60
- rescue => ex
61
- ensure
62
- @window.destroy if !@window.nil?
63
- VER::stop_ncurses
64
- p ex if ex
65
- p(ex.backtrace.join("\n")) if ex
66
- $log.debug( ex) if ex
67
- $log.debug(ex.backtrace.join("\n")) if ex
68
- end
69
- end