Sha256: fd13291e3da6423b93766158c38b9b4a801d09d8ad20e2719e579c7f6a4a9b09

Contents?: true

Size: 1.25 KB

Versions: 5

Compression:

Stored size: 1.25 KB

Contents

module Redcar
  class Tab
    include Redcar::Model
    include Redcar::Observable
    
    attr_reader :notebook
    
    def initialize(notebook)
      @notebook = notebook
      @title    = "unknown"
    end
    
    # Close the tab (remove it from the Notebook).
    #
    # Events: close
    def close
      notify_listeners(:close)
    end
    
    # Focus the tab within the notebook, and gives the keyboard focus to the 
    # contents of the tab, if appropriate.
    #
    # Events: focus
    def focus
      notify_listeners(:focus)
    end
    
    def title
      @title
    end
    
    def title=(title)
      @title = title
      notify_listeners(:changed_title, title)
    end
    
    def inspect
      "#<#{self.class.name} \"#{title}\">"
    end
    
    # Sets the notebook of the tab. Should not be called from user code.
    def set_notebook(notebook)
      @notebook = notebook
    end
    
    def edit_tab?
      is_a?(EditTab)
    end
    
    # Helper method to get the edit_view's document, if applicable.
    def document
      edit_view.document if edit_tab?
    end
    
    # Helper method to get this tab's Mirror object for the current
    # document, if applicable.
    def document_mirror
      document.mirror if document
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redcar-0.3.4.3 plugins/application/lib/application/tab.rb
redcar-0.3.4.2 plugins/application/lib/application/tab.rb
redcar-0.3.4.1 plugins/application/lib/application/tab.rb
redcar-0.3.4 plugins/application/lib/application/tab.rb
redcar-0.3.3 plugins/application/lib/application/tab.rb