Class: Terminitor::CmdCore

Inherits:
AbstractCore show all
Defined in:
lib/terminitor/cores/cmd_core/cmd_core.rb

Constant Summary collapse

CMD_XLT =
{
  'clear' => 'cls'
}

Instance Attribute Summary collapse

Attributes inherited from AbstractCore

#termfile, #terminal, #windows, #working_dir

Instance Method Summary collapse

Methods inherited from AbstractCore

#active_window, #load_termfile, #process!, #run_in_window, #set_delayed_options, #setup!

Constructor Details

#initialize(path) ⇒ CmdCore

Returns a new instance of CmdCore.



9
10
11
12
# File 'lib/terminitor/cores/cmd_core/cmd_core.rb', line 9

def initialize(path)
  @current_window = CurrentWindowsConsole.new
  super
end

Instance Attribute Details

#current_windowObject (readonly)

Returns the value of attribute current_window.



3
4
5
# File 'lib/terminitor/cores/cmd_core/cmd_core.rb', line 3

def current_window
  @current_window
end

Instance Method Details

#create_window(options = {}) ⇒ Object



28
29
30
31
32
33
# File 'lib/terminitor/cores/cmd_core/cmd_core.rb', line 28

def create_window(options = {})
  c = WindowsConsole.new :name=>'cmd'
  c.send_command "title #{options[:name]}\n" if options[:name]
  c.send_command "mode con: cols=#{options[:bounds][0]} lines=#{options[:bounds][1]}\n" if options[:bounds]
  c
end

#execute_command(cmd, options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/terminitor/cores/cmd_core/cmd_core.rb', line 14

def execute_command(cmd, options = {})
  cmd = CMD_XLT[cmd] || cmd
  cmd += "\n" if (cmd =~ /\n\Z/).nil?
  (options[:in] || current_window).send_command(cmd)
end

#open_tab(options = {}) ⇒ Object



20
21
22
# File 'lib/terminitor/cores/cmd_core/cmd_core.rb', line 20

def open_tab(options = {})
  create_window options
end

#open_window(options = {}) ⇒ Object



24
25
26
# File 'lib/terminitor/cores/cmd_core/cmd_core.rb', line 24

def open_window(options = {})
  create_window options
end