Class: VimMate::TerminalsWindow
- Inherits:
-
Object
- Object
- VimMate::TerminalsWindow
- Defined in:
- lib/vimmatelib/terminals_window.rb
Overview
The window that contains the terminals
Instance Method Summary collapse
-
#add_expander_signal(&block) ⇒ Object
Add a block that will be called when the user choose to expand or close the expander.
-
#add_new_terminal ⇒ Object
Add a new terminal at the left of the tab bar.
-
#delete_current_terminal ⇒ Object
Deletes terminal with number page_num, defaults to current page number.
-
#focus_terminal ⇒ Object
Set the focus to the current terminal.
-
#gtk_window ⇒ Object
The “window” for this object.
-
#initialize ⇒ TerminalsWindow
constructor
Create a TerminalsWindow.
-
#next_terminal ⇒ Object
Switch the next (right) terminal, if there exists one.
-
#prev_terminal ⇒ Object
Switch the previous (left) terminal, if there exists one.
Constructor Details
#initialize ⇒ TerminalsWindow
Create a TerminalsWindow
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vimmatelib/terminals_window.rb', line 44 def initialize @expander_signal = Set.new # Create the tabbed page @gtk_notebook = Gtk::Notebook.new @gtk_notebook.scrollable = true # Add a terminal at startup @gtk_notebook.append_page(new_terminal) # The last page is just an icon to create new tabs @gtk_notebook.append_page(Gtk::EventBox.new, Gtk::Image.new(Gtk::Stock::NEW, Gtk::IconSize::MENU)) # When we try to go to the last page, we create a new terminal instead @gtk_notebook.signal_connect_after("switch-page") do |notebook, page, page_num| add_new_terminal if page_num == (@gtk_notebook.n_pages - 1) end @gtk_notebook.set_size_request(0, Config[:terminals_height]) end |
Instance Method Details
#add_expander_signal(&block) ⇒ Object
Add a block that will be called when the user choose to expand or close the expander. The block takes one argument: if the expander is opened or closed
70 71 72 |
# File 'lib/vimmatelib/terminals_window.rb', line 70 def (&block) @expander_signal << block end |
#add_new_terminal ⇒ Object
Add a new terminal at the left of the tab bar.
81 82 83 84 85 |
# File 'lib/vimmatelib/terminals_window.rb', line 81 def add_new_terminal page_num = @gtk_notebook.n_pages - 1 @gtk_notebook.insert_page(page_num, new_terminal) @gtk_notebook.page = page_num end |
#delete_current_terminal ⇒ Object
Deletes terminal with number page_num, defaults to current page number.
88 89 90 91 92 |
# File 'lib/vimmatelib/terminals_window.rb', line 88 def delete_current_terminal page = @gtk_notebook.get_nth_page(@gtk_notebook.page) prev_terminal Process.kill 'HUP', page.pid end |
#focus_terminal ⇒ Object
Set the focus to the current terminal
75 76 77 78 |
# File 'lib/vimmatelib/terminals_window.rb', line 75 def focus_terminal page = @gtk_notebook.get_nth_page(@gtk_notebook.page) page.has_focus = true if page end |
#gtk_window ⇒ Object
The “window” for this object
63 64 65 |
# File 'lib/vimmatelib/terminals_window.rb', line 63 def gtk_window @gtk_notebook end |
#next_terminal ⇒ Object
Switch the next (right) terminal, if there exists one. Otherwise start again with the first terminal on the left.
96 97 98 99 100 101 102 |
# File 'lib/vimmatelib/terminals_window.rb', line 96 def next_terminal if @gtk_notebook.page < @gtk_notebook.n_pages - 2 @gtk_notebook.next_page else @gtk_notebook.page = 0 end end |
#prev_terminal ⇒ Object
Switch the previous (left) terminal, if there exists one. Otherwise start with again with the last terminal on the right.
106 107 108 109 110 111 112 |
# File 'lib/vimmatelib/terminals_window.rb', line 106 def prev_terminal if @gtk_notebook.page > 0 @gtk_notebook.prev_page else @gtk_notebook.page = @gtk_notebook.n_pages - 2 end end |