canis 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +45 -0
  3. data/CHANGES +52 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +24 -0
  7. data/Rakefile +2 -0
  8. data/canis.gemspec +25 -0
  9. data/examples/alpmenu.rb +46 -0
  10. data/examples/app.sample +19 -0
  11. data/examples/appemail.rb +191 -0
  12. data/examples/atree.rb +105 -0
  13. data/examples/bline.rb +181 -0
  14. data/examples/common/devel.rb +319 -0
  15. data/examples/common/file.rb +93 -0
  16. data/examples/data/README.markdown +9 -0
  17. data/examples/data/brew.txt +38 -0
  18. data/examples/data/color.2 +37 -0
  19. data/examples/data/gemlist.txt +59 -0
  20. data/examples/data/lotr.txt +12 -0
  21. data/examples/data/ports.txt +136 -0
  22. data/examples/data/table.txt +37 -0
  23. data/examples/data/tasks.csv +88 -0
  24. data/examples/data/tasks.txt +27 -0
  25. data/examples/data/todo.txt +16 -0
  26. data/examples/data/todocsv.csv +28 -0
  27. data/examples/data/unix1.txt +21 -0
  28. data/examples/data/unix2.txt +11 -0
  29. data/examples/dbdemo.rb +506 -0
  30. data/examples/dirtree.rb +177 -0
  31. data/examples/newtabbedwindow.rb +100 -0
  32. data/examples/newtesttabp.rb +92 -0
  33. data/examples/tabular.rb +212 -0
  34. data/examples/tasks.rb +179 -0
  35. data/examples/term2.rb +88 -0
  36. data/examples/testbuttons.rb +307 -0
  37. data/examples/testcombo.rb +102 -0
  38. data/examples/testdb.rb +182 -0
  39. data/examples/testfields.rb +208 -0
  40. data/examples/testflowlayout.rb +43 -0
  41. data/examples/testkeypress.rb +98 -0
  42. data/examples/testlistbox.rb +187 -0
  43. data/examples/testlistbox1.rb +199 -0
  44. data/examples/testmessagebox.rb +144 -0
  45. data/examples/testprogress.rb +116 -0
  46. data/examples/testree.rb +107 -0
  47. data/examples/testsplitlayout.rb +53 -0
  48. data/examples/testsplitlayout1.rb +49 -0
  49. data/examples/teststacklayout.rb +48 -0
  50. data/examples/testwsshortcuts.rb +68 -0
  51. data/examples/testwsshortcuts2.rb +129 -0
  52. data/lib/canis.rb +16 -0
  53. data/lib/canis/core/docs/index.txt +104 -0
  54. data/lib/canis/core/docs/list.txt +16 -0
  55. data/lib/canis/core/docs/style_help.yml +34 -0
  56. data/lib/canis/core/docs/tabbedpane.txt +15 -0
  57. data/lib/canis/core/docs/table.txt +31 -0
  58. data/lib/canis/core/docs/textpad.txt +48 -0
  59. data/lib/canis/core/docs/tree.txt +23 -0
  60. data/lib/canis/core/include/.DS_Store +0 -0
  61. data/lib/canis/core/include/action.rb +83 -0
  62. data/lib/canis/core/include/actionmanager.rb +49 -0
  63. data/lib/canis/core/include/appmethods.rb +179 -0
  64. data/lib/canis/core/include/bordertitle.rb +49 -0
  65. data/lib/canis/core/include/canisparser.rb +100 -0
  66. data/lib/canis/core/include/colorparser.rb +437 -0
  67. data/lib/canis/core/include/defaultfilerenderer.rb +64 -0
  68. data/lib/canis/core/include/io.rb +320 -0
  69. data/lib/canis/core/include/layouts/SplitLayout.rb +161 -0
  70. data/lib/canis/core/include/layouts/abstractlayout.rb +213 -0
  71. data/lib/canis/core/include/layouts/flowlayout.rb +104 -0
  72. data/lib/canis/core/include/layouts/stacklayout.rb +109 -0
  73. data/lib/canis/core/include/listbindings.rb +89 -0
  74. data/lib/canis/core/include/listeditable.rb +319 -0
  75. data/lib/canis/core/include/listoperations.rb +61 -0
  76. data/lib/canis/core/include/listselectionmodel.rb +388 -0
  77. data/lib/canis/core/include/multibuffer.rb +173 -0
  78. data/lib/canis/core/include/ractionevent.rb +73 -0
  79. data/lib/canis/core/include/rchangeevent.rb +27 -0
  80. data/lib/canis/core/include/rhistory.rb +95 -0
  81. data/lib/canis/core/include/rinputdataevent.rb +47 -0
  82. data/lib/canis/core/include/textdocument.rb +111 -0
  83. data/lib/canis/core/include/vieditable.rb +175 -0
  84. data/lib/canis/core/include/widgetmenu.rb +66 -0
  85. data/lib/canis/core/system/colormap.rb +165 -0
  86. data/lib/canis/core/system/keydefs.rb +32 -0
  87. data/lib/canis/core/system/ncurses.rb +237 -0
  88. data/lib/canis/core/system/panel.rb +129 -0
  89. data/lib/canis/core/system/window.rb +1081 -0
  90. data/lib/canis/core/util/ansiparser.rb +119 -0
  91. data/lib/canis/core/util/app.rb +696 -0
  92. data/lib/canis/core/util/basestack.rb +412 -0
  93. data/lib/canis/core/util/defaultcolorparser.rb +84 -0
  94. data/lib/canis/core/util/extras/README +5 -0
  95. data/lib/canis/core/util/extras/bottomline.rb +1815 -0
  96. data/lib/canis/core/util/extras/padreader.rb +192 -0
  97. data/lib/canis/core/util/focusmanager.rb +31 -0
  98. data/lib/canis/core/util/helpmanager.rb +160 -0
  99. data/lib/canis/core/util/oldwidgetshortcuts.rb +304 -0
  100. data/lib/canis/core/util/promptmenu.rb +235 -0
  101. data/lib/canis/core/util/rcommandwindow.rb +933 -0
  102. data/lib/canis/core/util/rdialogs.rb +520 -0
  103. data/lib/canis/core/util/textutils.rb +74 -0
  104. data/lib/canis/core/util/viewer.rb +238 -0
  105. data/lib/canis/core/util/widgetshortcuts.rb +508 -0
  106. data/lib/canis/core/widgets/applicationheader.rb +103 -0
  107. data/lib/canis/core/widgets/box.rb +58 -0
  108. data/lib/canis/core/widgets/divider.rb +310 -0
  109. data/lib/canis/core/widgets/extras/README.md +12 -0
  110. data/lib/canis/core/widgets/extras/rtextarea.rb +960 -0
  111. data/lib/canis/core/widgets/extras/stackflow.rb +474 -0
  112. data/lib/canis/core/widgets/keylabelprinter.rb +194 -0
  113. data/lib/canis/core/widgets/listbox.rb +326 -0
  114. data/lib/canis/core/widgets/listfooter.rb +86 -0
  115. data/lib/canis/core/widgets/rcombo.rb +210 -0
  116. data/lib/canis/core/widgets/rcontainer.rb +415 -0
  117. data/lib/canis/core/widgets/rlink.rb +30 -0
  118. data/lib/canis/core/widgets/rmenu.rb +970 -0
  119. data/lib/canis/core/widgets/rmenulink.rb +30 -0
  120. data/lib/canis/core/widgets/rmessagebox.rb +400 -0
  121. data/lib/canis/core/widgets/rprogress.rb +118 -0
  122. data/lib/canis/core/widgets/rtabbedpane.rb +631 -0
  123. data/lib/canis/core/widgets/rtabbedwindow.rb +70 -0
  124. data/lib/canis/core/widgets/rwidget.rb +3634 -0
  125. data/lib/canis/core/widgets/scrollbar.rb +147 -0
  126. data/lib/canis/core/widgets/statusline.rb +113 -0
  127. data/lib/canis/core/widgets/table.rb +1072 -0
  128. data/lib/canis/core/widgets/tabular.rb +264 -0
  129. data/lib/canis/core/widgets/textpad.rb +1674 -0
  130. data/lib/canis/core/widgets/tree.rb +690 -0
  131. data/lib/canis/core/widgets/tree/treecellrenderer.rb +150 -0
  132. data/lib/canis/core/widgets/tree/treemodel.rb +432 -0
  133. data/lib/canis/version.rb +3 -0
  134. metadata +229 -0
