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,281 +0,0 @@
|
|
1
|
-
require 'rbcurse/rscrollform'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
# See tabbed pane, and add_cols nad add_rows, on_entr and set_form_row to see cursor issue
|
5
|
-
# remove main form
|
6
|
-
# don't make a widget just an object
|
7
|
-
# let it create own form.
|
8
|
-
|
9
|
-
# NOTE: experimental, not yet firmed up
|
10
|
-
# If you use in application, please copy to some application folder in case i change this.
|
11
|
-
# Can be used for print_help_page
|
12
|
-
# SUGGESTIONS WELCOME.
|
13
|
-
# @since 1.4.1
|
14
|
-
module RubyCurses
|
15
|
-
|
16
|
-
class ResultsetBrowser #< Widget
|
17
|
-
#include EventHandler
|
18
|
-
include ConfigSetup
|
19
|
-
include RubyCurses::Utils
|
20
|
-
#dsl_property :xxx
|
21
|
-
# I don't think width is actually used, windows width matters. What of height ?
|
22
|
-
# THATS WRONG , i cannot eat up window. I should use object dimentsion for pad,
|
23
|
-
# not window dimensions
|
24
|
-
dsl_accessor :row, :col, :height, :width
|
25
|
-
dsl_accessor :should_print_border
|
26
|
-
|
27
|
-
def initialize win, config={}, &block
|
28
|
-
@should_print_border = true
|
29
|
-
@v_window = win #form.window
|
30
|
-
@window = @v_window
|
31
|
-
@focusable = true
|
32
|
-
@editable = true
|
33
|
-
@old_index = @current_index = 0
|
34
|
-
@fields = nil
|
35
|
-
config_setup config
|
36
|
-
instance_eval &block if block_given?
|
37
|
-
init_vars
|
38
|
-
end
|
39
|
-
def map_keys
|
40
|
-
@v_form.bind_key(?\C-n) { @current_index += 1 if @current_index < @rows.count-1 }
|
41
|
-
@v_form.bind_key(?\C-p) { @current_index -= 1 if @current_index > 0 }
|
42
|
-
@mapped = true
|
43
|
-
end
|
44
|
-
def init_vars
|
45
|
-
@row ||= 0
|
46
|
-
@col ||= 0
|
47
|
-
@height ||= 15
|
48
|
-
@width ||= 50
|
49
|
-
@field_offset = 14 # where actual Field should start (leaving space for label)
|
50
|
-
@row_offset ||= 0
|
51
|
-
@col_offset ||= 1
|
52
|
-
@border_offset = 0
|
53
|
-
if @should_print_border
|
54
|
-
@border_offset = 1
|
55
|
-
end
|
56
|
-
@v_form = RubyCurses::ScrollForm.new @v_window
|
57
|
-
@v_form.display_h(@height-1-@border_offset*2) if @height
|
58
|
-
@v_form.display_w(@width-1-@border_offset*2) if @width
|
59
|
-
end
|
60
|
-
def data=(rows)
|
61
|
-
@rows = rows
|
62
|
-
end
|
63
|
-
def columns=(columns)
|
64
|
-
@columns = columns
|
65
|
-
h = @columns.count + 2
|
66
|
-
w = 150
|
67
|
-
#row = 1
|
68
|
-
#col = 1
|
69
|
-
row = @row + @border_offset
|
70
|
-
col = @col + @border_offset
|
71
|
-
@v_form.set_pad_dimensions(row, col, h, w)
|
72
|
-
@v_form.should_print_border(false) # this should use dimensions of object not window. # 2011-10-12 15:48:14
|
73
|
-
# currently I don't have space for any buttons or anything. The form takes all space of the window
|
74
|
-
# not of the object defined.
|
75
|
-
# I should be able to tell Scrollform to use only thismuch of window.
|
76
|
-
end
|
77
|
-
def set_form_row
|
78
|
-
f = @v_form.get_current_field
|
79
|
-
f.set_form_row
|
80
|
-
end
|
81
|
-
def handle_key ch
|
82
|
-
map_keys unless @mapped
|
83
|
-
$log.debug "XXX: RB HK got ch "
|
84
|
-
ret = @v_form.handle_key ch
|
85
|
-
#set_form_row
|
86
|
-
if ret == :UNHANDLED
|
87
|
-
@v_form.process_key ch, self
|
88
|
-
end
|
89
|
-
repaint
|
90
|
-
@v_window.wrefresh
|
91
|
-
end
|
92
|
-
def repaint
|
93
|
-
@fields ||= _create_fields
|
94
|
-
#alert "old #{@old_index} , #{@current_index} "
|
95
|
-
if @old_index != @current_index
|
96
|
-
#alert "index change"
|
97
|
-
row = @rows[@current_index]
|
98
|
-
@columns.each_with_index { |e, i|
|
99
|
-
value = row[i]
|
100
|
-
len = value.to_s.length
|
101
|
-
type=@rows[0].types[i]
|
102
|
-
if type == "TEXT"
|
103
|
-
value = value.gsub(/\n/," ") if value
|
104
|
-
end
|
105
|
-
f = @fields[i]
|
106
|
-
@fields[i].set_buffer(value)
|
107
|
-
if f.display_length < len && len < (@width - @field_offset)
|
108
|
-
@fields[i].display_length len
|
109
|
-
end
|
110
|
-
}
|
111
|
-
@v_form.repaint
|
112
|
-
@window.wrefresh
|
113
|
-
Ncurses::Panel.update_panels
|
114
|
-
@old_index = @current_index
|
115
|
-
end
|
116
|
-
end
|
117
|
-
# maybe not required since we don't have 2 forms now
|
118
|
-
def unused_on_enter
|
119
|
-
if $current_key == KEY_BTAB
|
120
|
-
c = @v_form.widgets.count-1
|
121
|
-
@v_form.select_field c
|
122
|
-
else
|
123
|
-
@v_form.select_field 0
|
124
|
-
end
|
125
|
-
end
|
126
|
-
private
|
127
|
-
def _create_fields
|
128
|
-
color = $datacolor
|
129
|
-
if @should_print_border
|
130
|
-
@v_window.print_border @row, @col, @height-1, @width, color #, Ncurses::A_REVERSE
|
131
|
-
@row_offset += 1
|
132
|
-
@col_offset += 1
|
133
|
-
end
|
134
|
-
$log.debug "XXX: ROWS#{@rows}"
|
135
|
-
$log.debug "XXX: COLS#{@columns}"
|
136
|
-
$log.debug "XXX: row#{@rows[@current_index]}"
|
137
|
-
fields = []
|
138
|
-
r = @row + @row_offset # row was for where to print the total object, not this
|
139
|
-
c = @col + @col_offset + @field_offset # 14 is to leave space for labels
|
140
|
-
v_form = @v_form
|
141
|
-
@columns.each_with_index { |e, index|
|
142
|
-
#break if index >= @height-1 # create only as much space we have, SUCKS but just trying till be scroll
|
143
|
-
#$log.debug "XXX: #{r} #{c} EACH #{e}, #{index}, #{@rows[@current_index][index]}"
|
144
|
-
value=@rows[@current_index][index]
|
145
|
-
type=@rows[0].types[index]
|
146
|
-
if type == "TEXT"
|
147
|
-
value = value.gsub(/\n/," ") if value
|
148
|
-
end
|
149
|
-
len = [value.to_s.length, (@width - @field_offset)].min
|
150
|
-
f = Field.new v_form do
|
151
|
-
name e
|
152
|
-
row r
|
153
|
-
col c
|
154
|
-
bgcolor 'blue'
|
155
|
-
highlight_background 'cyan'
|
156
|
-
set_buffer value
|
157
|
-
display_length len
|
158
|
-
set_label Label.new v_form, {'text' => e, 'color'=>'cyan'}
|
159
|
-
end
|
160
|
-
fields << f
|
161
|
-
r += 1
|
162
|
-
}
|
163
|
-
@v_form.repaint
|
164
|
-
@window.wrefresh
|
165
|
-
Ncurses::Panel.update_panels
|
166
|
-
#$log.debug "XXX: created fields "
|
167
|
-
return fields
|
168
|
-
end
|
169
|
-
|
170
|
-
# ADD HERE
|
171
|
-
|
172
|
-
end # class
|
173
|
-
end # module
|
174
|
-
module RubyCurses
|
175
|
-
# a data viewer for viewing some text or filecontents
|
176
|
-
# view filename, :close_key => KEY_RETURN
|
177
|
-
# send data in an array
|
178
|
-
# view Array, :close_key => KEY_RETURN, :layout => [0,0,23,80]
|
179
|
-
# when passing layout reserve 4 rows for window and border. So for 2 lines of text
|
180
|
-
# give 6 rows.
|
181
|
-
class Browser
|
182
|
-
def self.browse_sql dbname, tablename, sql, config={} #:yield: ???
|
183
|
-
raise "file not found" unless File.exist? dbname
|
184
|
-
require 'sqlite3'
|
185
|
-
db = SQLite3::Database.new(dbname)
|
186
|
-
columns, *rows = db.execute2(sql)
|
187
|
-
#$log.debug "XXX COLUMNS #{sql} "
|
188
|
-
content = rows
|
189
|
-
return nil if content.nil? or content[0].nil?
|
190
|
-
datatypes = content[0].types
|
191
|
-
self.browse db, tablename, columns, rows, config
|
192
|
-
end
|
193
|
-
# @param filename as string or content as array
|
194
|
-
# @yield textview object for further configuration before display
|
195
|
-
# NOTE: i am experimentally yielding textview object so i could supress borders
|
196
|
-
# just for kicks, but on can also bind_keys or events if one wanted.
|
197
|
-
#def self.view what, config={} #:yield: textview
|
198
|
-
def self.browse dbconn, tablename, columns, rows, config={} #:yield: ???
|
199
|
-
wt = 0 # top margin
|
200
|
-
wl = 0 # left margin
|
201
|
-
wh = Ncurses.LINES-wt-3 # height, goes to bottom of screen
|
202
|
-
ww = Ncurses.COLS-wl-3 # width, goes to right end
|
203
|
-
wt, wl, wh, ww = config[:layout] if config.has_key? :layout
|
204
|
-
|
205
|
-
fp = config[:title] || ""
|
206
|
-
pf = config.fetch(:print_footer, true)
|
207
|
-
ta = config.fetch(:title_attrib, 'bold')
|
208
|
-
fa = config.fetch(:footer_attrib, 'bold')
|
209
|
-
|
210
|
-
wh = Ncurses.LINES-0
|
211
|
-
ww = Ncurses.COLS-0
|
212
|
-
layout = { :height => wh, :width => ww, :top => wt, :left => wl }
|
213
|
-
#v_window = config[:window] # using previous window cause crash seg fault
|
214
|
-
#v_window ||= VER::Window.new(layout) # copywin gives -1 and prints nothing
|
215
|
-
v_window = VER::Window.root_window
|
216
|
-
v_window.printstring 0, 30, "Database Browser Demo", $datacolor
|
217
|
-
@form = RubyCurses::Form.new v_window # only for some widgets that are not editable
|
218
|
-
header = app_header "rbcurse ", :text_center => "ResultsetBrowser Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
|
219
|
-
sl = status_line :row => v_window.height == 0 ? Ncurses.LINES-1 : v.window.height-1
|
220
|
-
sl.command { "Record Navigation: C-n C-p. Scrolling M-n, M-p, M-l, M-h" }
|
221
|
-
|
222
|
-
@form.repaint
|
223
|
-
|
224
|
-
#rb = ResultsetBrowser.new v_form, :row => 2, :col => 2
|
225
|
-
rb = ResultsetBrowser.new v_window, :row => 2, :col => 2, :height => 20, :width => 95
|
226
|
-
rb.columns = columns
|
227
|
-
rb.data = rows
|
228
|
-
rb.repaint
|
229
|
-
|
230
|
-
|
231
|
-
# yielding textview so you may further configure or bind keys or events
|
232
|
-
begin
|
233
|
-
#v_form.repaint
|
234
|
-
v_window.wrefresh
|
235
|
-
Ncurses::Panel.update_panels
|
236
|
-
# allow closing using q and Ctrl-q in addition to any key specified
|
237
|
-
# user should not need to specify key, since that becomes inconsistent across usages
|
238
|
-
while((ch = v_window.getchar()) != ?\C-q.getbyte(0) )
|
239
|
-
break if ch == config[:close_key]
|
240
|
-
rb.handle_key ch
|
241
|
-
#v_form.handle_key ch
|
242
|
-
end
|
243
|
-
rescue => err
|
244
|
-
$log.error err.to_s
|
245
|
-
$log.error err.backtrace.join("\n")
|
246
|
-
alert err.to_s
|
247
|
-
|
248
|
-
ensure
|
249
|
-
v_window.destroy if !v_window.nil?
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end # class
|
253
|
-
end # module
|
254
|
-
if __FILE__ == $PROGRAM_NAME
|
255
|
-
require 'rbcurse/app'
|
256
|
-
|
257
|
-
App.new do
|
258
|
-
header = app_header "rbcurse ", :text_center => "ResultsetBrowser Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
|
259
|
-
message "Press F10 to exit from here"
|
260
|
-
columns = ["Name","Age","City", "Country"]
|
261
|
-
data = [
|
262
|
-
[ "Rahul",31, "Delhi","India"],
|
263
|
-
[ "Dev",35, "Mumbai","India"],
|
264
|
-
[ "Jobs",56, "L.A","U.S.A"],
|
265
|
-
[ "Matz",40, "Tokyo","Nippon"]
|
266
|
-
]
|
267
|
-
|
268
|
-
#RubyCurses::Browser.browse("dummy", "atable", columns, data, :close_key => FFI::NCurses::KEY_F10, :title => "Enter to close") do |t|
|
269
|
-
sql = "select id, type, priority, title from bugs"
|
270
|
-
sql = "select * from bugs"
|
271
|
-
RubyCurses::Browser.browse_sql("../../../bugzy.sqlite", "bugs", sql, :close_key => FFI::NCurses::KEY_F10, :title => "Enter to close", :window => @window) do |t|
|
272
|
-
# you may configure textview further here.
|
273
|
-
#t.suppress_borders true
|
274
|
-
#t.color = :black
|
275
|
-
#t.bgcolor = :white
|
276
|
-
# or
|
277
|
-
#t.attr = :reverse
|
278
|
-
end
|
279
|
-
|
280
|
-
end # app
|
281
|
-
end
|
data/lib/rbcurse/extras/rlink.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'rbcurse'
|
2
|
-
##
|
3
|
-
module RubyCurses
|
4
|
-
class Link < Button
|
5
|
-
dsl_property :description
|
6
|
-
|
7
|
-
|
8
|
-
def initialize form, config={}, &block
|
9
|
-
super
|
10
|
-
@text_offset = 0
|
11
|
-
# haha we've never done this, pin the cursor up on 0,0
|
12
|
-
@col_offset = -1
|
13
|
-
if @mnemonic
|
14
|
-
form.bind_key(@mnemonic.downcase, self){ self.fire }
|
15
|
-
end
|
16
|
-
@display_length = config[:width]
|
17
|
-
end
|
18
|
-
def fire
|
19
|
-
super
|
20
|
-
self.focus
|
21
|
-
end
|
22
|
-
def getvalue_for_paint
|
23
|
-
getvalue()
|
24
|
-
end
|
25
|
-
##
|
26
|
-
end # class
|
27
|
-
end # module
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rbcurse/extras/rlink'
|
2
|
-
##
|
3
|
-
module RubyCurses
|
4
|
-
class MenuLink < Link
|
5
|
-
dsl_property :description
|
6
|
-
|
7
|
-
def initialize form, config={}, &block
|
8
|
-
super
|
9
|
-
@col_offset = -1 * @col
|
10
|
-
@row_offset = -1 * @row
|
11
|
-
end
|
12
|
-
# added for some standardization 2010-09-07 20:28
|
13
|
-
# alias :text :getvalue # NEXT VERSION
|
14
|
-
# change existing text to label
|
15
|
-
|
16
|
-
def getvalue_for_paint
|
17
|
-
"%s %-12s - %-s" % [ @mnemonic , getvalue(), @description ]
|
18
|
-
end
|
19
|
-
##
|
20
|
-
end # class
|
21
|
-
end # module
|
@@ -1,143 +0,0 @@
|
|
1
|
-
require 'rbcurse/app'
|
2
|
-
#include Ncurses # FFI 2011-09-8
|
3
|
-
include RubyCurses
|
4
|
-
|
5
|
-
# This paints a vertical white bar given row and col, and length. It also calculates and prints
|
6
|
-
# a small bar over this based on relaetd objects list.length and current_index.
|
7
|
-
# Typically, after setup one would keep updating only current_index from the repaint method
|
8
|
-
# of caller or in the traversal event. This would look best if the listbox also has a reverse video border, or none.
|
9
|
-
# @example
|
10
|
-
# lb = list_box ....
|
11
|
-
# sb = Scrollbar.new @form, :row => lb.row, :col => lb.col, :length => lb.height, :list_length => lb.row_count, :current_index => 0
|
12
|
-
# .... later as user traverses
|
13
|
-
# sb.current_index = lb.current_index
|
14
|
-
# sb = Scrollbar.new @form, :parent => list
|
15
|
-
#
|
16
|
-
# At a later stage, we will integrate this with lists and tables, so it will happen automatically.
|
17
|
-
#
|
18
|
-
# @since 1.2.0 UNTESTED
|
19
|
-
module RubyCurses
|
20
|
-
class Scrollbar < Widget
|
21
|
-
# row to start, same as listbox, required.
|
22
|
-
dsl_property :row
|
23
|
-
# column to start, same as listbox, required.
|
24
|
-
dsl_property :col
|
25
|
-
# how many rows is this (should be same as listboxes height, required.
|
26
|
-
dsl_property :length
|
27
|
-
# vertical or horizontal currently only VERTICAL
|
28
|
-
dsl_property :orientation
|
29
|
-
# initialize based on parent's values
|
30
|
-
dsl_property :parent
|
31
|
-
# which row is focussed, current_index of listbox, required.
|
32
|
-
dsl_property :current_index
|
33
|
-
# how many total rows of data does the list have, same as @list.length, required.
|
34
|
-
dsl_property :list_length
|
35
|
-
|
36
|
-
# TODO: if parent passed, we shold bind to ON_ENTER and get current_index, so no extra work is required.
|
37
|
-
|
38
|
-
def initialize form, config={}, &block
|
39
|
-
|
40
|
-
# setting default first or else Widget will place its BW default
|
41
|
-
#@color, @bgcolor = ColorMap.get_colors_for_pair $bottomcolor
|
42
|
-
super
|
43
|
-
@color_pair = get_color $datacolor, @color, @bgcolor
|
44
|
-
@scroll_pair = get_color $bottomcolor, :green, :white
|
45
|
-
#$log.debug "SCROLLBAR COLOR cp #{@color_pair} sp #{@scroll_pair} " if $log.debug?
|
46
|
-
@window = form.window
|
47
|
-
@editable = false
|
48
|
-
@focusable = false
|
49
|
-
@repaint_required = true
|
50
|
-
@orientation = :V
|
51
|
-
if @parent
|
52
|
-
@parent.bind :ENTER_ROW do |p|
|
53
|
-
# parent must implement row_count, and have a @current_index
|
54
|
-
raise StandardError, "Parent must implement row_count" unless p.respond_to? :row_count
|
55
|
-
self.current_index = p.current_index
|
56
|
-
@repaint_required = true #requred otherwise at end when same value sent, prop handler
|
57
|
-
# will not be fired (due to optimization).
|
58
|
-
end
|
59
|
-
# in some cases, on leaving a listbox or other component redraws itself to reduce
|
60
|
-
# selected or highlighted object, so the scrollbar gets overwritten. We need to repaint it.
|
61
|
-
@parent.bind :LEAVE do |p|
|
62
|
-
@repaint_required = true
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
##
|
68
|
-
# repaint the scrollbar
|
69
|
-
# Taking the data from parent as late as possible in case parent resized, or
|
70
|
-
# moved around by a container.
|
71
|
-
def repaint
|
72
|
-
if @parent
|
73
|
-
@row = @parent.row+1
|
74
|
-
@col = @parent.col + @parent.width - 1
|
75
|
-
@length = @parent.height - 2
|
76
|
-
@list_length = @parent.row_count
|
77
|
-
@current_index ||= @parent.current_index
|
78
|
-
@border_attrib ||= @parent.border_attrib
|
79
|
-
end
|
80
|
-
raise ArgumentError, "current_index must be provided" unless @current_index
|
81
|
-
raise ArgumentError, "list_length must be provided" unless @list_length
|
82
|
-
my_win = @form ? @form.window : @target_window
|
83
|
-
@graphic = my_win unless @graphic
|
84
|
-
return unless @repaint_required
|
85
|
-
|
86
|
-
# first print a right side vertical line
|
87
|
-
#bc = $bottomcolor # dark blue
|
88
|
-
bc = $datacolor
|
89
|
-
bordercolor = @border_color || bc
|
90
|
-
borderatt = @border_attrib || Ncurses::A_REVERSE
|
91
|
-
#$log.debug "SCROLL bordercolor #{bordercolor} , #{borderatt} " if $log.debug?
|
92
|
-
|
93
|
-
|
94
|
-
@graphic.attron(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
|
95
|
-
#$log.debug " XXX SCROLL #{@row} #{@col} #{@length} "
|
96
|
-
@graphic.mvvline(@row+0, @col, 1, @length-0)
|
97
|
-
@graphic.attroff(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
|
98
|
-
|
99
|
-
# now calculate and paint the scrollbar
|
100
|
-
pht = @length
|
101
|
-
listlen = @list_length * 1.0
|
102
|
-
@current_index = 0 if @current_index < 0
|
103
|
-
@current_index = listlen-1 if @current_index >= listlen
|
104
|
-
sclen = (pht/listlen)* @length
|
105
|
-
sclen = 1 if sclen < 1 # sometimes 0.7 for large lists 100 items 2011-10-1
|
106
|
-
scloc = (@current_index/listlen)* @length
|
107
|
-
scloc = (@length - sclen) if scloc > @length - sclen # don't exceed end
|
108
|
-
if @current_index == @list_length - 1
|
109
|
-
scloc = @length - sclen + 0 # earlier 1, but removed since sclen min 1 2011-10-1
|
110
|
-
end
|
111
|
-
@graphic.attron(Ncurses.COLOR_PAIR(@scroll_pair) | borderatt)
|
112
|
-
r = @row + scloc
|
113
|
-
c = @col + 0
|
114
|
-
#$log.debug " XXX SCROLLBAR #{r} #{c} #{sclen} "
|
115
|
-
@graphic.mvvline(r, c, 1, sclen)
|
116
|
-
@graphic.attroff(Ncurses.COLOR_PAIR(@scroll_pair) | borderatt)
|
117
|
-
@repaint_required = false
|
118
|
-
end
|
119
|
-
##
|
120
|
-
##
|
121
|
-
# ADD HERE
|
122
|
-
end
|
123
|
-
end
|
124
|
-
if __FILE__ == $PROGRAM_NAME
|
125
|
-
App.new do
|
126
|
-
r = 5
|
127
|
-
len = 20
|
128
|
-
list = []
|
129
|
-
0.upto(100) { |v| list << "#{v} scrollable data" }
|
130
|
-
lb = list_box "A list", :list => list
|
131
|
-
#sb = Scrollbar.new @form, :row => r, :col => 20, :length => len, :list_length => 50, :current_index => 0
|
132
|
-
rb = Scrollbar.new @form, :parent => lb
|
133
|
-
#hline :width => 20, :row => len+r
|
134
|
-
#keypress do |ch|
|
135
|
-
#case ch
|
136
|
-
#when :down
|
137
|
-
#sb.current_index += 1
|
138
|
-
#when :up
|
139
|
-
#sb.current_index -= 1
|
140
|
-
#end
|
141
|
-
#end
|
142
|
-
end
|
143
|
-
end
|