canis 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -9
  3. data/CHANGES +3 -0
  4. data/README.md +5 -3
  5. data/examples/alpmenu.rb +9 -5
  6. data/examples/app.sample +2 -2
  7. data/examples/appemail.rb +15 -15
  8. data/examples/atree.rb +7 -7
  9. data/examples/bline.rb +19 -19
  10. data/examples/common/devel.rb +3 -3
  11. data/examples/dbdemo.rb +53 -49
  12. data/examples/dirtree.rb +22 -19
  13. data/examples/newtabbedwindow.rb +5 -5
  14. data/examples/newtesttabp.rb +3 -3
  15. data/examples/tabular.rb +11 -11
  16. data/examples/tasks.rb +25 -25
  17. data/examples/term2.rb +8 -8
  18. data/examples/testbuttons.rb +24 -24
  19. data/examples/testcombo.rb +5 -5
  20. data/examples/testdb.rb +6 -6
  21. data/examples/testfields.rb +16 -16
  22. data/examples/testflowlayout.rb +3 -3
  23. data/examples/testkeypress.rb +5 -5
  24. data/examples/testlistbox.rb +18 -18
  25. data/examples/testlistbox1.rb +17 -17
  26. data/examples/testmessagebox.rb +5 -5
  27. data/examples/testprogress.rb +6 -6
  28. data/examples/testree.rb +3 -3
  29. data/examples/testsplitlayout.rb +4 -4
  30. data/examples/testsplitlayout1.rb +4 -4
  31. data/examples/teststacklayout.rb +4 -4
  32. data/examples/testwsshortcuts.rb +1 -1
  33. data/examples/testwsshortcuts2.rb +4 -4
  34. data/lib/canis/core/include/colorparser.rb +4 -4
  35. data/lib/canis/core/include/io.rb +3 -3
  36. data/lib/canis/core/include/layouts/abstractlayout.rb +3 -3
  37. data/lib/canis/core/include/layouts/flowlayout.rb +2 -2
  38. data/lib/canis/core/include/layouts/stacklayout.rb +3 -3
  39. data/lib/canis/core/system/colormap.rb +3 -3
  40. data/lib/canis/core/system/window.rb +7 -4
  41. data/lib/canis/core/util/extras/padreader.rb +2 -2
  42. data/lib/canis/core/util/rcommandwindow.rb +8 -4
  43. data/lib/canis/core/util/rdialogs.rb +1 -1
  44. data/lib/canis/core/util/widgetshortcuts.rb +9 -2
  45. data/lib/canis/core/widgets/applicationheader.rb +6 -2
  46. data/lib/canis/core/widgets/divider.rb +6 -2
  47. data/lib/canis/core/widgets/rmenu.rb +8 -4
  48. data/lib/canis/core/widgets/rmessagebox.rb +2 -2
  49. data/lib/canis/core/widgets/rwidget.rb +15 -15
  50. data/lib/canis/core/widgets/scrollbar.rb +5 -2
  51. data/lib/canis/core/widgets/table.rb +2 -2
  52. data/lib/canis/core/widgets/textpad.rb +8 -8
  53. data/lib/canis/core/widgets/tree.rb +57 -39
  54. data/lib/canis/core/widgets/tree/treecellrenderer.rb +3 -3
  55. data/lib/canis/version.rb +1 -1
  56. metadata +12 -13
  57. data/lib/canis/core/include/.DS_Store +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4779cdb032e8834979001fd88ebae06c9c1c3db
4
- data.tar.gz: 7065221a532c59f322d51c4514ec48193d240988
3
+ metadata.gz: 2aedc552388d718a2fa0b3f1348cbf1b0abca82c
4
+ data.tar.gz: 4b979f79c31ce74c68493c171bf52c05edc4d6b8
5
5
  SHA512:
6
- metadata.gz: 8109f9043da601a306f3ebf12b1f5272853a8d6f9295cc649e26129063fdb3358d4619a0d8e255ada027dd0f4c0d10488c314b51cd7e7eec0c8132d0540de05e
7
- data.tar.gz: bc1fd4348a75ddd4db70249715582aaa1f1b0d4b9f8b29613dfa45c5efbdd6c72c9a91b583c578dd210e1da196cfd7aa899f5b62b874c8c208c2e7bb45780e6a
6
+ metadata.gz: cb9f4d74881cbab7ad7d321fc689ffaaf799e59faff2a9930288ec1362ff2acf06eb6ab342265c5c89dfafb64a7d887a008d133d0e771cd3b25e2e285a4d09b8
7
+ data.tar.gz: 37af1c730ea7023e12f011d068010929624fe0e0c89feea74b2d643f71e075c7b2bf2732f01d23785a572425d25e346043a6b970d98c41fedbfc2ebd72d2a73d
data/.gitignore CHANGED
@@ -29,16 +29,7 @@ deprecated
29
29
  .srclist
30
30
  NOTES
31
31
  bug
32
- examples/common/rmail.rb
33
32
  examples/dump.yml
