Method: TopinambourActions.generate_term_copy_action

Defined in:
lib/actions.rb

.generate_term_copy_action(application) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/actions.rb', line 55

def self.generate_term_copy_action(application)
  action = generate_action("term_copy") do |_act, _param|
    term = application.windows[0].terminal
    event = Gtk.current_event

    _match, regex_type = term.match_check_event(event)
    if term.has_selection? || regex_type == -1
      term.copy_clipboard
    else
      clipboard = Gtk::Clipboard.get_default(Gdk::Display.default)
      clipboard.text = term.last_match unless term.last_match.nil?
    end
  end
  action
end