Class: Notes::NotesBlock

Inherits:
Object show all
Defined in:
lib/xiki/notes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, after_header, right) ⇒ NotesBlock

Returns a new instance of NotesBlock.



752
753
754
755
756
# File 'lib/xiki/notes.rb', line 752

def initialize(left, after_header, right)
  @left, @after_header, @right = left, after_header, right
  @header = $el.buffer_substring left, after_header
  @text = $el.buffer_substring after_header, right
end

Instance Attribute Details

#after_headerObject

Returns the value of attribute after_header.



749
750
751
# File 'lib/xiki/notes.rb', line 749

def after_header
  @after_header
end

#headerObject

Returns the value of attribute header.



750
751
752
# File 'lib/xiki/notes.rb', line 750

def header
  @header
end

#leftObject

Returns the value of attribute left.



749
750
751
# File 'lib/xiki/notes.rb', line 749

def left
  @left
end

#rightObject

Returns the value of attribute right.



749
750
751
# File 'lib/xiki/notes.rb', line 749

def right
  @right
end

#textObject

Returns the value of attribute text.



750
751
752
# File 'lib/xiki/notes.rb', line 750

def text
  @text
end

Instance Method Details

#archiveObject

cuts the block, and stores it in archive.file.notes example: ruby.notes -> archive.ruby.notes



806
807
808
809
810
811
812
# File 'lib/xiki/notes.rb', line 806

def archive
  delete_content
  filename = 'archive.' + $el.file_name_nondirectory(buffer_file_name)
  timestamp = "--- archived on #{Time.now.strftime('%Y-%m-%d at %H:%M')} --- \n"
  $el.append_to_file timestamp, nil, filename
  $el.append_to_file content, nil, filename
end


770
771
772
# File 'lib/xiki/notes.rb', line 770

def blink
  Effects.blink :left => after_header, :right => right
end

#contentObject



762
763
764
# File 'lib/xiki/notes.rb', line 762

def content
  header + text
end

#delete_contentObject



782
783
784
# File 'lib/xiki/notes.rb', line 782

def delete_content
  $el.delete_region left, right
end

#fade_inObject



778
779
780
# File 'lib/xiki/notes.rb', line 778

def fade_in
  Effects.glow :fade_in=>1, :what=>[left, right]
end

#fade_outObject



774
775
776
# File 'lib/xiki/notes.rb', line 774

def fade_out
  Effects.glow :fade_out=>1, :what=>[left, right]
end

#hide_textObject



797
798
799
800
801
802
# File 'lib/xiki/notes.rb', line 797

def hide_text
  @header_overlay ||= Overlay.find_or_make(left, after_header - 1)

  @body_overlay ||= Overlay.find_or_make(after_header, right)
  @body_overlay.invisible = true
end

#positionsObject



758
759
760
# File 'lib/xiki/notes.rb', line 758

def positions
  [left, after_header, right]
end

#show_textObject

initialize an overlay for this notes block it has a special hook that updates name to be header always this way we can always find the overlay corresponding to header



790
791
792
793
794
795
# File 'lib/xiki/notes.rb', line 790

def show_text
  @header_overlay ||= Overlay.find_or_make(left, after_header - 1)

  @body_overlay ||= Overlay.find_or_make(after_header, right)
  @body_overlay.invisible = false
end

#to_sObject



766
767
768
# File 'lib/xiki/notes.rb', line 766

def to_s
  content
end