34
- examples/oldwidgetshortcuts.rb
35
- examples/test2.rb
36
- examples/testskel.rb
37
- examples/teststackflow.rb
38
- examples/todo.txt
39
- examples/ugu.rb
40
- examples/x.tsv
41
- examples/xxx.rb
42
33
  issues.txt
43
34
  tags
44
35
  test.yml
data/CHANGES CHANGED
@@ -1,3 +1,6 @@
1
+ 2017-03-09 - 23:29
2
+ Replaced Fixnum with Integer since Fixnum deprecated in Ruby 2.4.
3
+
1
4
  2014-04-22 - 00:13
2
5
 
3
6
  Made some changes in getchar to return STRINGS but not implemented. Evaluating benefits
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Canis
2
2
 
3
+ ## Last update on 2017-03-19 for ruby 2.4 (fixnum to Integer).
4
+
3
5
  wrapper over ruby ffi-ncurses library with essential components/controls only.
4
6
 
5
7
  Canis has taken over the codebase of rbcurse. Canis is _not_ backward compatible with rbcurse.
@@ -105,12 +107,12 @@ https://github.com/rkumar/rbcurse-tutorial
105
107
  This tutorial needs to be updated for canis. Although, canis has diverged/forked from rbcurse, but the basic principles are still the same.
106
108
 
107
109
  There is some on-line documentation of classes at:
108
- http://rubydoc.info/gems/canis/0.0.5/frames
110
+ http://rubydoc.info/gems/canis/0.0.8/frames
109
111
 
110
112
  ## Contributing
111
113
 
112
- 0. Please give suggestions on how to improve the documentation.
113
- 0.1. Please give suggestion on how to improve canis.
114
+ - Please give suggestions on how to improve the documentation.
115
+ - Please give suggestions on how to improve canis.
114
116
 