@@ -0,0 +1,144 @@
1
+ # To test out the new messagebox
2
+ # The old messagebox provided a lot of convenience methods that were complicated
3
+ # and confusing. This one is simpler.
4
+ # The examples here are based on the old test1.rb that will not work now
5
+ # since the interface has been changed and simplified
6
+ #
7
+ require 'logger'
8
+ require 'canis'
9
+ require 'canis/core/widgets/rmessagebox'
10
+ #require 'canis/deprecated/widgets/rmessagebox'
11
+
12
+ if $0 == __FILE__
13
+ # Initialize curses
14
+ begin
15
+ # XXX update with new color and kb
16
+ Canis::start_ncurses # this is initializing colors via ColorMap.setup
17
+ $log = Logger.new((File.join(ENV['LOGDIR'] || "./" ,"canis14.log")))
18
+ $log.level = Logger::DEBUG
19
+
20
+ # @window = Canis::Window.root_window
21
+
22
+
23
+ catch(:close) do
24
+ choice = ARGV[0] && ARGV[0].to_i || 3
25
+ $log.debug "START MESSAGE BOX TEST #{ARGV[0]}. choice==#{choice} ---------"
26
+ # need to pass a form, not window.
27
+ case choice
28
+ when 1
29
+ require 'canis/core/widgets/listbox'
30
+ nn = "mylist"
31
+ l = Listbox.new nil, :row => 2, :col => 5, :list => %w[john tim lee wong kepler edward why chad andy],
32
+ :selection_mode => :multiple, :height => 10, :width => 20 , :selected_color => :green, :selected_bgcolor => :white, :selected_indices => [2,6], :name => nn
33
+ #default_values %w[ lee why ]
34
+
35
+ l.unbind_key(KEY_ENTER)
36
+ @mb = MessageBox.new :width => 30, :height => 18 do
37
+ title "Select a name"
38
+ button_type :ok_cancel
39
+ item Label.new :row => 1, :col => 1, :text => "Enter your name:"
40
+ item l
41
+ end
42
+ @mb.run
43
+ $log.debug "XXX: #{l.selected_indices} "
44
+ n = @mb.widget(nn)
45
+ $log.debug "XXXX: #{n.selected_indices}, #{n.name} "
46
+ when 2
47
+ @mb = Canis::MessageBox.new do
48
+ title "Color selector"
49
+ message "Select a color"
50
+ #item Label.new :text => "Select a color", :row => 1 , :col => 2
51
+
52
+ r = 3
53
+ c = 2
54
+ %w[&red &green &blue &yellow].each_with_index { |b, i|
55
+ bu = Button.new :name => b, :text => b, :row => r, :col => c
56
+ bu.command { throw(:close, i) }
57
+ item bu
58
+ #bu.default_button(true) if i == 0
59
+ #r += 1
60
+ c += b.length + 5
61
+ }
62
+ end
63
+ index = @mb.run
64
+ $log.debug "XXX: messagebox 2 ret #{index} "
65
+ when 3
66
+ @mb = Canis::MessageBox.new do
67
+ title "Enter your name"
68
+ #message "Enter your first name. You are not permitted to enter x z or q and must enter a capital first"
69
+ message "Enter your first name. Initcaps "
70
+ add Field.new :chars_allowed => /[^0-9]/, :valid_regex => /^[A-Z][a-z]*/, :default => "Matz", :bgcolor => :cyan
71
+ button_type :ok_cancel
72
+ end
73
+ @mb.run
74
+ $log.debug "XXX: got #{@mb.widget(1).text} "
75
+ when 4
76
+ mb = MessageBox.new :title => "HTTP Configuration" , :width => 50 do
77
+ add LabeledField.new :label => 'User', :name => "user", :width => 30, :bgcolor => :cyan
78
+ add CheckBox.new :text => "No &frames", :onvalue => "Selected", :offvalue => "UNselected"
79
+ add CheckBox.new :text => "Use &HTTP/1.0", :value => true
80
+ add CheckBox.new :text => "Use &passive FTP"
81
+ add Label.new :text => " Language ", :attr => REVERSE
82
+ $radio = Canis::Variable.new
83
+ add RadioButton.new :text => "py&thon", :value => "python", :color => :blue, :variable => $radio
84
+ add RadioButton.new :text => "rub&y", :color => :red, :variable => $radio
85
+ button_type :ok
86
+ end
87
+ field = mb.widget("user")
88
+ field.bind(:ENTER) do |f|
89
+ listconfig = {:bgcolor => :blue, :color => :white,
90
+ :relative_to => field, :col => field.col + 6, :width => field.width}
91
+ users= %w[john tim lee wong kepler edward _why chad andy]
92
+ #index = popuplist(users, :relative_to => field, :col => field.col + 6, :width => field.width)
93
+ index = popuplist(users, listconfig)
94
+ field.text users[index] if index
95
+ end
96
+ mb.run
97
+
98
+ when 5
99
+ require 'canis/core/widgets/listbox'
100
+ label = Label.new 'text' => 'File', 'mnemonic'=>'F', :row => 3, :col => 5
101
+ field = Field.new :name => "file", :row => 3 , :col => 10, :width => 40, :set_label => label
102
+ #flist = Dir.glob(File.join( File.expand_path("~/"), "*"))
103
+ flist = Dir.glob("*")
104
+ listb = Listbox.new :name => "mylist", :row => 4, :col => 3, :width => 50, :height => 10,
105
+ :list => flist, :title => "File List", :selected_bgcolor => :white, :selected_color => :blue,
106
+ :selection_mode => :single, :border_attrib => REVERSE
107
+ #listb.bind(:ENTER_ROW) { field.text listb.selected_item }
108
+ # if you find that cursor goes into listbox while typing, then
109
+ # i've put set_form_row in listbox list_data_changed
110
+ field.bind(:CHANGE) do |f|
111
+ flist = Dir.glob("*"+f.getvalue+"*")
112
+ #l.insert( 0, *flist) if flist
113
+ listb.list flist
114
+ end
115
+ listb.unbind_key(KEY_ENTER)
116
+ mb = Canis::MessageBox.new :height => 20, :width => 60 do
117
+ title "Sample File Selector"
118
+ add label
119
+ add field
120
+ add listb
121
+ #height 20
122
+ #width 60
123
+ #top 5
124
+ #left 20
125
+ #default_button 0
126
+ button_type :ok_cancel
127
+
128
+ end
129
+ mb.run
130
+ $log.debug "MBOX :1selected #{listb}"
131
+ $log.debug "MBOX :selected #{listb.selected_value}"
132
+ end
133
+
134
+ end
135
+ rescue => ex
136
+ ensure
137
+ @window.destroy unless @window.nil?
138
+ Canis::stop_ncurses
139
+ p ex if ex
140
+ p(ex.backtrace.join("\n")) if ex
141
+ $log.debug( ex) if ex
142
+ $log.debug(ex.backtrace.join("\n")) if ex
143
+ end
144
+ end
@@ -0,0 +1,116 @@
1
+ # ----------------------------------------------------------------------------- #
2
+ # File: testprogress.rb
3
+ # Description: a test program for progress bar widget
4
+ # creates two progress bars, one old style and one new
5
+ # Keeps running till 'q' pressed.
6
+ # Author: jkepler http://github.com/mare-imbrium/canis/
7
+ # Date: 2014-03-27 - 23:31
8
+ # License: Same as Ruby's License (http://www.ruby-lang.org/LICENSE.txt)
9
+ # Last update: 2014-04-05 12:39
10
+ # ----------------------------------------------------------------------------- #
11
+ # testprogress.rb Copyright (C) 2012-2014 kepler kumar
12
+ require 'logger'
13
+ require 'canis'
14
+ require 'canis/core/widgets/rprogress'
15
+ if $0 == __FILE__
16
+
17
+ #include Canis
18
+
19
+ begin
20
+ # Initialize curses
21
+ Canis::start_ncurses # this is initializing colors via ColorMap.setup
22
+ path = File.join(ENV["LOGDIR"] || "./" ,"canis14.log")
23
+ file = File.open(path, File::WRONLY|File::TRUNC|File::CREAT)
24
+ $log = Logger.new(path)
25
+ $log.level = Logger::DEBUG
26
+
27
+ @window = Canis::Window.root_window
28
+
29
+ catch(:close) do
30
+ @form = Form.new @window
31
+ title = (" "*30) + "Demo of Progress Bar (q quits, s - slow down) " + Canis::VERSION
32
+ Label.new @form, {:text => title, :row => 1, :col => 0, :color => :green, :bgcolor => :black}
33
+ Label.new @form, {:text => "Press q to quit, s/f make slow or fast", :row => 10, :col => 10}
34
+ Label.new @form, {:text => "Old style and modern style progress bars", :row => 12, :col => 10}
35
+ r = 14; fc = 12;
36
+
37
+ pbar1 = Progress.new @form, {:width => 20, :row => r, :col => fc,
38
+ :name => "pbar1", :style => :old}
39
+ #:bgcolor => :white, :color => 'red', :name => "pbar1", :style => :old}
40
+ pbar = Progress.new @form, {:width => 20, :row => r+2, :col => fc,
41
+ :bgcolor => :white, :color => :red, :name => "pbar"}
42
+
43
+ pbar.visible false
44
+ pb = @form.by_name["pbar"]
45
+ pb.visible true
46
+ len = 1
47
+ ct = (100) * 1.00
48
+ pb.fraction(len/ct)
49
+ pbar1.fraction(len/ct)
50
+ i = ((len/ct)*100).to_i
51
+ i = 100 if i > 100
52
+ pb.text = "completed:#{i}"
53
+
54
+
55
+ @form.repaint
56
+ @window.wrefresh
57
+ Ncurses::Panel.update_panels
58
+
59
+ # the main loop
60
+
61
+ # this is so there's no wait for a key, i want demo to proceed without key press, but
62
+ # respond if there is one
63
+ Ncurses::nodelay(@window.get_window, bf = true)
64
+
65
+ # sleep seconds between refresh of progress
66
+ slp = 0.1
67
+ ##while((ch = @window.getchar()) != FFI::NCurses::KEY_F10 )
68
+ #break if ch == ?\C-q.getbyte(0)
69
+ while((ch = @window.getch()) != 27)
70
+ break if ch == "q".ord
71
+ ## slow down
72
+ if ch == "s".ord
73
+ slp *= 2
74
+ elsif ch == "f".ord
75
+ ## make faster
76
+ slp /= 2.0
77
+ end
78
+ begin
79
+
80
+ sleep(slp)
81
+ len += 1
82
+ if len > 100
83
+ len = 1
84
+ sleep(1.0)
85
+ end
86
+ ct = (100) * 1.00
87
+ pb.fraction(len/ct)
88
+ pbar1.fraction(len/ct)
89
+ i = ((len/ct)*100).to_i
90
+ i = 100 if i > 100
91
+ pb.text = "completed:#{i}"
92
+
93
+ #@form.handle_key(ch)
94
+ @form.repaint
95
+ @window.wrefresh
96
+ Ncurses::Panel.update_panels
97
+ #end
98
+
99
+ rescue => err
100
+ break
101
+ end
102
+
103
+ @window.wrefresh
104
+ end # while loop
105
+ end # catch
106
+ rescue => ex
107
+ ensure
108
+ $log.debug " -==== EXCEPTION =====-"
109
+ $log.debug( ex) if ex
110
+ $log.debug(ex.backtrace.join("\n")) if ex
111
+ @window.destroy if !@window.nil?
112
+ Canis::stop_ncurses
113
+ puts ex if ex
114
+ puts(ex.backtrace.join("\n")) if ex
115
+ end
116
+ end
@@ -0,0 +1,107 @@
1
+ require 'canis'
2
+ require 'canis/core/widgets/tree'
3
+
4
+ if $0 == __FILE__
5
+ $choice = ARGV[0].to_i || 1
6
+ class Tester
7
+ def initialize
8
+ acolor = $reversecolor
9
+ end
10
+ def run
11
+ @window = Canis::Window.root_window
12
+ @form = Form.new @window
13
+
14
+ h = 20; w = 75; t = 3; l = 4
15
+ #$choice = 1
16
+ case $choice
17
+ when 1
18
+ root = TreeNode.new "ROOT"
19
+ subroot = TreeNode.new "subroot"
20
+ leaf1 = TreeNode.new "leaf 1"
21
+ leaf2 = TreeNode.new "leaf 2"
22
+
23
+ model = DefaultTreeModel.new root
24
+ #model.insert_node_into(subroot, root, 0)
25
+ #model.insert_node_into(leaf1, subroot, 0)
26
+ #model.insert_node_into(leaf2, subroot, 1)
27
+ root << subroot
28
+ subroot << leaf1 << leaf2
29
+ leaf1 << "leaf11"
30
+ leaf1 << "leaf12"
31
+
32
+ root.add "blocky", true do
33
+ add "block2"
34
+ add "block3" do
35
+ add "block31"
36
+ end
37
+ end
38
+ Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
39
+
40
+ when 2
41
+
42
+ # use an array to populate
43
+ # we need to do root_visible = false so you get just a list
44
+ model = %W[ ruby lua jruby smalltalk haskell scheme perl lisp ]
45
+ Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
46
+
47
+ when 3
48
+
49
+ # use an Has to populate
50
+ #model = { :ruby => %W[ "jruby", "mri", "yarv", "rubinius", "macruby" ], :python => %W[ cpython jython laden-swallow ] }
51
+ model = { :ruby => [ "jruby", {:mri => %W[ 1.8.6 1.8.7]}, {:yarv => %W[1.9.1 1.9.2]}, "rubinius", "macruby" ], :python => %W[ cpython jython pypy ] }
52
+
53
+ Tree.new @form, :data => model, :row =>2, :col=>2, :height => 20, :width => 30
54
+ #when 4
55
+ else
56
+ Tree.new @form, :row =>2, :col=>2, :height => 20, :width => 30 do
57
+ root "root" do
58
+ branch "vim" do
59
+ leaf "vimrc"
60
+ end
61
+ branch "ack" do
62
+ leaf "ackrc"
63
+ leaf "agrc"
64
+ end
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ #
71
+ help = "C-q to quit. <ENTER> to expand nodes. j/k to navigate. Pass command-line argument 1,2,3,4 #{$0} "
72
+ Canis::Label.new @form, {:text => help, :row => 1, :col => 2, :color => :cyan}
73
+ @form.repaint
74
+ @window.wrefresh
75
+ Ncurses::Panel.update_panels
76
+ while((ch = @window.getchar()) != ?\C-q.getbyte(0))
77
+ ret = @form.handle_key(ch)
78
+ @window.wrefresh
79
+ if ret == :UNHANDLED
80
+ str = keycode_tos ch
81
+ $log.debug " UNHANDLED #{str} by Vim #{ret} "
82
+ end
83
+ end
84
+
85
+ @window.destroy
86
+
87
+ end
88
+ end
89
+ include Canis
90
+ include Canis::Utils
91
+ # Initialize curses
92
+ begin
93
+ # XXX update with new color and kb
94
+ Canis::start_ncurses # this is initializing colors via ColorMap.setup
95
+ $log = Logger.new("canis14.log")
96
+ $log.level = Logger::DEBUG
97
+ n = Tester.new
98
+ n.run
99
+ rescue => ex
100
+ ensure
101
+ Canis::stop_ncurses
102
+ p ex if ex
103
+ puts(ex.backtrace.join("\n")) if ex
104
+ $log.debug( ex) if ex
105
+ $log.debug(ex.backtrace.join("\n")) if ex
106
+ end
107
+ end
@@ -0,0 +1,53 @@
1
+ # ----------------------------------------------------------------------------- #
2
+ # File: testsplitlayout.rb
3
+ # Description:
4
+ # Author: j kepler http://github.com/mare-imbrium/canis/
5
+ # Date: 2014-05-09 - 20:24
6
+ # License: MIT
7
+ # Last update: 2014-05-10 19:15
8
+ # ----------------------------------------------------------------------------- #
9
+ # testsplitlayout.rb Copyright (C) 2012-2014 j kepler
10
+
11
+ if __FILE__ == $PROGRAM_NAME
12
+ require 'canis/core/util/app'
13
+ require 'canis/core/widgets/listbox'
14
+ require 'canis/core/include/layouts/splitlayout'
15
+ App.new do
16
+
17
+ # if i add form here, it will repaint them first, and have no dimensions
18
+ lb = Listbox.new @form, :list => ["borodin","berlioz","bernstein","balakirev", "elgar"] , :name => "mylist"
19
+ lb1 = Listbox.new @form, :list => ["bach","beethoven","mozart","gorecki", "chopin","wagner","grieg","holst"] , :name => "mylist1"
20
+
21
+
22
+ alist = %w[ ruby perl python java jruby macruby rubinius rails rack sinatra pylons django cakephp grails]
23
+ str = "Hello, people of Earth.\nI am HAL, a textbox.\nUse arrow keys, j/k/h/l/gg/G/C-a/C-e/C-n/C-p\n"
24
+ str << alist.join("\n")
25
+ tv = TextPad.new @form, :name => "text", :text => str.split("\n")
26
+ lb3 = Listbox.new @form, :list => alist , :name => "mylist3"
27
+ lb2 = Listbox.new @form, :list => `gem list --local`.split("\n") , :name => "mylist2"
28
+
29
+ w = Ncurses.COLS-1
30
+ h = Ncurses.LINES-3
31
+ #layout = StackLayout.new :height => -1, :top_margin => 1, :bottom_margin => 1, :left_margin => 1
32
+
33
+ layout = SplitLayout.new :height => -1, :top_margin => 1, :bottom_margin => 1, :left_margin => 1
34
+ @form.layout_manager = layout
35
+ x,y = layout.vsplit( 0.30, 0.70)
36
+ raise "X" unless x
37
+ raise "Y" unless y
38
+ ##x = arr.first
39
+ #y = arr[1]
40
+ $log.debug "XY: #{x} , #{y} "
41
+ x.component = lb
42
+ y1, y2 = y.split( 0.40, 0.60 )
43
+ #y1.component = lb1
44
+ y2.component = lb2
45
+ y11,y12,y13 = y1.vsplit( 0.3, 0.3, 0.4)
46
+ #y11,y12 = y1.vsplit( 0.4, 0.6)
47
+ y11.component = lb1
48
+ y12.component = tv
49
+ y13.component = lb3
50
+
51
+ st = status_line :row => -1
52
+ end # app
53
+ end # if
@@ -0,0 +1,49 @@
1
+ # ----------------------------------------------------------------------------- #
2
+ # File: testsplitlayout.rb
3
+ # Description:
4
+ # Author: j kepler http://github.com/mare-imbrium/canis/
5
+ # Date: 2014-05-09 - 20:24
6
+ # License: MIT
7
+ # Last update: 2014-05-10 20:16
8
+ # ----------------------------------------------------------------------------- #
9
+ # testsplitlayout.rb Copyright (C) 2012-2014 j kepler
10
+
11
+ if __FILE__ == $PROGRAM_NAME
12
+ require 'canis/core/util/app'
13
+ require 'canis/core/widgets/listbox'
14
+ require 'canis/core/include/layouts/splitlayout'
15
+ App.new do
16
+
17
+ # if i add form here, it will repaint them first, and have no dimensions
18
+ lb = Listbox.new @form, :list => ["borodin","berlioz","bernstein","balakirev", "elgar"] , :name => "mylist"
19
+ lb1 = Listbox.new @form, :list => ["bach","beethoven","mozart","gorecki", "chopin","wagner","grieg","holst"] , :name => "mylist1"
20
+
21
+
22
+ alist = %w[ ruby perl python java jruby macruby rubinius rails rack sinatra pylons django cakephp grails]
23
+ str = "Hello, people of Earth.\nI am HAL, a textbox.\nUse arrow keys, j/k/h/l/gg/G/C-a/C-e/C-n/C-p\n"
24
+ str << alist.join("\n")
25
+ tv = TextPad.new @form, :name => "text", :text => str.split("\n")
26
+ lb3 = Listbox.new @form, :list => alist , :name => "mylist3"
27
+ lb2 = Listbox.new @form, :list => `gem list --local`.split("\n") , :name => "mylist2"
28
+
29
+ w = Ncurses.COLS-1
30
+ h = Ncurses.LINES-3
31
+ #layout = StackLayout.new :height => -1, :top_margin => 1, :bottom_margin => 1, :left_margin => 1
32
+
33
+ layout = SplitLayout.new :height => -1, :top_margin => 1, :bottom_margin => 1, :left_margin => 1
34
+ @form.layout_manager = layout
35
+ layout.vsplit(0.2, 0.8) do |x,y|
36
+ x.component = lb
37
+ y.split(0.4, 0.6) do |a,b|
38
+ b.component = lb2
39
+ a.vsplit( 0.3, 0.3, 0.4) do | p,q,r |
40
+ p << lb1
41
+ q << tv
42
+ r << lb3
43
+ end
44
+ end
45
+ end
46
+
47
+ st = status_line :row => -1
48
+ end # app
49
+ end # if