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
@@ -1,102 +0,0 @@
|
|
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/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
|
data/lib/rbcurse/celleditor.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
|
2
|
-
##
|
3
|
-
# This file gives us a mean of using a component as an editor in a list or later table.
|
4
|
-
# The component is created once and used with each row.
|
5
|
-
# It does not really have a form associated with it, although we do set a form
|
6
|
-
# so it can display itself. Otherwise it is not added to the forms widget list, so the
|
7
|
-
# form has no idea tha this widget exists.
|
8
|
-
#
|
9
|
-
# Tested with Field, combo and checkbox, tables.
|
10
|
-
#
|
11
|
-
module RubyCurses
|
12
|
-
class CellEditor
|
13
|
-
include ConfigSetup
|
14
|
-
include RubyCurses::Utils
|
15
|
-
|
16
|
-
def initialize component, config={}, &block
|
17
|
-
@component = component
|
18
|
-
s = @component.class.to_s.downcase()
|
19
|
-
s.slice!("rubycurses::")
|
20
|
-
@_class = s.to_sym
|
21
|
-
config_setup config # @config.each_pair { |k,v| variable_set(k,v) }
|
22
|
-
instance_eval &block if block_given?
|
23
|
-
end
|
24
|
-
def getvalue
|
25
|
-
case @_class
|
26
|
-
when :field
|
27
|
-
return field_getvalue
|
28
|
-
when :checkbox
|
29
|
-
return checkbox_getvalue
|
30
|
-
when :combobox
|
31
|
-
return combobox_getvalue
|
32
|
-
else
|
33
|
-
raise "Unknown class #{@_class} in CellEditor getv"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
# maybe this should check valid (on_leave) and throw exception
|
37
|
-
def field_getvalue
|
38
|
-
#@component.on_leave # throws exception! Added 2009-01-17 00:47
|
39
|
-
@component.init_vars # 2009-01-18 01:13 should not carry over to next row curpos and pcol
|
40
|
-
return @component.getvalue
|
41
|
-
end
|
42
|
-
def checkbox_getvalue
|
43
|
-
@component.getvalue
|
44
|
-
end
|
45
|
-
def combobox_getvalue
|
46
|
-
#@component.on_leave # added 2009-01-19 12:12
|
47
|
-
@component.getvalue
|
48
|
-
#@component.selected_item
|
49
|
-
end
|
50
|
-
def setvalue value
|
51
|
-
case @_class
|
52
|
-
when :field
|
53
|
-
@component.set_buffer value
|
54
|
-
when :checkbox
|
55
|
-
@component.checked value
|
56
|
-
when :combobox
|
57
|
-
@component.set_buffer value
|
58
|
-
#index = @component.list.index value
|
59
|
-
#@component.current_index = index
|
60
|
-
else
|
61
|
-
raise "Unknown class #{@_class} in CellEditor setv"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
def component
|
65
|
-
@component
|
66
|
-
end
|
67
|
-
# should be called from on_leave_cell of table, but is beng called from editing_stopped FIXME
|
68
|
-
def on_leave row, col
|
69
|
-
f = @component
|
70
|
-
f.on_leave
|
71
|
-
if f.respond_to? :editable and f.modified?
|
72
|
-
f.fire_handler(:CHANGED, f)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
def prepare_editor parent, row, col, value
|
76
|
-
#value = value.dup if value.respond_to? :dup
|
77
|
-
value = value.dup rescue value
|
78
|
-
setvalue value #.dup
|
79
|
-
widget = component()
|
80
|
-
widget.row = row
|
81
|
-
widget.col = col
|
82
|
-
# unfortunately 2009-01-11 19:47 combo boxes editable allows changing value
|
83
|
-
# FIXME so combo's can be editable, but no new value added
|
84
|
-
if @_class == :combobox
|
85
|
-
widget.editable = false if widget.respond_to? :editable # chb's don't ???
|
86
|
-
else
|
87
|
-
widget.editable = true if widget.respond_to? :editable # chb's don't ???
|
88
|
-
end
|
89
|
-
widget.focusable = true
|
90
|
-
widget.visible = true
|
91
|
-
widget.form = parent.form
|
92
|
-
#$log.debug " prepare editor value #{widget.display_length} displlen #{widget.maxlen}"
|
93
|
-
#$log.debug " prepare editor form: #{widget.form} " # 2011-11-15 12:54:41
|
94
|
-
#widget.display_length = widget.display_length -1
|
95
|
-
widget.bgcolor = 'yellow'
|
96
|
-
widget.color = 'black'
|
97
|
-
widget.on_enter
|
98
|
-
#widget.attr = Ncurses::A_REVERSE | Ncurses::A_BOLD
|
99
|
-
end
|
100
|
-
#This may not really be necessary since we paint the cell editor only if editing is on
|
101
|
-
def cancel_editor
|
102
|
-
widget = component()
|
103
|
-
# NOOO THIS IS CALLED BY CANCEL AND STOP
|
104
|
-
# somehow we need to ensure that if on_leave fails you can't get out. Here its a bit late
|
105
|
-
# i think FIXME TODO
|
106
|
-
#widget.on_leave # call so any triggers or validations can fire
|
107
|
-
widget.focusable = false
|
108
|
-
widget.visible = false
|
109
|
-
widget.attr = Ncurses::A_REVERSE
|
110
|
-
end
|
111
|
-
end # class
|
112
|
-
end # module
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'rbcurse/listcellrenderer'
|
2
|
-
module RubyCurses
|
3
|
-
|
4
|
-
##
|
5
|
-
# This is a basic list cell renderer that will render the to_s value of anything.
|
6
|
-
# Using alignment one can use for numbers too.
|
7
|
-
# However, for booleans it will print true and false. If editing, you may want checkboxes
|
8
|
-
class CheckBoxCellRenderer < ListCellRenderer
|
9
|
-
dsl_accessor :value # text of label
|
10
|
-
dsl_accessor :surround_chars
|
11
|
-
|
12
|
-
def initialize boolean=nil, config={}, &block
|
13
|
-
@value = boolean
|
14
|
-
@text = "" # what if someone wants to show a label later. ??? XXX
|
15
|
-
@editable = false
|
16
|
-
@focusable = false
|
17
|
-
config_setup config # @config.each_pair { |k,v| variable_set(k,v) }
|
18
|
-
instance_eval &block if block_given?
|
19
|
-
init_vars
|
20
|
-
end
|
21
|
-
def init_vars
|
22
|
-
@justify ||= :left
|
23
|
-
@display_length ||= 5
|
24
|
-
@surround_chars = ['[',']']
|
25
|
-
end
|
26
|
-
def getvalue
|
27
|
-
@value
|
28
|
-
end
|
29
|
-
|
30
|
-
##
|
31
|
-
#
|
32
|
-
def repaint graphic, r=@row,c=@col, row_index=-1,value=@value, focussed=false, selected=false
|
33
|
-
#$log.debug "label :#{@text}, #{value}, #{r}, #{c} col= #{@color}, #{@bgcolor} acolor= #{acolor} j:#{@justify} dlL: #{@display_length} "
|
34
|
-
|
35
|
-
prepare_default_colors focussed, selected
|
36
|
-
|
37
|
-
buttontext = value ? "X" : " "
|
38
|
-
# HOW TO DO THE TEXT ??? XXX
|
39
|
-
# the space in dtext next line is a cheat, to clear off the space that the
|
40
|
-
# editor is leaving.
|
41
|
-
dtext = " " #@display_length.nil? ? @text : "%-*s" % [@display_length, @text]
|
42
|
-
if @align_right
|
43
|
-
#@text_offset = 0
|
44
|
-
#@col_offset = dtext.length + @surround_chars[0].length + 1
|
45
|
-
str = "#{dtext} " + @surround_chars[0] + buttontext + @surround_chars[1]
|
46
|
-
else
|
47
|
-
pretext = @surround_chars[0] + buttontext + @surround_chars[1]
|
48
|
-
#@text_offset = pretext.length + 1
|
49
|
-
#@col_offset = @surround_chars[0].length
|
50
|
-
#@surround_chars[0] + buttontext + @surround_chars[1] + " #{@text}"
|
51
|
-
str = pretext + " #{dtext}"
|
52
|
-
end
|
53
|
-
graphic.printstring r, c, str, @color_pair,@attr
|
54
|
-
end
|
55
|
-
# ADD HERE
|
56
|
-
end
|
57
|
-
end
|
data/lib/rbcurse/colormap.rb
DELETED
@@ -1,159 +0,0 @@
|
|
1
|
-
require 'ver/ncurses'
|
2
|
-
module ColorMap
|
3
|
-
# 2010-09-20 12:22 changed colors from string to symbol
|
4
|
-
## private
|
5
|
-
# returns a color constant for a human color string
|
6
|
-
def ColorMap.get_color_const colorstring
|
7
|
-
ret = FFI::NCurses.const_get "COLOR_#{colorstring.upcase}"
|
8
|
-
#raise "color const nil ColorMap 8 " if !ret
|
9
|
-
end
|
10
|
-
## private
|
11
|
-
# creates a new color pair, puts in color map and returns color_pair
|
12
|
-
# number
|
13
|
-
def ColorMap.install_color fgc, bgc
|
14
|
-
#$log.debug " install_color found #{fgc} #{@bgc} "
|
15
|
-
@color_id += 1
|
16
|
-
fg = ColorMap.get_color_const fgc
|
17
|
-
bg = ColorMap.get_color_const bgc
|
18
|
-
FFI::NCurses.init_pair(@color_id, fg, bg);
|
19
|
-
$color_map[[fgc, bgc]] = @color_id
|
20
|
-
return @color_id
|
21
|
-
end
|
22
|
-
#
|
23
|
-
# returns the colors that make up the given pair
|
24
|
-
# you may want to find what makes up $bottomcolor and set color and bgcolor with it.
|
25
|
-
# @param [Fixnum] color_pair
|
26
|
-
# @return [Symbol, Symbol] foreground and backgrounf color
|
27
|
-
# @example
|
28
|
-
# color, bgcolor = get_colors_for_pair $datacolor
|
29
|
-
#
|
30
|
-
def ColorMap.get_colors_for_pair pair
|
31
|
-
$color_map.invert[pair]
|
32
|
-
end
|
33
|
-
## public
|
34
|
-
# returns a color_pair for a given foreground and background color
|
35
|
-
def ColorMap.get_color fgc, bgc=$def_bg_color
|
36
|
-
fgc = fgc.to_sym if fgc.is_a? String
|
37
|
-
bgc = bgc.to_sym if bgc.is_a? String
|
38
|
-
if $color_map.include? [fgc, bgc]
|
39
|
-
#$log.debug " get_color found #{fgc} #{@bgc} "
|
40
|
-
return $color_map[[fgc, bgc]]
|
41
|
-
else
|
42
|
-
#$log.debug " get_color NOT found #{fgc} #{@bgc} "
|
43
|
-
return ColorMap.install_color fgc, bgc
|
44
|
-
end
|
45
|
-
end
|
46
|
-
def ColorMap.colors
|
47
|
-
@@colors
|
48
|
-
end
|
49
|
-
# returns true if color is a valid one, else false
|
50
|
-
# @param [Symbol] color such as :black :cyan :yellow
|
51
|
-
# @return [Boolean] true if valid, else false
|
52
|
-
def ColorMap.is_color? color
|
53
|
-
@@colors.include? color.to_sym
|
54
|
-
end
|
55
|
-
|
56
|
-
## public
|
57
|
-
# setup color map at start of application
|
58
|
-
def ColorMap.setup
|
59
|
-
@color_id = 0
|
60
|
-
$color_map = {}
|
61
|
-
FFI::NCurses.start_color();
|
62
|
-
# Initialize few color pairs
|
63
|
-
$def_fg_color = :white # pls set these 2 for your application
|
64
|
-
$def_bg_color = :black
|
65
|
-
#COLORS = [COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW, COLOR_BLUE,
|
66
|
-
# COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE]
|
67
|
-
@@colors = [:black, :red, :green, :yellow, :blue, :magenta, :cyan, :white]
|
68
|
-
|
69
|
-
# make foreground colors
|
70
|
-
bg = ColorMap.get_color_const $def_bg_color
|
71
|
-
@@colors[0...@@colors.size].each_with_index do |color, i|
|
72
|
-
next if color == $def_bg_color
|
73
|
-
ColorMap.install_color color, $def_bg_color
|
74
|
-
end
|
75
|
-
$reversecolor = ColorMap.get_color $def_bg_color, $def_fg_color
|
76
|
-
$popupcolor = ColorMap.get_color :cyan, $def_fg_color
|
77
|
-
|
78
|
-
$errorcolor = ColorMap.get_color :white, :red
|
79
|
-
#$promptcolor = $selectedcolor = ColorMap.get_color(:yellow, :red)
|
80
|
-
$promptcolor = ColorMap.get_color(:yellow, :red)
|
81
|
-
$normalcolor = $datacolor = ColorMap.get_color(:white, :black)
|
82
|
-
$bottomcolor = $topcolor = ColorMap.get_color(:white, :blue)
|
83
|
-
$selectedcolor = $datacolor # since we now use reverse attr in list
|
84
|
-
|
85
|
-
$row_selected_attr = Ncurses::A_REVERSE
|
86
|
-
$row_focussed_attr = Ncurses::A_BOLD
|
87
|
-
$row_attr = Ncurses::A_NORMAL
|
88
|
-
|
89
|
-
# $log.debug " colormap SETUP: #{$datacolor} #{$reversecolor} "
|
90
|
-
end
|
91
|
-
|
92
|
-
end # modul
|
93
|
-
if $0 == __FILE__
|
94
|
-
require 'logger'
|
95
|
-
require 'ver/window'
|
96
|
-
#include Ncurses # FFI 2011-09-8
|
97
|
-
include ColorMap
|
98
|
-
# Initialize curses
|
99
|
-
begin
|
100
|
-
$log = Logger.new("rbc13.log")
|
101
|
-
VER::start_ncurses
|
102
|
-
@window = VER::Window.root_window
|
103
|
-
$log.level = Logger::DEBUG
|
104
|
-
ColorMap.setup
|
105
|
-
|
106
|
-
# Create the window to be associated with the form
|
107
|
-
# Un post form and free the memory
|
108
|
-
|
109
|
-
catch(:close) do
|
110
|
-
# $log.debug "START ---------"
|
111
|
-
# need to pass a form, not window.
|
112
|
-
r = 1; c = 2; i=0
|
113
|
-
attr = Ncurses::A_NORMAL
|
114
|
-
@window.printstring 20, c, "press 0-9 to change BG color, F1/q to quit. r-everse, n-ormal,b-old ", ColorMap.get_color('white')
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
while((ch = @window.getchar()) != FFI::NCurses::KEY_F1 )
|
119
|
-
next if ch == -1
|
120
|
-
break if ch == ?q.getbyte(0)
|
121
|
-
case ch
|
122
|
-
when ?r.getbyte(0)
|
123
|
-
attr |= Ncurses::A_REVERSE
|
124
|
-
when ?b.getbyte(0)
|
125
|
-
attr |= Ncurses::A_BOLD
|
126
|
-
when ?n.getbyte(0)
|
127
|
-
attr = Ncurses::A_NORMAL
|
128
|
-
when ?u.getbyte(0)
|
129
|
-
attr |= Ncurses::A_UNDERLINE
|
130
|
-
else
|
131
|
-
i = ch.chr.to_i
|
132
|
-
i = 1 if i > ColorMap::colors.length-1
|
133
|
-
end
|
134
|
-
bg = ColorMap::colors[i]
|
135
|
-
@@colors = %w[black red green yellow blue magenta cyan white]
|
136
|
-
@window.printstring r, c, "%-40s" % "red #{bg} ", ColorMap.get_color('red',bg) , attr
|
137
|
-
@window.printstring 2, c, "%-40s" % "blue #{bg} ", ColorMap.get_color('blue',bg) , attr
|
138
|
-
@window.printstring 3, c, "%-40s" % "white #{bg} ", ColorMap.get_color('white',bg) , attr
|
139
|
-
@window.printstring 4, c, "%-40s" % "green #{bg} ", ColorMap.get_color('green',bg) , attr
|
140
|
-
@window.printstring 5, c, "%-40s" % "cyan #{bg} ", ColorMap.get_color('cyan',bg) , attr
|
141
|
-
@window.printstring 6, c, "%-40s" % "magenta #{bg} ", ColorMap.get_color('magenta',bg) , attr
|
142
|
-
@window.printstring 7, c, "black #{bg} ", ColorMap.get_color('black',bg) , attr
|
143
|
-
@window.wrefresh
|
144
|
-
end
|
145
|
-
# VER::Keyboard.focus = tp
|
146
|
-
end
|
147
|
-
rescue => ex
|
148
|
-
ensure
|
149
|
-
# @panel = @window.panel if @window
|
150
|
-
# Ncurses::Panel.del_panel(@panel) if !@panel.nil?
|
151
|
-
# @window.delwin if !@window.nil?
|
152
|
-
@window.destroy unless @window.nil?
|
153
|
-
VER::stop_ncurses
|
154
|
-
p ex if ex
|
155
|
-
p(ex.backtrace.join("\n")) if ex
|
156
|
-
# $log.debug( ex) if ex
|
157
|
-
# $log.debug(ex.backtrace.join("\n")) if ex
|
158
|
-
end
|
159
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
module RubyCurses
|
2
|
-
|
3
|
-
##
|
4
|
-
# This is a list cell renderer that will render combo boxes.
|
5
|
-
# Since a combo box extends a field therefore the repaint of field is used.
|
6
|
-
# In other words there is nothing much to do here.
|
7
|
-
#
|
8
|
-
class ComboBoxCellRenderer < ListCellRenderer
|
9
|
-
include ConfigSetup
|
10
|
-
include RubyCurses::Utils
|
11
|
-
|
12
|
-
def initialize text="", config={}, &block
|
13
|
-
@text = text
|
14
|
-
@editable = false
|
15
|
-
@focusable = false
|
16
|
-
config_setup config # @config.each_pair { |k,v| variable_set(k,v) }
|
17
|
-
instance_eval &block if block_given?
|
18
|
-
init_vars
|
19
|
-
end
|
20
|
-
## me thinks this is unused
|
21
|
-
def getvalue
|
22
|
-
raise "I think this is unused. comboboxcellrenderer line 36"
|
23
|
-
@text
|
24
|
-
end
|
25
|
-
|
26
|
-
##
|
27
|
-
#
|
28
|
-
# ADD HERE
|
29
|
-
end
|
30
|
-
end
|