rbcurse 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +20 -0
- data/NOTES +45 -0
- data/README.markdown +47 -68
- data/TODO2.txt +29 -32
- data/VERSION +1 -1
- data/examples/abasiclist.rb +2 -0
- data/examples/app.rb +2 -2
- data/examples/app.sample +10 -0
- data/examples/appemail.rb +29 -2
- data/examples/appemaillb.rb +1 -1
- data/examples/appgcompose.rb +9 -2
- data/examples/appmethods.rb +69 -0
- data/examples/atree.rb +2 -2
- data/examples/menu1.rb +1 -1
- data/examples/newtesttabp.rb +8 -5
- data/examples/qdfilechooser.rb +6 -3
- data/examples/rfe.rb +71 -16
- data/examples/rmail.rb +76 -7
- data/examples/sqlc.rb +14 -3
- data/examples/sqlm.rb +3 -3
- data/examples/term.rb +48 -0
- data/examples/term2.rb +48 -21
- data/examples/test1.rb +2 -2
- data/examples/test2.rb +162 -71
- data/examples/testapp.rb +2 -2
- data/examples/testapp2.rb +1 -1
- data/examples/testchars.rb +47 -46
- data/examples/testcombo.rb +2 -2
- data/examples/testkeypress.rb +2 -2
- data/examples/testlistbox.rb +2 -2
- data/examples/testmenu.rb +1 -1
- data/examples/testmulticomp.rb +1 -1
- data/examples/testmultispl.rb +1 -1
- data/examples/testree.rb +1 -22
- data/examples/testscroller.rb +2 -2
- data/examples/testscrolllb.rb +2 -2
- data/examples/testscrollp.rb +2 -2
- data/examples/testscrollta.rb +2 -2
- data/examples/testscrolltable.rb +2 -2
- data/examples/testsplit.rb +2 -2
- data/examples/testsplit2.rb +2 -2
- data/examples/testsplit3.rb +2 -2
- data/examples/testsplit3_1.rb +2 -2
- data/examples/testsplit3a.rb +2 -2
- data/examples/testsplit3b.rb +2 -2
- data/examples/testsplitta.rb +2 -2
- data/examples/testsplittv.rb +2 -2
- data/examples/testsplittvv.rb +2 -2
- data/examples/testtable.rb +2 -2
- data/examples/testtabp.rb +2 -2
- data/examples/testtodo.rb +1 -1
- data/examples/testtpane.rb +2 -2
- data/examples/testtpane2.rb +2 -2
- data/examples/testtpanetable.rb +6 -5
- data/examples/testvimsplit.rb +2 -2
- data/examples/viewtodo.rb +1 -1
- data/lib/rbcurse.rb +2 -1
- data/lib/rbcurse/action.rb +1 -1
- data/lib/rbcurse/app.rb +51 -14
- data/lib/rbcurse/applicationheader.rb +1 -1
- data/lib/rbcurse/celleditor.rb +1 -1
- data/lib/rbcurse/colormap.rb +11 -11
- data/lib/rbcurse/comboboxcellrenderer.rb +1 -1
- data/lib/rbcurse/extras/bottomline.rb +22 -10
- data/lib/rbcurse/extras/directorylist.rb +14 -1
- data/lib/rbcurse/extras/divider.rb +1 -1
- data/lib/rbcurse/extras/listselectable.rb +2 -2
- data/lib/rbcurse/extras/masterdetail.rb +3 -1
- data/lib/rbcurse/extras/scrollbar.rb +1 -1
- data/lib/rbcurse/extras/stdscrwindow.rb +75 -24
- data/lib/rbcurse/extras/tabular.rb +8 -3
- data/lib/rbcurse/extras/viewer.rb +18 -2
- data/lib/rbcurse/io.rb +26 -13
- data/lib/rbcurse/keylabelprinter.rb +3 -2
- data/lib/rbcurse/listcellrenderer.rb +1 -0
- data/lib/rbcurse/listkeys.rb +3 -2
- data/lib/rbcurse/listselectable.rb +4 -3
- data/lib/rbcurse/rbasiclistbox.rb +12 -5
- data/lib/rbcurse/rcombo.rb +2 -2
- data/lib/rbcurse/rcommandwindow.rb +5 -3
- data/lib/rbcurse/rdialogs.rb +8 -2
- data/lib/rbcurse/rlistbox.rb +10 -2
- data/lib/rbcurse/rmenu.rb +4 -4
- data/lib/rbcurse/rmessagebox.rb +10 -5
- data/lib/rbcurse/rmulticontainer.rb +21 -8
- data/lib/rbcurse/rmultisplit.rb +2 -2
- data/lib/rbcurse/rmultitextview.rb +5 -3
- data/lib/rbcurse/rpopupmenu.rb +3 -3
- data/lib/rbcurse/rprogress.rb +3 -2
- data/lib/rbcurse/rscrollform.rb +2 -2
- data/lib/rbcurse/rscrollpane.rb +9 -9
- data/lib/rbcurse/rsplitpane.rb +2 -2
- data/lib/rbcurse/rsplitpane2.rb +2 -2
- data/lib/rbcurse/rtabbedpane.rb +48 -12
- data/lib/rbcurse/rtabbedwindow.rb +4 -4
- data/lib/rbcurse/rtable.rb +6 -3
- data/lib/rbcurse/rtextarea.rb +8 -8
- data/lib/rbcurse/rtextview.rb +3 -2
- data/lib/rbcurse/rtree.rb +2 -2
- data/lib/rbcurse/rviewport.rb +2 -2
- data/lib/rbcurse/rvimsplit.rb +3 -2
- data/lib/rbcurse/rwidget.rb +63 -26
- data/lib/rbcurse/scrollable.rb +1 -1
- data/lib/rbcurse/table/tablecellrenderer.rb +1 -1
- data/lib/rbcurse/table/tabledatecellrenderer.rb +1 -1
- data/lib/rbcurse/tree/treemodel.rb +1 -1
- data/lib/rbcurse/vieditable.rb +1 -0
- data/lib/ver/ncurses.rb +122 -4
- data/lib/ver/panel.rb +162 -0
- data/lib/ver/window.rb +262 -120
- metadata +19 -7
- data/examples/keytest.rb +0 -178
- data/examples/mpad2.rb +0 -156
@@ -70,11 +70,12 @@ module RubyCurses
|
|
70
70
|
# set columns names
|
71
71
|
# @param [Array<String>] column names, preferably padded out to width for column
|
72
72
|
def columns=(array)
|
73
|
+
$log.debug "tabular got columns #{array.count} #{array.inspect} " if $log
|
73
74
|
@columns = array
|
74
75
|
@columns.each_with_index { |c,i|
|
75
76
|
@chash[i] = ColumnInfo.new(c, c.to_s.length)
|
76
77
|
@cw[i] ||= c.to_s.length
|
77
|
-
|
78
|
+
#@calign[i] ||= :left # 2011-09-27 prevent setting later on
|
78
79
|
}
|
79
80
|
end
|
80
81
|
alias :headings= :columns=
|
@@ -82,14 +83,15 @@ module RubyCurses
|
|
82
83
|
# set data as an array of arrays
|
83
84
|
# @param [Array<Array>] data as array of arrays
|
84
85
|
def data=(list)
|
85
|
-
puts "got data: #{list.size} "
|
86
|
-
puts list
|
86
|
+
puts "got data: #{list.size} " if !$log
|
87
|
+
puts list if !$log
|
87
88
|
@list = list
|
88
89
|
end
|
89
90
|
|
90
91
|
# add a row of data
|
91
92
|
# @param [Array] an array containing entries for each column
|
92
93
|
def add array
|
94
|
+
$log.debug "tabular got add #{array.count} #{array.inspect} " if $log
|
93
95
|
@list ||= []
|
94
96
|
@list << array
|
95
97
|
end
|
@@ -210,12 +212,14 @@ module RubyCurses
|
|
210
212
|
end
|
211
213
|
}
|
212
214
|
@fmstr = fmt.join(@y)
|
215
|
+
puts "format: #{@fmstr} "
|
213
216
|
end
|
214
217
|
end
|
215
218
|
end
|
216
219
|
|
217
220
|
if __FILE__ == $PROGRAM_NAME
|
218
221
|
include RubyCurses
|
222
|
+
$log = nil
|
219
223
|
t = Tabular.new(['a', 'b'], [1, 2], [3, 4])
|
220
224
|
puts t.to_s
|
221
225
|
puts
|
@@ -223,6 +227,7 @@ if __FILE__ == $PROGRAM_NAME
|
|
223
227
|
t.add %w{ rahul 32 r@ruby.org }
|
224
228
|
t << %w{ _why 133 j@gnu.org }
|
225
229
|
t << %w{ Jane 1331 jane@gnu.org }
|
230
|
+
t.column_width 1, 10
|
226
231
|
t.align_column 1, :right
|
227
232
|
puts t.to_s
|
228
233
|
puts
|
@@ -3,6 +3,7 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
# NOTE: experimental, not yet firmed up
|
5
5
|
# If you use in application, please copy to some application folder in case i change this.
|
6
|
+
# Can be used for print_help_page
|
6
7
|
# TODO: add vi_keys here
|
7
8
|
# SUGGESTIONS WELCOME.
|
8
9
|
# @since 1.2.0
|
@@ -11,6 +12,8 @@ module RubyCurses
|
|
11
12
|
# view filename, :close_key => KEY_RETURN
|
12
13
|
# send data in an array
|
13
14
|
# view Array, :close_key => KEY_RETURN, :layout => [0,0,23,80]
|
15
|
+
# when passing layout reserve 4 rows for window and border. So for 2 lines of text
|
16
|
+
# give 6 rows.
|
14
17
|
class Viewer
|
15
18
|
# @param filename as string or content as array
|
16
19
|
# @yield textview object for further configuration before display
|
@@ -44,14 +47,27 @@ module RubyCurses
|
|
44
47
|
row 0
|
45
48
|
col 0
|
46
49
|
width ww
|
47
|
-
height wh-2
|
50
|
+
height wh-0 # earlier 2 but seems to be leaving space.
|
48
51
|
title fp
|
49
52
|
title_attrib ta
|
50
53
|
print_footer pf
|
51
54
|
footer_attrib fa
|
52
55
|
end
|
53
56
|
textview.set_content content #, :WRAP_WORD
|
54
|
-
|
57
|
+
|
58
|
+
t = textview
|
59
|
+
t.bind_key('<'){ f = t.form.window; c = f.left - 1; f.hide; f.mvwin(f.top, c); f.show;
|
60
|
+
f.reset_layout([f.height, f.width, f.top, c]);
|
61
|
+
}
|
62
|
+
t.bind_key('>'){ f = t.form.window; c = f.left + 1; f.hide; f.mvwin(f.top, c);
|
63
|
+
f.reset_layout([f.height, f.width, f.top, c]); f.show;
|
64
|
+
}
|
65
|
+
t.bind_key('^'){ f = t.form.window; c = f.top - 1 ; f.hide; f.mvwin(c, f.left);
|
66
|
+
f.reset_layout([f.height, f.width, c, f.left]) ; f.show;
|
67
|
+
}
|
68
|
+
t.bind_key('V'){ f = t.form.window; c = f.top + 1 ; f.hide; f.mvwin(c, f.left);
|
69
|
+
f.reset_layout([f.height, f.width, c, f.left]); f.show;
|
70
|
+
}
|
55
71
|
# yielding textview so you may further configure or bind keys or events
|
56
72
|
yield textview if block_given? # tentative
|
57
73
|
v_form.repaint
|
data/lib/rbcurse/io.rb
CHANGED
@@ -40,8 +40,8 @@ module Io
|
|
40
40
|
#def rbgetstr(win, r, c, prompt, maxlen, default, labels, validints=[], helptext="")
|
41
41
|
def rbgetstr(win, r, c, prompt, maxlen, config={})
|
42
42
|
#win ||= @target_window
|
43
|
-
$log.debug " inside rbgetstr #{win} r:#{r} c:#{c} p:#{prompt} m:#{maxlen} "
|
44
43
|
raise "rbgetstr got no window. io.rb" if win.nil?
|
44
|
+
$log.debug " inside io.rb rbgetstr #{win} r:#{r} c:#{c} p:#{prompt} m:#{maxlen} #{win.name} "
|
45
45
|
ins_mode = false
|
46
46
|
default = config[:default] || ""
|
47
47
|
prompt = "#{prompt} [#{default}]: " unless default
|
@@ -56,7 +56,7 @@ module Io
|
|
56
56
|
#x mylabels=["^G~Help ", "^C~Cancel"]
|
57
57
|
#x mylabels += labels if !labels.nil?
|
58
58
|
begin
|
59
|
-
Ncurses.
|
59
|
+
Ncurses.noecho(); # FFI RK 2011-09-11 seems this was causing issue of writing on top
|
60
60
|
#x print_key_labels( 0, 0, mylabels)
|
61
61
|
#curpos = 0
|
62
62
|
curpos = str.length
|
@@ -66,7 +66,7 @@ module Io
|
|
66
66
|
while true
|
67
67
|
#ch=win.mvwgetch(r, len) # get to right of prompt - WHY NOT WORKING ???
|
68
68
|
ch=win.getchar()
|
69
|
-
$log.debug " rbgetstr got ch:#{ch}, str:#{str}
|
69
|
+
$log.debug "io.rb rbgetstr got ch:#{ch}, #{win} , str:#{str}, len: #{len} "
|
70
70
|
case ch
|
71
71
|
when 3 # -1 # C-c
|
72
72
|
return -1, nil
|
@@ -74,7 +74,8 @@ module Io
|
|
74
74
|
return -1, nil
|
75
75
|
when 10, 13 # hits ENTER
|
76
76
|
break
|
77
|
-
when ?\C-h.getbyte(0), ?\C-?.getbyte(0), KEY_BSPACE # delete previous character/backspace
|
77
|
+
when ?\C-h.getbyte(0), ?\C-?.getbyte(0), KEY_BSPACE, 263 # delete previous character/backspace
|
78
|
+
# currently hitting C-h is giving 263 instead of 8
|
78
79
|
len -= 1 if len > prompt.length
|
79
80
|
curpos -= 1 if curpos > 0
|
80
81
|
str.slice!(curpos)
|
@@ -94,14 +95,31 @@ module Io
|
|
94
95
|
curpos -= 1 if curpos > 0
|
95
96
|
len -= 1 if len > prompt.length
|
96
97
|
win.wmove r, c+len # since getchar is not going back on del and bs
|
98
|
+
win.wrefresh # FFI 2011-09-19 otherwise not showing
|
97
99
|
next
|
98
100
|
when KEY_RIGHT
|
99
101
|
if curpos < str.length
|
100
102
|
curpos += 1 #if curpos < str.length
|
101
103
|
len += 1
|
102
104
|
win.wmove r, c+len # since getchar is not going back on del and bs
|
105
|
+
win.wrefresh # FFI 2011-09-19 otherwise not showing
|
103
106
|
end
|
104
107
|
next
|
108
|
+
when ?\C-a.getbyte(0)
|
109
|
+
#olen = str.length
|
110
|
+
#clear_this win, r, c, color, len+maxlen+1
|
111
|
+
#clear_line len+maxlen+1, @prompt_length
|
112
|
+
len -= curpos
|
113
|
+
curpos = 0
|
114
|
+
win.move r, c+len # since getchar is not going back on del and bs
|
115
|
+
win.wrefresh # FFI 2011-09-19 otherwise not showing
|
116
|
+
when ?\C-e.getbyte(0)
|
117
|
+
olen = str.length
|
118
|
+
len += (olen - curpos)
|
119
|
+
curpos = olen
|
120
|
+
#clear_line len+maxlen+1, @prompt_length
|
121
|
+
win.move r, c+len # since getchar is not going back on del and bs
|
122
|
+
win.wrefresh # FFI 2011-09-19 otherwise not showing
|
105
123
|
when ?\M-i.getbyte(0)
|
106
124
|
ins_mode = !ins_mode
|
107
125
|
next
|
@@ -147,6 +165,7 @@ module Io
|
|
147
165
|
end
|
148
166
|
print_this(win, prompt+str, color, r, c)
|
149
167
|
win.wmove r, c+len # more for arrow keys, curpos may not be end
|
168
|
+
win.wrefresh
|
150
169
|
prevchar = ch
|
151
170
|
end
|
152
171
|
str = default if str == ""
|
@@ -509,16 +528,10 @@ module Io
|
|
509
528
|
sleep(5)
|
510
529
|
end
|
511
530
|
def print_help_page(filename = "TODO")
|
512
|
-
#require '
|
513
|
-
#tp =
|
514
|
-
#tp.run
|
515
|
-
require 'panelreader'
|
516
|
-
tp = PanelReader.new()
|
517
|
-
tp.view_file(filename)
|
518
|
-
|
519
|
-
#require 'padreader'
|
520
|
-
#tp = PadReader.new()
|
531
|
+
#require 'panelreader' obsolete used FORN and fiELD
|
532
|
+
#tp = PanelReader.new()
|
521
533
|
#tp.view_file(filename)
|
534
|
+
|
522
535
|
end
|
523
536
|
#def newaskyesno(win, askstr, default = "N", helptext="Helptext for this question")
|
524
537
|
##
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rbcurse/rwidget'
|
2
|
-
include Ncurses
|
2
|
+
#include Ncurses # FFI 2011-09-8
|
3
3
|
include RubyCurses
|
4
4
|
module RubyCurses
|
5
5
|
class KeyLabelPrinter < Widget
|
@@ -80,7 +80,8 @@ module RubyCurses
|
|
80
80
|
print_key_labels_row(posy, posx, even)
|
81
81
|
posy = @row+1
|
82
82
|
print_key_labels_row(posy, posx, odd)
|
83
|
-
|
83
|
+
# uncommented next line after ffi-ncurses else not showing till key press FFI 2011-09-17
|
84
|
+
@win.wrefresh # needed else secod row not shown after askchoice XXX
|
84
85
|
end
|
85
86
|
def print_key_labels_row(posy, posx, arr)
|
86
87
|
# FIXME: this logic of padding needs to take into account
|
@@ -107,6 +107,7 @@ module RubyCurses
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
len = @display_length || value.length
|
110
|
+
#$log.debug " XXX @display_length: #{@display_length}, #{value.length}, L:#{len}, pw:#{@parent.width} ::attr:: #{@attr} "
|
110
111
|
graphic.printstring r, c, @format % [len, value], @color_pair, @attr
|
111
112
|
end # repaint
|
112
113
|
|
data/lib/rbcurse/listkeys.rb
CHANGED
@@ -4,8 +4,9 @@ module RubyCurses
|
|
4
4
|
# That was possible earlier, but now that i am binding the key at construction time
|
5
5
|
# any changes to the vars after construction won't have an effect.
|
6
6
|
def install_list_keys
|
7
|
-
@KEY_ROW_SELECTOR ||= ?\C-x.getbyte(0)
|
8
|
-
@
|
7
|
+
# @KEY_ROW_SELECTOR ||= ?\C-x.getbyte(0) # need to changed from C-x since used for actions # changed 2011 dts
|
8
|
+
@KEY_ROW_SELECTOR ||= 0 # need to changed from C-x since used for actions
|
9
|
+
@KEY_BLOCK_SELECTOR ||= ?\M-x.getbyte(0) # need to change since M-x used for commands
|
9
10
|
@KEY_GOTO_TOP ||= ?\M-0.getbyte(0)
|
10
11
|
@KEY_GOTO_BOTTOM ||= ?\M-9.getbyte(0)
|
11
12
|
#@KEY_ASK_FIND_FORWARD ||= ?\M-f.getbyte(0)
|
@@ -27,7 +27,7 @@ module RubyCurses
|
|
27
27
|
alias :is_row_selected :is_selected?
|
28
28
|
|
29
29
|
def add_row_selection_interval ix0, ix1
|
30
|
-
$log.debug " def add_row_selection_interval #{ix0}, ix1"
|
30
|
+
$log.debug " def add_row_selection_interval #{ix0}, #{ix1}"
|
31
31
|
# if row_selection_allowed
|
32
32
|
@list_selection_model.add_selection_interval ix0, ix1
|
33
33
|
@repaint_required = true
|
@@ -51,9 +51,10 @@ module RubyCurses
|
|
51
51
|
@repaint_required = true
|
52
52
|
end
|
53
53
|
# why is this commented off XXX could it override listscrollable
|
54
|
-
def selected_item
|
54
|
+
#def selected_item
|
55
|
+
#$log.warn "came in dummy selected_item of listselectable.rb"
|
55
56
|
# @list[@current_index]
|
56
|
-
end
|
57
|
+
#end
|
57
58
|
# returns selected indices
|
58
59
|
# TODO : if array passed, set those as selected indices
|
59
60
|
def selected_rows
|
@@ -16,7 +16,7 @@ require 'rbcurse/listcellrenderer'
|
|
16
16
|
require 'forwardable'
|
17
17
|
|
18
18
|
|
19
|
-
include Ncurses
|
19
|
+
#include Ncurses # FFI 2011-09-8
|
20
20
|
module RubyCurses
|
21
21
|
extend self
|
22
22
|
##
|
@@ -281,7 +281,7 @@ module RubyCurses
|
|
281
281
|
@repaint_required = true
|
282
282
|
when 27, ?\C-c.getbyte(0)
|
283
283
|
#editing_canceled @current_index if @cell_editing_allowed
|
284
|
-
#cancel_block # block
|
284
|
+
#cancel_block # block NW XXX don't think its required. 2011-09-9 FFI
|
285
285
|
$multiplier = 0
|
286
286
|
when @KEY_ASK_FIND_FORWARD
|
287
287
|
# ask_search_forward
|
@@ -414,15 +414,17 @@ module RubyCurses
|
|
414
414
|
@win_left = my_win.left
|
415
415
|
@win_top = my_win.top
|
416
416
|
@left_margin ||= @row_selected_symbol.length
|
417
|
+
# we are making sure display len does not exceed width XXX hope this does not wreak havoc elsewhere
|
418
|
+
_dl = [@display_length || 100, @width-2].min # 2011-09-17 RK overwriting when we move grabbar in vimsplit
|
417
419
|
|
418
420
|
$log.debug "basicrlistbox repaint #{@name} graphic #{@graphic}"
|
419
421
|
#$log.debug "XXX repaint to_print #{@to_print_borders} "
|
420
422
|
print_borders unless @suppress_borders # do this once only, unless everything changes
|
421
|
-
#maxlen = @maxlen
|
423
|
+
#maxlen = @maxlen || @width-2
|
422
424
|
tm = list()
|
423
425
|
rc = row_count
|
424
426
|
@longest_line = @width
|
425
|
-
$log.debug "
|
427
|
+
$log.debug " rbasiclistbox #{row_count}, w:#{@width} , maxlen:#{@maxlen} "
|
426
428
|
if rc > 0 # just added in case no data passed
|
427
429
|
tr = @toprow
|
428
430
|
acolor = get_color $datacolor
|
@@ -455,6 +457,7 @@ module RubyCurses
|
|
455
457
|
end
|
456
458
|
#renderer = get_default_cell_renderer_for_class content.class.to_s
|
457
459
|
renderer = cell_renderer()
|
460
|
+
renderer.display_length = _dl # 2011-09-17 RK overwriting when we move grabbar in vimsplit
|
458
461
|
renderer.repaint @graphic, r+hh, c+@left_margin, crow, content, focus_type, selected
|
459
462
|
else
|
460
463
|
# clear rows
|
@@ -495,7 +498,11 @@ module RubyCurses
|
|
495
498
|
# returns only the visible portion of string taking into account display length
|
496
499
|
# and horizontal scrolling. MODIFIES STRING
|
497
500
|
def truncate content # :nodoc:
|
498
|
-
maxlen = @maxlen
|
501
|
+
maxlen = @maxlen || @width-2
|
502
|
+
if maxlen == 0 # (otherwise it becoems -1 below)
|
503
|
+
content.replace ""
|
504
|
+
return
|
505
|
+
end
|
499
506
|
if !content.nil?
|
500
507
|
if content.length > maxlen # only show maxlen
|
501
508
|
@longest_line = content.length if content.length > @longest_line
|
data/lib/rbcurse/rcombo.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
require 'rbcurse'
|
13
13
|
require 'rbcurse/rlistbox'
|
14
14
|
|
15
|
-
include Ncurses
|
15
|
+
#include Ncurses # FFI 2011-09-8
|
16
16
|
include RubyCurses
|
17
17
|
module RubyCurses
|
18
18
|
META_KEY = 128
|
@@ -44,7 +44,7 @@ module RubyCurses
|
|
44
44
|
def init_vars
|
45
45
|
super
|
46
46
|
@show_symbol ||= true
|
47
|
-
@COMBO_SYMBOL ||=
|
47
|
+
@COMBO_SYMBOL ||= FFI::NCurses::ACS_DARROW #GEQUAL
|
48
48
|
bind_key(KEY_UP) { previous_row }
|
49
49
|
bind_key(KEY_DOWN) { next_row }
|
50
50
|
end
|
@@ -157,7 +157,7 @@ module RubyCurses
|
|
157
157
|
if @window
|
158
158
|
begin
|
159
159
|
panel = @window.panel
|
160
|
-
Ncurses::Panel.del_panel(panel) if panel
|
160
|
+
Ncurses::Panel.del_panel(panel.pointer) if panel
|
161
161
|
@window.delwin
|
162
162
|
rescue => exc
|
163
163
|
end
|
@@ -248,8 +248,8 @@ module RubyCurses
|
|
248
248
|
@to = ListObject.new self, text, config
|
249
249
|
end
|
250
250
|
yield @to if block_given?
|
251
|
-
@to.display_interactive
|
252
|
-
@to
|
251
|
+
@to.display_interactive # this returns the item selected
|
252
|
+
@to # this will return the ListObject to the user with list and current_index
|
253
253
|
end
|
254
254
|
# non interactive list display - EACH CALL IS CREATING A LIST OBJECT
|
255
255
|
def udisplay_list text, config={}
|
@@ -312,6 +312,7 @@ module RubyCurses
|
|
312
312
|
def display_interactive
|
313
313
|
display_content
|
314
314
|
while !@stop
|
315
|
+
@window.wrefresh # FFI 2011-09-12
|
315
316
|
# FIXME only clear and redisplay if change has happened (repaint_require)
|
316
317
|
handle_keys { |ch| @cw.clear; display_content }
|
317
318
|
end
|
@@ -524,6 +525,7 @@ module RubyCurses
|
|
524
525
|
|
525
526
|
#setrowcol row, nil
|
526
527
|
@window.wmove row, c
|
528
|
+
@window.wrefresh # FFI added to keep cursor display in synch with selection
|
527
529
|
end
|
528
530
|
def OLDbounds_check
|
529
531
|
@start = 0 if @start < 0
|
data/lib/rbcurse/rdialogs.rb
CHANGED
@@ -13,7 +13,7 @@ TODO:
|
|
13
13
|
Add select_one (message, values, default)
|
14
14
|
=end
|
15
15
|
require 'rubygems'
|
16
|
-
require 'ncurses'
|
16
|
+
##require 'ncurses'
|
17
17
|
require 'logger'
|
18
18
|
require 'rbcurse/rwidget'
|
19
19
|
require 'rbcurse/rmessagebox'
|
@@ -29,6 +29,9 @@ require 'rbcurse/rmessagebox'
|
|
29
29
|
def alert text, config={}, &block
|
30
30
|
title = config['title'] || "Alert"
|
31
31
|
#instance_eval &block if block_given?
|
32
|
+
if text.is_a? RubyCurses::Variable # added 2011-09-20 incase variable passed
|
33
|
+
text = text.get_value
|
34
|
+
end
|
32
35
|
mb = RubyCurses::MessageBox.new nil, config do
|
33
36
|
title title
|
34
37
|
message text
|
@@ -49,7 +52,10 @@ end
|
|
49
52
|
##
|
50
53
|
# allows user entry of a string.
|
51
54
|
# In config you may pass Field related properties such as chars_allowed, valid_regex, values, etc.
|
52
|
-
def get_string(message, len=
|
55
|
+
def get_string(message, len=50, default="", config={})
|
56
|
+
|
57
|
+
config["input_config"] = {}
|
58
|
+
config["input_config"]["maxlen"] = len
|
53
59
|
config["maxlen"]=len
|
54
60
|
title = config["title"] || "Input required"
|
55
61
|
mb = RubyCurses::MessageBox.new nil, config do
|
data/lib/rbcurse/rlistbox.rb
CHANGED
@@ -18,7 +18,7 @@ require 'rbcurse/listkeys'
|
|
18
18
|
require 'forwardable'
|
19
19
|
|
20
20
|
|
21
|
-
include Ncurses
|
21
|
+
#include Ncurses # FFI 2011-09-8
|
22
22
|
module RubyCurses
|
23
23
|
extend self
|
24
24
|
##
|
@@ -307,9 +307,10 @@ module RubyCurses
|
|
307
307
|
@stop = true
|
308
308
|
return
|
309
309
|
when KEY_ENTER, 10, 13
|
310
|
+
# if you press ENTER without selecting, it won't come here
|
311
|
+
# it will fire button OK's fire, if that's the default button
|
310
312
|
fire_handler :PRESS, @listbox.focussed_index
|
311
313
|
# since Listbox is handling enter, COMBO_SELECT will not be fired
|
312
|
-
# $log.debug "popup ENTER : #{@selected_index} "
|
313
314
|
# $log.debug "popup ENTER : #{field.name}" if !field.nil?
|
314
315
|
@stop = true
|
315
316
|
return
|
@@ -701,6 +702,11 @@ module RubyCurses
|
|
701
702
|
$log.debug " listbox got ch #{ch}"
|
702
703
|
#$log.debug " when kps #{@KEY_PREV_SELECTION} "
|
703
704
|
case ch
|
705
|
+
when 10,13, KEY_ENTER
|
706
|
+
# this means you cannot just bind_key 10 or 13 like we once did
|
707
|
+
fire_action_event # trying out REMOVE 2011-09-16 FFI
|
708
|
+
$log.debug " 333 listbox catching 10,13 fire_action_event "
|
709
|
+
return 0
|
704
710
|
when KEY_UP # show previous value
|
705
711
|
return previous_row
|
706
712
|
when KEY_DOWN # show previous value
|
@@ -779,6 +785,7 @@ module RubyCurses
|
|
779
785
|
ret = set_selection_for_char ch.chr
|
780
786
|
else
|
781
787
|
ret = process_key ch, self
|
788
|
+
$log.debug "111 listbox #{@current_index} "
|
782
789
|
@multiplier = 0
|
783
790
|
return :UNHANDLED if ret == :UNHANDLED
|
784
791
|
end
|
@@ -1039,6 +1046,7 @@ module RubyCurses
|
|
1039
1046
|
# returns only the visible portion of string taking into account display length
|
1040
1047
|
# and horizontal scrolling. MODIFIES STRING
|
1041
1048
|
# if you;ve truncated the data, it could stay truncated even if lb is increased. be careful
|
1049
|
+
# FIXME if _maxlen becomes 0 then maxlen -1 will print whole string again
|
1042
1050
|
def truncate content
|
1043
1051
|
_maxlen = @maxlen || @width-@internal_width
|
1044
1052
|
_maxlen = @width-@internal_width if _maxlen > @width-@internal_width
|