rbcurse-core 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +69 -0
- data/VERSION +1 -0
- data/examples/abasiclist.rb +151 -0
- data/examples/alpmenu.rb +46 -0
- data/examples/app.sample +17 -0
- data/examples/atree.rb +100 -0
- data/examples/common/file.rb +45 -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/table.txt +37 -0
- data/examples/data/tasks.csv +88 -0
- data/examples/data/tasks.txt +27 -0
- data/examples/data/todo.txt +10 -0
- data/examples/data/todocsv.csv +28 -0
- data/examples/data/unix1.txt +21 -0
- data/examples/data/unix2.txt +11 -0
- data/examples/dbdemo.rb +487 -0
- data/examples/dirtree.rb +90 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/newtesttabp.rb +92 -0
- data/examples/tabular.rb +132 -0
- data/examples/tasks.rb +167 -0
- data/examples/term2.rb +83 -0
- data/examples/testkeypress.rb +72 -0
- data/examples/testlistbox.rb +158 -0
- data/examples/testmessagebox.rb +140 -0
- data/examples/testree.rb +106 -0
- data/examples/testwsshortcuts.rb +66 -0
- data/examples/testwsshortcuts2.rb +127 -0
- data/lib/rbcurse.rb +8 -0
- data/lib/rbcurse/core/docs/index.txt +73 -0
- data/lib/rbcurse/core/include/action.rb +40 -0
- data/lib/rbcurse/core/include/appmethods.rb +112 -0
- data/lib/rbcurse/core/include/bordertitle.rb +41 -0
- data/lib/rbcurse/core/include/chunk.rb +182 -0
- data/lib/rbcurse/core/include/io.rb +953 -0
- data/lib/rbcurse/core/include/listcellrenderer.rb +140 -0
- data/lib/rbcurse/core/include/listeditable.rb +317 -0
- data/lib/rbcurse/core/include/listscrollable.rb +590 -0
- data/lib/rbcurse/core/include/listselectable.rb +264 -0
- data/lib/rbcurse/core/include/multibuffer.rb +83 -0
- data/lib/rbcurse/core/include/orderedhash.rb +77 -0
- data/lib/rbcurse/core/include/ractionevent.rb +67 -0
- data/lib/rbcurse/core/include/rchangeevent.rb +27 -0
- data/lib/rbcurse/core/include/rhistory.rb +62 -0
- data/lib/rbcurse/core/include/rinputdataevent.rb +47 -0
- data/lib/rbcurse/core/include/vieditable.rb +170 -0
- data/lib/rbcurse/core/system/colormap.rb +163 -0
- data/lib/rbcurse/core/system/keyboard.rb +150 -0
- data/lib/rbcurse/core/system/keydefs.rb +30 -0
- data/lib/rbcurse/core/system/ncurses.rb +218 -0
- data/lib/rbcurse/core/system/panel.rb +162 -0
- data/lib/rbcurse/core/system/window.rb +901 -0
- data/lib/rbcurse/core/util/ansiparser.rb +117 -0
- data/lib/rbcurse/core/util/app.rb +1235 -0
- data/lib/rbcurse/core/util/basestack.rb +407 -0
- data/lib/rbcurse/core/util/bottomline.rb +1850 -0
- data/lib/rbcurse/core/util/colorparser.rb +71 -0
- data/lib/rbcurse/core/util/focusmanager.rb +31 -0
- data/lib/rbcurse/core/util/padreader.rb +189 -0
- data/lib/rbcurse/core/util/rcommandwindow.rb +587 -0
- data/lib/rbcurse/core/util/rdialogs.rb +619 -0
- data/lib/rbcurse/core/util/viewer.rb +149 -0
- data/lib/rbcurse/core/util/widgetshortcuts.rb +505 -0
- data/lib/rbcurse/core/widgets/applicationheader.rb +102 -0
- data/lib/rbcurse/core/widgets/box.rb +58 -0
- data/lib/rbcurse/core/widgets/divider.rb +310 -0
- data/lib/rbcurse/core/widgets/keylabelprinter.rb +178 -0
- data/lib/rbcurse/core/widgets/rcombo.rb +238 -0
- data/lib/rbcurse/core/widgets/rcontainer.rb +415 -0
- data/lib/rbcurse/core/widgets/rlink.rb +30 -0
- data/lib/rbcurse/core/widgets/rlist.rb +723 -0
- data/lib/rbcurse/core/widgets/rmenu.rb +939 -0
- data/lib/rbcurse/core/widgets/rmenulink.rb +22 -0
- data/lib/rbcurse/core/widgets/rmessagebox.rb +373 -0
- data/lib/rbcurse/core/widgets/rprogress.rb +118 -0
- data/lib/rbcurse/core/widgets/rtabbedpane.rb +615 -0
- data/lib/rbcurse/core/widgets/rtabbedwindow.rb +68 -0
- data/lib/rbcurse/core/widgets/rtextarea.rb +920 -0
- data/lib/rbcurse/core/widgets/rtextview.rb +780 -0
- data/lib/rbcurse/core/widgets/rtree.rb +787 -0
- data/lib/rbcurse/core/widgets/rwidget.rb +3040 -0
- data/lib/rbcurse/core/widgets/scrollbar.rb +143 -0
- data/lib/rbcurse/core/widgets/statusline.rb +94 -0
- data/lib/rbcurse/core/widgets/tabular.rb +264 -0
- data/lib/rbcurse/core/widgets/tabularwidget.rb +1211 -0
- data/lib/rbcurse/core/widgets/textpad.rb +516 -0
- data/lib/rbcurse/core/widgets/tree/treecellrenderer.rb +150 -0
- data/lib/rbcurse/core/widgets/tree/treemodel.rb +428 -0
- metadata +156 -0
@@ -0,0 +1,102 @@
|
|
1
|
+
# ----------------------------------------------------------------------------- #
|
2
|
+
# File: applicationheader.rb
|
3
|
+
# Description: Prints a header on first row, with right, left and centered text
|
4
|
+
# NOTE: on some terminal such as xterm-256color spaces do not print
|
5
|
+
# so you will see black or empty spaces between text.
|
6
|
+
# This does not happen on screen and xterm-color.
|
7
|
+
# Author: rkumar http://github.com/rkumar/rbcurse/
|
8
|
+
# Date:
|
9
|
+
# License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
|
10
|
+
# Last update: 2011-11-16 - 00:07
|
11
|
+
#
|
12
|
+
# CHANGES:
|
13
|
+
# For some terminals, like xterm-256color which were not printing spaces
|
14
|
+
# I've changed to code so only text is printed where it has to with no
|
15
|
+
# padding. These terminals remove the padding color.
|
16
|
+
# ----------------------------------------------------------------------------- #
|
17
|
+
#
|
18
|
+
require 'rbcurse/core/widgets/rwidget'
|
19
|
+
include RubyCurses
|
20
|
+
module RubyCurses
|
21
|
+
class ApplicationHeader < Widget
|
22
|
+
dsl_property :text1
|
23
|
+
dsl_property :text2
|
24
|
+
dsl_property :text_center
|
25
|
+
dsl_property :text_right
|
26
|
+
|
27
|
+
|
28
|
+
def initialize form, text1, config={}, &block
|
29
|
+
|
30
|
+
@text1 = text1
|
31
|
+
# setting default first or else Widget will place its BW default
|
32
|
+
@color, @bgcolor = ColorMap.get_colors_for_pair $bottomcolor
|
33
|
+
super form, config, &block
|
34
|
+
@color_pair = get_color $bottomcolor, @color, @bgcolor
|
35
|
+
@window = form.window
|
36
|
+
@editable = false
|
37
|
+
@focusable = false
|
38
|
+
@cols ||= Ncurses.COLS-1
|
39
|
+
@row ||= 0
|
40
|
+
@col ||= 0
|
41
|
+
@repaint_required = true
|
42
|
+
#@color_pair ||= $bottomcolor # XXX this was forcing the color
|
43
|
+
#pair
|
44
|
+
@text2 ||= ""
|
45
|
+
@text_center ||= ""
|
46
|
+
@text_right ||= ""
|
47
|
+
end
|
48
|
+
def getvalue
|
49
|
+
@text1
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# XXX need to move wrapping etc up and done once.
|
54
|
+
def repaint
|
55
|
+
return unless @repaint_required
|
56
|
+
|
57
|
+
#print_header(htext, posy = 0, posx = 0)
|
58
|
+
att = get_attrib @attr
|
59
|
+
len = @window.width
|
60
|
+
len = Ncurses.COLS-0 if len == 0
|
61
|
+
# print a bar across the screen
|
62
|
+
@window.attron(Ncurses.COLOR_PAIR(@color_pair) | att)
|
63
|
+
@window.mvhline(@row, @col, 1, len)
|
64
|
+
@window.attroff(Ncurses.COLOR_PAIR(@color_pair) | att)
|
65
|
+
#print_header(@text1 + " %15s " % @text2 + " %20s" % @text_center , posy=0, posx=0)
|
66
|
+
|
67
|
+
# Now print the text in the correct positions with no padding, else some terminal
|
68
|
+
# will blacken the text out.
|
69
|
+
print_header("#{@text1} #{@text2}") # + " %20s" % @text_center , posy=0, posx=0)
|
70
|
+
print_center("#{@text_center}") # + " %20s" % @text_center , posy=0, posx=0)
|
71
|
+
print_top_right(@text_right)
|
72
|
+
@repaint_required = false
|
73
|
+
end
|
74
|
+
def print_header(htext, r = 0, c = 0)
|
75
|
+
#win = @window
|
76
|
+
#len = @window.width
|
77
|
+
#len = Ncurses.COLS-0 if len == 0
|
78
|
+
#
|
79
|
+
#@form.window.printstring r, c, "%-*s" % [len, htext], @color_pair, @attr
|
80
|
+
@form.window.printstring r, c, htext, @color_pair, @attr
|
81
|
+
end
|
82
|
+
def print_center(htext, r = 0, c = 0)
|
83
|
+
win = @window
|
84
|
+
len = win.width
|
85
|
+
len = Ncurses.COLS-0 if len == 0
|
86
|
+
#
|
87
|
+
#@form.window.printstring r, c, "%-*s" % [len, htext], @color_pair, @attr
|
88
|
+
win.printstring r, ((len-htext.length)/2).floor, htext, @color_pair, @attr
|
89
|
+
end
|
90
|
+
def print_top_right(htext)
|
91
|
+
$log.debug " def print_top_right(#{htext})"
|
92
|
+
hlen = htext.length
|
93
|
+
len = Ncurses.COLS-0
|
94
|
+
len = @window.width
|
95
|
+
len = Ncurses.COLS-0 if len == 0
|
96
|
+
@form.window.printstring 0, len-hlen, htext, @color_pair, @attr
|
97
|
+
end
|
98
|
+
##
|
99
|
+
##
|
100
|
+
# ADD HERE
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# ------------------------------------------------------------ #
|
2
|
+
# File: box.rb
|
3
|
+
# Description: draws a box around some group of items
|
4
|
+
# Author: rkumar http://github.com/rkumar/rbcurse/
|
5
|
+
# Date: 06.11.11 - 18:22
|
6
|
+
# Last update: 06.11.11 - 19:53
|
7
|
+
# ------------------------------------------------------------ #
|
8
|
+
#
|
9
|
+
require 'rbcurse'
|
10
|
+
require 'rbcurse/core/include/bordertitle'
|
11
|
+
include RubyCurses
|
12
|
+
#include RubyCurses::BorderTitle
|
13
|
+
|
14
|
+
# @example
|
15
|
+
#
|
16
|
+
# At a later stage, we will integrate this with lists and tables, so it will happen automatically.
|
17
|
+
#
|
18
|
+
# @since 1.4.1 UNTESTED
|
19
|
+
module RubyCurses
|
20
|
+
class Box < Widget
|
21
|
+
|
22
|
+
include BorderTitle
|
23
|
+
|
24
|
+
# margin for placing widgets inside
|
25
|
+
# This is not used inside here, but is used by stacks.
|
26
|
+
# @see widgetshortcuts.rb
|
27
|
+
dsl_accessor :margin_left, :margin_top
|
28
|
+
|
29
|
+
def initialize form, config={}, &block
|
30
|
+
|
31
|
+
bordertitle_init
|
32
|
+
super
|
33
|
+
@window = form.window if @form
|
34
|
+
@editable = false
|
35
|
+
@focusable = false
|
36
|
+
#@height += 1 # for that silly -1 that happens
|
37
|
+
@repaint_required = true
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# repaint the scrollbar
|
42
|
+
def repaint
|
43
|
+
return unless @repaint_required
|
44
|
+
bc = $datacolor
|
45
|
+
bordercolor = @border_color || bc
|
46
|
+
borderatt = @border_attrib || Ncurses::A_NORMAL
|
47
|
+
@window.print_border row, col, height, width, bordercolor, borderatt
|
48
|
+
#print_borders
|
49
|
+
print_title
|
50
|
+
@repaint_required = false
|
51
|
+
end
|
52
|
+
##
|
53
|
+
##
|
54
|
+
# ADD HERE
|
55
|
+
end
|
56
|
+
end
|
57
|
+
if __FILE__ == $PROGRAM_NAME
|
58
|
+
end
|
@@ -0,0 +1,310 @@
|
|
1
|
+
require 'rbcurse/core/util/app'
|
2
|
+
#include Ncurses # FFI 2011-09-8
|
3
|
+
include RubyCurses
|
4
|
+
|
5
|
+
# TODO : We can consider making it independent of objects, or allow for a margin so it does not write
|
6
|
+
# over the object. Then it will be always visible.
|
7
|
+
# TODO: if lists and tables, can without borders actually adjust then putting this independent
|
8
|
+
# would make even more sense, since it won't eat an extra line.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# lb = list_box ....
|
12
|
+
# rb = Divider.new @form, :parent => lb, :side => :right
|
13
|
+
#
|
14
|
+
# At a later stage, we will integrate this with lists and tables, so it will happen automatically.
|
15
|
+
#
|
16
|
+
# @since 1.2.0
|
17
|
+
module RubyCurses
|
18
|
+
class DragEvent < Struct.new(:source, :type); end
|
19
|
+
|
20
|
+
# This is a horizontal or vertical bar (like a scrollbar), at present attached to a
|
21
|
+
# widget that is focusable, and allows user to press arrow keys.
|
22
|
+
# It highlights on focus, the caller can expand and contract components in a container
|
23
|
+
# or even screen, based on arrow movements. This allows for a visual resizing of components.
|
24
|
+
# @example
|
25
|
+
# lb = list_box ....
|
26
|
+
# rb = Divider.new @form, :parent => lb, :side => :right
|
27
|
+
#
|
28
|
+
# NOTE: since this can be deactivated, containers need to check focusable before passing
|
29
|
+
# focus in
|
30
|
+
# 2010-10-07 23:56 made focusable false by default. Add divider to
|
31
|
+
# FocusManager when creating, so F3 can be used to set focusable
|
32
|
+
# See rvimsplit.rb for example
|
33
|
+
|
34
|
+
class Divider < Widget
|
35
|
+
# row to start, same as listbox, required.
|
36
|
+
dsl_property :row
|
37
|
+
# column to start, same as listbox, required.
|
38
|
+
dsl_property :col
|
39
|
+
# how many rows is this (should be same as listboxes height, required.
|
40
|
+
dsl_property :length
|
41
|
+
# vertical or horizontal currently only VERTICAL
|
42
|
+
dsl_property :side
|
43
|
+
# initialize based on parent's values
|
44
|
+
dsl_property :parent
|
45
|
+
# which row is focussed, current_index of listbox, required.
|
46
|
+
# how many total rows of data does the list have, same as @list.length, required.
|
47
|
+
dsl_accessor :next_component # 'next' bombing in dsl_accessor 2011-10-2 PLS CHANGE ELSEWHERE
|
48
|
+
|
49
|
+
# TODO: if parent passed, we shold bind to ON_ENTER and get current_index, so no extra work is required.
|
50
|
+
|
51
|
+
def initialize form, config={}, &block
|
52
|
+
|
53
|
+
# setting default first or else Widget will place its BW default
|
54
|
+
#@color, @bgcolor = ColorMap.get_colors_for_pair $bottomcolor
|
55
|
+
super
|
56
|
+
@height = 1
|
57
|
+
@color_pair = get_color $datacolor, @color, @bgcolor
|
58
|
+
@scroll_pair = get_color $bottomcolor, :green, :white
|
59
|
+
#@window = form.window
|
60
|
+
@editable = false
|
61
|
+
# you can set to true upon creation, or use F3 on vimsplit to
|
62
|
+
# toggle focusable
|
63
|
+
@focusable = false
|
64
|
+
@repaint_required = true
|
65
|
+
@_events.push(:DRAG_EVENT)
|
66
|
+
map_keys
|
67
|
+
unless @parent
|
68
|
+
raise ArgumentError, "row col and length should be provided" if !@row || !@col || !@length
|
69
|
+
end
|
70
|
+
#if @parent
|
71
|
+
#@parent.bind :ENTER_ROW do |p|
|
72
|
+
## parent must implement row_count, and have a @current_index
|
73
|
+
#raise StandardError, "Parent must implement row_count" unless p.respond_to? :row_count
|
74
|
+
#self.current_index = p.current_index
|
75
|
+
#@repaint_required = true #requred otherwise at end when same value sent, prop handler
|
76
|
+
## will not be fired (due to optimization).
|
77
|
+
#end
|
78
|
+
#end
|
79
|
+
end
|
80
|
+
def map_keys
|
81
|
+
if !defined? $deactivate_dividers
|
82
|
+
$deactivate_dividers = false
|
83
|
+
end
|
84
|
+
# deactivate only this bar
|
85
|
+
bind_key(?f) {@focusable=false; }
|
86
|
+
# deactivate all bars, i've had nuff!
|
87
|
+
bind_key(?F) {deactivate_all(true)}
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# repaint the scrollbar
|
92
|
+
# Taking the data from parent as late as possible in case parent resized, or
|
93
|
+
# moved around by a container.
|
94
|
+
# NOTE: sometimes if this is inside another object, the divider repaints but then
|
95
|
+
# is wiped out when that objects print_border is called. So such an obkect (e.g.
|
96
|
+
# vimsplit) should call repaint after its has done its own repaint. that does mean
|
97
|
+
# the repaint happens twice during movement
|
98
|
+
def repaint
|
99
|
+
woffset = 2
|
100
|
+
coffset = 1
|
101
|
+
if @parent
|
102
|
+
woffset = 0 if @parent.suppress_borders
|
103
|
+
@border_attrib ||= @parent.border_attrib
|
104
|
+
case @side
|
105
|
+
when :right
|
106
|
+
@row = @parent.row+1
|
107
|
+
@col = @parent.col + @parent.width - 0
|
108
|
+
@length = @parent.height - woffset
|
109
|
+
when :left
|
110
|
+
@row = @parent.row+1
|
111
|
+
@col = @parent.col+0 #+ @parent.width - 1
|
112
|
+
@length = @parent.height - woffset
|
113
|
+
when :top
|
114
|
+
@row = @parent.row+0
|
115
|
+
@col = @parent.col + @parent.col_offset #+ @parent.width - 1
|
116
|
+
@length = @parent.width - woffset
|
117
|
+
when :bottom
|
118
|
+
@row = @parent.row+@parent.height-0 #1
|
119
|
+
@col = @parent.col+@parent.col_offset #+ @parent.width - 1
|
120
|
+
@length = @parent.width - woffset
|
121
|
+
end
|
122
|
+
else
|
123
|
+
# row, col and length should be passed
|
124
|
+
end
|
125
|
+
my_win = @form ? @form.window : @target_window
|
126
|
+
@graphic = my_win unless @graphic
|
127
|
+
raise "graphic is nil in divider, perhaps form was nil when creating" unless @graphic
|
128
|
+
return unless @repaint_required
|
129
|
+
|
130
|
+
# first print a right side vertical line
|
131
|
+
#bc = $bottomcolor # dark blue
|
132
|
+
bc = $datacolor
|
133
|
+
bordercolor = @border_color || bc
|
134
|
+
borderatt = @border_attrib || Ncurses::A_REVERSE
|
135
|
+
if @focussed
|
136
|
+
bordercolor = $promptcolor || bordercolor
|
137
|
+
end
|
138
|
+
|
139
|
+
borderatt = convert_attrib_to_sym(borderatt) if borderatt.is_a? Symbol
|
140
|
+
|
141
|
+
@graphic.attron(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
|
142
|
+
$log.debug " XXX DIVIDER #{@row} #{@col} #{@length} "
|
143
|
+
case @side
|
144
|
+
when :right, :left
|
145
|
+
@graphic.mvvline(@row, @col, 1, @length)
|
146
|
+
when :top, :bottom
|
147
|
+
@graphic.mvhline(@row, @col, 1, @length)
|
148
|
+
end
|
149
|
+
@graphic.attroff(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
|
150
|
+
_paint_marker
|
151
|
+
#alert "divider repaint at #{row} #{col} "
|
152
|
+
|
153
|
+
@repaint_required = false
|
154
|
+
end
|
155
|
+
def convert_attrib_to_sym attr
|
156
|
+
case attr
|
157
|
+
when 'reverse'
|
158
|
+
Ncurses::A_REVERSE
|
159
|
+
when 'bold'
|
160
|
+
Ncurses::A_BOLD
|
161
|
+
when 'normal'
|
162
|
+
Ncurses::A_NORMAL
|
163
|
+
when 'blink'
|
164
|
+
Ncurses::A_BLINK
|
165
|
+
when 'underline'
|
166
|
+
Ncurses::A_UNDERLINE
|
167
|
+
else
|
168
|
+
Ncurses::A_REVERSE
|
169
|
+
end
|
170
|
+
end
|
171
|
+
# deactivate all dividers
|
172
|
+
# The application has to provide a key or button to activate all
|
173
|
+
# or just this one.
|
174
|
+
def deactivate_all tf=true
|
175
|
+
$deactivate_dividers = tf
|
176
|
+
@focusable = !tf
|
177
|
+
end
|
178
|
+
def handle_key ch
|
179
|
+
# all dividers have been deactivated
|
180
|
+
if $deactivate_dividers || !@focusable
|
181
|
+
@focusable = false
|
182
|
+
return :UNHANDLED
|
183
|
+
end
|
184
|
+
case @side
|
185
|
+
when :right, :left
|
186
|
+
case ch
|
187
|
+
when KEY_RIGHT
|
188
|
+
fire_handler :DRAG_EVENT, DragEvent.new(self, ch)
|
189
|
+
when KEY_LEFT
|
190
|
+
fire_handler :DRAG_EVENT, DragEvent.new(self, ch)
|
191
|
+
else
|
192
|
+
ret = process_key ch, self
|
193
|
+
return ret if ret == :UNHANDLED
|
194
|
+
end
|
195
|
+
set_form_col
|
196
|
+
when :top, :bottom
|
197
|
+
case ch
|
198
|
+
when KEY_UP
|
199
|
+
fire_handler :DRAG_EVENT, DragEvent.new(self, ch)
|
200
|
+
when KEY_DOWN
|
201
|
+
fire_handler :DRAG_EVENT, DragEvent.new(self, ch)
|
202
|
+
else
|
203
|
+
ret = process_key ch, self
|
204
|
+
return ret if ret == :UNHANDLED
|
205
|
+
end
|
206
|
+
set_form_col
|
207
|
+
else
|
208
|
+
end
|
209
|
+
@repaint_required = true
|
210
|
+
return 0
|
211
|
+
end
|
212
|
+
def on_enter
|
213
|
+
if $deactivate_dividers || !@focusable
|
214
|
+
@focusable = false
|
215
|
+
return :UNHANDLED
|
216
|
+
end
|
217
|
+
# since it is over border of component, we need to repaint
|
218
|
+
@focussed = true
|
219
|
+
@repaint_required = true
|
220
|
+
repaint
|
221
|
+
end
|
222
|
+
def on_leave
|
223
|
+
@focussed = false
|
224
|
+
@repaint_required = true
|
225
|
+
repaint
|
226
|
+
# TODO: we should review this since its not over the parent any longer
|
227
|
+
if @parent
|
228
|
+
# since it is over border of component, we need to clear
|
229
|
+
@parent.repaint_required
|
230
|
+
# if we don't paint now, parent paints over other possible dividers
|
231
|
+
@parent.repaint
|
232
|
+
end
|
233
|
+
end
|
234
|
+
def set_form_row
|
235
|
+
return unless @focusable
|
236
|
+
r,c = rowcol
|
237
|
+
setrowcol r, c
|
238
|
+
end
|
239
|
+
# set the cursor on first point of bar
|
240
|
+
def set_form_col
|
241
|
+
return unless @focusable
|
242
|
+
# need to set it to first point, otherwise it could be off the widget
|
243
|
+
r,c = rowcol
|
244
|
+
setrowcol r, c
|
245
|
+
end
|
246
|
+
# is this a vertical divider
|
247
|
+
def v?
|
248
|
+
@side == :top || @side == :bottom
|
249
|
+
end
|
250
|
+
# is this a horizontal divider
|
251
|
+
def h?
|
252
|
+
@side == :right || @side == :left
|
253
|
+
end
|
254
|
+
private
|
255
|
+
def _paint_marker #:nodoc:
|
256
|
+
r,c = rowcol
|
257
|
+
if @focussed
|
258
|
+
@graphic.mvwaddch r,c, Ncurses::ACS_DIAMOND
|
259
|
+
if v?
|
260
|
+
@graphic.mvwaddch r,c+1, Ncurses::ACS_UARROW
|
261
|
+
@graphic.mvwaddch r,c+2, Ncurses::ACS_DARROW
|
262
|
+
else
|
263
|
+
@graphic.mvwaddch r+1,c, Ncurses::ACS_LARROW
|
264
|
+
@graphic.mvwaddch r+2,c, Ncurses::ACS_RARROW
|
265
|
+
end
|
266
|
+
else
|
267
|
+
#@graphic.mvwaddch r,c, Ncurses::ACS_CKBOARD
|
268
|
+
end
|
269
|
+
end
|
270
|
+
##
|
271
|
+
##
|
272
|
+
# ADD HERE
|
273
|
+
end # class
|
274
|
+
end # module
|
275
|
+
if __FILE__ == $PROGRAM_NAME
|
276
|
+
App.new do
|
277
|
+
r = 5
|
278
|
+
len = 20
|
279
|
+
list = []
|
280
|
+
0.upto(100) { |v| list << "#{v} scrollable data" }
|
281
|
+
lb = list_box "A list", :list => list, :row => 2, :col => 2
|
282
|
+
#sb = Scrollbar.new @form, :row => r, :col => 20, :length => len, :list_length => 50, :current_index => 0
|
283
|
+
rb = Divider.new @form, :parent => lb, :side => :right
|
284
|
+
rb.bind :DRAG_EVENT do |e|
|
285
|
+
message "got an event #{e.type} "
|
286
|
+
case e.type
|
287
|
+
when KEY_RIGHT
|
288
|
+
lb.width += 1
|
289
|
+
when KEY_LEFT
|
290
|
+
lb.width -= 1
|
291
|
+
end
|
292
|
+
lb.repaint_required
|
293
|
+
end
|
294
|
+
rb1 = Divider.new @form, :parent => lb, :side => :bottom
|
295
|
+
rb.focusable(true)
|
296
|
+
rb1.focusable(true)
|
297
|
+
rb1.bind :DRAG_EVENT do |e|
|
298
|
+
message " 2 got an event #{e.type} "
|
299
|
+
end
|
300
|
+
#hline :width => 20, :row => len+r
|
301
|
+
#keypress do |ch|
|
302
|
+
#case ch
|
303
|
+
#when :down
|
304
|
+
#sb.current_index += 1
|
305
|
+
#when :up
|
306
|
+
#sb.current_index -= 1
|
307
|
+
#end
|
308
|
+
#end
|
309
|
+
end
|
310
|
+
end
|