rbcurse-extras 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +75 -0
- data/VERSION +1 -0
- data/examples/data/list.txt +300 -0
- data/examples/data/lotr.txt +12 -0
- data/examples/data/table.txt +36 -0
- data/examples/data/tasks.txt +27 -0
- data/examples/data/unix1.txt +21 -0
- data/examples/inc/qdfilechooser.rb +70 -0
- data/examples/inc/rfe_renderer.rb +121 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/rfe.rb +1236 -0
- data/examples/test2.rb +670 -0
- data/examples/testeditlist.rb +78 -0
- data/examples/testtable.rb +270 -0
- data/examples/testvimsplit.rb +141 -0
- data/lib/rbcurse/extras/include/celleditor.rb +112 -0
- data/lib/rbcurse/extras/include/checkboxcellrenderer.rb +57 -0
- data/lib/rbcurse/extras/include/comboboxcellrenderer.rb +30 -0
- data/lib/rbcurse/extras/include/defaultlistselectionmodel.rb +79 -0
- data/lib/rbcurse/extras/include/listkeys.rb +37 -0
- data/lib/rbcurse/extras/include/listselectable.rb +144 -0
- data/lib/rbcurse/extras/include/tableextended.rb +40 -0
- data/lib/rbcurse/extras/widgets/horizlist.rb +203 -0
- data/lib/rbcurse/extras/widgets/menutree.rb +63 -0
- data/lib/rbcurse/extras/widgets/multilinelabel.rb +142 -0
- data/lib/rbcurse/extras/widgets/rcomboedit.rb +256 -0
- data/lib/rbcurse/extras/widgets/rlink.rb.moved +27 -0
- data/lib/rbcurse/extras/widgets/rlistbox.rb +1247 -0
- data/lib/rbcurse/extras/widgets/rmenulink.rb.moved +21 -0
- data/lib/rbcurse/extras/widgets/rmulticontainer.rb +304 -0
- data/lib/rbcurse/extras/widgets/rmultisplit.rb +722 -0
- data/lib/rbcurse/extras/widgets/rmultitextview.rb +306 -0
- data/lib/rbcurse/extras/widgets/rpopupmenu.rb +755 -0
- data/lib/rbcurse/extras/widgets/rtable.rb +1758 -0
- data/lib/rbcurse/extras/widgets/rvimsplit.rb +800 -0
- data/lib/rbcurse/extras/widgets/table/tablecellrenderer.rb +86 -0
- data/lib/rbcurse/extras/widgets/table/tabledatecellrenderer.rb +98 -0
- metadata +94 -0
@@ -0,0 +1,86 @@
|
|
1
|
+
module RubyCurses
|
2
|
+
class TableCellRenderer
|
3
|
+
#include DSL
|
4
|
+
#include EventHandler
|
5
|
+
include ConfigSetup
|
6
|
+
include RubyCurses::Utils
|
7
|
+
dsl_accessor :justify # :right, :left, :center # added 2008-12-22 19:02
|
8
|
+
dsl_accessor :display_length # please give this to ensure the we only print this much
|
9
|
+
dsl_accessor :height # if you want a multiline label.
|
10
|
+
dsl_accessor :text # text of label
|
11
|
+
dsl_accessor :color, :bgcolor
|
12
|
+
dsl_accessor :row, :col
|
13
|
+
dsl_accessor :parent #usuall the table to get colors and other default info
|
14
|
+
|
15
|
+
def initialize text="", config={}, &block
|
16
|
+
@text = text
|
17
|
+
@editable = false
|
18
|
+
@focusable = false
|
19
|
+
config_setup config # @config.each_pair { |k,v| variable_set(k,v) }
|
20
|
+
instance_eval &block if block_given?
|
21
|
+
init_vars
|
22
|
+
end
|
23
|
+
def init_vars
|
24
|
+
@justify ||= :left
|
25
|
+
@display_length ||= 10
|
26
|
+
end
|
27
|
+
def transform value
|
28
|
+
return value.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# XXX need to move wrapping etc up and done once.
|
33
|
+
def repaint graphic, r=@row,c=@col, row_index=-1, value=@text, focussed=false, selected=false
|
34
|
+
lablist = []
|
35
|
+
#value=value.to_s # ??
|
36
|
+
value=transform value
|
37
|
+
if @height && @height > 1
|
38
|
+
lablist = wrap_text(value, @display_length).split("\n")
|
39
|
+
else
|
40
|
+
# ensure we do not exceed
|
41
|
+
if !@display_length.nil?
|
42
|
+
if value.length > @display_length
|
43
|
+
dlen = @display_length - 1
|
44
|
+
dlen = 0 if dlen < 0
|
45
|
+
value = value[0..dlen]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
lablist << value
|
49
|
+
end
|
50
|
+
len = @display_length || value.length
|
51
|
+
#$log.debug "less ZERO #{@display_length} || #{value.length}, ri: #{row_index}" if len < 0
|
52
|
+
acolor = get_color $datacolor
|
53
|
+
#acolor =get_color $datacolor, @color || @parent.color, @bgcolor || @parent.bgcolor #unless @parent.nil?
|
54
|
+
_attr = Ncurses::A_NORMAL
|
55
|
+
if selected
|
56
|
+
_attr = Ncurses::A_BOLD if selected
|
57
|
+
acolor =get_color $selectedcolor, @parent.selected_color, @parent.selected_bgcolor unless @parent.nil?
|
58
|
+
end
|
59
|
+
if focussed
|
60
|
+
_attr |= Ncurses::A_REVERSE
|
61
|
+
end
|
62
|
+
#$log.debug "label :#{@text}, #{value}, #{r}, #{c} col= #{@color}, #{@bgcolor} acolor= #{acolor} j:#{@justify} dlL: #{@display_length} "
|
63
|
+
_height = @height || 1
|
64
|
+
str = @justify.to_sym == :right ? "%*s" : "%-*s" # added 2008-12-22 19:05
|
65
|
+
# loop added for labels that are wrapped.
|
66
|
+
# TODO clear separately since value can change in status like labels
|
67
|
+
0.upto(_height-1) { |i|
|
68
|
+
graphic.printstring r+i, c, " " * len , acolor,_attr
|
69
|
+
}
|
70
|
+
lablist.each_with_index do |_value, ix|
|
71
|
+
break if ix >= _height
|
72
|
+
if @justify.to_sym == :center
|
73
|
+
padding = (@display_length - _value.length)/2
|
74
|
+
padding = 0 if padding < 0
|
75
|
+
_value = " "*padding + _value + " "*padding # so its cleared if we change it midway
|
76
|
+
end
|
77
|
+
# XXX 2009-10-05 23:01 since the len can vary when scrolling
|
78
|
+
# right justification for numbers suffers.
|
79
|
+
# perhaps one should use display_length and then truncate using len
|
80
|
+
graphic.printstring r, c, str % [len, _value], acolor,_attr
|
81
|
+
r += 1
|
82
|
+
end
|
83
|
+
end
|
84
|
+
# ADD HERE LABEL
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module RubyCurses
|
2
|
+
class TableDateCellRenderer
|
3
|
+
#include EventHandler
|
4
|
+
include ConfigSetup
|
5
|
+
include RubyCurses::Utils
|
6
|
+
dsl_accessor :justify # :right, :left, :center # added 2008-12-22 19:02
|
7
|
+
dsl_accessor :format # date or numeric format
|
8
|
+
dsl_accessor :format_hint # date :DATE_ONLY, :TIME_ONLY, :LONG
|
9
|
+
dsl_accessor :display_length # please give this to ensure the we only print this much
|
10
|
+
dsl_accessor :height # if you want a multiline label.
|
11
|
+
dsl_accessor :text # text of label
|
12
|
+
dsl_accessor :color, :bgcolor
|
13
|
+
dsl_accessor :row, :col
|
14
|
+
dsl_accessor :parent #usuall the table to get colors and other default info
|
15
|
+
|
16
|
+
def initialize text="", config={}, &block
|
17
|
+
@text = text
|
18
|
+
@editable = false
|
19
|
+
@focusable = false
|
20
|
+
config_setup config # @config.each_pair { |k,v| variable_set(k,v) }
|
21
|
+
instance_eval &block if block_given?
|
22
|
+
init_vars
|
23
|
+
end
|
24
|
+
def init_vars
|
25
|
+
@justify ||= :left
|
26
|
+
@display_length ||= 10
|
27
|
+
@format ||= "%Y/%m/%d %H:%M"
|
28
|
+
case @format_hint
|
29
|
+
when :LONG
|
30
|
+
@format = nil
|
31
|
+
when :DATE_ONLY
|
32
|
+
@format = "%Y/%m/%d"
|
33
|
+
when :TIME_ONLY
|
34
|
+
@format ||= "%H/%M"
|
35
|
+
when :TIME_ONLY_12
|
36
|
+
@format ||= "%I/%M%p"
|
37
|
+
end
|
38
|
+
# use %I:%M%p for 12 hour ampm"
|
39
|
+
end
|
40
|
+
def transform value
|
41
|
+
if @format.nil?
|
42
|
+
return value.to_s
|
43
|
+
end
|
44
|
+
return value.strftime(@format)
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# XXX need to move wrapping etc up and done once.
|
49
|
+
def repaint graphic, r=@row,c=@col, row_index=-1,value=@text, focussed=false, selected=false
|
50
|
+
lablist = []
|
51
|
+
#value=value.to_s # ??
|
52
|
+
value=transform value
|
53
|
+
if @height && @height > 1
|
54
|
+
lablist = wrap_text(value, @display_length).split("\n")
|
55
|
+
else
|
56
|
+
# ensure we do not exceed
|
57
|
+
if !@display_length.nil?
|
58
|
+
if value.length > @display_length
|
59
|
+
dlen = @display_length - 1
|
60
|
+
dlen = 0 if dlen < 0
|
61
|
+
value = value[0..dlen]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
lablist << value
|
65
|
+
end
|
66
|
+
len = @display_length || value.length
|
67
|
+
acolor = get_color $datacolor
|
68
|
+
#acolor =get_color $datacolor, @color || @parent.color, @bgcolor || @parent.bgcolor #unless @parent.nil?
|
69
|
+
_attr = Ncurses::A_NORMAL
|
70
|
+
if selected
|
71
|
+
_attr = Ncurses::A_BOLD if selected
|
72
|
+
acolor =get_color $selectedcolor, @parent.selected_color, @parent.selected_bgcolor unless @parent.nil?
|
73
|
+
end
|
74
|
+
if focussed
|
75
|
+
_attr |= Ncurses::A_REVERSE
|
76
|
+
end
|
77
|
+
#$log.debug "label :#{@text}, #{value}, #{r}, #{c} col= #{@color}, #{@bgcolor} acolor= #{acolor} j:#{@justify} dlL: #{@display_length} "
|
78
|
+
_height = @height || 1
|
79
|
+
str = @justify.to_sym == :right ? "%*s" : "%-*s" # added 2008-12-22 19:05
|
80
|
+
# loop added for labels that are wrapped.
|
81
|
+
# TODO clear separately since value can change in status like labels
|
82
|
+
0.upto(_height-1) { |i|
|
83
|
+
graphic.printstring r+i, c, " " * len , acolor,_attr
|
84
|
+
}
|
85
|
+
lablist.each_with_index do |_value, ix|
|
86
|
+
break if ix >= _height
|
87
|
+
if @justify.to_sym == :center
|
88
|
+
padding = (@display_length - _value.length)/2
|
89
|
+
padding = 0 if padding < 0
|
90
|
+
_value = " "*padding + _value + " "*padding # so its cleared if we change it midway
|
91
|
+
end
|
92
|
+
graphic.printstring r, c, str % [len, _value], acolor,_attr
|
93
|
+
r += 1
|
94
|
+
end
|
95
|
+
end
|
96
|
+
# ADD HERE
|
97
|
+
end
|
98
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rbcurse-extras
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rahul Kumar
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rbcurse-core
|
16
|
+
requirement: &70122079095420 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.3
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70122079095420
|
25
|
+
description: Ruby curses/ncurses widgets for easy application development on text
|
26
|
+
terminals, augmenting rbcurse-core
|
27
|
+
email: sentinel1879@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files:
|
31
|
+
- README.md
|
32
|
+
files:
|
33
|
+
- README.md
|
34
|
+
- VERSION
|
35
|
+
- examples/data/list.txt
|
36
|
+
- examples/data/lotr.txt
|
37
|
+
- examples/data/table.txt
|
38
|
+
- examples/data/tasks.txt
|
39
|
+
- examples/data/unix1.txt
|
40
|
+
- examples/inc/qdfilechooser.rb
|
41
|
+
- examples/inc/rfe_renderer.rb
|
42
|
+
- examples/newtabbedwindow.rb
|
43
|
+
- examples/rfe.rb
|
44
|
+
- examples/test2.rb
|
45
|
+
- examples/testeditlist.rb
|
46
|
+
- examples/testtable.rb
|
47
|
+
- examples/testvimsplit.rb
|
48
|
+
- lib/rbcurse/extras/include/celleditor.rb
|
49
|
+
- lib/rbcurse/extras/include/checkboxcellrenderer.rb
|
50
|
+
- lib/rbcurse/extras/include/comboboxcellrenderer.rb
|
51
|
+
- lib/rbcurse/extras/include/defaultlistselectionmodel.rb
|
52
|
+
- lib/rbcurse/extras/include/listkeys.rb
|
53
|
+
- lib/rbcurse/extras/include/listselectable.rb
|
54
|
+
- lib/rbcurse/extras/include/tableextended.rb
|
55
|
+
- lib/rbcurse/extras/widgets/horizlist.rb
|
56
|
+
- lib/rbcurse/extras/widgets/menutree.rb
|
57
|
+
- lib/rbcurse/extras/widgets/multilinelabel.rb
|
58
|
+
- lib/rbcurse/extras/widgets/rcomboedit.rb
|
59
|
+
- lib/rbcurse/extras/widgets/rlink.rb.moved
|
60
|
+
- lib/rbcurse/extras/widgets/rlistbox.rb
|
61
|
+
- lib/rbcurse/extras/widgets/rmenulink.rb.moved
|
62
|
+
- lib/rbcurse/extras/widgets/rmulticontainer.rb
|
63
|
+
- lib/rbcurse/extras/widgets/rmultisplit.rb
|
64
|
+
- lib/rbcurse/extras/widgets/rmultitextview.rb
|
65
|
+
- lib/rbcurse/extras/widgets/rpopupmenu.rb
|
66
|
+
- lib/rbcurse/extras/widgets/rtable.rb
|
67
|
+
- lib/rbcurse/extras/widgets/rvimsplit.rb
|
68
|
+
- lib/rbcurse/extras/widgets/table/tablecellrenderer.rb
|
69
|
+
- lib/rbcurse/extras/widgets/table/tabledatecellrenderer.rb
|
70
|
+
homepage: https://github.com/rkumar/rbcurse-extras
|
71
|
+
licenses: []
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubyforge_project: rbcurse
|
90
|
+
rubygems_version: 1.8.10
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: Ruby Ncurses Toolkit additional widgets
|
94
|
+
test_files: []
|