Class: TopinambourTerminal

Inherits:
Vte::Terminal
  • Object
show all
Defined in:
lib/terminal.rb

Overview

The default vte terminal customized

Constant Summary collapse

REGEXES =
[:REGEX_URL_AS_IS, :REGEX_URL_FILE, :REGEX_URL_HTTP,
:REGEX_URL_VOIP, :REGEX_EMAIL, :REGEX_NEWS_MAN, :CSS_COLORS]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_string, toplevel, working_dir = nil) ⇒ TopinambourTerminal

Create a new TopinambourTerminal instance that runs command_string



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/terminal.rb', line 43

def initialize(command_string, toplevel, working_dir = nil)
  super()
  @toplevel = toplevel
  @settings = toplevel.application.settings
  set_name('topinambour-terminal')
  command_array = parse_command(command_string)
  rescued_spawn(command_array, working_dir)

  signal_connect('child-exited') {@toplevel.quit_gracefully}

  load_settings
  add_matches
  add_popup_menu
  handle_mouse_clic
end

Instance Attribute Details

#last_matchObject (readonly)

Returns the value of attribute last_match.



37
38
39
# File 'lib/terminal.rb', line 37

def last_match
  @last_match
end

Returns the value of attribute menu.



37
38
39
# File 'lib/terminal.rb', line 37

def menu
  @menu
end

#pidObject (readonly)

Returns the value of attribute pid.



37
38
39
# File 'lib/terminal.rb', line 37

def pid
  @pid
end

Instance Method Details

#colors=(colors) ⇒ Object



103
104
105
# File 'lib/terminal.rb', line 103

def colors=(colors)
  set_colors(colors[0], colors[1], colors[2..-1])
end

#font=(font_str) ⇒ Object



107
108
109
110
111
112
# File 'lib/terminal.rb', line 107

def font=(font_str)
  @settings['font'] = font_str
  font = Pango::FontDescription.new(font_str)
  set_font(font)
  @font = font
end

#load_colorsObject



92
93
94
95
96
# File 'lib/terminal.rb', line 92

def load_colors
  colors_strings = @settings['colorscheme']
  @colors = colors_strings.map { |c| Gdk::RGBA.parse(c) }
  @colors
end

#load_fontObject



98
99
100
101
# File 'lib/terminal.rb', line 98

def load_font
  font_str = @settings['font']
  @font = Pango::FontDescription.new(font_str)
end

#load_settingsObject

Methods used to load Gio::Settings #



79
80
81
82
83
84
# File 'lib/terminal.rb', line 79

def load_settings
  load_colors
  set_colors(@colors[0], @colors[1], @colors[2..-1])
  set_font(load_font)
  set_size(*load_size_settings)
end

#load_size_settingsObject



86
87
88
89
90
# File 'lib/terminal.rb', line 86

def load_size_settings
  h = @settings['height']
  w = @settings['width']
  [w, h]
end

#pid_dirObject



59
60
61
# File 'lib/terminal.rb', line 59

def pid_dir
  File.readlink("/proc/#{@pid}/cwd")
end

#sizeObject



67
68
69
70
71
72
73
# File 'lib/terminal.rb', line 67

def size
  col = column_count
  char_w = char_width
  row = row_count
  char_h = char_height
  [col * char_w, row * char_h]
end

#terminal_titleObject



63
64
65
# File 'lib/terminal.rb', line 63

def terminal_title
  @custom_title.class == String ? @custom_title : window_title.to_s
end