rbcurse 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/CHANGELOG +20 -0
  2. data/NOTES +45 -0
  3. data/README.markdown +47 -68
  4. data/TODO2.txt +29 -32
  5. data/VERSION +1 -1
  6. data/examples/abasiclist.rb +2 -0
  7. data/examples/app.rb +2 -2
  8. data/examples/app.sample +10 -0
  9. data/examples/appemail.rb +29 -2
  10. data/examples/appemaillb.rb +1 -1
  11. data/examples/appgcompose.rb +9 -2
  12. data/examples/appmethods.rb +69 -0
  13. data/examples/atree.rb +2 -2
  14. data/examples/menu1.rb +1 -1
  15. data/examples/newtesttabp.rb +8 -5
  16. data/examples/qdfilechooser.rb +6 -3
  17. data/examples/rfe.rb +71 -16
  18. data/examples/rmail.rb +76 -7
  19. data/examples/sqlc.rb +14 -3
  20. data/examples/sqlm.rb +3 -3
  21. data/examples/term.rb +48 -0
  22. data/examples/term2.rb +48 -21
  23. data/examples/test1.rb +2 -2
  24. data/examples/test2.rb +162 -71
  25. data/examples/testapp.rb +2 -2
  26. data/examples/testapp2.rb +1 -1
  27. data/examples/testchars.rb +47 -46
  28. data/examples/testcombo.rb +2 -2
  29. data/examples/testkeypress.rb +2 -2
  30. data/examples/testlistbox.rb +2 -2
  31. data/examples/testmenu.rb +1 -1
  32. data/examples/testmulticomp.rb +1 -1
  33. data/examples/testmultispl.rb +1 -1
  34. data/examples/testree.rb +1 -22
  35. data/examples/testscroller.rb +2 -2
  36. data/examples/testscrolllb.rb +2 -2
  37. data/examples/testscrollp.rb +2 -2
  38. data/examples/testscrollta.rb +2 -2
  39. data/examples/testscrolltable.rb +2 -2
  40. data/examples/testsplit.rb +2 -2
  41. data/examples/testsplit2.rb +2 -2
  42. data/examples/testsplit3.rb +2 -2
  43. data/examples/testsplit3_1.rb +2 -2
  44. data/examples/testsplit3a.rb +2 -2
  45. data/examples/testsplit3b.rb +2 -2
  46. data/examples/testsplitta.rb +2 -2
  47. data/examples/testsplittv.rb +2 -2
  48. data/examples/testsplittvv.rb +2 -2
  49. data/examples/testtable.rb +2 -2
  50. data/examples/testtabp.rb +2 -2
  51. data/examples/testtodo.rb +1 -1
  52. data/examples/testtpane.rb +2 -2
  53. data/examples/testtpane2.rb +2 -2
  54. data/examples/testtpanetable.rb +6 -5
  55. data/examples/testvimsplit.rb +2 -2
  56. data/examples/viewtodo.rb +1 -1
  57. data/lib/rbcurse.rb +2 -1
  58. data/lib/rbcurse/action.rb +1 -1
  59. data/lib/rbcurse/app.rb +51 -14
  60. data/lib/rbcurse/applicationheader.rb +1 -1
  61. data/lib/rbcurse/celleditor.rb +1 -1
  62. data/lib/rbcurse/colormap.rb +11 -11
  63. data/lib/rbcurse/comboboxcellrenderer.rb +1 -1
  64. data/lib/rbcurse/extras/bottomline.rb +22 -10
  65. data/lib/rbcurse/extras/directorylist.rb +14 -1
  66. data/lib/rbcurse/extras/divider.rb +1 -1
  67. data/lib/rbcurse/extras/listselectable.rb +2 -2
  68. data/lib/rbcurse/extras/masterdetail.rb +3 -1
  69. data/lib/rbcurse/extras/scrollbar.rb +1 -1
  70. data/lib/rbcurse/extras/stdscrwindow.rb +75 -24
  71. data/lib/rbcurse/extras/tabular.rb +8 -3
  72. data/lib/rbcurse/extras/viewer.rb +18 -2
  73. data/lib/rbcurse/io.rb +26 -13
  74. data/lib/rbcurse/keylabelprinter.rb +3 -2
  75. data/lib/rbcurse/listcellrenderer.rb +1 -0
  76. data/lib/rbcurse/listkeys.rb +3 -2
  77. data/lib/rbcurse/listselectable.rb +4 -3
  78. data/lib/rbcurse/rbasiclistbox.rb +12 -5
  79. data/lib/rbcurse/rcombo.rb +2 -2
  80. data/lib/rbcurse/rcommandwindow.rb +5 -3
  81. data/lib/rbcurse/rdialogs.rb +8 -2
  82. data/lib/rbcurse/rlistbox.rb +10 -2
  83. data/lib/rbcurse/rmenu.rb +4 -4
  84. data/lib/rbcurse/rmessagebox.rb +10 -5
  85. data/lib/rbcurse/rmulticontainer.rb +21 -8
  86. data/lib/rbcurse/rmultisplit.rb +2 -2
  87. data/lib/rbcurse/rmultitextview.rb +5 -3
  88. data/lib/rbcurse/rpopupmenu.rb +3 -3
  89. data/lib/rbcurse/rprogress.rb +3 -2
  90. data/lib/rbcurse/rscrollform.rb +2 -2
  91. data/lib/rbcurse/rscrollpane.rb +9 -9
  92. data/lib/rbcurse/rsplitpane.rb +2 -2
  93. data/lib/rbcurse/rsplitpane2.rb +2 -2
  94. data/lib/rbcurse/rtabbedpane.rb +48 -12
  95. data/lib/rbcurse/rtabbedwindow.rb +4 -4
  96. data/lib/rbcurse/rtable.rb +6 -3
  97. data/lib/rbcurse/rtextarea.rb +8 -8
  98. data/lib/rbcurse/rtextview.rb +3 -2
  99. data/lib/rbcurse/rtree.rb +2 -2
  100. data/lib/rbcurse/rviewport.rb +2 -2
  101. data/lib/rbcurse/rvimsplit.rb +3 -2
  102. data/lib/rbcurse/rwidget.rb +63 -26
  103. data/lib/rbcurse/scrollable.rb +1 -1
  104. data/lib/rbcurse/table/tablecellrenderer.rb +1 -1
  105. data/lib/rbcurse/table/tabledatecellrenderer.rb +1 -1
  106. data/lib/rbcurse/tree/treemodel.rb +1 -1
  107. data/lib/rbcurse/vieditable.rb +1 -0
  108. data/lib/ver/ncurses.rb +122 -4
  109. data/lib/ver/panel.rb +162 -0
  110. data/lib/ver/window.rb +262 -120
  111. metadata +19 -7
  112. data/examples/keytest.rb +0 -178
  113. data/examples/mpad2.rb +0 -156
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rbcurse
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.0
5
+ version: 1.3.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rahul Kumar
@@ -10,9 +10,19 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-09-14 00:00:00 Z
14
- dependencies: []
15
-
13
+ date: 2011-09-28 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ffi-ncurses
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.4.0
24
+ type: :runtime
25
+ version_requirements: *id001
16
26
  description: Ruby curses/ncurses widgets for easy application development on text terminals (ruby 1.9, 1.8)
