Class: Vedeu::Runtime::MainLoop

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/runtime/main_loop.rb

Overview

Provides the main loop for a Vedeu application.

Class Method Summary collapse

Class Method Details

.mode_switch!(mode = nil) ⇒ Object

Parameters:

  • mode (Symbol) (defaults to: nil)


20
21
22
23
24
25
26
27
28
29
# File 'lib/vedeu/runtime/main_loop.rb', line 20

def mode_switch!(mode = nil)
  @loop        = false
  @mode_switch = true

  Vedeu::Terminal::Mode.switch_mode!(mode)

  Vedeu.trigger(:_drb_restart_)

  fail Vedeu::Error::ModeSwitch
end

.safe_exit_point!void

This method returns an undefined value.

Check the application has started and we wish to continue running.

Raises:



66
67
68
# File 'lib/vedeu/runtime/main_loop.rb', line 66

def safe_exit_point!
  fail Vedeu::Error::Interrupt if @started && !@loop
end

.start!void

This method returns an undefined value.

Start the main loop.

Yield Returns:

  • (void)

    The client application.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vedeu/runtime/main_loop.rb', line 35

def start!
  @started     = true
  @loop        = true
  @mode_switch = false

  Vedeu.trigger(:_refresh_cursor_, Vedeu.focus)

  Vedeu.trigger(:_refresh_)

  while @loop
    yield

    safe_exit_point!
  end
rescue Vedeu::Error::Interrupt
  Vedeu.log(message: 'Vedeu execution interrupted, exiting.')
end

.stop!void

This method returns an undefined value.

Signal that we wish to terminate the running application.



56
57
58
# File 'lib/vedeu/runtime/main_loop.rb', line 56

def stop!
  @loop = false
end