rbcurse 1.4.1 → 1.5.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +31 -0
- data/README.markdown +69 -11
- data/VERSION +1 -1
- data/lib/rbcurse.rb +5 -5
- metadata +10 -198
- data/Makefile +0 -21
- data/Manifest.txt +0 -91
- data/TODO +0 -372
- data/TODO2.txt +0 -118
- data/examples/README.txt +0 -67
- data/examples/abasiclist.rb +0 -33
- data/examples/alpmenu.rb +0 -42
- data/examples/app.rb +0 -859
- data/examples/app.sample +0 -10
- data/examples/appdirtree.rb +0 -75
- data/examples/appemail.rb +0 -191
- data/examples/appemaillb.rb +0 -308
- data/examples/appgcompose.rb +0 -315
- data/examples/atree.rb +0 -64
- data/examples/common/file.rb +0 -40
- data/examples/common/rmail.rb +0 -257
- data/examples/data.txt +0 -683
- data/examples/data/README.markdown +0 -9
- data/examples/data/brew.txt +0 -38
- data/examples/data/color.2 +0 -37
- data/examples/data/gemlist.txt +0 -60
- data/examples/data/lotr.txt +0 -12
- data/examples/data/ports.txt +0 -136
- data/examples/data/tasks.txt +0 -27
- data/examples/data/todocsv.csv +0 -28
- data/examples/data/unix1.txt +0 -21
- data/examples/data/unix2.txt +0 -11
- data/examples/dbdemo.rb +0 -495
- data/examples/deprecated/appgmail.rb +0 -952
- data/examples/deprecated/splitp.rb +0 -56
- data/examples/deprecated/testscrolllb.rb +0 -86
- data/examples/deprecated/testscrollp.rb +0 -88
- data/examples/deprecated/testscrollta.rb +0 -80
- data/examples/deprecated/testscrolltable.rb +0 -165
- data/examples/deprecated/testsplit.rb +0 -87
- data/examples/deprecated/testsplit2.rb +0 -123
- data/examples/deprecated/testsplit3.rb +0 -215
- data/examples/deprecated/testsplit3_1.rb +0 -244
- data/examples/deprecated/testsplit3a.rb +0 -215
- data/examples/deprecated/testsplit3b.rb +0 -237
- data/examples/deprecated/testsplitta.rb +0 -148
- data/examples/deprecated/testsplittv.rb +0 -142
- data/examples/deprecated/testsplittvv.rb +0 -144
- data/examples/deprecated/testtpane.rb +0 -215
- data/examples/deprecated/testtpane2.rb +0 -145
- data/examples/deprecated/testtpanetable.rb +0 -203
- data/examples/dirtree.rb +0 -88
- data/examples/experimental/resultsetdemo.rb +0 -280
- data/examples/experimental/testmform.rb +0 -35
- data/examples/experimental/testscroller.rb +0 -117
- data/examples/experimental/teststackflow.rb +0 -111
- data/examples/menu1.rb +0 -112
- data/examples/multispl.rb +0 -86
- data/examples/newmessagebox.rb +0 -130
- data/examples/newtabbedwindow.rb +0 -100
- data/examples/newtesttabp.rb +0 -121
- data/examples/qdfilechooser.rb +0 -68
- data/examples/rfe.rb +0 -1195
- data/examples/rfe_renderer.rb +0 -121
- data/examples/sqlc.rb +0 -454
- data/examples/sqlm.rb +0 -437
- data/examples/sqlt.rb +0 -408
- data/examples/status.txt +0 -68
- data/examples/table1.rb +0 -24
- data/examples/term2.rb +0 -84
- data/examples/test1.rb +0 -239
- data/examples/test2.rb +0 -674
- data/examples/testapp.rb +0 -44
- data/examples/testapp2.rb +0 -58
- data/examples/testchars.rb +0 -137
- data/examples/testcombo.rb +0 -91
- data/examples/testkeypress.rb +0 -66
- data/examples/testlistbox.rb +0 -113
- data/examples/testmenu.rb +0 -101
- data/examples/testmulticomp.rb +0 -70
- data/examples/testmulticontainer.rb +0 -94
- data/examples/testmultispl.rb +0 -199
- data/examples/testree.rb +0 -106
- data/examples/testtable.rb +0 -263
- data/examples/testtabp.rb +0 -107
- data/examples/testtodo.rb +0 -584
- data/examples/testvimsplit.rb +0 -112
- data/examples/testwsshortcuts.rb +0 -64
- data/examples/testwsshortcuts2.rb +0 -126
- data/examples/todo.db +0 -0
- data/examples/todo.yml +0 -191
- data/examples/viewtodo.rb +0 -574
- data/lib/rbcurse/action.rb +0 -40
- data/lib/rbcurse/app.rb +0 -1374
- data/lib/rbcurse/applicationheader.rb +0 -102
- data/lib/rbcurse/celleditor.rb +0 -112
- data/lib/rbcurse/checkboxcellrenderer.rb +0 -57
- data/lib/rbcurse/colormap.rb +0 -159
- data/lib/rbcurse/comboboxcellrenderer.rb +0 -30
- data/lib/rbcurse/common/ansiparser.rb +0 -117
- data/lib/rbcurse/common/appmethods.rb +0 -112
- data/lib/rbcurse/common/basestack.rb +0 -407
- data/lib/rbcurse/common/bordertitle.rb +0 -41
- data/lib/rbcurse/common/chunk.rb +0 -177
- data/lib/rbcurse/common/colorparser.rb +0 -71
- data/lib/rbcurse/common/keydefs.rb +0 -30
- data/lib/rbcurse/common/widgetshortcuts.rb +0 -302
- data/lib/rbcurse/defaultlistselectionmodel.rb +0 -79
- data/lib/rbcurse/deprecated/README.markdown +0 -12
- data/lib/rbcurse/deprecated/rscrollpane.rb +0 -512
- data/lib/rbcurse/deprecated/rsplitpane.rb +0 -894
- data/lib/rbcurse/deprecated/rsplitpane2.rb +0 -1009
- data/lib/rbcurse/deprecated/rviewport.rb +0 -204
- data/lib/rbcurse/experimental/README.markdown +0 -14
- data/lib/rbcurse/experimental/resultsettextview.rb +0 -585
- data/lib/rbcurse/experimental/stackflow.rb +0 -478
- data/lib/rbcurse/extras/bottomline.rb +0 -1850
- data/lib/rbcurse/extras/box.rb +0 -58
- data/lib/rbcurse/extras/directorylist.rb +0 -467
- data/lib/rbcurse/extras/directorytree.rb +0 -69
- data/lib/rbcurse/extras/divider.rb +0 -310
- data/lib/rbcurse/extras/focusmanager.rb +0 -31
- data/lib/rbcurse/extras/horizlist.rb +0 -203
- data/lib/rbcurse/extras/listselectable.rb +0 -264
- data/lib/rbcurse/extras/masterdetail.rb +0 -166
- data/lib/rbcurse/extras/menutree.rb +0 -63
- data/lib/rbcurse/extras/multiform.rb +0 -330
- data/lib/rbcurse/extras/multilinelabel.rb +0 -142
- data/lib/rbcurse/extras/newmessagebox.rb +0 -328
- data/lib/rbcurse/extras/newtabbedpane.rb +0 -612
- data/lib/rbcurse/extras/newtabbedwindow.rb +0 -68
- data/lib/rbcurse/extras/padreader.rb +0 -189
- data/lib/rbcurse/extras/rcomboedit.rb +0 -256
- data/lib/rbcurse/extras/resultsetbrowser.rb +0 -281
- data/lib/rbcurse/extras/rlink.rb +0 -27
- data/lib/rbcurse/extras/rmenulink.rb +0 -21
- data/lib/rbcurse/extras/scrollbar.rb +0 -143
- data/lib/rbcurse/extras/statusline.rb +0 -94
- data/lib/rbcurse/extras/stdscrwindow.rb +0 -309
- data/lib/rbcurse/extras/tableextended.rb +0 -40
- data/lib/rbcurse/extras/tabular.rb +0 -264
- data/lib/rbcurse/extras/tabularwidget.rb +0 -1150
- data/lib/rbcurse/extras/textpad.rb +0 -516
- data/lib/rbcurse/extras/viewer.rb +0 -136
- data/lib/rbcurse/io.rb +0 -850
- data/lib/rbcurse/keylabelprinter.rb +0 -178
- data/lib/rbcurse/listcellrenderer.rb +0 -140
- data/lib/rbcurse/listeditable.rb +0 -310
- data/lib/rbcurse/listkeys.rb +0 -37
- data/lib/rbcurse/listscrollable.rb +0 -564
- data/lib/rbcurse/listselectable.rb +0 -142
- data/lib/rbcurse/mapper.rb +0 -130
- data/lib/rbcurse/orderedhash.rb +0 -77
- data/lib/rbcurse/ractionevent.rb +0 -67
- data/lib/rbcurse/rbasiclistbox.rb +0 -768
- data/lib/rbcurse/rchangeevent.rb +0 -27
- data/lib/rbcurse/rcombo.rb +0 -238
- data/lib/rbcurse/rcommandwindow.rb +0 -587
- data/lib/rbcurse/rcontainer.rb +0 -415
- data/lib/rbcurse/rdialogs.rb +0 -451
- data/lib/rbcurse/rinputdataevent.rb +0 -47
- data/lib/rbcurse/rlistbox.rb +0 -1196
- data/lib/rbcurse/rmenu.rb +0 -939
- data/lib/rbcurse/rmessagebox.rb +0 -348
- data/lib/rbcurse/rmulticontainer.rb +0 -304
- data/lib/rbcurse/rmultisplit.rb +0 -722
- data/lib/rbcurse/rmultitextview.rb +0 -306
- data/lib/rbcurse/rpopupmenu.rb +0 -755
- data/lib/rbcurse/rprogress.rb +0 -118
- data/lib/rbcurse/rscrollform.rb +0 -418
- data/lib/rbcurse/rtabbedpane.rb +0 -1158
- data/lib/rbcurse/rtabbedwindow.rb +0 -167
- data/lib/rbcurse/rtable.rb +0 -1718
- data/lib/rbcurse/rtextarea.rb +0 -920
- data/lib/rbcurse/rtextview.rb +0 -761
- data/lib/rbcurse/rtree.rb +0 -780
- data/lib/rbcurse/rvimsplit.rb +0 -763
- data/lib/rbcurse/rwidget.rb +0 -2915
- data/lib/rbcurse/scrollable.rb +0 -301
- data/lib/rbcurse/table/tablecellrenderer.rb +0 -86
- data/lib/rbcurse/table/tabledatecellrenderer.rb +0 -98
- data/lib/rbcurse/tree/treecellrenderer.rb +0 -150
- data/lib/rbcurse/tree/treemodel.rb +0 -428
- data/lib/rbcurse/undomanager.rb +0 -188
- data/lib/rbcurse/vieditable.rb +0 -144
- data/lib/ver/keyboard.rb +0 -150
- data/lib/ver/keyboard2.rb +0 -170
- data/lib/ver/ncurses.rb +0 -218
- data/lib/ver/panel.rb +0 -162
- data/lib/ver/rpad.rb +0 -375
- data/lib/ver/window.rb +0 -882
- data/test/test_rbcurse.rb +0 -0
data/lib/rbcurse/rprogress.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
#require 'ncurses'
|
2
|
-
require 'logger'
|
3
|
-
require 'rbcurse'
|
4
|
-
|
5
|
-
#include Ncurses # FFI 2011-09-8
|
6
|
-
include RubyCurses
|
7
|
-
module RubyCurses
|
8
|
-
extend self
|
9
|
-
##
|
10
|
-
# TODO user may want to print a label on progress: like not started or complete.
|
11
|
-
class Progress < Widget
|
12
|
-
dsl_property :width # please give this to ensure the we only print this much
|
13
|
-
dsl_property :fraction # how much to cover
|
14
|
-
dsl_property :char # what char to use for filling, default space
|
15
|
-
dsl_property :text # text to put over bar
|
16
|
-
dsl_accessor :style # :old or nil/anything else
|
17
|
-
dsl_accessor :surround_chars # "[]"
|
18
|
-
|
19
|
-
def initialize form, config={}, &block
|
20
|
-
|
21
|
-
@row = config.fetch("row",-1)
|
22
|
-
@col = config.fetch("col",-1)
|
23
|
-
@bgcolor = config.fetch("bgcolor", $def_bg_color)
|
24
|
-
@color = config.fetch("color", $def_fg_color)
|
25
|
-
@name = config.fetch("name", "pbar")
|
26
|
-
@editable = false
|
27
|
-
@focusable = false
|
28
|
-
super
|
29
|
-
@surround_chars ||= "[]" # for :old style
|
30
|
-
@repaint_required = true
|
31
|
-
end
|
32
|
-
def getvalue
|
33
|
-
@fraction || 0.0
|
34
|
-
end
|
35
|
-
|
36
|
-
##
|
37
|
-
#
|
38
|
-
def repaint
|
39
|
-
return unless @repaint_required
|
40
|
-
$log.debug " XXXX PBAR inside repaint #{@color} , #{@fraction} "
|
41
|
-
r,c = rowcol
|
42
|
-
#value = getvalue_for_paint
|
43
|
-
acolor = get_color @bgcolor
|
44
|
-
bcolor = get_color @color
|
45
|
-
@graphic = @form.window if @graphic.nil? ## HACK messagebox givig this in repaint, 423 not working ??
|
46
|
-
len = 0
|
47
|
-
w2 = @width - 6 #2 account for brackets and printing of percentage
|
48
|
-
if @fraction
|
49
|
-
@fraction = 1.0 if @fraction > 1.0
|
50
|
-
@fraction = 0 if @fraction < 0
|
51
|
-
if @fraction > 0
|
52
|
-
len = @fraction * @width
|
53
|
-
end
|
54
|
-
end
|
55
|
-
if @style == :old
|
56
|
-
ftext=""
|
57
|
-
char = @char || "="
|
58
|
-
if @fraction && @fraction >= 0
|
59
|
-
len = @fraction * (w2)
|
60
|
-
ftext << sprintf("%3d%s",(@fraction * 100).to_i, "%")
|
61
|
-
end
|
62
|
-
incomplete = w2 - len
|
63
|
-
complete = len
|
64
|
-
# I am printing 2 times since sometimes the ending bracket gets printed one position less
|
65
|
-
str = @surround_chars[0] + " "*w2 + @surround_chars[1] + ftext
|
66
|
-
@graphic.printstring r, c, str , acolor,@attr
|
67
|
-
str = char*complete
|
68
|
-
str[-1] = ">" if char == "=" && complete > 2
|
69
|
-
@graphic.printstring r, c+1, str , acolor,@attr
|
70
|
-
else
|
71
|
-
|
72
|
-
char = @char || " "
|
73
|
-
# first print the background horizonal bar
|
74
|
-
@graphic.printstring r, c, " " * @width , acolor,@attr
|
75
|
-
|
76
|
-
# if the user has passed a percentage we need to print that in @color
|
77
|
-
if @fraction
|
78
|
-
#bcolor = get_color @color
|
79
|
-
#@fraction = 1.0 if @fraction > 1.0
|
80
|
-
#@fraction = 0 if @fraction < 0
|
81
|
-
#if @fraction > 0
|
82
|
-
#len = @fraction * @width
|
83
|
-
#char = @char || " "
|
84
|
-
|
85
|
-
# if text is to printed over the bar
|
86
|
-
if @text
|
87
|
-
textcolor = get_color $datacolor, 'black'
|
88
|
-
txt = @text
|
89
|
-
txt = @text[0..@width] if @text.length > @width
|
90
|
-
textattr = 'bold'
|
91
|
-
# write the text in a color that contrasts with the background
|
92
|
-
# typically black
|
93
|
-
@graphic.printstring r, c, txt , textcolor, textattr if @text
|
94
|
-
|
95
|
-
# now write the text again, in a color that contrasts with the progress
|
96
|
-
# bar color that is expanding. However, the text must be padded to len and truncated
|
97
|
-
# to len as well. it must be exactly len in size.
|
98
|
-
txt = sprintf("%-*s", len, txt)
|
99
|
-
if len > 0
|
100
|
-
if len < txt.length
|
101
|
-
txt = txt[0..len]
|
102
|
-
end
|
103
|
-
textcolor = get_color $datacolor, 'white', @color
|
104
|
-
@graphic.printstring r, c, txt , textcolor, textattr if @text
|
105
|
-
end
|
106
|
-
else
|
107
|
-
# no text was given just print a horizontal bar
|
108
|
-
@graphic.printstring r, c, char * len , bcolor, 'reverse'
|
109
|
-
end
|
110
|
-
end # frac > 0
|
111
|
-
end # fraction
|
112
|
-
end # style
|
113
|
-
@repaint_required = false
|
114
|
-
end
|
115
|
-
def repaint_old
|
116
|
-
end
|
117
|
-
# ADD HERE progress
|
118
|
-
end
|
data/lib/rbcurse/rscrollform.rb
DELETED
@@ -1,418 +0,0 @@
|
|
1
|
-
=begin
|
2
|
-
* Name: ScrollForm - a form that can take more than the screen and focus only on what's visible
|
3
|
-
* This class originated in TabbedPane for the top button form which only scrolls
|
4
|
-
* horizontally and uses objects that have a ht of 1. Here we have to deal with
|
5
|
-
* large objects and vertical scrolling.
|
6
|
-
* Description:
|
7
|
-
* Author: rkumar
|
8
|
-
|
9
|
-
--------
|
10
|
-
* Date: 2010-03-16 11:32
|
11
|
-
* License:
|
12
|
-
Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
13
|
-
|
14
|
-
|
15
|
-
NOTE:
|
16
|
-
There are going to be tricky cases we have to deal with such as objects that start in the viewable
|
17
|
-
area but finish outside, or vice versa.
|
18
|
-
|
19
|
-
What if we wish some static text to be displayed at top or bottom of ScrollForm
|
20
|
-
=end
|
21
|
-
require 'logger'
|
22
|
-
require 'rbcurse'
|
23
|
-
|
24
|
-
#include Ncurses # FFI 2011-09-8
|
25
|
-
include RubyCurses
|
26
|
-
module RubyCurses
|
27
|
-
extend self
|
28
|
-
class ScrollForm < RubyCurses::Form
|
29
|
-
# the pad prints from this col to window
|
30
|
-
attr_accessor :pmincol # advance / scroll columns
|
31
|
-
# the pad prints from this row to window, usually 0
|
32
|
-
attr_accessor :pminrow # advance / scroll rows (vertically)
|
33
|
-
#attr_accessor :display_w # width of screen display NOW METHODS
|
34
|
-
#attr_accessor :display_h # ht of screen display
|
35
|
-
attr_accessor :row_offset, :col_offset
|
36
|
-
attr_accessor :scroll_unit # by how much should be scroll
|
37
|
-
attr_reader :orig_top, :orig_left
|
38
|
-
attr_reader :window
|
39
|
-
attr_accessor :name
|
40
|
-
attr_reader :cols_panned, :rows_panned
|
41
|
-
def initialize win, &block
|
42
|
-
@target_window = win
|
43
|
-
super
|
44
|
-
@pminrow = @pmincol = 0
|
45
|
-
@row_offset = @col_offset = 0
|
46
|
-
@scroll_unit = 3
|
47
|
-
@cols_panned = @rows_panned = 0
|
48
|
-
@repaint_all = true
|
49
|
-
|
50
|
-
# take display dimensions from window. It is safe to override immediately after form creation
|
51
|
-
@display_h = win.height
|
52
|
-
@display_w = win.width
|
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
|
64
|
-
|
65
|
-
init_vars
|
66
|
-
end
|
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
|
70
|
-
bind_key(?\M-h, :scroll_left)
|
71
|
-
bind_key(?\M-l, :scroll_right)
|
72
|
-
bind_key(?\M-n, :scroll_down)
|
73
|
-
bind_key(?\M-p, :scroll_up)
|
74
|
-
end
|
75
|
-
def should_print_border flag=true
|
76
|
-
@print_border_flag = flag
|
77
|
-
@row_offset = @col_offset = 1
|
78
|
-
end
|
79
|
-
# This is how we set size of pad and where it prints on screen
|
80
|
-
# This is all that's needed after constructor.
|
81
|
-
# @param [Fixnum] t top (row on screen to print pad on)
|
82
|
-
# @param [Fixnum] l left (col on screen to print)
|
83
|
-
# @param [Fixnum] h height (how many lines in Pad, usually more that screens actual height)
|
84
|
-
# @param [Fixnum] w width (how many cols in Pad, often more than screens width)
|
85
|
-
#
|
86
|
-
def set_pad_dimensions(t, l, h, w )
|
87
|
-
@pad_h = h
|
88
|
-
@pad_w = w
|
89
|
-
@top = @orig_top = t
|
90
|
-
@left = @orig_left = l
|
91
|
-
create_pad
|
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
|
129
|
-
##
|
130
|
-
# create a pad to work on.
|
131
|
-
# XXX We reuse window, which is already the main window
|
132
|
-
# So if we try creating pad later, then old external window is used.
|
133
|
-
# However, many methods in superclass operate on window so we needed to overwrite. What do i do ?
|
134
|
-
#private
|
135
|
-
def create_pad
|
136
|
-
#raise "Pad already created" if @pad
|
137
|
-
return @pad if @pad
|
138
|
-
r = @top
|
139
|
-
c = @left
|
140
|
-
layout = { :height => @pad_h, :width => @pad_w, :top => r, :left => c }
|
141
|
-
@window = VER::Pad.create_with_layout(layout)
|
142
|
-
|
143
|
-
@window.name = "Pad::ScrollPad" # 2010-02-02 20:01
|
144
|
-
@name = "Form::ScrollForm"
|
145
|
-
@pad = @window
|
146
|
-
return @window
|
147
|
-
end
|
148
|
-
public
|
149
|
-
def scroll_right
|
150
|
-
s = @scroll_unit + $multiplier
|
151
|
-
$log.debug " scroll_right #{s} m: #{$multiplier} "
|
152
|
-
$multiplier = 0
|
153
|
-
return false if !validate_scroll_col(@pmincol + s)
|
154
|
-
@pmincol += s # some check is required or we'll crash
|
155
|
-
@cols_panned -= s
|
156
|
-
$log.debug " handled ch M-l in ScrollForm"
|
157
|
-
@window.modified = true
|
158
|
-
return 0
|
159
|
-
end
|
160
|
-
##
|
161
|
-
# validate fails once unit + mult > 1. Then it won't go further
|
162
|
-
# unit should be one by default.
|
163
|
-
def scroll_left
|
164
|
-
s = @scroll_unit + $multiplier
|
165
|
-
$log.debug " scroll_left #{s} m: #{$multiplier} "
|
166
|
-
$multiplier = 0
|
167
|
-
#return false if !validate_scroll_col(@pmincol - s)
|
168
|
-
if !validate_scroll_col(@pmincol - s)
|
169
|
-
@pmincol = 0
|
170
|
-
@cols_panned = 0
|
171
|
-
else
|
172
|
-
@pmincol -= s # some check is required or we'll crash
|
173
|
-
@cols_panned += s
|
174
|
-
end
|
175
|
-
@window.modified = true
|
176
|
-
return 0
|
177
|
-
end
|
178
|
-
def scroll_down
|
179
|
-
s = @scroll_unit + $multiplier; $multiplier = 0
|
180
|
-
return false if !validate_scroll_row(@pminrow + s)
|
181
|
-
@pminrow += s # some check is required or we'll crash
|
182
|
-
@rows_panned -= s
|
183
|
-
@window.modified = true
|
184
|
-
#@repaint_all = true
|
185
|
-
return 0
|
186
|
-
end
|
187
|
-
def scroll_up
|
188
|
-
s = @scroll_unit + $multiplier; $multiplier = 0
|
189
|
-
$log.debug " scroll_up #{s} "
|
190
|
-
#return false if !validate_scroll_row(@pminrow - s)
|
191
|
-
if !validate_scroll_row(@pminrow - s)
|
192
|
-
@pminrow = 0
|
193
|
-
@rows_panned = 0
|
194
|
-
$log.debug " !valid #{@pminrow} "
|
195
|
-
else
|
196
|
-
@pminrow -= s # some check is required or we'll crash
|
197
|
-
@rows_panned += s
|
198
|
-
$log.debug " valid #{@pminrow} "
|
199
|
-
end
|
200
|
-
@window.modified = true
|
201
|
-
#@repaint_all = true
|
202
|
-
return 0
|
203
|
-
end
|
204
|
-
# print a border on the main window, just for kicks
|
205
|
-
def print_border
|
206
|
-
$log.debug " SCROLL print_border ..."
|
207
|
-
#@window.print_border_only(@top-@rows_panned, @left+@cols_panned, @display_h, @display_w, $datacolor)
|
208
|
-
@target_window.print_border_only(@top, @left, @display_h, @display_w+1, $datacolor)
|
209
|
-
end
|
210
|
-
def print_footer
|
211
|
-
footer = "Lines %d-%d (%d) Cols %d-%d (%d) " % [ @pminrow, @pminrow + @display_h, @orig_top + @pad_h, @pmincol, @pmincol + @display_w, @orig_left + @pad_w ]
|
212
|
-
@target_window.printstring(@top +@display_h, @left + 3, footer, $datacolor)
|
213
|
-
end
|
214
|
-
# XXX what if we want a static area at bottom ?
|
215
|
-
# maybe we should rename targetwindow to window
|
216
|
-
# and window to pad
|
217
|
-
# super may need target window
|
218
|
-
def repaint
|
219
|
-
print_border if @repaint_all and @print_border_flag
|
220
|
-
print_footer if @print_border_flag
|
221
|
-
$log.debug " scrollForm repaint calling parent #{@row} #{@col}+ #{@cols_panned} #{@col_offset} "
|
222
|
-
super
|
223
|
-
prefresh
|
224
|
-
if @print_border_flag
|
225
|
-
_print_more_data_marker true
|
226
|
-
_print_more_columns_marker true
|
227
|
-
end
|
228
|
-
#$log.debug " @target_window.wmove #{@row+@rows_panned+@row_offset}, #{@col+@cols_panned+@col_offset} "
|
229
|
-
@target_window.wmove @row+@rows_panned+@row_offset, @col+@cols_panned+@col_offset
|
230
|
-
@window.modified = false
|
231
|
-
@repaint_all = false
|
232
|
-
end
|
233
|
-
## refresh pad onto window
|
234
|
-
# I am now copying onto main window, else prefresh has funny effects
|
235
|
-
def prefresh
|
236
|
-
## reduce so we don't go off in top+h and top+w
|
237
|
-
$log.debug " start ret = @buttonpad.prefresh( #{@pminrow} , #{@pmincol} , #{@top} , #{@left} , top + #{@display_h} left + #{@display_w} ) "
|
238
|
-
if @pminrow + @display_h > @orig_top + @pad_h
|
239
|
-
$log.debug " if #{@pminrow} + #{@display_h} > #{@orig_top} +#{@pad_h} "
|
240
|
-
$log.debug " ERROR 1 "
|
241
|
-
#return -1
|
242
|
-
end
|
243
|
-
if @pmincol + @display_w > @orig_left + @pad_w
|
244
|
-
$log.debug " if #{@pmincol} + #{@display_w} > #{@orig_left} +#{@pad_w} "
|
245
|
-
$log.debug " ERROR 2 "
|
246
|
-
return -1
|
247
|
-
end
|
248
|
-
# actually if there is a change in the screen, we may still need to allow update
|
249
|
-
# but ensure that size does not exceed
|
250
|
-
if @top + @display_h > @orig_top + @pad_h
|
251
|
-
$log.debug " if #{@top} + #{@display_h} > #{@orig_top} +#{@pad_h} "
|
252
|
-
$log.debug " ERROR 3 "
|
253
|
-
return -1
|
254
|
-
end
|
255
|
-
if @left + @display_w > @orig_left + @pad_w
|
256
|
-
$log.debug " if #{@left} + #{@display_w} > #{@orig_left} +#{@pad_w} "
|
257
|
-
$log.debug " ERROR 4 "
|
258
|
-
return -1
|
259
|
-
end
|
260
|
-
# maybe we should use copywin to copy onto @target_window
|
261
|
-
$log.debug " ret = @window.prefresh( #{@pminrow} , #{@pmincol} , #{@top} , #{@left} , #{@top} + #{@display_h}, #{@left} + #{@display_w} ) "
|
262
|
-
omit = 0
|
263
|
-
# this works but if want to avoid copying border
|
264
|
-
#ret = @window.prefresh(@pminrow, @pmincol, @top+@row_offset, @left+@col_offset, @top + @display_h - @row_offset , @left + @display_w - @col_offset)
|
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)"
|
267
|
-
## Haha , we are back to the old notorious copywin which has given mankind
|
268
|
-
# so much grief that it should be removed in the next round of creation.
|
269
|
-
ret = @window.copywin(@target_window.get_window, @pminrow, @pmincol, @top+@row_offset, @left+@col_offset,
|
270
|
-
@top + @display_h - @row_offset , @left + @display_w - @col_offset, 0)
|
271
|
-
|
272
|
-
$log.debug " copywin ret = #{ret} "
|
273
|
-
end
|
274
|
-
private
|
275
|
-
def validate_scroll_row minrow
|
276
|
-
return false if minrow < 0
|
277
|
-
if minrow + @display_h > @orig_top + @pad_h
|
278
|
-
$log.debug " if #{minrow} + #{@display_h} > #{@orig_top} +#{@pad_h} "
|
279
|
-
$log.debug " ERROR 1 "
|
280
|
-
return false
|
281
|
-
end
|
282
|
-
return true
|
283
|
-
end
|
284
|
-
def validate_scroll_col mincol
|
285
|
-
return false if mincol < 0
|
286
|
-
if mincol + @display_w > @orig_left + @pad_w
|
287
|
-
$log.debug " if #{mincol} + #{@display_w} > #{@orig_left} +#{@pad_w} "
|
288
|
-
$log.debug " ERROR 2 "
|
289
|
-
return false
|
290
|
-
end
|
291
|
-
return true
|
292
|
-
end
|
293
|
-
# when tabbing through buttons, we need to account for all that panning/scrolling goin' on
|
294
|
-
# this is typically called by putchar or putc in editable components like field.
|
295
|
-
# XXX DELETE THIS IS SUPPOSE
|
296
|
-
def OLDsetrowcol r, c
|
297
|
-
$log.debug " SCROLL setrowcol #{r}, #{c} + #{@cols_panned}"
|
298
|
-
# aha ! here's where i can check whether the cursor is falling off the viewable area
|
299
|
-
cc = nil
|
300
|
-
rr = nil
|
301
|
-
if c
|
302
|
-
cc = c #+ @cols_panned
|
303
|
-
if c+@cols_panned < @orig_left
|
304
|
-
# this essentially means this widget (button) is not in view, its off to the left
|
305
|
-
$log.debug " setrowcol OVERRIDE #{c} #{@cols_panned} < #{@orig_left} "
|
306
|
-
$log.debug " aborting settrow col for now"
|
307
|
-
return
|
308
|
-
end
|
309
|
-
if c+@cols_panned > @orig_left + @display_w
|
310
|
-
# this essentially means this button is not in view, its off to the right
|
311
|
-
$log.debug " setrowcol OVERRIDE #{c} #{@cols_panned} > #{@orig_left} + #{@display_w} "
|
312
|
-
$log.debug " aborting settrow col for now"
|
313
|
-
return
|
314
|
-
end
|
315
|
-
end
|
316
|
-
if r
|
317
|
-
rr = r+@rows_panned
|
318
|
-
end
|
319
|
-
super rr, cc
|
320
|
-
end
|
321
|
-
public
|
322
|
-
def add_widget w
|
323
|
-
super
|
324
|
-
$log.debug " inside add_widget #{w.name} pad w #{@pad_w} #{w.col}, #{@pad_h} "
|
325
|
-
if w.col >= @pad_w
|
326
|
-
@pad_w += 10 # XXX currently just a guess value, we need length and maybe some extra
|
327
|
-
@window.wresize(@pad_h, @pad_w) if @pad
|
328
|
-
end
|
329
|
-
if w.row >= @pad_h
|
330
|
-
@pad_h += 10 # XXX currently just a guess value, we need length and maybe some extra
|
331
|
-
$log.debug " SCROLL add_widget ..."
|
332
|
-
@window.wresize(@pad_h, @pad_w) if @pad
|
333
|
-
end
|
334
|
-
end
|
335
|
-
## Is a component visible, typically used to prevent traversal into the field
|
336
|
-
# @returns [true, false] false if components has scrolled off
|
337
|
-
def visible? component
|
338
|
-
r, c = component.rowcol
|
339
|
-
return false if c+@cols_panned < @orig_left
|
340
|
-
return false if c+@cols_panned > @orig_left + @display_w
|
341
|
-
# XXX TODO for rows UNTESTED for rows
|
342
|
-
return false if r + @rows_panned < @orig_top
|
343
|
-
return false if r + @rows_panned > @orig_top + @display_h - 2
|
344
|
-
|
345
|
-
return true
|
346
|
-
end
|
347
|
-
# returns index of first visible component. Currently using column index
|
348
|
-
# I am doing this for horizontal scrolling presently
|
349
|
-
# @return [index, -1] -1 if none visible, else index/offset
|
350
|
-
def first_visible_component_index
|
351
|
-
@widgets.each_with_index do |w, ix|
|
352
|
-
return ix if visible?(w) and focusable?(w)
|
353
|
-
end
|
354
|
-
return -1
|
355
|
-
end
|
356
|
-
def last_visible_component_index
|
357
|
-
ret = -1
|
358
|
-
@widgets.each_with_index do |w, ix|
|
359
|
-
ret = ix if visible?(w) and focusable?(w)
|
360
|
-
end
|
361
|
-
return ret
|
362
|
-
end
|
363
|
-
def req_first_field
|
364
|
-
index = first_visible_component_index
|
365
|
-
ret = select_field(index)
|
366
|
-
return ret
|
367
|
-
end
|
368
|
-
def req_last_field
|
369
|
-
select_field(last_visible_component_index)
|
370
|
-
end
|
371
|
-
def focusable?(w)
|
372
|
-
w.focusable and visible?(w)
|
373
|
-
end
|
374
|
-
|
375
|
-
# XXX needs to be called from repaint and print_border
|
376
|
-
# @param [boolean] should marker be printed or not
|
377
|
-
def _print_more_data_marker tf
|
378
|
-
tf = false
|
379
|
-
# the bottom marker meaning there's more data below
|
380
|
-
if @pminrow + @display_h < @pad_h
|
381
|
-
tf = true
|
382
|
-
end
|
383
|
-
marker = tf ? Ncurses::ACS_CKBOARD : Ncurses::ACS_VLINE
|
384
|
-
h = @display_h; w = @display_w
|
385
|
-
r = @orig_top
|
386
|
-
c = @orig_left
|
387
|
-
$log.debug " more data #{r+h-1}, #{c+w-1} : row #{r} h #{h} w #{w} col #{c} "
|
388
|
-
@target_window.mvwaddch r+h-1, c+w-0, marker
|
389
|
-
# the top marker to show that there is data above
|
390
|
-
marker = @pminrow > 0 ? Ncurses::ACS_CKBOARD : Ncurses::ACS_VLINE
|
391
|
-
@target_window.mvwaddch r+1, c+w-0, marker
|
392
|
-
end
|
393
|
-
|
394
|
-
# XXX needs to be called from repaint and print_border
|
395
|
-
# @param [boolean] should marker be printed or not
|
396
|
-
def _print_more_columns_marker tf
|
397
|
-
tf = false
|
398
|
-
if @pmincol + @display_w < @pad_w
|
399
|
-
tf = true
|
400
|
-
end
|
401
|
-
marker = tf ? Ncurses::ACS_CKBOARD : Ncurses::ACS_HLINE
|
402
|
-
h = @display_h; w = @display_w
|
403
|
-
r = @orig_top
|
404
|
-
c = @orig_left
|
405
|
-
@target_window.mvwaddch r+h, c+w-2, marker
|
406
|
-
#
|
407
|
-
# show if columns to left or not
|
408
|
-
marker = @pmincol > 0 ? Ncurses::ACS_CKBOARD : Ncurses::ACS_HLINE
|
409
|
-
@target_window.mvwaddch r+h, c+1, marker
|
410
|
-
end
|
411
|
-
end # class ScrollF
|
412
|
-
|
413
|
-
# the return of the prodigals
|
414
|
-
# The Expanding Heart
|
415
|
-
# The coming together of all those who were
|
416
|
-
|
417
|
-
|
418
|
-
end # module
|