cura 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +15 -0
  3. data/Gemfile.lock +122 -0
  4. data/LICENSE +20 -0
  5. data/README.md +159 -0
  6. data/Rakefile +42 -0
  7. data/cura.gemspec +23 -0
  8. data/examples/box_model/bin/box_model +11 -0
  9. data/examples/box_model/debug.log +0 -0
  10. data/examples/box_model/lib/box_model.rb +21 -0
  11. data/examples/box_model/lib/box_model/application.rb +24 -0
  12. data/examples/hello_world/bin/hello_world +10 -0
  13. data/examples/hello_world/lib/hello_world.rb +201 -0
  14. data/examples/mruby-examples/README.md +10 -0
  15. data/examples/mruby-examples/include/cura_examples.h +6 -0
  16. data/examples/mruby-examples/mrbgem.rake +14 -0
  17. data/examples/mruby-examples/src/gem_init.c +34 -0
  18. data/examples/mruby-examples/tools/hello_world/hello_world.c +6 -0
  19. data/examples/todo_list/app.log +9 -0
  20. data/examples/todo_list/bin/todo_list +26 -0
  21. data/examples/todo_list/data.db +0 -0
  22. data/examples/todo_list/debug.log +0 -0
  23. data/examples/todo_list/lib/todo_list.rb +28 -0
  24. data/examples/todo_list/lib/todo_list/application.rb +54 -0
  25. data/examples/todo_list/lib/todo_list/component/header.rb +27 -0
  26. data/examples/todo_list/lib/todo_list/component/list.rb +50 -0
  27. data/examples/todo_list/lib/todo_list/component/list_item.rb +28 -0
  28. data/examples/todo_list/lib/todo_list/component/list_items.rb +97 -0
  29. data/examples/todo_list/lib/todo_list/component/lists.rb +89 -0
  30. data/examples/todo_list/lib/todo_list/database.rb +50 -0
  31. data/examples/todo_list/lib/todo_list/model/list.rb +9 -0
  32. data/examples/todo_list/lib/todo_list/model/list_item.rb +9 -0
  33. data/examples/todo_list/profile.html +11354 -0
  34. data/lib/cura.rb +13 -0
  35. data/lib/cura/adapter.rb +67 -0
  36. data/lib/cura/application.rb +245 -0
  37. data/lib/cura/attributes/has_ancestry.rb +40 -0
  38. data/lib/cura/attributes/has_application.rb +31 -0
  39. data/lib/cura/attributes/has_attributes.rb +89 -0
  40. data/lib/cura/attributes/has_children.rb +113 -0
  41. data/lib/cura/attributes/has_colors.rb +66 -0
  42. data/lib/cura/attributes/has_coordinates.rb +49 -0
  43. data/lib/cura/attributes/has_dimensions.rb +63 -0
  44. data/lib/cura/attributes/has_events.rb +89 -0
  45. data/lib/cura/attributes/has_focusability.rb +37 -0
  46. data/lib/cura/attributes/has_initialize.rb +15 -0
  47. data/lib/cura/attributes/has_offsets.rb +82 -0
  48. data/lib/cura/attributes/has_orientation.rb +53 -0
  49. data/lib/cura/attributes/has_relative_coordinates.rb +39 -0
  50. data/lib/cura/attributes/has_root.rb +104 -0
  51. data/lib/cura/attributes/has_side_attributes.rb +95 -0
  52. data/lib/cura/attributes/has_windows.rb +70 -0
  53. data/lib/cura/borders.rb +16 -0
  54. data/lib/cura/color.rb +330 -0
  55. data/lib/cura/component/base.rb +180 -0
  56. data/lib/cura/component/button.rb +57 -0
  57. data/lib/cura/component/group.rb +77 -0
  58. data/lib/cura/component/label.rb +224 -0
  59. data/lib/cura/component/listbox.rb +152 -0
  60. data/lib/cura/component/pack.rb +144 -0
  61. data/lib/cura/component/scrollbar.rb +184 -0
  62. data/lib/cura/component/textbox.rb +118 -0
  63. data/lib/cura/cursor.rb +77 -0
  64. data/lib/cura/error/base.rb +10 -0
  65. data/lib/cura/error/invalid_adapter.rb +18 -0
  66. data/lib/cura/error/invalid_application.rb +18 -0
  67. data/lib/cura/error/invalid_color.rb +18 -0
  68. data/lib/cura/error/invalid_component.rb +18 -0
  69. data/lib/cura/error/invalid_middleware.rb +18 -0
  70. data/lib/cura/event.rb +38 -0
  71. data/lib/cura/event/base.rb +108 -0
  72. data/lib/cura/event/click.rb +14 -0
  73. data/lib/cura/event/dispatcher.rb +122 -0
  74. data/lib/cura/event/focus.rb +14 -0
  75. data/lib/cura/event/handler.rb +74 -0
  76. data/lib/cura/event/key_down.rb +68 -0
  77. data/lib/cura/event/middleware/aimer/base.rb +38 -0
  78. data/lib/cura/event/middleware/aimer/dispatcher_target.rb +24 -0
  79. data/lib/cura/event/middleware/aimer/mouse_focus.rb +48 -0
  80. data/lib/cura/event/middleware/aimer/target_option.rb +38 -0
  81. data/lib/cura/event/middleware/base.rb +21 -0
  82. data/lib/cura/event/middleware/dispatch.rb +20 -0
  83. data/lib/cura/event/middleware/translator/base.rb +37 -0
  84. data/lib/cura/event/middleware/translator/mouse_click.rb +44 -0
  85. data/lib/cura/event/mouse.rb +34 -0
  86. data/lib/cura/event/mouse_button.rb +103 -0
  87. data/lib/cura/event/mouse_wheel_down.rb +14 -0
  88. data/lib/cura/event/mouse_wheel_up.rb +14 -0
  89. data/lib/cura/event/resize.rb +17 -0
  90. data/lib/cura/event/selected.rb +14 -0
  91. data/lib/cura/event/unfocus.rb +14 -0
  92. data/lib/cura/focus_controller.rb +89 -0
  93. data/lib/cura/key.rb +313 -0
  94. data/lib/cura/margins.rb +16 -0
  95. data/lib/cura/offsets.rb +91 -0
  96. data/lib/cura/padding.rb +16 -0
  97. data/lib/cura/pencil.rb +29 -0
  98. data/lib/cura/version.rb +6 -0
  99. data/lib/cura/window.rb +85 -0
  100. data/spec/cura/attributes/has_ancestry_spec.rb +108 -0
  101. data/spec/cura/attributes/has_application_spec.rb +59 -0
  102. data/spec/cura/attributes/has_attributes_spec.rb +75 -0
  103. data/spec/cura/attributes/has_children_spec.rb +169 -0
  104. data/spec/cura/attributes/has_colors_spec.rb +20 -0
  105. data/spec/cura/attributes/has_coordinates_spec.rb +19 -0
  106. data/spec/cura/attributes/has_dimensions_spec.rb +19 -0
  107. data/spec/cura/attributes/has_events_spec.rb +18 -0
  108. data/spec/cura/attributes/has_focusability_spec.rb +58 -0
  109. data/spec/cura/attributes/has_offsets_spec.rb +18 -0
  110. data/spec/cura/attributes/has_orientation_spec.rb +102 -0
  111. data/spec/cura/attributes/has_relative_coordinates_spec.rb +18 -0
  112. data/spec/cura/attributes/has_side_attributes_spec.rb +19 -0
  113. data/spec/spec_helper.rb +12 -0
  114. data/spec/support/shared_examples_for_attributes.rb +122 -0
  115. metadata +211 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2dc4976329742a1e8bc47cc375e5ff89ef1497b7
