class GerminalTerminal
The default vte terminal customized
Attributes
colors[RW]
pid[R]
preview[RW]
tab_label[RW]
Public Class Methods
new(command_string, working_dir = nil)
click to toggle source
Create a new GerminalTerminal
instance that runs command_string
Calls superclass method
# File lib/terminal.rb, line 41 def initialize(command_string, working_dir = nil) super() # TODO: make a begin/rescue like in glib2-2.2.4/sample/shell.rb command_array = GLib::Shell.parse(command_string) @pid = spawn(:argv => command_array, :working_directory => working_dir, :spawn_flags => GLib::Spawn::SEARCH_PATH) signal_connect "child-exited" do |widget| notebook = widget.parent current_page = notebook.page_num(widget) if notebook.n_pages > 1 notebook.remove_page(current_page) notebook.get_nth_page(notebook.page).grab_focus else notebook.remove_page(current_page) notebook.toplevel.application.quit end end signal_connect "window-title-changed" do |widget| if parent && parent.current == self current_label = parent.get_tab_label(widget) if @tab_label.class == String current_label.text = @tab_label else current_label.text = window_title parent.toplevel.current_label.text = window_title end end end builder = Gtk::Builder.new(:resource => "/com/github/cedlemo/germinal/terminal-menu.ui") @menu = Gtk::Popover.new(self, builder["termmenu"]) signal_connect "button-press-event" do |widget, event| if event.type == Gdk::EventType::BUTTON_PRESS && event.button == Gdk::BUTTON_SECONDARY x, y = event.window.coords_to_parent(event.x, event.y) rect = Gdk::Rectangle.new(x - allocation.x, y - allocation.y, 1, 1) widget.menu.set_pointing_to(rect) widget.menu.show true else false end end configure end
Public Instance Methods
apply_colors()
click to toggle source
# File lib/terminal.rb, line 121 def apply_colors set_colors(@colors[0], @colors[1], @colors[2..-1]) end
get_css_colors()
click to toggle source
# File lib/terminal.rb, line 100 def get_css_colors background = nil foreground = nil colors = [] background = parse_css_color(TERMINAL_COLOR_NAMES[0].to_s) foreground = parse_css_color(TERMINAL_COLOR_NAMES[1].to_s) TERMINAL_COLOR_NAMES[2..-1].each do |c| color = parse_css_color(c.to_s) colors << color end [background, foreground] + colors end
get_css_font()
click to toggle source
# File lib/terminal.rb, line 113 def get_css_font font = style_get_property("font") unless font font = Pango::FontDescription.new(DEFAULT_TERMINAL_FONT) end font end
pid_dir()
click to toggle source
# File lib/terminal.rb, line 96 def pid_dir File.readlink("/proc/#{@pid}/cwd") end
Private Instance Methods
add_matches()
click to toggle source
# File lib/terminal.rb, line 143 def add_matches puts methods.grep(/rege/) match_add_gregex("cedlemo") end
configure()
click to toggle source
# File lib/terminal.rb, line 134 def configure set_rewrap_on_resize(true) set_scrollback_lines(-1) @colors = get_css_colors set_font(get_css_font) apply_colors #add_matches end
parse_css_color(color_name)
click to toggle source
# File lib/terminal.rb, line 127 def parse_css_color(color_name) default_color = Gdk::RGBA.parse(DEFAULT_TERMINAL_COLORS[TERMINAL_COLOR_NAMES.index(color_name.to_sym)]) color_from_css = style_get_property(color_name) color = color_from_css ? color_from_css : default_color color end