Class: DXRubyEditor::Editor
- Inherits:
-
RenderTarget
- Object
- RenderTarget
- DXRubyEditor::Editor
- Defined in:
- lib/dxruby_editor/editor.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#theme ⇒ Object
Returns the value of attribute theme.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
-
#_update ⇒ Object
main loop.
- #debug ⇒ Object
-
#initialize(width: 640, height: Window.height, theme: nil) ⇒ Editor
constructor
call once.
- #new_file(text: '') ⇒ Object
- #open(file_name, size: 640, theme: nil) ⇒ Object
- #production ⇒ Object
Constructor Details
#initialize(width: 640, height: Window.height, theme: nil) ⇒ Editor
call once
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/dxruby_editor/editor.rb', line 11 def initialize(width: 640, height: Window.height, theme: nil) Window.before_call[:editor_update] = method(:_update) Window.after_call[:editor_draw] = method(:_rendering) @width = width @height = height @theme = theme || Core::Theme.new super(width, height, @theme[:bg]) @x = Window.width - @width @y = 0 @context = nil self end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/dxruby_editor/editor.rb', line 3 def context @context end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
3 4 5 |
# File 'lib/dxruby_editor/editor.rb', line 3 def height @height end |
#theme ⇒ Object
Returns the value of attribute theme.
4 5 6 |
# File 'lib/dxruby_editor/editor.rb', line 4 def theme @theme end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
3 4 5 |
# File 'lib/dxruby_editor/editor.rb', line 3 def width @width end |
#x ⇒ Object
Returns the value of attribute x.
4 5 6 |
# File 'lib/dxruby_editor/editor.rb', line 4 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
4 5 6 |
# File 'lib/dxruby_editor/editor.rb', line 4 def y @y end |
Instance Method Details
#_update ⇒ Object
main loop
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/dxruby_editor/editor.rb', line 55 def _update Core::KeyInput.update(@context) Core::MouseInput.update(@context) Core::Command.update(@context) @run_code = @context.str if Input.key_push?(K_F5) if @run_code puts "----------------------------" puts @run_code end begin eval(@run_code || '') rescue StandardError => e puts(e.) end @context.tick += 1 end |
#debug ⇒ Object
50 |
# File 'lib/dxruby_editor/editor.rb', line 50 def debug; end |
#new_file(text: '') ⇒ Object
30 31 32 33 34 35 |
# File 'lib/dxruby_editor/editor.rb', line 30 def new_file(text: '') i = 1 file_name = "untitled-#{i}.rb" file_name = "untitled-#{i += 1}.rb" while File.exist?(file_name) @context = EditorContext.new(file_name, text) end |
#open(file_name, size: 640, theme: nil) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/dxruby_editor/editor.rb', line 42 def open(file_name, size: 640, theme: nil) file = File.open(File.join($LOAD_PATH[0], file_name), 'r') text = file.read file.close @context = EditorContext.new(file_name, text) end |
#production ⇒ Object
52 |
# File 'lib/dxruby_editor/editor.rb', line 52 def production; end |