Class: TermDump::BasicTerminal

Inherits:
Object
  • Object
show all
Includes:
TerminalHelper
Defined in:
lib/termdump/terminal/base/base.rb

Direct Known Subclasses

Terminal

Instance Method Summary collapse

Methods included from TerminalHelper

#convert_key_sequence, #escape

Constructor Details

#initialize(config) ⇒ BasicTerminal

Returns a new instance of BasicTerminal.



7
8
9
10
11
# File 'lib/termdump/terminal/base/base.rb', line 7

def initialize config
  @user_defined_config = config
  @config = {}
  @default_config = {}
end

Instance Method Details

#configure(configure_key) ⇒ Object

Get user defined value/configure value/default value with a configure item. Raise keyError if value not found.



15
16
17
18
19
# File 'lib/termdump/terminal/base/base.rb', line 15

def configure configure_key
  @user_defined_config.fetch(configure_key) {|key_in_config|
    @config.fetch(key_in_config) {|default_key|
      @default_config.fetch(default_key)}}
end

#exec(cwd, cmd) ⇒ Object

run command in current window cwd is the directory the command executed in cmd if the cmd is nil, don’t need to execute it; else execute the cmd

Raises:

  • (NotImplementedError)


24
25
26
27
# File 'lib/termdump/terminal/base/base.rb', line 24

def exec cwd, cmd
  raise NotImplementedError.new(
    "exec should be implemented to execute cmd on current window")
end

#window(name, cwd, cmd) ⇒ Object

open a new window of this terminal automatically and focus on name is the name of new window cwd is the directory the command executed in cmd if the cmd is nil, don’t need to execute it; else execute the cmd

Raises:

  • (NotImplementedError)


33
34
35
36
# File 'lib/termdump/terminal/base/base.rb', line 33

def window name, cwd, cmd
  raise NotImplementedError.new(
    "window should be implemented to open new window")
end