rbcurse 1.4.0 → 1.4.1.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/NOTES +68 -0
- data/README.markdown +73 -330
- data/TODO2.txt +2 -2
- data/VERSION +1 -1
- data/examples/abasiclist.rb +8 -2
- data/examples/alpmenu.rb +1 -1
- data/examples/app.rb +1 -24
- data/examples/appdirtree.rb +1 -1
- data/examples/appemail.rb +8 -14
- data/examples/appemaillb.rb +2 -2
- data/examples/appgcompose.rb +7 -5
- data/examples/common/file.rb +40 -0
- data/examples/{rmail.rb → common/rmail.rb} +0 -0
- data/examples/data/README.markdown +9 -0
- data/examples/data/brew.txt +38 -0
- data/examples/data/color.2 +37 -0
- data/examples/data/gemlist.txt +60 -0
- data/examples/data/lotr.txt +12 -0
- data/examples/data/ports.txt +136 -0
- data/examples/data/tasks.txt +27 -0
- data/examples/{todocsv.csv → data/todocsv.csv} +0 -0
- data/examples/data/unix1.txt +21 -0
- data/examples/data/unix2.txt +11 -0
- data/examples/dbdemo.rb +49 -14
- data/examples/{appgmail.rb → deprecated/appgmail.rb} +1 -1
- data/examples/{splitp.rb → deprecated/splitp.rb} +0 -0
- data/examples/{testscrolllb.rb → deprecated/testscrolllb.rb} +0 -0
- data/examples/{testscrollp.rb → deprecated/testscrollp.rb} +0 -0
- data/examples/{testscrollta.rb → deprecated/testscrollta.rb} +0 -0
- data/examples/{testscrolltable.rb → deprecated/testscrolltable.rb} +0 -0
- data/examples/{testsplit.rb → deprecated/testsplit.rb} +0 -0
- data/examples/{testsplit2.rb → deprecated/testsplit2.rb} +0 -0
- data/examples/{testsplit3.rb → deprecated/testsplit3.rb} +0 -0
- data/examples/{testsplit3_1.rb → deprecated/testsplit3_1.rb} +0 -0
- data/examples/{testsplit3a.rb → deprecated/testsplit3a.rb} +0 -0
- data/examples/{testsplit3b.rb → deprecated/testsplit3b.rb} +0 -0
- data/examples/{testsplitta.rb → deprecated/testsplitta.rb} +0 -0
- data/examples/{testsplittv.rb → deprecated/testsplittv.rb} +0 -0
- data/examples/{testsplittvv.rb → deprecated/testsplittvv.rb} +0 -0
- data/examples/{testtpane.rb → deprecated/testtpane.rb} +0 -0
- data/examples/{testtpane2.rb → deprecated/testtpane2.rb} +0 -0
- data/examples/{testtpanetable.rb → deprecated/testtpanetable.rb} +0 -0
- data/examples/dirtree.rb +17 -7
- data/examples/experimental/resultsetdemo.rb +280 -0
- data/examples/experimental/testmform.rb +35 -0
- data/examples/{testscroller.rb → experimental/testscroller.rb} +1 -19
- data/examples/experimental/teststackflow.rb +111 -0
- data/examples/menu1.rb +1 -0
- data/examples/multispl.rb +4 -4
- data/examples/newmessagebox.rb +130 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/newtesttabp.rb +0 -3
- data/examples/qdfilechooser.rb +0 -3
- data/examples/rfe.rb +134 -18
- data/examples/rfe_renderer.rb +48 -2
- data/examples/sqlc.rb +2 -1
- data/examples/sqlm.rb +0 -2
- data/examples/table1.rb +1 -7
- data/examples/term2.rb +4 -1
- data/examples/test1.rb +0 -5
- data/examples/test2.rb +42 -31
- data/examples/testapp2.rb +8 -1
- data/examples/testchars.rb +0 -4
- data/examples/testcombo.rb +5 -9
- data/examples/testkeypress.rb +0 -3
- data/examples/testmenu.rb +0 -4
- data/examples/testmulticomp.rb +3 -5
- data/examples/testmulticontainer.rb +94 -0
- data/examples/testtable.rb +0 -5
- data/examples/testtabp.rb +16 -18
- data/examples/testtodo.rb +1 -5
- data/examples/testwsshortcuts.rb +64 -0
- data/examples/testwsshortcuts2.rb +126 -0
- data/examples/viewtodo.rb +1 -4
- data/lib/rbcurse.rb +1 -1
- data/lib/rbcurse/app.rb +92 -69
- data/lib/rbcurse/applicationheader.rb +46 -6
- data/lib/rbcurse/celleditor.rb +1 -9
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -4
- data/lib/rbcurse/common/ansiparser.rb +117 -0
- data/{examples → lib/rbcurse/common}/appmethods.rb +25 -0
- data/lib/rbcurse/common/basestack.rb +407 -0
- data/lib/rbcurse/common/bordertitle.rb +41 -0
- data/lib/rbcurse/common/chunk.rb +177 -0
- data/lib/rbcurse/common/colorparser.rb +71 -0
- data/lib/rbcurse/common/keydefs.rb +30 -0
- data/lib/rbcurse/common/widgetshortcuts.rb +302 -0
- data/lib/rbcurse/deprecated/README.markdown +12 -0
- data/lib/rbcurse/{rscrollpane.rb → deprecated/rscrollpane.rb} +0 -0
- data/lib/rbcurse/{rsplitpane.rb → deprecated/rsplitpane.rb} +0 -0
- data/lib/rbcurse/{rsplitpane2.rb → deprecated/rsplitpane2.rb} +0 -0
- data/lib/rbcurse/{rviewport.rb → deprecated/rviewport.rb} +0 -0
- data/lib/rbcurse/experimental/README.markdown +14 -0
- data/lib/rbcurse/experimental/resultsettextview.rb +585 -0
- data/lib/rbcurse/experimental/stackflow.rb +478 -0
- data/lib/rbcurse/extras/bottomline.rb +85 -16
- data/lib/rbcurse/extras/box.rb +58 -0
- data/lib/rbcurse/extras/directorylist.rb +1 -1
- data/lib/rbcurse/extras/horizlist.rb +203 -0
- data/lib/rbcurse/extras/listselectable.rb +8 -0
- data/lib/rbcurse/extras/multiform.rb +330 -0
- data/lib/rbcurse/extras/multilinelabel.rb +142 -0
- data/lib/rbcurse/extras/newmessagebox.rb +328 -0
- data/lib/rbcurse/extras/newtabbedpane.rb +612 -0
- data/lib/rbcurse/extras/newtabbedwindow.rb +68 -0
- data/lib/rbcurse/extras/padreader.rb +189 -0
- data/lib/rbcurse/extras/rcomboedit.rb +256 -0
- data/lib/rbcurse/extras/resultsetbrowser.rb +281 -0
- data/lib/rbcurse/extras/statusline.rb +44 -6
- data/lib/rbcurse/extras/tabularwidget.rb +141 -104
- data/lib/rbcurse/extras/textpad.rb +516 -0
- data/lib/rbcurse/extras/viewer.rb +2 -0
- data/lib/rbcurse/io.rb +120 -3
- data/lib/rbcurse/listcellrenderer.rb +2 -1
- data/lib/rbcurse/listkeys.rb +1 -1
- data/lib/rbcurse/listscrollable.rb +72 -7
- data/lib/rbcurse/rbasiclistbox.rb +64 -12
- data/lib/rbcurse/rchangeevent.rb +0 -1
- data/lib/rbcurse/rcombo.rb +54 -59
- data/lib/rbcurse/rcommandwindow.rb +46 -10
- data/lib/rbcurse/rcontainer.rb +415 -0
- data/lib/rbcurse/rdialogs.rb +242 -165
- data/lib/rbcurse/rinputdataevent.rb +0 -1
- data/lib/rbcurse/rlistbox.rb +19 -9
- data/lib/rbcurse/rmessagebox.rb +1 -5
- data/lib/rbcurse/rmulticontainer.rb +64 -61
- data/lib/rbcurse/rmultitextview.rb +0 -2
- data/lib/rbcurse/rpopupmenu.rb +0 -2
- data/lib/rbcurse/rscrollform.rb +61 -12
- data/lib/rbcurse/rtabbedpane.rb +89 -73
- data/lib/rbcurse/rtabbedwindow.rb +53 -211
- data/lib/rbcurse/rtable.rb +0 -2
- data/lib/rbcurse/rtextarea.rb +14 -14
- data/lib/rbcurse/rtextview.rb +165 -50
- data/lib/rbcurse/rvimsplit.rb +15 -12
- data/lib/rbcurse/rwidget.rb +404 -150
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -4
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -3
- data/lib/ver/ncurses.rb +1 -9
- data/lib/ver/rpad.rb +375 -0
- data/lib/ver/window.rb +262 -440
- metadata +73 -31
data/lib/rbcurse/rlistbox.rb
CHANGED
@@ -9,8 +9,6 @@ NOTE: listbox now traps RETURN/ENTER/13 so if you are trapping it, please use bi
|
|
9
9
|
TODO
|
10
10
|
Perhaps keep printed data created by convert_value_to_text cached, and used for searching
|
11
11
|
cursor movement and other functions.
|
12
|
-
[ ] XXX Can we separate editing out. Make a ReadonlyList, and extend it as EditableList. This way the usual
|
13
|
-
use case remains cleaner.
|
14
12
|
=end
|
15
13
|
require 'rbcurse'
|
16
14
|
require 'rbcurse/listcellrenderer'
|
@@ -221,7 +219,7 @@ module RubyCurses
|
|
221
219
|
@height ||= [@max_visible_items || 10, @list.length].min
|
222
220
|
$log.debug " POPUP XXX #{@max_visible_items} ll:#{@list.length} h:#{@height}"
|
223
221
|
# get widgets absolute coords
|
224
|
-
if
|
222
|
+
if @relative_to
|
225
223
|
layout = @relative_to.form.window.layout
|
226
224
|
@row = @row + layout[:top]
|
227
225
|
@col = @col + layout[:left]
|
@@ -245,7 +243,7 @@ module RubyCurses
|
|
245
243
|
@form = RubyCurses::Form.new @window
|
246
244
|
@window.bkgd(Ncurses.COLOR_PAIR($reversecolor));
|
247
245
|
@window.wrefresh
|
248
|
-
|
246
|
+
#@panel = @window.panel # useless line ?
|
249
247
|
Ncurses::Panel.update_panels
|
250
248
|
print_input # creates the listbox
|
251
249
|
@form.repaint
|
@@ -429,7 +427,7 @@ module RubyCurses
|
|
429
427
|
dsl_property :left_margin
|
430
428
|
# please set these in he constructor block. Settin them later will have no effect
|
431
429
|
# since i would have bound them to actions
|
432
|
-
dsl_accessor :KEY_ROW_SELECTOR #
|
430
|
+
dsl_accessor :KEY_ROW_SELECTOR # editable lists may want to use 0 or some other key
|
433
431
|
dsl_accessor :KEY_GOTO_TOP # this is going to go
|
434
432
|
dsl_accessor :KEY_GOTO_BOTTOM # this is going to go
|
435
433
|
dsl_accessor :KEY_CLEAR_SELECTION # this is going to go
|
@@ -472,7 +470,14 @@ module RubyCurses
|
|
472
470
|
install_keys
|
473
471
|
init_vars
|
474
472
|
install_list_keys
|
475
|
-
|
473
|
+
# OMG What about people whove installed custom renders such as rfe.rb 2011-10-15
|
474
|
+
#bind(:PROPERTY_CHANGE){|e| @cell_renderer = nil } # will be recreated if anything changes 2011-09-28 V1.3.1
|
475
|
+
bind(:PROPERTY_CHANGE){|e|
|
476
|
+
# I can't delete the cell renderer, but this may not have full effect if one color is passed.
|
477
|
+
if @cell_renderer.respond_to? e.property_name
|
478
|
+
@cell_renderer.send(e.property_name.to_sym, e.newvalue)
|
479
|
+
end
|
480
|
+
} # will be recreated if anything changes 2011-09-28 V1.3.1
|
476
481
|
|
477
482
|
if @list && !@list.selected_index.nil?
|
478
483
|
set_focus_on @list.selected_index # the new version
|
@@ -508,7 +513,11 @@ module RubyCurses
|
|
508
513
|
bind_key([?g,?g]){ goto_top() }
|
509
514
|
bind_key(?/){ ask_search() }
|
510
515
|
bind_key(?n){ find_more() }
|
511
|
-
bind_key(32){ toggle_row_selection() }
|
516
|
+
#bind_key(32){ toggle_row_selection() } # some guys may want another selector
|
517
|
+
if @cell_editing_allowed && @KEY_ROW_SELECTOR == 32
|
518
|
+
@KEY_ROW_SELECTOR = 0 # Ctrl-Space
|
519
|
+
end
|
520
|
+
bind_key(@KEY_ROW_SELECTOR){ toggle_row_selection() }
|
512
521
|
bind_key(10){ fire_action_event }
|
513
522
|
bind_key(13){ fire_action_event }
|
514
523
|
@keys_mapped = true
|
@@ -629,7 +638,7 @@ module RubyCurses
|
|
629
638
|
end
|
630
639
|
end
|
631
640
|
# added 2010-09-15 00:11 to make life easier
|
632
|
-
def_delegators :@list, :insert, :remove_all, :delete_at, :include?, :each, :values
|
641
|
+
def_delegators :@list, :insert, :remove_all, :delete_at, :include?, :each, :values, :size
|
633
642
|
# get element at
|
634
643
|
# @param [Fixnum] index for element
|
635
644
|
# @return [Object] element
|
@@ -684,6 +693,7 @@ module RubyCurses
|
|
684
693
|
### START FOR scrollable ###
|
685
694
|
def get_content
|
686
695
|
#@list 2008-12-01 23:13
|
696
|
+
# NOTE: we never stored the listvariable, so its redundant, we used its value to set list
|
687
697
|
@list_variable && @list_variable.value || @list
|
688
698
|
end
|
689
699
|
def get_window
|
@@ -972,7 +982,7 @@ module RubyCurses
|
|
972
982
|
tm = list()
|
973
983
|
rc = row_count
|
974
984
|
@longest_line = @width
|
975
|
-
$log.debug " rlistbox #{row_count} "
|
985
|
+
$log.debug " rlistbox repaint #{row_count} #{name} "
|
976
986
|
if rc > 0 # just added in case no data passed
|
977
987
|
tr = @toprow
|
978
988
|
acolor = get_color $datacolor # should be set once, if color or bgcolor changs TODO FIXME
|
data/lib/rbcurse/rmessagebox.rb
CHANGED
@@ -257,18 +257,14 @@ module RubyCurses
|
|
257
257
|
else
|
258
258
|
row=(@layout[:height]/3) if row.nil?
|
259
259
|
@message_col = (width-message.length)/2
|
260
|
+
@message_col = 4 if @message.is_a? Array
|
260
261
|
@message_col = 4 if @message_col < 4 # this was often disappearing 2010-10-17 13:00
|
261
262
|
#$log.debug "XX ALERT col #{@message_col} w: #{width} len: #{message.length} "
|
262
263
|
end
|
263
264
|
@message_row = row
|
264
265
|
# added 2009-11-05 14:53 to fix erasure of border
|
265
266
|
display_length -= @message_col
|
266
|
-
# FIXME : wont print if newline at end of message !!!
|
267
|
-
#@window.printstring( row, @message_col , message, color=$reversecolor)
|
268
267
|
# 2008-12-30 19:45 experimenting with label so we can get justify and wrapping.
|
269
|
-
#@window.printstring( row, @message_col , message, color=$reversecolor)
|
270
|
-
#$log.debug " print_message: row #{row}, col #{@message_col} "
|
271
|
-
#message_label = RubyCurses::Label.new @form, {'text' => message, "name"=>"message_label","row" => row, "col" => @message_col, "display_length" => display_length, "height" => @message_height, "attr"=>"reverse"}
|
272
268
|
# 2011-09-20 trying to take care of when user changes color and bgcolor while calling.
|
273
269
|
clr = @color || :black
|
274
270
|
bgclr = @bgcolor || :white
|
@@ -8,12 +8,8 @@
|
|
8
8
|
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
9
9
|
|
10
10
|
=end
|
11
|
-
#require 'rubygems'
|
12
|
-
##require 'ncurses'
|
13
|
-
#require 'logger'
|
14
11
|
require 'rbcurse'
|
15
12
|
|
16
|
-
#include Ncurses # FFI 2011-09-8
|
17
13
|
include RubyCurses
|
18
14
|
module RubyCurses
|
19
15
|
extend self
|
@@ -25,7 +21,7 @@ module RubyCurses
|
|
25
21
|
# or TextArea or even ListBox or Table someday. Should then be a Module rather than a class.
|
26
22
|
class MultiContainer < Widget
|
27
23
|
dsl_accessor :title
|
28
|
-
|
24
|
+
|
29
25
|
|
30
26
|
def initialize form = nil, config={}, &block
|
31
27
|
@focusable = true
|
@@ -57,14 +53,61 @@ module RubyCurses
|
|
57
53
|
def current_component
|
58
54
|
@bmanager.current
|
59
55
|
end
|
56
|
+
##
|
57
|
+
# Add a component with a title
|
58
|
+
# @param [Widget] component
|
59
|
+
# @param [String] title
|
60
|
+
def add component, title
|
61
|
+
component.row = @row+@row_offset+0 # FFI changed 1 to 0 2011-09-12
|
62
|
+
component.col = @col+@col_offset+0 # FFI changed 1 to 0 2011-09-12
|
63
|
+
component.width = @width-2
|
64
|
+
component.height = @height-2
|
65
|
+
component.form = @form
|
66
|
+
component.override_graphic(@graphic)
|
67
|
+
@current_buffer = @bmanager.add component, title
|
68
|
+
@current_component = @current_buffer.component
|
69
|
+
#set_current_component
|
70
|
+
#set_form_row ## FFI added 2011-09-12 to get cursor at start when adding
|
71
|
+
$log.debug "MULTICONT ADD got cb : #{@current_component} "
|
72
|
+
end
|
73
|
+
def set_current_component
|
74
|
+
@current_component = @current_buffer.component
|
75
|
+
@current_title = @current_component.title # NOTE: unused, don't knw what for
|
76
|
+
set_form_row
|
77
|
+
@current_component.repaint_all true
|
78
|
+
end
|
79
|
+
# required otherwise some components may not get correct cursor position on entry
|
80
|
+
# e.g. table
|
81
|
+
def on_enter
|
82
|
+
set_form_row
|
83
|
+
end
|
84
|
+
def set_form_row #:nodoc:
|
85
|
+
if !@current_component.nil?
|
86
|
+
cc = @current_component
|
87
|
+
|
88
|
+
@current_component.on_enter # 2011-10-19 why was this not there earlier
|
89
|
+
|
90
|
+
# 2011-10-21 I've tried removing next 2 lines but there are certain case
|
91
|
+
# that do need them. See testmulticontainer.rb
|
92
|
+
|
93
|
+
@current_component.set_form_row
|
94
|
+
@current_component.set_form_col
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
def set_form_col
|
99
|
+
# deliberately empty since Form will call this and Widgets one is unsuitable
|
100
|
+
# for us
|
101
|
+
end
|
60
102
|
##
|
61
103
|
# multi-container
|
62
104
|
def handle_key ch #:nodoc:
|
63
|
-
|
105
|
+
$log.debug " MULTI handlekey #{ch}, #{@current_component}"
|
64
106
|
ret = :UNHANDLED
|
65
107
|
return :UNHANDLED unless @current_component
|
108
|
+
|
66
109
|
ret = @current_component.handle_key(ch)
|
67
|
-
$log.debug " MULTI = comp #{@current_component} returned #{ret} "
|
110
|
+
$log.debug " MULTI = current comp #{@current_component} returned #{ret} "
|
68
111
|
if ret == :UNHANDLED
|
69
112
|
# check for bindings, these cannot override above keys since placed at end
|
70
113
|
begin
|
@@ -72,13 +115,13 @@ module RubyCurses
|
|
72
115
|
$log.debug " MULTI = process_key returned #{ret} "
|
73
116
|
if ch > 177 && ch < 187
|
74
117
|
n = ch - 177
|
118
|
+
|
75
119
|
component_at(n)
|
120
|
+
ret = 0 # other unhandled goes back
|
76
121
|
# go to component n
|
77
122
|
end
|
78
123
|
rescue => err
|
79
|
-
# $error_message = err # changed 2010 dts
|
80
124
|
$error_message.value = err.to_s
|
81
|
-
#@form.window.print_error_message PLEASE CREATE LABEL
|
82
125
|
$log.error " Multicomponent process_key #{err} "
|
83
126
|
$log.debug(err.backtrace.join("\n"))
|
84
127
|
alert err.to_s
|
@@ -91,18 +134,19 @@ module RubyCurses
|
|
91
134
|
def repaint
|
92
135
|
print_border if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes
|
93
136
|
return unless @current_component
|
94
|
-
$log.debug " MULTI REPAINT "
|
137
|
+
$log.debug " MULTI REPAINT - calling current_comps repaint #{@current_component} "
|
95
138
|
ret = @current_component.repaint
|
96
139
|
end
|
97
140
|
def print_border #:nodoc:
|
98
|
-
|
141
|
+
#$log.debug " #{@name} print_borders, #{@graphic.name} "
|
99
142
|
color = $datacolor
|
100
143
|
@graphic.print_border_only @row, @col, @height-1, @width, color #, Ncurses::A_REVERSE
|
101
144
|
print_title
|
102
145
|
end
|
103
146
|
def print_title #:nodoc:
|
104
|
-
|
105
|
-
|
147
|
+
#$log.debug " print_title #{@row}, #{@col}, #{@width} "
|
148
|
+
_title = @title || "" + @current_title
|
149
|
+
@graphic.printstring( @row, @col+(@width-_title.length)/2, _title, $datacolor, @title_attrib) unless _title.nil?
|
106
150
|
end
|
107
151
|
# this is just a test of the simple "most" menu
|
108
152
|
# can use this for next, prev, first, last, new, delete, overwrite etc
|
@@ -122,37 +166,29 @@ module RubyCurses
|
|
122
166
|
menu.display @form.window, $error_message_row, $error_message_col, $datacolor #, menu
|
123
167
|
end
|
124
168
|
|
125
|
-
#%w[next previous first last].each do |pos|
|
126
|
-
#eval(
|
127
|
-
#"def _buffer_#{pos}
|
128
|
-
#@current_component = @bmanager.#{pos}
|
129
|
-
#set_current_buffer
|
130
|
-
#end"
|
131
|
-
#)
|
132
|
-
#end
|
133
169
|
|
134
170
|
def goto_next_component
|
135
171
|
perror "No other buffer" and return if @bmanager.size < 2
|
136
172
|
|
137
|
-
@
|
173
|
+
@current_buffer = @bmanager.next
|
138
174
|
set_current_component
|
139
175
|
end
|
140
176
|
|
141
177
|
def goto_prev_component
|
142
178
|
perror "No other buffer" and return if @bmanager.size < 2
|
143
179
|
|
144
|
-
@
|
145
|
-
$log.debug " buffer_prev got #{@
|
180
|
+
@current_buffer = @bmanager.previous
|
181
|
+
$log.debug " buffer_prev got #{@current_buffer} "
|
146
182
|
set_current_component
|
147
183
|
end
|
148
184
|
def goto_first_component
|
149
|
-
@
|
150
|
-
$log.debug " buffer_first got #{@
|
185
|
+
@current_buffer = @bmanager.first
|
186
|
+
$log.debug " buffer_first got #{@current_buffer} "
|
151
187
|
set_current_component
|
152
188
|
end
|
153
189
|
def goto_last_component
|
154
|
-
@
|
155
|
-
$log.debug " buffer_last got #{@
|
190
|
+
@current_buffer = @bmanager.last
|
191
|
+
$log.debug " buffer_last got #{@current_buffer} "
|
156
192
|
set_current_component
|
157
193
|
end
|
158
194
|
def delete_component
|
@@ -172,27 +208,6 @@ module RubyCurses
|
|
172
208
|
#$log.debug " buffer_last got #{@current_component} "
|
173
209
|
set_current_component
|
174
210
|
end
|
175
|
-
##
|
176
|
-
# Add a component with a title
|
177
|
-
# @param [Widget] component
|
178
|
-
# @param [String] title
|
179
|
-
def add component, title
|
180
|
-
component.row = @row+@row_offset+0 # FFI changed 1 to 0 2011-09-12
|
181
|
-
component.col = @col+@col_offset+0 # FFI changed 1 to 0 2011-09-12
|
182
|
-
component.width = @width-2
|
183
|
-
component.height = @height-2
|
184
|
-
component.form = @form
|
185
|
-
component.override_graphic(@graphic)
|
186
|
-
@current_component = @bmanager.add component, title
|
187
|
-
set_current_component
|
188
|
-
set_form_row ## FFI added 2011-09-12 to get cursor at start when adding
|
189
|
-
$log.debug " ADD got cb : #{@current_component} "
|
190
|
-
end
|
191
|
-
def set_current_component
|
192
|
-
@current_component = @current_component.component
|
193
|
-
@current_title = @current_component.title
|
194
|
-
@current_component.repaint_all true
|
195
|
-
end
|
196
211
|
def perror errmess
|
197
212
|
alert errmess
|
198
213
|
#@form.window.print_error_message errmess
|
@@ -208,18 +223,6 @@ module RubyCurses
|
|
208
223
|
}
|
209
224
|
menu.display @form.window, $error_message_row, $error_message_col, $datacolor
|
210
225
|
end
|
211
|
-
# required otherwise some components may not get correct cursor position on entry
|
212
|
-
# e.g. table
|
213
|
-
def on_enter
|
214
|
-
set_form_row
|
215
|
-
end
|
216
|
-
def set_form_row #:nodoc:
|
217
|
-
if !@current_component.nil?
|
218
|
-
#$log.debug " #{@name} set_form_row calling sfr for #{@current_component.name} "
|
219
|
-
@current_component.set_form_row
|
220
|
-
@current_component.set_form_col
|
221
|
-
end
|
222
|
-
end
|
223
226
|
end # class multicontainer
|
224
227
|
##
|
225
228
|
# Handles multiple buffers, navigation, maintenance etc
|
data/lib/rbcurse/rpopupmenu.rb
CHANGED
@@ -24,8 +24,6 @@ a user friendly string to identifiy the action, as well as a disabled option.
|
|
24
24
|
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
25
25
|
|
26
26
|
=end
|
27
|
-
require 'rubygems'
|
28
|
-
#require 'ncurses'
|
29
27
|
require 'logger'
|
30
28
|
require 'rbcurse'
|
31
29
|
require 'rbcurse/action'
|
data/lib/rbcurse/rscrollform.rb
CHANGED
@@ -18,8 +18,6 @@ area but finish outside, or vice versa.
|
|
18
18
|
|
19
19
|
What if we wish some static text to be displayed at top or bottom of ScrollForm
|
20
20
|
=end
|
21
|
-
require 'rubygems'
|
22
|
-
#require 'ncurses'
|
23
21
|
require 'logger'
|
24
22
|
require 'rbcurse'
|
25
23
|
|
@@ -32,8 +30,8 @@ module RubyCurses
|
|
32
30
|
attr_accessor :pmincol # advance / scroll columns
|
33
31
|
# the pad prints from this row to window, usually 0
|
34
32
|
attr_accessor :pminrow # advance / scroll rows (vertically)
|
35
|
-
attr_accessor :display_w # width of screen display
|
36
|
-
attr_accessor :display_h # ht of screen display
|
33
|
+
#attr_accessor :display_w # width of screen display NOW METHODS
|
34
|
+
#attr_accessor :display_h # ht of screen display
|
37
35
|
attr_accessor :row_offset, :col_offset
|
38
36
|
attr_accessor :scroll_unit # by how much should be scroll
|
39
37
|
attr_reader :orig_top, :orig_left
|
@@ -52,12 +50,23 @@ module RubyCurses
|
|
52
50
|
# take display dimensions from window. It is safe to override immediately after form creation
|
53
51
|
@display_h = win.height
|
54
52
|
@display_w = win.width
|
55
|
-
|
56
|
-
|
53
|
+
if @display_h == 0
|
54
|
+
@display_h = (Ncurses.LINES - win.top - 2)
|
55
|
+
else
|
56
|
+
@display_h = win.height - 2
|
57
|
+
end
|
58
|
+
if @display_w == 0
|
59
|
+
@display_w = (Ncurses.COLS - win.left - 2)
|
60
|
+
else
|
61
|
+
# copywin fails unless u use rootwindow, so what gives in this case
|
62
|
+
@display_w = win.width - 2
|
63
|
+
end
|
57
64
|
|
58
65
|
init_vars
|
59
66
|
end
|
60
67
|
def init_vars
|
68
|
+
# maybe we should use C-x combinations rather than these keys which might be used
|
69
|
+
# by other widgets, apps
|
61
70
|
bind_key(?\M-h, :scroll_left)
|
62
71
|
bind_key(?\M-l, :scroll_right)
|
63
72
|
bind_key(?\M-n, :scroll_down)
|
@@ -81,14 +90,51 @@ module RubyCurses
|
|
81
90
|
@left = @orig_left = l
|
82
91
|
create_pad
|
83
92
|
end
|
93
|
+
# old program tabbed pane uses this. fix
|
94
|
+
# @deprecated use set_pad_dimensions
|
95
|
+
def set_layout h,w,t,l
|
96
|
+
set_pad_dimensions t,l,h,w
|
97
|
+
end
|
98
|
+
def display_h(*val)
|
99
|
+
if val.empty?
|
100
|
+
return @display_h
|
101
|
+
else
|
102
|
+
#raise ArgumentError "display_h should be ... " if val[0] ...
|
103
|
+
oldvalue = @display_h
|
104
|
+
@display_h = val[0]
|
105
|
+
$log.debug "XXX:given display_h to #{@display_h} "
|
106
|
+
@display_h = [@display_h, @target_window.height - 2].min unless @target_window.height == 0
|
107
|
+
$log.debug "XXX:set display_h to #{@display_h} "
|
108
|
+
#fire_property_handler(:display_h, oldvalue, @display_h)
|
109
|
+
end
|
110
|
+
self
|
111
|
+
end
|
112
|
+
#
|
113
|
+
# By default we are determining these 2 values based on window's dims.
|
114
|
+
# However, if you use a widget that is smaller than the window, then
|
115
|
+
# you will want to overwrite these values.
|
116
|
+
def display_w(*val)
|
117
|
+
if val.empty?
|
118
|
+
return @display_w
|
119
|
+
else
|
120
|
+
#raise ArgumentError "display_h should be ... " if val[0] ...
|
121
|
+
oldvalue = @display_w
|
122
|
+
@display_w = val[0]
|
123
|
+
@display_w = [@display_w, @target_window.width - 2].min unless @target_window.width == 0
|
124
|
+
$log.debug "XXX:set display_w to #{@display_w} "
|
125
|
+
#fire_property_handler(:display_h, oldvalue, @display_h)
|
126
|
+
end
|
127
|
+
self
|
128
|
+
end
|
84
129
|
##
|
85
130
|
# create a pad to work on.
|
86
131
|
# XXX We reuse window, which is already the main window
|
87
132
|
# So if we try creating pad later, then old external window is used.
|
88
133
|
# However, many methods in superclass operate on window so we needed to overwrite. What do i do ?
|
89
|
-
private
|
134
|
+
#private
|
90
135
|
def create_pad
|
91
|
-
raise "Pad already created" if @pad
|
136
|
+
#raise "Pad already created" if @pad
|
137
|
+
return @pad if @pad
|
92
138
|
r = @top
|
93
139
|
c = @left
|
94
140
|
layout = { :height => @pad_h, :width => @pad_w, :top => r, :left => c }
|
@@ -171,12 +217,14 @@ module RubyCurses
|
|
171
217
|
# super may need target window
|
172
218
|
def repaint
|
173
219
|
print_border if @repaint_all and @print_border_flag
|
174
|
-
print_footer
|
220
|
+
print_footer if @print_border_flag
|
175
221
|
$log.debug " scrollForm repaint calling parent #{@row} #{@col}+ #{@cols_panned} #{@col_offset} "
|
176
222
|
super
|
177
223
|
prefresh
|
178
|
-
|
179
|
-
|
224
|
+
if @print_border_flag
|
225
|
+
_print_more_data_marker true
|
226
|
+
_print_more_columns_marker true
|
227
|
+
end
|
180
228
|
#$log.debug " @target_window.wmove #{@row+@rows_panned+@row_offset}, #{@col+@cols_panned+@col_offset} "
|
181
229
|
@target_window.wmove @row+@rows_panned+@row_offset, @col+@cols_panned+@col_offset
|
182
230
|
@window.modified = false
|
@@ -215,6 +263,7 @@ module RubyCurses
|
|
215
263
|
# this works but if want to avoid copying border
|
216
264
|
#ret = @window.prefresh(@pminrow, @pmincol, @top+@row_offset, @left+@col_offset, @top + @display_h - @row_offset , @left + @display_w - @col_offset)
|
217
265
|
#
|
266
|
+
$log.debug "ret = @window.copywin( #{@pminrow} , #{@pmincol} , #{@top+@row_offset} , #{@left+@col_offset} , #{@top} + #{@display_h} - #{@row_offset} , #{@left} + #{@display_w} - #{@col_offset} , 0)"
|
218
267
|
## Haha , we are back to the old notorious copywin which has given mankind
|
219
268
|
# so much grief that it should be removed in the next round of creation.
|
220
269
|
ret = @window.copywin(@target_window.get_window, @pminrow, @pmincol, @top+@row_offset, @left+@col_offset,
|
@@ -291,7 +340,7 @@ module RubyCurses
|
|
291
340
|
return false if c+@cols_panned > @orig_left + @display_w
|
292
341
|
# XXX TODO for rows UNTESTED for rows
|
293
342
|
return false if r + @rows_panned < @orig_top
|
294
|
-
return false if r + @rows_panned > @orig_top + @display_h
|
343
|
+
return false if r + @rows_panned > @orig_top + @display_h - 2
|
295
344
|
|
296
345
|
return true
|
297
346
|
end
|