115
117
  1. Fork it ( https://github.com/[my-github-username]/canis/fork )
116
118
  2. Create your feature branch (`git checkout -b my-new-feature`)
@@ -1,6 +1,10 @@
1
1
  require 'canis/core/util/app'
2
2
 
3
- App.new do
3
+ def load_relative(path)
4
+ load File.expand_path("../#{path}", __FILE__)
5
+ end
6
+
7
+ App.new do
4
8
  #title "Demo of Menu - canis"
5
9
  #subtitle "Hit F1 to quit, F2 for menubar toggle"
6
10
  header = app_header "canis #{Canis::VERSION}", :text_center => "Alpine Menu Demo", :text_right =>""
@@ -10,24 +14,24 @@ require 'canis/core/util/app'
10
14
  w = 60
11
15
  menulink :text => "&View Dirs", :width => w, :description => "View Dirs in tree" do |s, *stuff|
12
16
  message "Pressed #{s.text} "
13
- load './dirtree.rb'
17
+ load_relative './dirtree.rb'
14
18
  #require './viewtodo'; todo = ViewTodo::TodoApp.new; todo.run
15
19
  end
16
20
  blank
17
21
  menulink :text => "&Tabular", :width => w, :description => "Tabula Rasa" do |s, *stuff|
18
22
  message "Pressed #{s.text} "
19
- load './tabular.rb'
23
+ load_relative './tabular.rb'
20
24
  #require './testtodo'; todo = TestTodo::TodoApp.new; todo.run
21
25
  end
22
26
  blank
23
27
  menulink :text => "&Messages", :width => w, :description => "View Tasks" do |s, *stuff|
24
28
  message "Pressed #{s.text} "
25
- load './tasks.rb'
29
+ load_relative './tasks.rb'
26
30
  end
27
31
  blank
28
32
  menulink :text => "&Database", :width => w, :description => "Database Demo" do |s, *stuff|
29
33
  message "Pressed #{s.getvalue} "
30
- load './dbdemo.rb'
34
+ load_relative './dbdemo.rb'
31
35
  end
32
36
  blank
33
37
  # somehow ? in mnemonic won't work
@@ -6,11 +6,11 @@ here as you want
6
6
  eos
7
7
  end
8
8
 
9
- App.new do
9
+ App.new do
10
10
  ## application code comes here
11
11
  @form.help_manager.help_text = help_text()
12
12
 
13
- @header = app_header "My App #{MyApp::VERSION}", :text_center => "Yet Another Email Client that sucks", :text_right =>"Some text", :color => :black, :bgcolor => :white
13
+ @header = app_header "My App #{App::VERSION}", :text_center => "Yet Another Email Client that sucks", :text_right =>"Some text", :color => :black, :bgcolor => :white
14
14
 
15
15
  @status_line = status_line
16
16
  @status_line.command {
@@ -8,11 +8,11 @@ require './common/rmail'
8
8
  # this will go into top namespace so will conflict with other apps!
9
9
  def testchoose
10
10
  # list filters as you type
11
- $log.debug "called CHOOSE " if $log.debug?
11
+ $log.debug "called CHOOSE " if $log.debug?
12
12
  filter = "*"
13
13
  filter = ENV['PWD']+"/*"
14
14
  str = choose filter, :title => "Files", :prompt => "Choose a file: "
15
- message "We got #{str} "
15
+ message "We got #{str} "
16
16
  end
17
17
  def testnumberedmenu
18
18
  list1 = %w{ ruby perl python erlang rake java lisp scheme chicken }
@@ -33,7 +33,7 @@ def testdisplay_text
33
33
  end
34
34
  def testdir
35
35
  # this behaves like vim's file selector, it fills in values
36
- str = ask("File? ", Pathname) do |q|
36
+ str = ask("File? ", Pathname) do |q|
37
37
  q.completion_proc = Proc.new {|str| Dir.glob(str +"*").collect { |f| File.directory?(f) ? f+"/" : f } }
38
38
  q.helptext = "Enter start of filename and tab to get completion"
39
39
  end
@@ -42,16 +42,16 @@ end
42
42
  def test
43
43
  end
44
44
  def saveas1
45
- @tv.saveas
45
+ @tv.saveas
46
46
  end
47
47
 
48
- # experimental.
48
+ # experimental.
49
49
  # if components have some commands, can we find a way of passing the command to them
50
50
  # method_missing gave a stack overflow.
51
51
  def execute_this(meth, *args)
52
- $log.debug "app email got #{meth} " if $log.debug?
52
+ $log.debug "app email got #{meth} " if $log.debug?
53
53
  cc = @vim.current_component
54
- [cc, @lb2, @tv].each do |c|
54
+ [cc, @lb2, @tv].each do |c|
55
55
  if c.respond_to?(meth, true)
56
56
  c.send(meth, *args)
57
57
  return true
@@ -60,7 +60,7 @@ def execute_this(meth, *args)
60
60
  false
61
61
  end
62
62
 
63
- App.new do
63
+ App.new do
64
64
  ht = 24
65
65
  @messages = nil
66
66
  $unread_hash = {}
@@ -72,7 +72,7 @@ App.new do
72
72
 
73
73
  stack :margin_top => 1, :margin => 0, :width => :EXPAND do
74
74
  # NOTE: please fix the next 2 lines based on where your mbox files reside
75
- model = ["~/mbox"]
75
+ model = ["~/mbox"]
76
76
  others = "~/mail/"
77
77
  boxes = Dir.new(File.expand_path(others)).entries
78
78
  boxes.delete(".")
@@ -84,28 +84,28 @@ App.new do
84
84
  @vim = master_detail :width => :EXPAND
85
85
  @dirs = listbox :list => model, :height => ht, :border_attrib => borderattrib, :suppress_borders => true
86
86
  @dirs.one_key_selection = false
87
-
87
+
88
88
  # commands that can be mapped to or executed using M-x
89
89
  # however, commands of components aren't yet accessible.
90
90
  def get_commands
91
91
  %w{ testchoose testnumberedmenu testdisplay_list testdisplay_text testdir saveas1 }
92
92
  end
93
- # we override/open instance so as to only print basename. Also, print unread count
93
+ # we override/open instance so as to only print basename. Also, print unread count
94
94
  def @dirs.convert_value_to_text(text, crow)
95
95
  str = File.basename(text)
96
96
  if $unread_hash.has_key?(str)
97
97
  str << " (#{$unread_hash[str]})"
98
98
  else
99
- str
99
+ str
100
100
  end
101
101
  end
102
102
  def test1XX
103
- $log.debug "called test1 " if $log.debug?
103
+ $log.debug "called test1 " if $log.debug?
104
104
  str = choose "*.rb", :title => "Files", :prompt => "Choose a file: "
105
105
  end
106
106
  def help_text
107
107
  <<-eos
108
- APPEMAIL HELP
108
+ APPEMAIL HELP
109
109
 
110
110
  This is some help text for appemail.
111
111
  We are testing out this feature.
@@ -131,7 +131,7 @@ App.new do
131
131
  end
132
132
  @vim.set_left_component @dirs
133
133
 
134
-
134
+
135
135
  @mails = []
136
136
  headings = %w{ Stat # Date From Subject }
137
137
  @lb2 = tabular_widget :suppress_borders => true
@@ -1,11 +1,11 @@
1
1
  require 'canis/core/util/app'
2
2
 
3
- App.new do
3
+ App.new do
4
4
  var = Variable.new
5
- header = app_header "canis #{Canis::VERSION}", :text_center => "Tree Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
5
+ header = app_header "canis #{Canis::VERSION}", :text_center => "Tree Demo", :text_right =>"New Improved!", :color => :black, :bgcolor => :white, :attr => :bold
6
6
  message "Press Enter to expand/collapse"
7
7
 
8
- @form.bind_key(FFI::NCurses::KEY_F3) {
8
+ @form.bind_key(FFI::NCurses::KEY_F3) {
9
9
  require 'canis/core/util/viewer'
10
10
  Canis::Viewer.view("canis14.log", :close_key => KEY_ENTER, :title => "<Enter> to close")
11
11
  }
@@ -37,7 +37,7 @@ App.new do
37
37
  stack :margin_top => 0, :width_pc => "30" do
38
38
 
39
39
  # using an Array, these would be expanded on selection, using an event
40
- tree :data => Dir.glob("*"), :title=> "[ Array ]" do
40
+ tree :data => Dir.glob("*"), :title=> "[ Array ]" do
41
41
  command do |node|
42
42
  # insert dir entries unless done so already
43
43
  if node.children && !node.children.empty?
@@ -71,7 +71,7 @@ App.new do
71
71
  leaf1 << "leaf12"
72
72
 
73
73
  # more rubyish way
74
- root.add "blocky", true do
74
+ root.add "blocky", true do
75
75
  add "block2"
76
76
  add "block3" do
77
77
  add "block31"
@@ -86,14 +86,14 @@ App.new do
86
86
  # using height_pc as 100 was causing prefresh to fail if file lines went beyond 31
87
87
  # tput lines gives 32 so only when file length exceeded was it actually writing beyond screen
88
88
  t = textview :suppress_borders => true, :height_pc => 90, :color => :green, :bgcolor => :black
89
- var.command do |filename|
89
+ var.command do |filename|
90
90
  filename = filename.value
91
91
  if File.directory? filename
92
92
  lines = Dir.entries(filename )
93
93
  t.set_content lines
94
94
  elsif File.exist? filename
95
95
  # next line bombs on "invalid byte sequence on UTF-8" on split.
96
- lines = File.open(filename,'r').read.split("\n")
96
+ lines = File.open(filename,'r').read.split("\n")
97
97
  # next line bombs on binary files. normally we would check file type using +file+ command
98
98
  t.set_content lines
99
99
  else
@@ -3,7 +3,7 @@ require 'canis/core/util/rcommandwindow'
3
3
  require 'fileutils'
4
4
  require 'pathname'
5
5
  require 'canis/core/include/defaultfilerenderer'
6
- require './common/devel.rb'
6
+ require_relative './common/devel.rb'
7
7
 
8
8
  # this will go into top namespace so will conflict with other apps!
9
9
  def testnumberedmenu
@@ -32,7 +32,7 @@ def testdisplay_text
32
32
  end
33
33
  def testdir
34
34
  # this behaves like vim's file selector, it fills in values
35
- str = rb_gets("File? ", Pathname) do |q|
35
+ str = rb_gets("File? ", Pathname) do |q|
36
36
  #q.completion_proc = Proc.new {|str| Dir.glob(str +"*").collect { |f| File.directory?(f) ? f+"/" : f } }
37
37
  q.help_text = "Enter start of filename and tab to get completion"
38
38
  end
@@ -43,9 +43,9 @@ end
43
43
  # method_missing gave a stack overflow.
44
44
  def execute_this(meth, *args)
45
45
  alert " #{meth} not found ! "
46
- $log.debug "app email got #{meth} " if $log.debug?
46
+ $log.debug "app email got #{meth} " if $log.debug?
47
47
  cc = @form.get_current_field
48
- [cc].each do |c|
48
+ [cc].each do |c|
49
49
  if c.respond_to?(meth, true)
50
50
  c.send(meth, *args)
51
51
  return true
@@ -54,7 +54,7 @@ def execute_this(meth, *args)
54
54
  false
55
55
  end
56
56
 
57
- App.new do
57
+ App.new do
58
58
  @startdir ||= File.expand_path("..")
59
59
  def show file
60
60
  w = @form.by_name["tv"]
@@ -63,43 +63,43 @@ App.new do
63
63
  w.text lines
64
64
  w.title "[ #{file} ]"
65
65
  elsif File.exists? file
66
- lines = File.open(file,'r').readlines
66
+ lines = File.open(file,'r').readlines
67
67
  w.text lines
68
68
  w.title "[ #{file} ]"
69
69
  end
70
70
  end
71
71
  def testchoosedir
72
72
  # list filters as you type
73
- $log.debug "called CHOOSE " if $log.debug?
74
- str = choose_file :title => "Select a file",
73
+ $log.debug "called CHOOSE " if $log.debug?
74
+ str = choose_file :title => "Select a file",
75
75
  :recursive => true,
76
76
  :dirs => true,
77
77
  :directory => @startdir,
78
78
  :help_text => "Enter pattern, use UP DOWN to traverse, Backspace to delete, ENTER to select. Esc-Esc to quit"
79
79
  if str
80
- message "We got #{str} "
80
+ message "We got #{str} "
81
81
  show str
82
82
  end
83
83
  end
84
84
  def testchoosefile
85
85
  # list filters as you type a pattern
86
86
  glob = "**/*.rb"
87
- str = choose_file glob, :title => "Select a file",
87
+ str = choose_file glob, :title => "Select a file",
88
88
  :directory => @startdir,
89
89
  :help_text => "Enter pattern, use UP DOWN to traverse, Backspace to delete, ENTER to select. Esc-Esc to quit"
90
90
  if str and str != ""
91
- message "We got #{str} "
91
+ message "We got #{str} "
92
92
  show str
93
93
  end
94
94
  end
95
95
  ht = 24
96
96
  borderattrib = :reverse
97
- @header = app_header "canis #{Canis::VERSION}", :text_center => "rCommandline Test",
97
+ @header = app_header "canis #{Canis::VERSION}", :text_center => "rCommandline Test",
98
98
  :text_right =>"Press :", :color => :white, :bgcolor => 236
99
99
  message "Press F10 (or qq) to exit, F1 Help, : for Menu "
100
100
 
101
101
 
102
-
102
+
103
103
  # commands that can be mapped to or executed using M-x
104
104
  # however, commands of components aren't yet accessible.
105
105
  def get_commands
@@ -107,7 +107,7 @@ App.new do
107
107
  end
108
108
  def help_text
109
109
  <<-eos
110
- rCommandLine HELP
110
+ rCommandLine HELP
111
111
 
112
112
  These are some features for either getting filenames from user
113
113
  at the bottom of the window like vim and others do, or filtering
@@ -130,7 +130,7 @@ App.new do
130
130
  testdir - vim style, tabbing completes matching files
131
131
  testnumberedmenu - use menu indexes to select options
132
132
  testdisplaylist - display a list at bottom of screen
133
- Press <ENTER> to select, arrow keys to traverse,
133
+ Press <ENTER> to select, arrow keys to traverse,
134
134
  and characters to filter list.
135
135
  testdisplaytext - display text at bottom (current file contents)
136
136
  Press <ENTER> when done.
@@ -164,10 +164,10 @@ App.new do
164
164
  menu.display_new :title => "Menu"
165
165
  end
166
166
  @form.bind_key(?:, "App Menu") { app_menu; }
167
- @form.bind_key(?=, "Choose File") {
167
+ @form.bind_key(?=, "Choose File") {
168
168
  @curdir ||= Dir.pwd
169
169
  Dir.chdir(@curdir) if Dir.pwd != @curdir
170
- #testdisplay_list;
170
+ #testdisplay_list;
171
171
  testchoosefile;
172
172
  }
173
173
 
@@ -175,7 +175,7 @@ App.new do
175
175
  tv = textview :height_pc => 100, :width_pc => 100, :name => "tv", :suppress_borders => true
176
176
  tv.renderer ruby_renderer
177
177
  end # stack
178
-
178
+
179
179
  sl = status_line :row => Ncurses.LINES-1
180
- testdisplay_list
180
+ testdisplay_list
181
181
  end # app
@@ -4,7 +4,7 @@
4
4
  # Author: j kepler http://github.com/mare-imbrium/canis/
5
5
  # Date: 2014-06-02 - 20:26
6
6
  # License: MIT
7
- # Last update: 2014-08-30 17:50
7
+ # Last update: 2017-03-09 23:13
8
8
  # ----------------------------------------------------------------------------- #
9
9
  # devel.rb Copyright (C) 2012-2014 j kepler
10
10
  require 'canis/core/include/appmethods'
@@ -96,7 +96,7 @@ module Canis
96
96
  val = val.keys
97
97
  end
98
98
  case val
99
- when String, Fixnum, Integer, TrueClass, FalseClass, NilClass, Array, Hash, Symbol
99
+ when String, Integer, TrueClass, FalseClass, NilClass, Array, Hash, Symbol
100
100
  ;
101
101
  else
102
102
  val = "Not shown"
@@ -144,7 +144,7 @@ module Canis
144
144
  end
145
145
  end
146
146
  case val
147
- when String, Fixnum, Integer, TrueClass, FalseClass, NilClass, Array, Hash, Symbol
147
+ when String, Integer, TrueClass, FalseClass, NilClass, Array, Hash, Symbol
148
148
  ;
149
149
  else
150
150
  val = "Not shown"
@@ -1,5 +1,9 @@
1
1
  require 'canis/core/util/app'
2
- require 'sqlite3'
2
+ begin
3
+ require 'sqlite3'
4
+ rescue LoadError
5
+ puts "LoadError: You need sqlite3 installed for this example"
6
+ end
3
7
 
4
8
  def menu_bar hash, config={}, &block
5
9
  if hash.is_a? Hash
@@ -27,9 +31,9 @@ def menu_bar hash, config={}, &block
27
31
  width = config[:title].size + 4 if width < config[:title].size + 4
28
32
  end
29
33
  height = config[:height]
30
- height ||= [max_visible_items || 10+2, list.length+2].min
31
- #layout(1+height, width+4, row, col)
32
- layout = { :height => 0+height, :width => 0+width, :top => row, :left => col }
34
+ height ||= [max_visible_items || 10+2, list.length+2].min
35
+ #layout(1+height, width+4, row, col)
36
+ layout = { :height => 0+height, :width => 0+width, :top => row, :left => col }
33
37
  window = Canis::Window.new(layout)
34
38
  window.name = "WINDOW:popuplist"
35
39
  window.wbkgd(Ncurses.COLOR_PAIR($reversecolor));
@@ -44,17 +48,17 @@ def menu_bar hash, config={}, &block
44
48
  listconfig[:height] = height
45
49
  listconfig[:selection_mode] ||= :single
46
50
  listconfig.merge!(config)
47
- listconfig.delete(:row);
48
- listconfig.delete(:col);
51
+ listconfig.delete(:row);
52
+ listconfig.delete(:col);
49
53
  # trying to pass populists block to listbox
50
54
  lb = Canis::Listbox.new form, listconfig, &block
51
55
  #lb.should_show_focus = true
52
56
  #$row_focussed_attr = REVERSE
53
57
 
54
-
55
- # added next line so caller can configure listbox with
58
+
59
+ # added next line so caller can configure listbox with
56
60
  # events such as ENTER_ROW, LEAVE_ROW or LIST_SELECTION_EVENT or PRESS
57
- # 2011-11-11
61
+ # 2011-11-11
58
62
  #yield lb if block_given? # No it won't work since this returns
59
63
  window.wrefresh
60
64
  Ncurses::Panel.update_panels
@@ -92,7 +96,7 @@ def menu_bar hash, config={}, &block
92
96
  if val.is_a? Hash or val.is_a? Array
93
97
  unentered_hash = val
94
98
  choices << lb.current_value
95
- unentered_window, _list = display_submenu val, :row => lb.current_index, :col => lb.width, :relative_to => lb,
99
+ unentered_window, _list = display_submenu val, :row => lb.current_index, :col => lb.width, :relative_to => lb,
96
100
  :bgcolor => :cyan
97
101
  end
98
102
  else
@@ -106,7 +110,7 @@ def menu_bar hash, config={}, &block
106
110
  if val
107
111
  choices << lb.current_value
108
112
  unentered_hash = val
109
- unentered_window, _list = display_submenu val, :row => lb.current_index, :col => lb.width, :relative_to => lb,
113
+ unentered_window, _list = display_submenu val, :row => lb.current_index, :col => lb.width, :relative_to => lb,
110
114
  :bgcolor => :cyan
111
115
  end
112
116
 
@@ -190,9 +194,9 @@ def display_submenu hash, config={}, &block
190
194
  width = config[:title].size + 4 if width < config[:title].size + 4
191
195
  end
192
196
  height = config[:height]
193
- height ||= [max_visible_items || 10+2, list.length+2].min
194
- #layout(1+height, width+4, row, col)
195
- layout = { :height => 0+height, :width => 0+width, :top => row, :left => col }
197
+ height ||= [max_visible_items || 10+2, list.length+2].min
198
+ #layout(1+height, width+4, row, col)
199
+ layout = { :height => 0+height, :width => 0+width, :top => row, :left => col }
196
200
  window = Canis::Window.new(layout)
197
201
  window.name = "WINDOW:popuplist"
198
202
  window.wbkgd(Ncurses.COLOR_PAIR($reversecolor));
@@ -205,15 +209,15 @@ def display_submenu hash, config={}, &block
205
209
  listconfig[:height] = height
206
210
  listconfig[:selection_mode] ||= :single
207
211
  listconfig.merge!(config)
208
- listconfig.delete(:row);
209
- listconfig.delete(:col);
212
+ listconfig.delete(:row);
213
+ listconfig.delete(:col);
210
214
  # trying to pass populists block to listbox
211
215
  lb = Canis::Listbox.new form, listconfig, &block
212
216
 
213
-
214
- # added next line so caller can configure listbox with
217
+
218
+ # added next line so caller can configure listbox with
215
219
  # events such as ENTER_ROW, LEAVE_ROW or LIST_SELECTION_EVENT or PRESS
216
- # 2011-11-11
220
+ # 2011-11-11
217
221
  #yield lb if block_given? # No it won't work since this returns
218
222
  window.wrefresh
219
223
  Ncurses::Panel.update_panels
@@ -294,7 +298,7 @@ def create_menu
294
298
  # menu should have array of hashes (or just a string)
295
299
  #db = { :name => "Databases", :accelerator => "M-d", :enabled = true, :on_right => :get_databases }
296
300
  #or = { :name => "Open Recent", :accelerator => "M-o", :enabled = true, :on_right => :get_recent }
297
- #find_array = {"Find ..." => :find, "Find Next" => :find_next, "Find Previous" => :find_prev}
301
+ #find_array = {"Find ..." => :find, "Find Next" => :find_next, "Find Previous" => :find_prev}
298
302
  items["File >"] = ["Open ... C-o" , "Open Recent", "Databases" , "Tables", "Exit"]
299
303
  items["Window >"] = { "Tile" => nil, "Find >" => {"Find ..." => :find, "Find Next" => :find_next, "Find Previous" => :find_prev},
300
304
  "Edit" => nil, "Whatever" => nil}
@@ -326,7 +330,7 @@ def create_menu
326
330
  ix = popuplist( items[value] , :row => r + 2 + ix, :col => 10, :bgcolor => :cyan, :color => :white)
327
331
  end
328
332
  end
329
- #
333
+ #
330
334
  # changed order of name and fields, thanks hramrach
331
335
  def view_data name, fields="*"
332
336
  fields = "*" if fields == ""
@@ -355,7 +359,7 @@ def view_sql stmt
355
359
  require 'canis/core/widgets/tabular'
356
360
  t = Tabular.new do |t|
357
361
  t.headings = $columns
358
- t.data=content
362
+ t.data=content
359
363
  end
360
364
  view t.render
361
365
  end
@@ -366,7 +370,7 @@ def view_sql stmt
366
370
  end
367
371
  end
368
372
 
369
- App.new do
373
+ App.new do
370
374
  $log = create_logger "canisdb.log"
371
375
  #header = app_header "canis #{Canis::VERSION}", :text_center => "Database Demo", :text_right =>"enabled"
372
376
  form = @form
@@ -384,7 +388,7 @@ App.new do
384
388
  end
385
389
  def help_text
386
390
  <<-eos
387
- DBDEMO HELP
391
+ DBDEMO HELP
388
392
 
389
393
  This is some help text for dbdemo.
390
394
  We are testing out this feature.
@@ -407,7 +411,7 @@ App.new do
407
411
  Alt-x - Command mode (<tab> to see commands and select)
408
412
  : - Command mode
409
413
  Alt-z - Commands in TextArea
410
-
414
+
411
415
  Sql Entry Area
412
416
  C-x e Edit in $EDITOR or vi
413
417
  M-? To see other key-bindings
@@ -442,13 +446,13 @@ App.new do
442
446
  @form.by_name["clist"].clear_selection
443
447
  @form.by_name["clist"].remove_all
444
448
  end
445
-
449
+
446
450
  else
447
451
  alert "Can't find a .db or .sqlite file"
448
452
  end
449
453
  end
450
454
  @form.help_manager.help_text = help_text()
451
- # TODO accelerators and
455
+ # TODO accelerators and
452
456
  # getting a handle for later use
453
457
  mb = menubar do
454
458
  keep_visible true
@@ -456,7 +460,7 @@ App.new do
456
460
  menu "File" do
457
461
  item "Open", "O" do
458
462
  accelerator "Ctrl-O"
459
- command do
463
+ command do
460
464
  alert "HA!! you wanted to open a file?"
461
465
  end
462
466
  end
@@ -484,9 +488,9 @@ App.new do
484
488
  create_popup(get_column_names(text), :multiple) { |value| view_data( text, value.join(",") ) }
485
489
  end
486
490
  end
487
- item "New", "N"
491
+ item "New", "N"
488
492
  separator
489
- item "Exit", "x" do
493
+ item "Exit", "x" do
490
494
  accelerator "F10"
491
495
  command do
492
496
  throw(:close)
@@ -523,7 +527,7 @@ App.new do
523
527
  end
524
528
  menu "Shell" do
525
529
  require 'canis/core/include/appmethods.rb'
526
- require './common/devel.rb'
530
+ require_relative './common/devel.rb'
527
531
  item "Shell Output ..." do
528
532
  command { shell_output }
529
533
  end
@@ -568,7 +572,7 @@ App.new do
568
572
  # too much confusion between selected and focussed row
569
573
  #$current_table = eve.text if $db
570
574
  #end
571
- clist = listbox :name => "clist", :list => ["No columns"], :title => "Columns", :height => 14,
575
+ clist = listbox :name => "clist", :list => ["No columns"], :title => "Columns", :height => 14,
572
576
  :selection_mode => :multiple,
573
577
  :selected_color => :cyan, :selected_bgcolor => :white , :selected_attr => Ncurses::A_REVERSE,
574
578
  :help_text => "Enter to View selected fields, 'v' to select columns, w - where, o-order"
@@ -576,11 +580,11 @@ App.new do
576
580
 
577
581
  # change selected color when user enters or exits
578
582
  [clist , tlist].each do |o|
579
- o.bind(:ENTER) do
583
+ o.bind(:ENTER) do
580
584
  # reduce flicker by only modifying if necesssary
581
585
  o.selected_color = :cyan if o.selected_color != :cyan
582
586
  end
583
- o.bind(:LEAVE) do
587
+ o.bind(:LEAVE) do
584
588
  # reduce flicker by only modifying if necesssary
585
589
  o.selected_color = :blue unless o.selected_indices.empty?
586
590
  end
@@ -602,7 +606,7 @@ App.new do
602
606
  end
603
607
  view_data $selected_table, cols
604
608
  else
605
- alert "Select a table first ('v' selects)."
609
+ alert "Select a table first ('v' selects)."
606
610
  end
607
611
  end
608
612
  clist.bind_key('w', 'add to where condition') {
@@ -629,41 +633,41 @@ App.new do
629
633
  $log.debug "XXX: ORDER: #{$order_columns}. Press F4 when done"
630
634
  }
631
635
  @statusline = status_line :row => -3, :bgcolor => :magenta, :color => :black
632
- @statusline.command {
636
+ @statusline.command {
633
637
  # trying this out. If you want a persistent message that remains till the next on
634
638
  # then send it in as $status_message
635
639
  text = $status_message.value || ""
636
640
  if !$current_db
637
641
  "[%-s] %s" % [ "#[bg=red,fg=white,bold]Select a Database#[end]", text]
638
642
  elsif !$current_table
639
- "[DB: #[fg=white,bg=blue]%-s#[end] | %-s ] %s" % [ $current_db || "None", $current_table || "#[bg=red,fg=white]Select a table#[end]", text]
643
+ "[DB: #[fg=white,bg=blue]%-s#[end] | %-s ] %s" % [ $current_db || "None", $current_table || "#[bg=red,fg=white]Select a table#[end]", text]
640
644
  else
641
- "DB: #[fg=white,bg=green,bold]%-s#[end] | #[fg=white,bold]%-s#[end] ] %s" % [ $current_db || "None", $current_table || "----", text]
645
+ "DB: #[fg=white,bg=green,bold]%-s#[end] | #[fg=white,bold]%-s#[end] ] %s" % [ $current_db || "None", $current_table || "----", text]
642
646
  end
643
647
  }
644
648
  @adock = nil
645
649
  keyarray = [
646
- ["F1" , "Help"], ["F10" , "Exit"],
650
+ ["F1" , "Help"], ["F10" , "Exit"],
647
651
  ["F2", "Menu"], ["F4", "View"],
648
652
  ["M-d", "Database"], ["M-t", "Table"],
649
653
  ["M-x", "Command"], nil
650
654
  ]
651
655
  tlist_keyarray = keyarray + [ ["v", "Select"], nil, ["Enter","View"] ]
652
656
 
653
- clist_keyarray = keyarray + [ ["v", "Select"], ["V", "Range Sel"],
657
+ clist_keyarray = keyarray + [ ["v", "Select"], ["V", "Range Sel"],
654
658
  ["Enter","View"], ['w', 'where'],
655
659
  ["o","order by"], ['O', 'order desc']
656
660
  ]
657
661
  tarea_keyarray = keyarray + [ ["M-z", "Commands"], nil ]
658
- #tarea_sub_keyarray = [ ["r", "Run"], ["c", "clear"], ["w","Save"], ["a", "Append next"],
662
+ #tarea_sub_keyarray = [ ["r", "Run"], ["c", "clear"], ["w","Save"], ["a", "Append next"],
659
663
  #["y", "Yank"], ["Y", "yank pop"] ]
660
- tarea_sub_keyarray = [ ["r", "Run"], ["c", "clear"], ["e", "Edit externally"], ["w","Kill Ring Save (M-w)"], ["a", "Append Next"],
664
+ tarea_sub_keyarray = [ ["r", "Run"], ["c", "clear"], ["e", "Edit externally"], ["w","Kill Ring Save (M-w)"], ["a", "Append Next"],
661
665
  ["y", "Yank (C-y)"], ["Y", "yank pop (M-y)"],
662
666
  ["u", "Undo (C-_)"], ["R", "Redo (C-r)"],
663
667
  ]
664
668
 
665
669
  gw = get_color($reversecolor, 'green', 'black')
666
- @adock = dock keyarray, { :row => Ncurses.LINES-2, :footer_color_pair => $datacolor,
670
+ @adock = dock keyarray, { :row => Ncurses.LINES-2, :footer_color_pair => $datacolor,
667
671
  :footer_mnemonic_color_pair => gw }
668
672
  @adock.set_key_labels tlist_keyarray, :tables
669
673
  @adock.set_key_labels clist_keyarray, :columns
@@ -741,7 +745,7 @@ App.new do
741
745
  end
742
746
  view_data $current_table, cols
743
747
  else
744
- alert "Select a table first."
748
+ alert "Select a table first."
745
749
  end
746
750
  end
747
751
  end # stack
@@ -777,7 +781,7 @@ App.new do
777
781
  while((ch = @window.getchar()) != ?\C-c.getbyte(0) )
778
782
  if ch < 33 || ch > 126
779
783
  Ncurses.beep
780
- elsif !keys.include?(ch.chr)
784
+ elsif !keys.include?(ch.chr)
781
785
  Ncurses.beep
782
786
  else
783
787
  hash.fetch(ch.chr).call
@@ -795,7 +799,7 @@ App.new do
795
799
 
796
800
  if filename
797
801
  str = tarea.get_text
798
- File.open(filename, 'a') {|f| f.write(str) }
802
+ File.open(filename, 'a') {|f| f.write(str) }
799
803
  @oldfilename = filename
800
804
  @cmd_history << filename unless @cmd_history.include? filename
801
805
 
@@ -809,18 +813,18 @@ App.new do
809
813
  filter = "*"
810
814
  #str = choose filter, :title => "Files", :prompt => "Choose a file: "
811
815
  cproc = Proc.new { |str| Dir.glob(str + "*") }
812
- str = rb_gets "Choose a file: ", :title => "Files", :tab_completion => cproc,
816
+ str = rb_gets "Choose a file: ", :title => "Files", :tab_completion => cproc,
813
817
  :help_text => "Press <tab> to complete filenames. C-a, C-e, C-k. Alt-?"
814
818
  if str && File.exists?(str)
815
819
  begin
816
- tarea.set_content(str)
820
+ tarea.set_content(str)
817
821
  message "Read content from #{str} "
818
822
  rescue => err
819
823
  print_error_message "No file named: #{str}: #{err.to_s} "
820
824
  end
821
825
  end
822
826
  end
823
- #ok_button = button( [button_row,30], "OK", {:mnemonic => 'O'}) do
827
+ #ok_button = button( [button_row,30], "OK", {:mnemonic => 'O'}) do
824
828
  #end
825
829
  end
826
830
  blank