17
27
  email: sentinel1879@gmail.com
18
28
  executables: []
@@ -36,17 +46,17 @@ files:
36
46
  - examples/abasiclist.rb
37
47
  - examples/alpmenu.rb
38
48
  - examples/app.rb
49
+ - examples/app.sample
39
50
  - examples/appdirtree.rb
40
51
  - examples/appemail.rb
41
52
  - examples/appemaillb.rb
42
53
  - examples/appgcompose.rb
43
54
  - examples/appgmail.rb
55
+ - examples/appmethods.rb
44
56
  - examples/atree.rb
45
57
  - examples/data.txt
46
58
  - examples/dirtree.rb
47
- - examples/keytest.rb
48
59
  - examples/menu1.rb
49
- - examples/mpad2.rb
50
60
  - examples/multispl.rb
51
61
  - examples/newtesttabp.rb
52
62
  - examples/qdfilechooser.rb
@@ -58,6 +68,7 @@ files:
58
68
  - examples/sqlm.rb
59
69
  - examples/status.txt
60
70
  - examples/table1.rb
71
+ - examples/term.rb
61
72
  - examples/term2.rb
62
73
  - examples/test1.rb
63
74
  - examples/test2.rb
@@ -168,6 +179,7 @@ files:
168
179
  - lib/ver/keyboard.rb
169
180
  - lib/ver/keyboard2.rb
170
181
  - lib/ver/ncurses.rb
182
+ - lib/ver/panel.rb
171
183
  - lib/ver/window.rb
172
184
  - test/test_rbcurse.rb
173
185
  homepage: http://rbcurse.rubyforge.org/
@@ -196,6 +208,6 @@ rubyforge_project: rbcurse
196
208
  rubygems_version: 1.8.8
197
209
  signing_key:
198
210
  specification_version: 3
199
- summary: Ruby ncurses Toolkit using ffi since v1.2.3
211
+ summary: Ruby Ncurses Toolkit (using ffi-ncurses since v1.3.0)
200
212
  test_files: []
