canis 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +45 -0
- data/CHANGES +52 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +24 -0
- data/Rakefile +2 -0
- data/canis.gemspec +25 -0
- data/examples/alpmenu.rb +46 -0
- data/examples/app.sample +19 -0
- data/examples/appemail.rb +191 -0
- data/examples/atree.rb +105 -0
- data/examples/bline.rb +181 -0
- data/examples/common/devel.rb +319 -0
- data/examples/common/file.rb +93 -0
- data/examples/data/README.markdown +9 -0
- data/examples/data/brew.txt +38 -0
- data/examples/data/color.2 +37 -0
- data/examples/data/gemlist.txt +59 -0
- data/examples/data/lotr.txt +12 -0
- data/examples/data/ports.txt +136 -0
- data/examples/data/table.txt +37 -0
- data/examples/data/tasks.csv +88 -0
- data/examples/data/tasks.txt +27 -0
- data/examples/data/todo.txt +16 -0
- data/examples/data/todocsv.csv +28 -0
- data/examples/data/unix1.txt +21 -0
- data/examples/data/unix2.txt +11 -0
- data/examples/dbdemo.rb +506 -0
- data/examples/dirtree.rb +177 -0
- data/examples/newtabbedwindow.rb +100 -0
- data/examples/newtesttabp.rb +92 -0
- data/examples/tabular.rb +212 -0
- data/examples/tasks.rb +179 -0
- data/examples/term2.rb +88 -0
- data/examples/testbuttons.rb +307 -0
- data/examples/testcombo.rb +102 -0
- data/examples/testdb.rb +182 -0
- data/examples/testfields.rb +208 -0
- data/examples/testflowlayout.rb +43 -0
- data/examples/testkeypress.rb +98 -0
- data/examples/testlistbox.rb +187 -0
- data/examples/testlistbox1.rb +199 -0
- data/examples/testmessagebox.rb +144 -0
- data/examples/testprogress.rb +116 -0
- data/examples/testree.rb +107 -0
- data/examples/testsplitlayout.rb +53 -0
- data/examples/testsplitlayout1.rb +49 -0
- data/examples/teststacklayout.rb +48 -0
- data/examples/testwsshortcuts.rb +68 -0
- data/examples/testwsshortcuts2.rb +129 -0
- data/lib/canis.rb +16 -0
- data/lib/canis/core/docs/index.txt +104 -0
- data/lib/canis/core/docs/list.txt +16 -0
- data/lib/canis/core/docs/style_help.yml +34 -0
- data/lib/canis/core/docs/tabbedpane.txt +15 -0
- data/lib/canis/core/docs/table.txt +31 -0
- data/lib/canis/core/docs/textpad.txt +48 -0
- data/lib/canis/core/docs/tree.txt +23 -0
- data/lib/canis/core/include/.DS_Store +0 -0
- data/lib/canis/core/include/action.rb +83 -0
- data/lib/canis/core/include/actionmanager.rb +49 -0
- data/lib/canis/core/include/appmethods.rb +179 -0
- data/lib/canis/core/include/bordertitle.rb +49 -0
- data/lib/canis/core/include/canisparser.rb +100 -0
- data/lib/canis/core/include/colorparser.rb +437 -0
- data/lib/canis/core/include/defaultfilerenderer.rb +64 -0
- data/lib/canis/core/include/io.rb +320 -0
- data/lib/canis/core/include/layouts/SplitLayout.rb +161 -0
- data/lib/canis/core/include/layouts/abstractlayout.rb +213 -0
- data/lib/canis/core/include/layouts/flowlayout.rb +104 -0
- data/lib/canis/core/include/layouts/stacklayout.rb +109 -0
- data/lib/canis/core/include/listbindings.rb +89 -0
- data/lib/canis/core/include/listeditable.rb +319 -0
- data/lib/canis/core/include/listoperations.rb +61 -0
- data/lib/canis/core/include/listselectionmodel.rb +388 -0
- data/lib/canis/core/include/multibuffer.rb +173 -0
- data/lib/canis/core/include/ractionevent.rb +73 -0
- data/lib/canis/core/include/rchangeevent.rb +27 -0
- data/lib/canis/core/include/rhistory.rb +95 -0
- data/lib/canis/core/include/rinputdataevent.rb +47 -0
- data/lib/canis/core/include/textdocument.rb +111 -0
- data/lib/canis/core/include/vieditable.rb +175 -0
- data/lib/canis/core/include/widgetmenu.rb +66 -0
- data/lib/canis/core/system/colormap.rb +165 -0
- data/lib/canis/core/system/keydefs.rb +32 -0
- data/lib/canis/core/system/ncurses.rb +237 -0
- data/lib/canis/core/system/panel.rb +129 -0
- data/lib/canis/core/system/window.rb +1081 -0
- data/lib/canis/core/util/ansiparser.rb +119 -0
- data/lib/canis/core/util/app.rb +696 -0
- data/lib/canis/core/util/basestack.rb +412 -0
- data/lib/canis/core/util/defaultcolorparser.rb +84 -0
- data/lib/canis/core/util/extras/README +5 -0
- data/lib/canis/core/util/extras/bottomline.rb +1815 -0
- data/lib/canis/core/util/extras/padreader.rb +192 -0
- data/lib/canis/core/util/focusmanager.rb +31 -0
- data/lib/canis/core/util/helpmanager.rb +160 -0
- data/lib/canis/core/util/oldwidgetshortcuts.rb +304 -0
- data/lib/canis/core/util/promptmenu.rb +235 -0
- data/lib/canis/core/util/rcommandwindow.rb +933 -0
- data/lib/canis/core/util/rdialogs.rb +520 -0
- data/lib/canis/core/util/textutils.rb +74 -0
- data/lib/canis/core/util/viewer.rb +238 -0
- data/lib/canis/core/util/widgetshortcuts.rb +508 -0
- data/lib/canis/core/widgets/applicationheader.rb +103 -0
- data/lib/canis/core/widgets/box.rb +58 -0
- data/lib/canis/core/widgets/divider.rb +310 -0
- data/lib/canis/core/widgets/extras/README.md +12 -0
- data/lib/canis/core/widgets/extras/rtextarea.rb +960 -0
- data/lib/canis/core/widgets/extras/stackflow.rb +474 -0
- data/lib/canis/core/widgets/keylabelprinter.rb +194 -0
- data/lib/canis/core/widgets/listbox.rb +326 -0
- data/lib/canis/core/widgets/listfooter.rb +86 -0
- data/lib/canis/core/widgets/rcombo.rb +210 -0
- data/lib/canis/core/widgets/rcontainer.rb +415 -0
- data/lib/canis/core/widgets/rlink.rb +30 -0
- data/lib/canis/core/widgets/rmenu.rb +970 -0
- data/lib/canis/core/widgets/rmenulink.rb +30 -0
- data/lib/canis/core/widgets/rmessagebox.rb +400 -0
- data/lib/canis/core/widgets/rprogress.rb +118 -0
- data/lib/canis/core/widgets/rtabbedpane.rb +631 -0
- data/lib/canis/core/widgets/rtabbedwindow.rb +70 -0
- data/lib/canis/core/widgets/rwidget.rb +3634 -0
- data/lib/canis/core/widgets/scrollbar.rb +147 -0
- data/lib/canis/core/widgets/statusline.rb +113 -0
- data/lib/canis/core/widgets/table.rb +1072 -0
- data/lib/canis/core/widgets/tabular.rb +264 -0
- data/lib/canis/core/widgets/textpad.rb +1674 -0
- data/lib/canis/core/widgets/tree.rb +690 -0
- data/lib/canis/core/widgets/tree/treecellrenderer.rb +150 -0
- data/lib/canis/core/widgets/tree/treemodel.rb +432 -0
- data/lib/canis/version.rb +3 -0
- metadata +229 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 816492c76956497f6216f58530ac662a8914f404
|
4
|
+
data.tar.gz: 81030d5970df8c6ada548ad6a5cbe1782d8c2f16
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6a2294dabd5cd4b38db99ca783c7b3d2005dd9c3b3cb2823c4d284cf60d88f503f870cca06b9596224696a4e70f611417a9e29a341f862921df3e07497face81
|
7
|
+
data.tar.gz: 6510464a766ee936761d32fbbaef6e2d9ed21f3e81d7425956f7d45de5dd2d5b1797cfd71c8799f1499187917f1d8a4c971ab8c0de88d777f134ed00730873f5
|
data/.gitignore
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
*.log
|
24
|
+
*.sqlite
|
25
|
+
*.bak
|
26
|
+
todo
|
27
|
+
issues
|
28
|
+
deprecated
|
29
|
+
.srclist
|
30
|
+
NOTES
|
31
|
+
bug
|
32
|
+
examples/common/rmail.rb
|
33
|
+
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
|
+
issues.txt
|
43
|
+
tags
|
44
|
+
test.yml
|
45
|
+
todo.0.0.1
|
data/CHANGES
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
2014-04-22 - 00:13
|
2
|
+
|
3
|
+
Made some changes in getchar to return STRINGS but not implemented. Evaluating benefits
|
4
|
+
in moving to chars, and how to go about.
|
5
|
+
|
6
|
+
2014-04-23 - 00:23
|
7
|
+
|
8
|
+
removed many dead methods from window and some from widget
|
9
|
+
slight changes in button and label : when_form replaced by FORM_ATTACHED
|
10
|
+
|
11
|
+
2014-05-05 - 20:12
|
12
|
+
|
13
|
+
- moved to new cleaner method of reading keys from keyboard
|
14
|
+
- Added ButtonGroup for RadioButtons.
|
15
|
+
- removed Bottomline and enhanced rcommandline instead
|
16
|
+
|
17
|
+
2014-05-09 - 22:23
|
18
|
+
|
19
|
+
- introduced layouts. Now a user can hardcode locations of widgets or use a layout
|
20
|
+
to do the same. A layout is able to handle a resize of the screen.
|
21
|
+
|
22
|
+
2014-05-25 - 16:03
|
23
|
+
|
24
|
+
- Major rewrite of colorparser. now colors are not hardcoded while parsing. We now store link
|
25
|
+
to parent chunk, so that a change in textpads color can affect the pad without a re-parse.
|
26
|
+
Parent's color's are resolved at render time.
|
27
|
+
|
28
|
+
2014-05-31 - 18:20
|
29
|
+
- minor changes that could result in some color related issues with buttons or other widgets
|
30
|
+
- repaint in various widgets no longer sets @bgcolor and @color, it uses the method
|
31
|
+
Same with @attr. messagebox also does not set the color variables but uses the method
|
32
|
+
- clear_pad clear_row uses content_cols i/o width so complete pad is cleared.
|
33
|
+
Also i have put a return in the middle, i think the second part of clear is redundant
|
34
|
+
now, if the first half works properly.
|
35
|
+
|
36
|
+
2014-06-06 - 00:05
|
37
|
+
- Released 0.0.1
|
38
|
+
|
39
|
+
2014-06-19 - 17:16
|
40
|
+
- Still trying to simplify and refactor TextPad so there are no changes for a fairly long time.
|
41
|
+
- Removed content_type complexity into TextDocument so Textpad can be dumb.
|
42
|
+
|
43
|
+
Built 0.0.2 but i did not release it.
|
44
|
+
|
45
|
+
2014-07-09 - 22:48
|
46
|
+
- for 0.0.3
|
47
|
+
- removed label string from Field and moved to LabeledField
|
48
|
+
This change has an impact in many examples, and combo
|
49
|
+
- some changes in creation of $log so that if none specified then it can go to /dev/null
|
50
|
+
This way an app can have its own logger and not bother about canis' logging.
|
51
|
+
Or it can merge the two.
|
52
|
+
- Moved helpmanager from rwidgets to its own file. Needs to be refactored and cleaned up.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 kepler
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Canis
|
2
|
+
|
3
|
+
ncurses library for ruby with essential components/controls only
|
4
|
+
|
5
|
+
Things are looking better now. Textpad seems to be more or less stable as far
|
6
|
+
as changes are concerned
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
gem install canis
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
TODO: Write usage instructions here
|
15
|
+
|
16
|
+
Textpad is more or less frozen. I have also simplified Field a bit.
|
17
|
+
|
18
|
+
## Contributing
|
19
|
+
|
20
|
+
1. Fork it ( https://github.com/[my-github-username]/canis/fork )
|
21
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
22
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
23
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
24
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/canis.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'canis/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "canis"
|
8
|
+
spec.version = Canis::VERSION
|
9
|
+
spec.authors = ["kepler"]
|
10
|
+
spec.email = ["githubkepler.50s@gishpuppy.com"]
|
11
|
+
spec.summary = %q{ruby ncurses library for easy application development}
|
12
|
+
spec.description = %q{ruby ncurses library for easy application development providing most controls, minimal source}
|
13
|
+
spec.homepage = "https://github.com/mare-imbrium/canis"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake", ">= 0.9.6"
|
23
|
+
#spec.add_development_dependency "ffi-ncurses", ">= 0.4.0"
|
24
|
+
spec.add_runtime_dependency "ffi-ncurses", ">= 0.4.0", ">= 0.4.0"
|
25
|
+
end
|
data/examples/alpmenu.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'canis/core/util/app'
|
2
|
+
|
3
|
+
App.new do
|
4
|
+
#title "Demo of Menu - canis"
|
5
|
+
#subtitle "Hit F1 to quit, F2 for menubar toggle"
|
6
|
+
header = app_header "canis #{Canis::VERSION}", :text_center => "Alpine Menu Demo", :text_right =>""
|
7
|
+
|
8
|
+
stack :margin_top => 10, :margin_left => 15 do
|
9
|
+
#w = "Messages".length + 1
|
10
|
+
w = 60
|
11
|
+
menulink :text => "&View Dirs", :width => w, :description => "View Dirs in tree" do |s, *stuff|
|
12
|
+
message "Pressed #{s.text} "
|
13
|
+
load './dirtree.rb'
|
14
|
+
#require './viewtodo'; todo = ViewTodo::TodoApp.new; todo.run
|
15
|
+
end
|
16
|
+
blank
|
17
|
+
menulink :text => "&Tabular", :width => w, :description => "Tabula Rasa" do |s, *stuff|
|
18
|
+
message "Pressed #{s.text} "
|
19
|
+
load './tabular.rb'
|
20
|
+
#require './testtodo'; todo = TestTodo::TodoApp.new; todo.run
|
21
|
+
end
|
22
|
+
blank
|
23
|
+
menulink :text => "&Messages", :width => w, :description => "View Tasks" do |s, *stuff|
|
24
|
+
message "Pressed #{s.text} "
|
25
|
+
load './tasks.rb'
|
26
|
+
end
|
27
|
+
blank
|
28
|
+
menulink :text => "&Database", :width => w, :description => "Database Demo" do |s, *stuff|
|
29
|
+
message "Pressed #{s.getvalue} "
|
30
|
+
load './dbdemo.rb'
|
31
|
+
end
|
32
|
+
blank
|
33
|
+
# somehow ? in mnemonic won't work
|
34
|
+
menulink :text => "&Setup", :width => w, :description => "Configure Alpine options" do |s, *stuff|
|
35
|
+
#message "Pressed #{s.text} "
|
36
|
+
alert "Not done!"
|
37
|
+
end
|
38
|
+
blank
|
39
|
+
menulink :text => "&Quit", :width => w, :description => "Quit this application" do |s, *stuff|
|
40
|
+
quit
|
41
|
+
end
|
42
|
+
@form.bind(:ENTER) do |w|
|
43
|
+
header.text_right = w.text
|
44
|
+
end
|
45
|
+
end # stack
|
46
|
+
end # app
|
data/examples/app.sample
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'canis/core/util/app'
|
2
|
+
def help_text
|
3
|
+
<<-eos
|
4
|
+
Enter as much help text
|
5
|
+
here as you want
|
6
|
+
eos
|
7
|
+
end
|
8
|
+
|
9
|
+
App.new do
|
10
|
+
## application code comes here
|
11
|
+
@form.help_manager.help_text = help_text()
|
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
|
14
|
+
|
15
|
+
@status_line = status_line
|
16
|
+
@status_line.command {
|
17
|
+
|
18
|
+
}
|
19
|
+
end # app
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'canis/core/util/app'
|
2
|
+
require 'fileutils'
|
3
|
+
require './common/rmail'
|
4
|
+
# You need mailread.rb which is present in 1.8, but missing in 1.9
|
5
|
+
# I've loaded it here ... http://gist.github.com/634166 with line encoding
|
6
|
+
# You need to fix paths of local mbox files
|
7
|
+
|
8
|
+
# this will go into top namespace so will conflict with other apps!
|
9
|
+
def testchoose
|
10
|
+
# list filters as you type
|
11
|
+
$log.debug "called CHOOSE " if $log.debug?
|
12
|
+
filter = "*"
|
13
|
+
filter = ENV['PWD']+"/*"
|
14
|
+
str = choose filter, :title => "Files", :prompt => "Choose a file: "
|
15
|
+
message "We got #{str} "
|
16
|
+
end
|
17
|
+
def testnumberedmenu
|
18
|
+
list1 = %w{ ruby perl python erlang rake java lisp scheme chicken }
|
19
|
+
list1[0] = %w{ ruby ruby1.9 ruby1.8.x jruby rubinius ROR }
|
20
|
+
list1[5] = %w{ java groovy grails }
|
21
|
+
str = numbered_menu list1, { :title => "Languages: ", :prompt => "Select :" }
|
22
|
+
$log.debug "17 We got #{str.class} "
|
23
|
+
message "We got #{str} "
|
24
|
+
end
|
25
|
+
def testdisplay_list
|
26
|
+
# scrollable list
|
27
|
+
str = display_list Dir.glob("t*.rb"), :title => "Select a file"
|
28
|
+
$log.debug "23 We got #{str} : #{str.class} , #{str.list[str.current_index]} "
|
29
|
+
message "We got #{str.list[str.current_index]} "
|
30
|
+
end
|
31
|
+
def testdisplay_text
|
32
|
+
str = display_text_interactive File.read($0), :title => "#{$0}"
|
33
|
+
end
|
34
|
+
def testdir
|
35
|
+
# this behaves like vim's file selector, it fills in values
|
36
|
+
str = ask("File? ", Pathname) do |q|
|
37
|
+
q.completion_proc = Proc.new {|str| Dir.glob(str +"*").collect { |f| File.directory?(f) ? f+"/" : f } }
|
38
|
+
q.helptext = "Enter start of filename and tab to get completion"
|
39
|
+
end
|
40
|
+
message "We got #{str} "
|
41
|
+
end
|
42
|
+
def test
|
43
|
+
end
|
44
|
+
def saveas1
|
45
|
+
@tv.saveas
|
46
|
+
end
|
47
|
+
|
48
|
+
# experimental.
|
49
|
+
# if components have some commands, can we find a way of passing the command to them
|
50
|
+
# method_missing gave a stack overflow.
|
51
|
+
def execute_this(meth, *args)
|
52
|
+
$log.debug "app email got #{meth} " if $log.debug?
|
53
|
+
cc = @vim.current_component
|
54
|
+
[cc, @lb2, @tv].each do |c|
|
55
|
+
if c.respond_to?(meth, true)
|
56
|
+
c.send(meth, *args)
|
57
|
+
return true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
false
|
61
|
+
end
|
62
|
+
|
63
|
+
App.new do
|
64
|
+
ht = 24
|
65
|
+
@messages = nil
|
66
|
+
$unread_hash = {}
|
67
|
+
@tv = nil
|
68
|
+
borderattrib = :reverse
|
69
|
+
@header = app_header "canis #{Canis::VERSION}", :text_center => "Yet Another Email Client that sucks", :text_right =>"", :color => :black, :bgcolor => :white
|
70
|
+
message "Press F10 to exit ...................................................."
|
71
|
+
|
72
|
+
|
73
|
+
stack :margin_top => 1, :margin => 0, :width => :EXPAND do
|
74
|
+
# NOTE: please fix the next 2 lines based on where your mbox files reside
|
75
|
+
model = ["~/mbox"]
|
76
|
+
others = "~/mail/"
|
77
|
+
boxes = Dir.new(File.expand_path(others)).entries
|
78
|
+
boxes.delete(".")
|
79
|
+
boxes.delete("..")
|
80
|
+
boxes = boxes.collect do |e| others+e; end
|
81
|
+
model.push *boxes
|
82
|
+
|
83
|
+
#@vim = MasterDetail.new @form, :row => 1, :col => 1, :width => :EXPAND
|
84
|
+
@vim = master_detail :width => :EXPAND
|
85
|
+
@dirs = listbox :list => model, :height => ht, :border_attrib => borderattrib, :suppress_borders => true
|
86
|
+
@dirs.one_key_selection = false
|
87
|
+
|
88
|
+
# commands that can be mapped to or executed using M-x
|
89
|
+
# however, commands of components aren't yet accessible.
|
90
|
+
def get_commands
|
91
|
+
%w{ testchoose testnumberedmenu testdisplay_list testdisplay_text testdir saveas1 }
|
92
|
+
end
|
93
|
+
# we override/open instance so as to only print basename. Also, print unread count
|
94
|
+
def @dirs.convert_value_to_text(text, crow)
|
95
|
+
str = File.basename(text)
|
96
|
+
if $unread_hash.has_key?(str)
|
97
|
+
str << " (#{$unread_hash[str]})"
|
98
|
+
else
|
99
|
+
str
|
100
|
+
end
|
101
|
+
end
|
102
|
+
def test1XX
|
103
|
+
$log.debug "called test1 " if $log.debug?
|
104
|
+
str = choose "*.rb", :title => "Files", :prompt => "Choose a file: "
|
105
|
+
end
|
106
|
+
def help_text
|
107
|
+
<<-eos
|
108
|
+
APPEMAIL HELP
|
109
|
+
|
110
|
+
This is some help text for appemail.
|
111
|
+
We are testing out this feature.
|
112
|
+
|
113
|
+
Alt-x - Command mode (<tab> to see commands and select)
|
114
|
+
: - Command mode
|
115
|
+
<Enter> - Display mail headers for mailbox
|
116
|
+
Display body for selected header
|
117
|
+
F3 - Enable sidebars in order to change size of windows (toggle)
|
118
|
+
F10 - Quit application
|
119
|
+
|
120
|
+
Some commands for using bottom of screen as vim and emacs do.
|
121
|
+
|
122
|
+
testchoose - filter directory list as you type
|
123
|
+
testdir - vim style, tabbing completes matching files
|
124
|
+
testnumberedmenu - use menu indexes to select options
|
125
|
+
testdisplaylist - display a list at bottom of screen
|
126
|
+
testdisplaytext - display text at bottom
|
127
|
+
|
128
|
+
-----------------------------------------------------------------------
|
129
|
+
Hope you enjoyed this help.
|
130
|
+
eos
|
131
|
+
end
|
132
|
+
@vim.set_left_component @dirs
|
133
|
+
|
134
|
+
|
135
|
+
@mails = []
|
136
|
+
headings = %w{ Stat # Date From Subject }
|
137
|
+
@lb2 = tabular_widget :suppress_borders => true
|
138
|
+
@lb2.columns = headings
|
139
|
+
@lb2.column_align 1, :right
|
140
|
+
@lb2.column_align 0, :right
|
141
|
+
@lb2.header_fgcolor :white
|
142
|
+
@lb2.header_bgcolor :cyan
|
143
|
+
@vim.set_right_top_component @lb2
|
144
|
+
@dirs.bind :PRESS do |e|
|
145
|
+
@lines = []
|
146
|
+
mx = Mbox.new File.expand_path(e.text)
|
147
|
+
mx.array_each do |text|
|
148
|
+
@lines << text
|
149
|
+
end
|
150
|
+
message_immediate " #{e.text} has #{@lines.size} messages"
|
151
|
+
$unread_hash[File.basename(e.text)] = mx.unread_count
|
152
|
+
@lb2.set_content @lines
|
153
|
+
@lb2.estimate_column_widths=true
|
154
|
+
@messages = mx.mails()
|
155
|
+
end
|
156
|
+
@lb2.bind :PRESS do |e|
|
157
|
+
case @lb2
|
158
|
+
when Canis::TabularWidget
|
159
|
+
if e.action_command == :header
|
160
|
+
# now does sorting on multiple keys
|
161
|
+
else
|
162
|
+
index = e.source.current_index - 1 # this should check what first data index is
|
163
|
+
if index >= 0
|
164
|
+
@tv.set_content(@messages[index].body, :WRAP_WORD)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
else
|
168
|
+
@tv.set_content(@messages[e.source.current_index].body, :WRAP_WORD)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
@lb2.bind :ENTER_ROW do |e|
|
172
|
+
@header.text_right "Row #{e.current_index} of #{@messages.size} "
|
173
|
+
message "Row #{e.current_index} of #{@messages.size} "
|
174
|
+
raw_message "Row #{e.current_index} of #{@messages.size} " # 2011-10-17 14:08:27
|
175
|
+
x = e.current_index
|
176
|
+
y = @messages.size
|
177
|
+
#raw_progress((x*1.0)/y)
|
178
|
+
#raw_progress([x,y])
|
179
|
+
end
|
180
|
+
|
181
|
+
@tv = @vim.set_right_bottom_component "Email body comes here. "
|
182
|
+
@tv.suppress_borders true
|
183
|
+
@tv.border_attrib = borderattrib
|
184
|
+
end # stack
|
185
|
+
@statusline = status_line :row => Ncurses.LINES-1
|
186
|
+
#@statusline.command { }
|
187
|
+
@form.bind_key(?\M-v) { test11() }
|
188
|
+
@form.bind_key(?\M-V) { testme() }
|
189
|
+
@form.bind_key(?\M-c) { test1() }
|
190
|
+
@form.bind_key(?\M-C) { test2() }
|
191
|
+
end # app
|