canis 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -9
- data/CHANGES +3 -0
- data/README.md +5 -3
- data/examples/alpmenu.rb +9 -5
- data/examples/app.sample +2 -2
- data/examples/appemail.rb +15 -15
- data/examples/atree.rb +7 -7
- data/examples/bline.rb +19 -19
- data/examples/common/devel.rb +3 -3
- data/examples/dbdemo.rb +53 -49
- data/examples/dirtree.rb +22 -19
- data/examples/newtabbedwindow.rb +5 -5
- data/examples/newtesttabp.rb +3 -3
- data/examples/tabular.rb +11 -11
- data/examples/tasks.rb +25 -25
- data/examples/term2.rb +8 -8
- data/examples/testbuttons.rb +24 -24
- data/examples/testcombo.rb +5 -5
- data/examples/testdb.rb +6 -6
- data/examples/testfields.rb +16 -16
- data/examples/testflowlayout.rb +3 -3
- data/examples/testkeypress.rb +5 -5
- data/examples/testlistbox.rb +18 -18
- data/examples/testlistbox1.rb +17 -17
- data/examples/testmessagebox.rb +5 -5
- data/examples/testprogress.rb +6 -6
- data/examples/testree.rb +3 -3
- data/examples/testsplitlayout.rb +4 -4
- data/examples/testsplitlayout1.rb +4 -4
- data/examples/teststacklayout.rb +4 -4
- data/examples/testwsshortcuts.rb +1 -1
- data/examples/testwsshortcuts2.rb +4 -4
- data/lib/canis/core/include/colorparser.rb +4 -4
- data/lib/canis/core/include/io.rb +3 -3
- data/lib/canis/core/include/layouts/abstractlayout.rb +3 -3
- data/lib/canis/core/include/layouts/flowlayout.rb +2 -2
- data/lib/canis/core/include/layouts/stacklayout.rb +3 -3
- data/lib/canis/core/system/colormap.rb +3 -3
- data/lib/canis/core/system/window.rb +7 -4
- data/lib/canis/core/util/extras/padreader.rb +2 -2
- data/lib/canis/core/util/rcommandwindow.rb +8 -4
- data/lib/canis/core/util/rdialogs.rb +1 -1
- data/lib/canis/core/util/widgetshortcuts.rb +9 -2
- data/lib/canis/core/widgets/applicationheader.rb +6 -2
- data/lib/canis/core/widgets/divider.rb +6 -2
- data/lib/canis/core/widgets/rmenu.rb +8 -4
- data/lib/canis/core/widgets/rmessagebox.rb +2 -2
- data/lib/canis/core/widgets/rwidget.rb +15 -15
- data/lib/canis/core/widgets/scrollbar.rb +5 -2
- data/lib/canis/core/widgets/table.rb +2 -2
- data/lib/canis/core/widgets/textpad.rb +8 -8
- data/lib/canis/core/widgets/tree.rb +57 -39
- data/lib/canis/core/widgets/tree/treecellrenderer.rb +3 -3
- data/lib/canis/version.rb +1 -1
- metadata +12 -13
- data/lib/canis/core/include/.DS_Store +0 -0
@@ -42,20 +42,19 @@ module Canis
|
|
42
42
|
# structures {{{
|
43
43
|
TreeSelectionEvent = Struct.new(:node, :tree, :state, :previous_node, :row_first)
|
44
44
|
# structures }}}
|
45
|
-
|
45
|
+
# renderer {{{
|
46
46
|
#
|
47
47
|
# TODO see how jtable does the renderers and columns stuff.
|
48
48
|
#
|
49
49
|
# perhaps we can combine the two but have different methods or some flag
|
50
50
|
# that way oter methods can be shared
|
51
51
|
class DefaultTreeRenderer < AbstractTextPadRenderer
|
52
|
-
|
53
52
|
attr_accessor :icon_can_collapse, :icon_can_expand, :icon_not_visited, :icon_no_children
|
54
53
|
attr_accessor :row_selected_attr
|
55
54
|
|
56
|
-
PLUS_PLUS
|
57
|
-
PLUS_MINUS = "+-"
|
58
|
-
PLUS_Q = "+?"
|
55
|
+
PLUS_PLUS = "++".freeze
|
56
|
+
PLUS_MINUS = "+-".freeze
|
57
|
+
PLUS_Q = "+?".freeze
|
59
58
|
# source is the textpad or extending widget needed so we can call show_colored_chunks
|
60
59
|
# if the user specifies column wise colors
|
61
60
|
def initialize source
|
@@ -65,24 +64,25 @@ module Canis
|
|
65
64
|
@color_pair = $datacolor
|
66
65
|
@attrib = NORMAL
|
67
66
|
@_check_coloring = nil
|
68
|
-
@icon_can_collapse =
|
69
|
-
@icon_can_expand =
|
70
|
-
@icon_not_visited =
|
71
|
-
@icon_no_children = "+-"
|
72
|
-
|
67
|
+
@icon_can_collapse = PLUS_MINUS
|
68
|
+
@icon_can_expand = PLUS_PLUS
|
69
|
+
@icon_not_visited = PLUS_Q
|
70
|
+
@icon_no_children = "+-" # how about '+|'
|
73
71
|
# adding setting column_model auto on 2014-04-10 - 10:53 why wasn;t this here already
|
74
72
|
#tree_model(source.tree_model)
|
75
73
|
end
|
74
|
+
|
76
75
|
# set fg and bg color of content rows, default is $datacolor (white on black).
|
77
76
|
def content_colors fg, bg
|
78
77
|
@color = fg
|
79
78
|
@bgcolor = bg
|
80
79
|
@color_pair = get_color($datacolor, fg, bg)
|
81
80
|
end
|
81
|
+
|
82
82
|
def content_attrib att
|
83
83
|
@attrib = att
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
# @param pad for calling print methods on
|
87
87
|
# @param lineno the line number on the pad to print on
|
88
88
|
# @param text data to print
|
@@ -112,15 +112,14 @@ module Canis
|
|
112
112
|
raise "attrib is nil in tree render 104" unless att
|
113
113
|
raise "color pair is nil in tree render 104" unless cp
|
114
114
|
# added for selection, but will crash if selection is not extended !!! XXX
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
115
|
+
if @source.is_row_selected? lineno
|
116
|
+
att = @row_selected_attr || $row_selected_attr
|
117
|
+
# FIXME currentl this overflows into next row
|
118
|
+
end
|
119
119
|
|
120
120
|
FFI::NCurses.wattron(pad,FFI::NCurses.COLOR_PAIR(cp) | att)
|
121
121
|
FFI::NCurses.mvwaddstr(pad, lineno, 0, _value)
|
122
122
|
FFI::NCurses.wattroff(pad,FFI::NCurses.COLOR_PAIR(cp) | att)
|
123
|
-
|
124
123
|
end
|
125
124
|
# check if we need to individually color columns or we can do the entire
|
126
125
|
# row in one shot
|
@@ -157,20 +156,26 @@ module Canis
|
|
157
156
|
require 'canis/core/include/listoperations'
|
158
157
|
|
159
158
|
class Tree < TextPad
|
160
|
-
|
161
159
|
include Canis::ListOperations
|
162
160
|
|
161
|
+
TREE_EVENTS = [:ENTER_ROW,
|
162
|
+
:LEAVE_ROW,
|
163
|
+
:TREE_COLLAPSED_EVENT,
|
164
|
+
:TREE_EXPANDED_EVENT,
|
165
|
+
:TREE_SELECTION_EVENT,
|
166
|
+
:TREE_WILL_COLLAPSE_EVENT,
|
167
|
+
:TREE_WILL_EXPAND_EVENT]
|
168
|
+
|
163
169
|
dsl_accessor :print_footer
|
164
|
-
attr_reader :treemodel
|
170
|
+
attr_reader :treemodel
|
165
171
|
dsl_accessor :default_value # node to show as selected - what if user doesn't have it?
|
166
172
|
|
167
173
|
def initialize form = nil, config={}, &block
|
168
|
-
|
169
174
|
@_header_adjustment = 0 #1
|
170
175
|
@col_min_width = 3
|
171
176
|
|
172
177
|
@expanded_state = {}
|
173
|
-
register_events(
|
178
|
+
register_events(TREE_EVENTS)
|
174
179
|
super
|
175
180
|
#@_events.push(*[:ENTER_ROW, :LEAVE_ROW, :TREE_COLLAPSED_EVENT, :TREE_EXPANDED_EVENT, :TREE_SELECTION_EVENT, :TREE_WILL_COLLAPSE_EVENT, :TREE_WILL_EXPAND_EVENT])
|
176
181
|
create_default_renderer unless @renderer # 2014-04-10 - 11:01
|
@@ -183,9 +188,11 @@ module Canis
|
|
183
188
|
@list_selection_model = nil
|
184
189
|
@list_selection_model = Canis::DefaultListSelectionModel.new self
|
185
190
|
end
|
191
|
+
|
186
192
|
def create_default_renderer
|
187
|
-
renderer
|
193
|
+
renderer DefaultTreeRenderer.new(self)
|
188
194
|
end
|
195
|
+
|
189
196
|
def init_vars
|
190
197
|
# show_selector and symbol etc unused
|
191
198
|
if @show_selector
|
@@ -199,8 +206,8 @@ module Canis
|
|
199
206
|
@internal_width = 2 # taking into account borders accounting for 2 cols
|
200
207
|
@internal_width = 0 if @suppress_borders # should it be 0 ???
|
201
208
|
super
|
202
|
-
|
203
209
|
end
|
210
|
+
|
204
211
|
# maps keys to methods
|
205
212
|
# checks @key_map can be :emacs or :vim.
|
206
213
|
def map_keys
|
@@ -223,6 +230,7 @@ module Canis
|
|
223
230
|
#require 'canis/core/include/listbindings'
|
224
231
|
#bindings
|
225
232
|
end
|
233
|
+
|
226
234
|
# Returns root if no argument given.
|
227
235
|
# Now we return root if already set
|
228
236
|
# Made node nillable so we can return root.
|
@@ -242,7 +250,6 @@ module Canis
|
|
242
250
|
# pass data to create this tree model
|
243
251
|
# used to be list
|
244
252
|
def data alist=nil
|
245
|
-
|
246
253
|
# if nothing passed, print an empty root, rather than crashing
|
247
254
|
alist = [] if alist.nil?
|
248
255
|
@data = alist # data given by user
|
@@ -276,6 +283,7 @@ module Canis
|
|
276
283
|
fire_dimension_changed
|
277
284
|
self
|
278
285
|
end
|
286
|
+
|
279
287
|
# private, for use by repaint
|
280
288
|
def _list
|
281
289
|
if @_structure_changed
|
@@ -290,6 +298,7 @@ module Canis
|
|
290
298
|
end
|
291
299
|
return @list
|
292
300
|
end
|
301
|
+
|
293
302
|
# repaint whenever a change heppens
|
294
303
|
# 2014-04-16 - 22:31 - I need to put a call to _list somewhere whenever a change happens
|
295
304
|
# (i.e. recreate list from the tree model object)..
|
@@ -298,20 +307,23 @@ module Canis
|
|
298
307
|
_list()
|
299
308
|
super
|
300
309
|
end
|
310
|
+
|
301
311
|
def convert_to_list tree
|
302
312
|
@list = @native_text = get_expanded_descendants(tree.root)
|
303
313
|
#$log.debug "XXX convert #{tree.root.children.size} "
|
304
314
|
#$log.debug " converted tree to list. #{@list.size} "
|
305
315
|
end
|
316
|
+
|
306
317
|
def traverse node, level=0, &block
|
307
318
|
raise "disuse"
|
308
319
|
#icon = node.is_leaf? ? "-" : "+"
|
309
320
|
#puts "%*s %s" % [ level+1, icon, node.user_object ]
|
310
321
|
yield node, level if block_given?
|
311
|
-
node.children.each do |e|
|
322
|
+
node.children.each do |e|
|
312
323
|
traverse e, level+1, &block
|
313
324
|
end
|
314
325
|
end
|
326
|
+
|
315
327
|
# return object under cursor
|
316
328
|
# Note: this should not be confused with selected row/s. User may not have selected this.
|
317
329
|
# This is only useful since in some demos we like to change a status bar as a user scrolls down
|
@@ -338,6 +350,7 @@ module Canis
|
|
338
350
|
toggle_row_selection
|
339
351
|
@default_value = nil
|
340
352
|
end
|
353
|
+
|
341
354
|
### START FOR scrollable ###
|
342
355
|
def get_content
|
343
356
|
#@list 2008-12-01 23:13
|
@@ -345,9 +358,11 @@ module Canis
|
|
345
358
|
# called by next_match in listscrollable
|
346
359
|
@list
|
347
360
|
end
|
361
|
+
|
348
362
|
def get_window
|
349
363
|
@graphic
|
350
364
|
end
|
365
|
+
|
351
366
|
### END FOR scrollable ###
|
352
367
|
# override widgets text
|
353
368
|
def getvalue
|
@@ -367,8 +382,6 @@ module Canis
|
|
367
382
|
#------- data modification methods ------#
|
368
383
|
|
369
384
|
|
370
|
-
#
|
371
|
-
|
372
385
|
## add a row to the table
|
373
386
|
# The name add will be removed soon, pls use << instead.
|
374
387
|
def <<( array)
|
@@ -424,7 +437,7 @@ module Canis
|
|
424
437
|
ha = @_header_adjustment
|
425
438
|
# ha takes into account whether there are headers or not
|
426
439
|
footer = "#{@current_index+1-ha} of #{@list.length-ha} "
|
427
|
-
@graphic.printstring(
|
440
|
+
@graphic.printstring(@row + @height -1 , @col+2, footer, @color_pair || $datacolor, @footer_attrib)
|
428
441
|
@repaint_footer_required = false
|
429
442
|
end
|
430
443
|
def is_row_selected? row=@current_index
|
@@ -477,18 +490,20 @@ module Canis
|
|
477
490
|
expand_node node
|
478
491
|
end
|
479
492
|
end
|
493
|
+
|
480
494
|
def row_to_node row=@current_index
|
481
495
|
@list[row]
|
482
496
|
end
|
497
|
+
|
483
498
|
# convert a given node to row
|
484
499
|
def node_to_row node
|
485
500
|
crow = nil
|
486
|
-
@list.each_with_index
|
501
|
+
@list.each_with_index do |e,i|
|
487
502
|
if e == node
|
488
503
|
crow = i
|
489
504
|
break
|
490
505
|
end
|
491
|
-
|
506
|
+
end
|
492
507
|
crow
|
493
508
|
end
|
494
509
|
# private
|
@@ -530,9 +545,9 @@ module Canis
|
|
530
545
|
def mark_parents_expanded node
|
531
546
|
# i am setting parents as expanded, but NOT firing handlers - XXX separate this into expand_parents
|
532
547
|
_path = node.tree_path
|
533
|
-
_path.each do |e|
|
548
|
+
_path.each do |e|
|
534
549
|
# if already expanded parent then break we should break
|
535
|
-
set_expanded_state(e, true)
|
550
|
+
set_expanded_state(e, true)
|
536
551
|
end
|
537
552
|
end
|
538
553
|
# goes up to root of this node, and expands down to this node
|
@@ -540,7 +555,7 @@ module Canis
|
|
540
555
|
# as in a dir listing when current dir is deep in heirarchy.
|
541
556
|
def expand_parents node
|
542
557
|
_path = node.tree_path
|
543
|
-
_path.each do |e|
|
558
|
+
_path.each do |e|
|
544
559
|
# if already expanded parent then break we should break
|
545
560
|
#set_expanded_state(e, true)
|
546
561
|
expand_node(e)
|
@@ -590,17 +605,19 @@ module Canis
|
|
590
605
|
goto_parent node
|
591
606
|
collapse_node parent
|
592
607
|
end
|
608
|
+
|
593
609
|
def goto_parent node=:current_index
|
594
610
|
node = row_to_node if node == :current_index
|
595
611
|
parent = node.parent
|
596
612
|
return if parent.nil?
|
597
613
|
crow = @current_index
|
598
|
-
|
614
|
+
# TODO we have beautiful ruby stuff to do that! (find)
|
615
|
+
@list.each_with_index do |e,i|
|
599
616
|
if e == parent
|
600
617
|
crow = i
|
601
618
|
break
|
602
619
|
end
|
603
|
-
|
620
|
+
end
|
604
621
|
@repaint_required = true
|
605
622
|
#set_form_row # will not work if off form
|
606
623
|
#set_focus_on crow
|
@@ -656,26 +673,27 @@ module Canis
|
|
656
673
|
$log.debug "TREE #{user_path} " if $log.debug?
|
657
674
|
root = @treemodel.root
|
658
675
|
found = nil
|
659
|
-
user_path.each
|
676
|
+
user_path.each do |e|
|
660
677
|
success = false
|
661
|
-
root.children.each
|
678
|
+
root.children.each do |c|
|
662
679
|
if c.user_object == e
|
663
680
|
found = c
|
664
681
|
success = true
|
665
682
|
root = c
|
666
683
|
break
|
667
684
|
end
|
668
|
-
|
685
|
+
end
|
669
686
|
return false unless success
|
670
|
-
|
671
|
-
}
|
687
|
+
end
|
672
688
|
return found
|
673
689
|
end
|
690
|
+
|
674
691
|
# default block
|
675
692
|
# @since 1.5.0 2011-11-22
|
676
693
|
def command *args, &block
|
677
694
|
bind :TREE_WILL_EXPAND_EVENT, *args, &block
|
678
695
|
end
|
696
|
+
|
679
697
|
private
|
680
698
|
# please do not rely on this yet, name could change
|
681
699
|
def _structure_changed tf=true
|
@@ -75,9 +75,9 @@ module Canis
|
|
75
75
|
# when field is focussed again
|
76
76
|
#
|
77
77
|
# @param [Buffer] window or buffer object used for printing
|
78
|
-
# @param [
|
79
|
-
# @param [
|
80
|
-
# @param [
|
78
|
+
# @param [Integer] row
|
79
|
+
# @param [Integer] column
|
80
|
+
# @param [Integer] actual index into data, some lists may have actual data elsewhere and
|
81
81
|
# display data separate. e.g. rfe_renderer (directory listing)
|
82
82
|
# @param [String] text to print in cell
|
83
83
|
# @param [Boolean, :SOFT_FOCUS] cell focussed, not focussed, cell focussed but field is not focussed
|
data/lib/canis/version.rb
CHANGED
metadata
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kepler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.9.6
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.9.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: ffi-ncurses
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.4.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.4.0
|
55
55
|
description: ruby ncurses library for easy application development providing most
|
@@ -60,7 +60,7 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
- .gitignore
|
63
|
+
- ".gitignore"
|
64
64
|
- CHANGES
|
65
65
|
- Gemfile
|
66
66
|
- LICENSE.txt
|
@@ -120,7 +120,6 @@ files:
|
|
120
120
|
- lib/canis/core/docs/table.txt
|
121
121
|
- lib/canis/core/docs/textpad.txt
|
122
122
|
- lib/canis/core/docs/tree.txt
|
123
|
-
- lib/canis/core/include/.DS_Store
|
124
123
|
- lib/canis/core/include/action.rb
|
125
124
|
- lib/canis/core/include/actionmanager.rb
|
126
125
|
- lib/canis/core/include/appmethods.rb
|
@@ -212,17 +211,17 @@ require_paths:
|
|
212
211
|
- lib
|
213
212
|
required_ruby_version: !ruby/object:Gem::Requirement
|
214
213
|
requirements:
|
215
|
-
- -
|
214
|
+
- - ">="
|
216
215
|
- !ruby/object:Gem::Version
|
217
216
|
version: '0'
|
218
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
218
|
requirements:
|
220
|
-
- -
|
219
|
+
- - ">="
|
221
220
|
- !ruby/object:Gem::Version
|
222
221
|
version: '0'
|
223
222
|
requirements: []
|
224
223
|
rubyforge_project:
|
225
|
-
rubygems_version: 2.
|
224
|
+
rubygems_version: 2.6.8
|
226
225
|
signing_key:
|
227
226
|
specification_version: 4
|
228
227
|
summary: ruby ncurses library for easy application development
|
Binary file
|