4
+ data.tar.gz: 0c8446f8d98820d0da375ba4e34e339a5c6b9a72
5
+ SHA512:
6
+ metadata.gz: ae30d4bb7ace9f7aa1691a2f2bf50977a6c83ea1d7d4e4b14c60a202abd7a8518bab8ef3c10aba4244943c82b4c8f2155c5eeab46458a67e91c50fa27ec5a362
7
+ data.tar.gz: b3916599cb6e07dfa49a0829c524b4553def25e987d9249b84180b18bcc8cc43f578436d91fff0d7f2544a569d9d8a9084fceb1b95513a62ac378ad7d659860e
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "fuubar", "~> 2.0.0"
5
+ gem "mutant-rspec", "~> 0.8.0"
6
+ gem "rake", "~> 10.4.2"
7
+ gem "reek", "~> 3.0.4"
8
+ gem "rspec", "~> 3.3.0"
9
+ gem "rubocop", "~> 0.32.1"
10
+ gem "ruby-prof", "~> 0.15.8"
11
+ gem "simplecov-json", "~> 0.2"
12
+ gem "simplecov", "~> 0.10.0"
13
+ gem "yard", "~> 0.8.7.6"
14
+ gem "yardstick", "~> 0.9.9"
15
+ end
@@ -0,0 +1,122 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ abstract_type (0.0.7)
5
+ adamantium (0.2.0)
6
+ ice_nine (~> 0.11.0)
7
+ memoizable (~> 0.4.0)
8
+ anima (0.2.0)
9
+ abstract_type (~> 0.0.7)
10
+ adamantium (~> 0.1)
11
+ equalizer (~> 0.0.8)
12
+ ast (2.0.0)
13
+ astrolabe (1.3.1)
14
+ parser (~> 2.2)
15
+ concord (0.1.5)
16
+ adamantium (~> 0.2.0)
17
+ equalizer (~> 0.0.9)
18
+ diff-lcs (1.2.5)
19
+ docile (1.1.5)
20
+ equalizer (0.0.11)
21
+ fuubar (2.0.0)
22
+ rspec (~> 3.0)
23
+ ruby-progressbar (~> 1.4)
24
+ ice_nine (0.11.1)
25
+ json (1.8.3)
26
+ memoizable (0.4.2)
27
+ thread_safe (~> 0.3, >= 0.3.1)
28
+ morpher (0.2.3)
29
+ abstract_type (~> 0.0.7)
30
+ adamantium (~> 0.2.0)
31
+ anima (~> 0.2.0)
32
+ ast (~> 2.0.0)
33
+ concord (~> 0.1.4)
34
+ equalizer (~> 0.0.9)
35
+ ice_nine (~> 0.11.0)
36
+ procto (~> 0.0.2)
37
+ mutant (0.8.0)
38
+ abstract_type (~> 0.0.7)
39
+ adamantium (~> 0.2.0)
40
+ anima (~> 0.2.0)
41
+ ast (~> 2.0)
42
+ concord (~> 0.1.5)
43
+ diff-lcs (~> 1.2)
44
+ equalizer (~> 0.0.9)
45
+ ice_nine (~> 0.11.1)
46
+ memoizable (~> 0.4.2)
47
+ morpher (~> 0.2.3)
48
+ parallel (~> 1.3)
49
+ parser (~> 2.2.2)
50
+ procto (~> 0.0.2)
51
+ unparser (~> 0.2.4)
52
+ mutant-rspec (0.8.0)
53
+ mutant (~> 0.8.0)
54
+ rspec-core (>= 3.2.0, < 3.4.0)
55
+ parallel (1.6.0)
56
+ parser (2.2.2.6)
57
+ ast (>= 1.1, < 3.0)
58
+ powerpack (0.1.1)
59
+ procto (0.0.2)
60
+ rainbow (2.0.0)
61
+ rake (10.4.2)
62
+ reek (3.0.4)
63
+ parser (~> 2.2.2.5)
64
+ rainbow (~> 2.0)
65
+ unparser (~> 0.2.2)
66
+ rspec (3.3.0)
67
+ rspec-core (~> 3.3.0)
68
+ rspec-expectations (~> 3.3.0)
69
+ rspec-mocks (~> 3.3.0)
70
+ rspec-core (3.3.1)
71
+ rspec-support (~> 3.3.0)
72
+ rspec-expectations (3.3.0)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.3.0)
75
+ rspec-mocks (3.3.1)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.3.0)
78
+ rspec-support (3.3.0)
79
+ rubocop (0.32.1)
80
+ astrolabe (~> 1.3)
81
+ parser (>= 2.2.2.5, < 3.0)
82
+ powerpack (~> 0.1)
83
+ rainbow (>= 1.99.1, < 3.0)
84
+ ruby-progressbar (~> 1.4)
85
+ ruby-prof (0.15.8)
86
+ ruby-progressbar (1.7.5)
87
+ simplecov (0.10.0)
88
+ docile (~> 1.1.0)
89
+ json (~> 1.8)
90
+ simplecov-html (~> 0.10.0)
91
+ simplecov-html (0.10.0)
92
+ simplecov-json (0.2)
93
+ json
94
+ simplecov
95
+ thread_safe (0.3.5)
96
+ unparser (0.2.4)
97
+ abstract_type (~> 0.0.7)
98
+ adamantium (~> 0.2.0)
99
+ concord (~> 0.1.5)
100
+ diff-lcs (~> 1.2.5)
101
+ equalizer (~> 0.0.9)
102
+ parser (~> 2.2.2)
103
+ procto (~> 0.0.2)
104
+ yard (0.8.7.6)
105
+ yardstick (0.9.9)
106
+ yard (~> 0.8, >= 0.8.7.2)
107
+
108
+ PLATFORMS
109
+ ruby
110
+
111
+ DEPENDENCIES
112
+ fuubar (~> 2.0.0)
113
+ mutant-rspec (~> 0.8.0)
114
+ rake (~> 10.4.2)
115
+ reek (~> 3.0.4)
116
+ rspec (~> 3.3.0)
117
+ rubocop (~> 0.32.1)
118
+ ruby-prof (~> 0.15.8)
119
+ simplecov (~> 0.10.0)
120
+ simplecov-json (~> 0.2)
121
+ yard (~> 0.8.7.6)
122
+ yardstick (~> 0.9.9)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Ryan Scott Lewis <ryan@rynet.us>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,159 @@
1
+ # Cura
2
+
3
+ A component toolkit for creating both graphical and text-based user interfaces.
4
+
5
+ Cura provides:
6
+
7
+ * Component system
8
+ * * Tree hierarchy
9
+ * * Box model layouts
10
+ * Event system
11
+ * * Dispatching
12
+ * * Middleware (aiming & translating)
13
+ * * Handling
14
+ * * Delegation
15
+ * Adapter system
16
+
17
+ ## Install
18
+
19
+ ### Bundler: `gem 'cura'`
20
+
21
+ ### RubyGems: `gem install cura`
22
+
23
+ ## Adapters
24
+
25
+ ### Ruby
26
+
27
+ Used for its libraries.
28
+
29
+ **Text-based User Interface (TUI)**
30
+
31
+ * [Termbox][ruby-termbox]
32
+ * [Termbox FFI][ruby-termbox-ffi]
33
+ * [Curses][ruby-curses]
34
+
35
+ **Graphical User Interface (GUI)**
36
+
37
+ * [OpenGL][ruby-opengl]
38
+ * [OpenGL FFI][ruby-opengl-ffi]
39
+ * [SDL][ruby-sdl]
40
+ * [SDL FFI][ruby-sdl-ffi]
41
+ * [Gosu][ruby-gosu]
42
+
43
+ ### MRuby
44
+
45
+ Used for its compilability and portability.
46
+
47
+ **Text-based User Interface (TUI)**
48
+
49
+ * [Termbox][mruby-termbox]
50
+
51
+ **Graphical User Interface (GUI)**
52
+
53
+ * [SDL][mruby-sdl]
54
+
55
+ ### JRuby
56
+
57
+ Used for compilability, speed, and libraries.
58
+ Ruby FFI based adapters should also work in JRuby.
59
+
60
+ **Text-based User Interface (TUI)**
61
+
62
+ * [Lanterna][jruby-lanterna]
63
+
64
+ **Graphical User Interface (GUI)**
65
+
66
+ * [AWT][jruby-awt]
67
+
68
+ ## Usage
69
+
70
+ > **NOTE:** The following is not functional yet. Move along...
71
+
72
+ ```rb
73
+ require 'cura'
74
+
75
+ # Define our window
76
+
77
+ class MainWindow < Cura::Window
78
+
79
+ def initialize
80
+ super
81
+
82
+ @label = Cura::Label.new(
83
+ text: 'Hello, world!',
84
+ bold: true,
85
+ underline: true,
86
+ alignment: { horizontal: :center },
87
+ margin: 10,
88
+ border: { size: 1, color: Cura::Color.red },
89
+ padding: 3
90
+ )
91
+
92
+ add_child( @label ) # Will mixin any adapter methods for Label
93
+ end
94
+
95
+ end
96
+
97
+ # Define our application and add our window
98
+
99
+ class Application < Cura::Application
100
+
101
+ def initialize
102
+ super
103
+
104
+ @window = MainWindow.new
105
+
106
+ add_window( @window )
107
+
108
+ @window.show # Note that in TUIs, only one window can be shown at once.
109
+ end
110
+
111
+ end
112
+
113
+ # Require any adapters
114
+
115
+ require 'cura-adapter-termbox'
116
+ require 'cura-adapter-termbox-ffi'
117
+ require 'cura-adapter-curses'
118
+ require 'cura-adapter-sdl'
119
+ require 'cura-adapter-sdl-ffi'
120
+ require 'cura-adapter-opengl'
121
+ require 'cura-adapter-opengl-ffi'
122
+ require 'cura-adapter-gosu'
123
+
124
+ # Choose adapter
125
+
126
+ adapter_names = Cura::Adapter.all.collect(&:name)
127
+ adapter = loop do
128
+ puts "Choose one or type 'exit': #{ adapter_names.join(', ') }"
129
+ print '> '
130
+
131
+ answer = gets.downcase.strip
132
+
133
+ exit if answer == 'exit'
134
+ retry unless adapter_names.include?( answer.to_sym )
135
+ end
136
+
137
+ # Run application with adapter
138
+
139
+ Application.run( adapter: adapter )
140
+ ```
141
+
142
+ ## Copyright
143
+
144
+ Copyright © 2015 Ryan Scott Lewis <ryan@rynet.us>.
145
+
146
+ The MIT License (MIT) - See LICENSE for further details.
147
+
148
+ [ruby-termbox]: https://github.com/RyanScottLewis/ruby-cura-adapter-termbox
149
+ [ruby-termbox-ffi]: https://github.com/RyanScottLewis/ruby-cura-adapter-termbox-ffi
150
+ [ruby-curses]: https://github.com/RyanScottLewis/ruby-cura-adapter-curses
151
+ [ruby-sdl]: https://github.com/RyanScottLewis/ruby-cura-adapter-sdl
152
+ [ruby-sdl-ffi]: https://github.com/RyanScottLewis/ruby-cura-adapter-sdl-ffi
153
+ [ruby-opengl]: https://github.com/RyanScottLewis/ruby-cura-adapter-opengl
154
+ [ruby-opengl-ffi]: https://github.com/RyanScottLewis/ruby-cura-adapter-opengl-ffi
155
+ [ruby-gosu]: https://github.com/RyanScottLewis/ruby-cura-adapter-gosu
156
+ [mruby-termbox]: https://github.com/RyanScottLewis/mruby-cura-adapter-termbox
157
+ [mruby-sdl]: https://github.com/RyanScottLewis/mruby-cura-adapter-sdl
158
+ [jruby-lanterna]: https://github.com/RyanScottLewis/jruby-cura-adapter-lanterna
159
+ [jruby-awt]: https://github.com/RyanScottLewis/jruby-cura-adapter-awt
@@ -0,0 +1,42 @@
1
+ require "pathname"
2
+ require "rubygems/package_task"
3
+ require "yard"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+ require "reek/rake/task"
7
+ require "yardstick/rake/measurement"
8
+ require "yardstick/rake/verify"
9
+
10
+ gemspec = Pathname.glob(Pathname.new(__FILE__).join("..", "*.gemspec")).first
11
+ spec = Gem::Specification.load(gemspec.to_s)
12
+
13
+ Gem::PackageTask.new(spec) do |task|
14
+ task.need_zip = false
15
+ end
16
+
17
+ YARD::Rake::YardocTask.new
18
+
19
+ RSpec::Core::RakeTask.new(:spec)
20
+
21
+ RuboCop::RakeTask.new do |task|
22
+ task.patterns = ["lib/**/*.rb"]
23
+ task.formatters = ["fuubar"]
24
+ end
25
+
26
+ Reek::Rake::Task.new do |t|
27
+ t.fail_on_error = false
28
+ end
29
+
30
+ options = YAML.load_file(".yardstick.yml")
31
+ Yardstick::Rake::Measurement.new(:yardstick, options) do |measurement|
32
+ measurement.output = "coverage/yard.txt"
33
+ end
34
+
35
+ # Yardstick::Rake::Verify.new do |verify|
36
+ # verify.threshold = 100
37
+ # end
38
+
39
+ desc "Mutation testing"
40
+ task :mutant do
41
+ exec("mutant --include lib --require cura --use rspec Cura*")
42
+ end
@@ -0,0 +1,23 @@
1
+ require "pathname"
2
+ require_relative "lib/cura/version.rb"
3
+
4
+ # cura : management, administration, care, concern, charge
5
+ Gem::Specification.new do |s|
6
+ # Variables
7
+ s.author = "Ryan Scott Lewis"
8
+ s.email = "ryan@rynet.us"
9
+ s.summary = "A library written in pure Ruby for building user interfaces."
10
+ s.license = "MIT"
11
+ s.version = Cura::VERSION
12
+
13
+ # Dependencies
14
+ s.add_development_dependency "builder", "~> 3.2.2" # TODO: What? Is this needed?
15
+
16
+ # Pragmatically set variables
17
+ s.homepage = "http://github.com/RyanScottLewis/#{s.name}"
18
+ s.description = s.summary
19
+ s.name = Pathname.new(__FILE__).basename(".gemspec").to_s
20
+ s.require_paths = ["lib"]
21
+ s.files = Dir["{{Rake,Gem}file{.lock,},README*,VERSION,LICENSE,*.gemspec,{lib,bin,spec}/**/*.rb}"]
22
+ s.test_files = Dir["{examples,spec,test}/**/*"]
23
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "pathname"
4
+ $LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "..", "..", "lib").expand_path.to_s)
5
+ $LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "..", "..", "..", "ruby-cura-termbox_ffi", "lib").expand_path.to_s)
6
+ $LOAD_PATH.unshift(Pathname.new(__FILE__).join("..", "..", "lib").expand_path.to_s)
7
+
8
+ require "box_model"
9
+ require "cura/termbox_ffi/adapter"
10
+
11
+ BoxModel.run
File without changes
@@ -0,0 +1,21 @@
1
+ require "pathname"
2
+
3
+ LOG_PATH = Pathname.new(__FILE__).join("..", "..", "debug.log")
4
+ LOG_PATH.truncate(0) if LOG_PATH.exist?
5
+
6
+ require "logger"
7
+ LOGGER = Logger.new(LOG_PATH)
8
+
9
+ require "box_model/application"
10
+
11
+ module BoxModel
12
+
13
+ class << self
14
+
15
+ def run
16
+ Application.run
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,24 @@
1
+ require "cura"
2
+
3
+ module BoxModel
4
+
5
+ class Application < Cura::Application
6
+
7
+ on_event(:key_down) { |event| stop if event.control? && event.name == :C }
8
+
9
+ def initialize(attributes={})
10
+ super
11
+
12
+ window = Cura::Window.new
13
+ add_window(window)
14
+
15
+ group = Cura::Component::Group.new(background: Cura::Color.red, margin: 1, padding: 1)
16
+ window.add_child(group)
17
+
18
+ label = Cura::Component::Label.new(text: "Hello, world!", background: Cura::Color.blue, padding: 1)
19
+ group.add_child(label)
20
+ end
21
+
22
+ end
23
+
24
+ end