201
213
 
data/examples/keytest.rb DELETED
@@ -1,178 +0,0 @@
1
- $LOAD_PATH << "/Users/rahul/work/projects/rbcurse/"
2
- require 'rubygems'
3
- require 'ncurses'
4
- require 'logger'
5
- require 'rbcurse'
6
- #require 'lib/ver/ncurses'
7
- #require 'lib/ver/window'
8
- require 'rbcurse/rwidget'
9
- require 'ver/keyboard2'
10
- require 'rbcurse/mapper'
11
-
12
- # Using mapper with keyboard2 which gives numeric keys
13
- # The error messages are not so pretty, otherwise its okay... error messages need a little work
14
- # Use C-q or q to quit
15
- ## C-s starts a new mode :cx, 'i' gets back to normal
16
- #include Ncurses
17
- # NOTE: this test was created only to test upcoming 1.9 key change and how to handle it.
18
-
19
-
20
- def printstr(pad, r,c,string, color, att = Ncurses::A_NORMAL)
21
-
22
- #att = bold ? Ncurses::A_BLINK|Ncurses::A_BOLD : Ncurses::A_NORMAL
23
- # att = bold ? Ncurses::A_BOLD : Ncurses::A_NORMAL
24
- pad.attrset(Ncurses.COLOR_PAIR(color) | att)
25
- #pad.mvprintw(r, c, "%s", string);
26
- pad.mvaddstr(r, c, "%s" % string);
27
- pad.attroff(Ncurses.COLOR_PAIR(color) | att)
28
- end
29
- class KeyTest
30
- attr_reader :window # needed by keyboard to do getch
31
- attr_accessor :mode # needed by handler
32
- def initialize win
33
- @window = win
34
- @color = $datacolor
35
- @mode = :normal
36
- map_keys
37
- VER::Keyboard2.focus = self
38
- end
39
- def down
40
- printstr(@window, 12,1,"GOT Down ", @color, att = Ncurses::A_NORMAL)
41
- end
42
- def up
43
- printstr(@window, 12,1,"GOT Up ", @color, att = Ncurses::A_REVERSE)
44
- end
45
- def do_select
46
- printstr(@window, 12,1,"GOT do_select", @color, att = Ncurses::A_BOLD)
47
- end
48
-
49
- def map_keys
50
- @mapper = Mapper.new(self)
51
- @keyhandler = @mapper # i don't want a separate handler, this will do
52
-
53
- # view refers to the object passed to constrcutor of Mapper, here it is self
54
- @mapper.let :normal do
55
- map(?\C-x, ?\C-d){ view.down }
56
- map(?\C-x, ?\C-u){ view.up }
57
- map(?\C-x, ?q){ view.stop }
58
- map(?\C-x, ?\C-s){ view.do_search_ask }
59
- map(?\C-x, ?\C-x){ view.do_select }
60
- map(?q){ view.stop }
61
- map(?q){ view.stop }
62
- map(32){ view.space }
63
- map(?n){ view.space }
64
- map(?j){ :down }
65
- map(?k){ view.up }
66
- map(?p){ view.minus }
67
- map(?[) { view.goto_start }
68
- map(?]) { view.goto_end }
69
- map(?-) { view.minus }
70
-
71
- map('right') { view.right}
72
- map(?l) { view.right}
73
- map('left') {view.left}
74
- map(?h) {view.left}
75
- map(KEY_DOWN) { view.down }
76
- map(?j) { view.down }
77
- map(KEY_UP) { view.up }
78
- map(KEY_ENTER) { view.enter }
79
- map(?g) { view.handle_goto_ask }
80
- map(?/) { view.do_search_ask }
81
- map(?\C-n) { view.do_search_next }
82
- map(?\C-p) { view.do_search_prev }
83
- map(?x) { view.do_select }
84
- map(?\') { view.do_next_selection }
85
- map(?") { view.do_prev_selection }
86
- map(?\C-e) { view.do_clear_selection }
87
- ## C-s starts a new mode, i gets back to normal
88
- map(?\C-s){ view.mode = :cx }
89
- # all printable chars not trapped above are caught here
90
- map(/^([[:print:]])$/){ view.show("Got printable: #{@arg} ") }
91
-
92
-
93
- map(?\C-q){ view.stop }
94
- end
95
-
96
- ## a mode, started by C-s, use i to go back, q to quit
97
- @mapper.let :cx do
98
- map(?c.getbyte(0)){ view.show(:c) }
99
- map(?a.getbyte(0)){ view.show(:a) }
100
- map(?r.getbyte(0)){ view.show(:r) }
101
- map(?q.getbyte(0)){ view.stop }
102
- map(?i.getbyte(0)){ view.mode = :normal }
103
- end
104
- end
105
- def press(key)
106
- # I can intercept printable keys here
107
- $log.debug("press key: %s" % key)
108
- begin
109
- @keyhandler.press(key)
110
- #break if stopping?
111
- return if stopping?
112
- if !@message.nil?
113
- printstr(@window, 18,1,"%40s" % @message, $promptcolor, att = Ncurses::A_NORMAL)
114
- @message = nil
115
- end
116
-
117
- rescue ::Exception => ex
118
- $log.debug ex
119
- show(ex.message)
120
- end
121
- end # press
122
-
123
- # from VER
124
- def stopping?
125
- @stop
126
- end
127
- def show string
128
- @message = string
129
- end
130
-
131
- # without this system hangs if unknown key presed
132
- def info(message)
133
- @message = message
134
- end
135
-
136
- def stop
137
- @stop = true
138
- throw(:close)
139
- end
140
- end
141
- if $0 == __FILE__
142
- include RubyCurses
143
- include RubyCurses::Utils
144
- begin
145
- # Initialize curses
146
- VER::start_ncurses
147
- $reversecolor = 2
148
- $errorcolor = 7
149
- $promptcolor = $selectedcolor = 4
150
- $normalcolor = $datacolor = 5
151
- $bottomcolor = $topcolor = 6
152
-
153
- # Create the window to be associated with the form
154
- # Un post form and free the memory
155
- $log = Logger.new("view.log")
156
- $log.level = Logger::DEBUG
157
-
158
- catch(:close) do
159
- @layout = { :height => 0, :width => 0, :top => 0, :left => 0 }
160
- @window = VER::Window.new(@layout)
161
- @window.bkgd(Ncurses.COLOR_PAIR(5));
162
- @panel = @window.panel
163
- @window.wrefresh
164
- Ncurses::Panel.update_panels
165
- $log.debug "START ---------"
166
- kt = KeyTest.new @window
167
- end
168
- rescue => ex
169
- ensure
170
- Ncurses::Panel.del_panel(@panel) if !@panel.nil?
171
- @window.delwin if !@window.nil?
172
- VER::stop_ncurses
173
- p ex if ex
174
- p(ex.backtrace.join("\n")) if ex
175
- $log.debug( ex) if ex
176
- $log.debug(ex.backtrace.join("\n")) if ex
177
- end
178
- end
data/examples/mpad2.rb DELETED
@@ -1,156 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # REQUIRES A FILE NAMED "TODO" in current folder, to display and page
4
- # a basic file pager to check out ncurses ruby pad
5
- # working in 1.8.7 but not showing anything when i hit a key in 1.9.1
6
- require 'rubygems'
7
- require 'ncurses'
8
- require 'logger'
9
-
10
- include Ncurses
11
- include Ncurses::Form
12
-
13
- class Fixnum
14
- def ord
15
- self
16
- end
17
- ## mostly for control and meta characters
18
- def getbyte(n)
19
- self
20
- end
21
- end unless "a"[0] == "a"
22
-
23
-
24
- # Initialize curses
25
- begin
26
- stdscr = Ncurses.initscr();
27
- Ncurses.start_color();
28
- Ncurses.cbreak();
29
- Ncurses.noecho();
30
- Ncurses.keypad(stdscr, true);
31
-
32
- # Initialize few color pairs
33
- Ncurses.init_pair(1, COLOR_RED, COLOR_BLACK);
34
- Ncurses.init_pair(2, COLOR_BLACK, COLOR_WHITE);
35
- Ncurses.init_pair(3, COLOR_BLACK, COLOR_BLUE);
36
- Ncurses.init_pair(4, COLOR_YELLOW, COLOR_RED); # for selected item
37
- Ncurses.init_pair(5, COLOR_WHITE, COLOR_BLACK); # for unselected menu items
38
- Ncurses.init_pair(6, COLOR_WHITE, COLOR_BLUE); # for bottom/top bar
39
- Ncurses.init_pair(7, COLOR_WHITE, COLOR_RED); # for error messages
40
- #stdscr.bkgd(Ncurses.COLOR_PAIR(6)); ## DO NOT TOUCH stdscr please
41
-
42
- $log = Logger.new("view.log")
43
- $log.level = Logger::DEBUG
44
- # Create the window to be associated with the form
45
- @screenrows = Ncurses.LINES-3
46
- screencols = 80
47
- @startrow = 1
48
- my_form_win = WINDOW.new(0,0,0,0)
49
- x = Array.new
50
- y = Array.new
51
- Ncurses.getmaxyx(my_form_win, y, x)
52
- $log.debug " x = #{x[0]}, y = #{y[0]}"
53
- screencols = 99; x[0]-15
54
- my_panel = my_form_win.new_panel
55
- textary = File.open("../TODO","r").readlines
56
- my_pad = Ncurses.newpad(textary.count,100)
57
- pad = my_pad.new_panel
58
- Ncurses::Panel.update_panels
59
-
60
- my_form_win.bkgd(Ncurses.COLOR_PAIR(5));
61
- my_pad.keypad(TRUE);
62
-
63
- # Set main window and sub window
64
-
65
- # Print a border around the main window and print a title */
66
- #my_form_win.box(0, 0);
67
- #print_in_middle(my_form_win, 1, 0, cols[0] + 14, "Main Menu", Ncurses.COLOR_PAIR(6));
68
- Ncurses.refresh();
69
-
70
- textary.each_index { |ix|
71
- my_pad.mvaddstr(ix, 0, textary[ix])
72
- }
73
-
74
- # Print field types
75
-
76
- #my_pad.prefresh(0,0, 0,0, Ncurses.LINES,Ncurses.COLS-1);
77
- #my_form_win.wrefresh();
78
- @prow = 0; @pcol = 0;
79
- #my_pad.prefresh(0,0, @startrow ,0, @screenrows,Ncurses.COLS-1);
80
- # trying out overwrite since copywin retuns ERR -1
81
- #ret = Ncurses.copywin(my_pad, my_form_win, 0,0,@startrow,0, @screenrows, Ncurses.COLS-1, 0)
82
- ### ret = Ncurses.overwrite(my_pad, my_form_win) # worked
83
- ### $log.debug("overwrite #{ret}")
84
- # ret = Ncurses.overwrite(my_form_win, my_pad)
85
- #my_form_win.wrefresh(); << this line clears what pad has put, but needed by copywin etc i think
86
-
87
-
88
- # Loop through to get user requests
89
- # # XXX Need to clear pad so earlier data in last line does not still remain
90
- while((ch = my_pad.getch()) != KEY_F1 )
91
- case ch
92
- when ?j.getbyte(0)
93
- @prow += 1
94
- #next
95
- # disallow
96
- if @prow > textary.count
97
- @prow = textary.count
98
- Ncurses.beep
99
- next
100
- end
101
- #when KEY_UP
102
- when ?k.getbyte(0)
103
- @prow -= 1
104
- #next
105
- # disallow
106
- if @prow <= 0
107
- Ncurses.beep
108
- @prow = 0
109
- next
110
- end
111
- when 32
112
- @prow += @screenrows
113
- if @prow > textary.count
114
- @prow = textary.count
115
- Ncurses.beep
116
- next
117
- end
118
- when ?-.getbyte(0)
119
- if @prow <= 0
120
- Ncurses.beep
121
- @prow = 0
122
- next
123
- end
124
- @prow -= @screenrows
125
- when ?t.getbyte(0)
126
- @pcol = @prow = 0
127
- when ?h.getbyte(0)
128
- @pcol += 1
129
- when ?l.getbyte(0)
130
- @pcol -= 1
131
- when ?r.getbyte(0)
132
- my_form_win.wclear # 2009-10-10 17:46
133
- when KEY_ENTER, 10
134
- # selection
135
- when ?q.getbyte(0), ?\,
136
- break
137
- end
138
- @pcol = 0 if @pcol < 0
139
- # clear is required but in 1.9.1 there is no prefresh after a clear. screen blanks out totally
140
- #my_form_win.wclear # 2009-10-10 17:46
141
- #my_form_win.werase # 2009-10-10 17:46
142
- # my_pad.prefresh(@prow,@pcol, @startrow,0, @screenrows,Ncurses.COLS-1);
143
- #ret = Ncurses.copywin(my_pad, my_form_win, @prow,@pcol,@startrow,0, @screenrows, Ncurses.COLS-1, 0)
144
- #ret = my_pad.copywin( my_form_win, @prow,@pcol,@startrow,0, @screenrows, Ncurses.COLS-1, 0)
145
- ret = my_pad.copywin( my_form_win, @prow,@pcol,0,0, @screenrows, screencols, 0)
146
- $log.debug("copywin #{ret} : cols:#{screencols}")
147
- my_form_win.wrefresh # if i don't put this then upon return the other screen is still shown
148
- # till i press a key
149
- Ncurses::Panel.update_panels
150
- end
151
- # Un post form and free the memory
152
-
153
-
154
- ensure
155
- Ncurses.endwin();
156
- end