Class: GerminalTerminal
- Inherits:
-
Vte::Terminal
- Object
- Vte::Terminal
- GerminalTerminal
- Defined in:
- lib/terminal.rb
Overview
The default vte terminal customized
Instance Attribute Summary collapse
-
#colors ⇒ Object
Returns the value of attribute colors.
-
#menu ⇒ Object
readonly
Returns the value of attribute menu.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#preview ⇒ Object
Returns the value of attribute preview.
-
#tab_label ⇒ Object
Returns the value of attribute tab_label.
Instance Method Summary collapse
- #apply_colors ⇒ Object
- #get_css_colors ⇒ Object
- #get_css_font ⇒ Object
- #get_pid_dir ⇒ Object
-
#initialize(command_string, working_dir = nil) ⇒ GerminalTerminal
constructor
Create a new GerminalTerminal instance that runs command_string.
Constructor Details
#initialize(command_string, working_dir = nil) ⇒ GerminalTerminal
Create a new GerminalTerminal instance that runs command_string
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/terminal.rb', line 49 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 || notebook = .parent current_page = notebook.page_num() 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 || if parent && parent.current == self current_label = parent.get_tab_label() 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 |, event| if event.type == Gdk::EventType::BUTTON_PRESS && event. == 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) ..set_pointing_to(rect) ..show true else false end end configure end |
Instance Attribute Details
#colors ⇒ Object
Returns the value of attribute colors.
26 27 28 |
# File 'lib/terminal.rb', line 26 def colors @colors end |
#menu ⇒ Object (readonly)
Returns the value of attribute menu.
25 26 27 |
# File 'lib/terminal.rb', line 25 def @menu end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
25 26 27 |
# File 'lib/terminal.rb', line 25 def pid @pid end |
#preview ⇒ Object
Returns the value of attribute preview.
26 27 28 |
# File 'lib/terminal.rb', line 26 def preview @preview end |
#tab_label ⇒ Object
Returns the value of attribute tab_label.
26 27 28 |
# File 'lib/terminal.rb', line 26 def tab_label @tab_label end |
Instance Method Details
#apply_colors ⇒ Object
129 130 131 |
# File 'lib/terminal.rb', line 129 def apply_colors set_colors(@colors[0], @colors[1], @colors[2..-1]) end |
#get_css_colors ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/terminal.rb', line 108 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 ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/terminal.rb', line 121 def get_css_font font = style_get_property("font") unless font font = Pango::FontDescription.new(DEFAULT_TERMINAL_FONT) end font end |
#get_pid_dir ⇒ Object
104 105 106 |
# File 'lib/terminal.rb', line 104 def get_pid_dir File.readlink("/proc/#{@pid}/cwd") end |