Class: Textbringer::EchoArea

Inherits:
Window
  • Object
show all
Defined in:
lib/textbringer/window.rb

Constant Summary

Constants inherited from Window

Window::ALT_ALPHA_BASE, Window::ALT_NUMBER_BASE, Window::HAVE_GET_KEY_MODIFIERS, Window::KEY_NAMES

Instance Attribute Summary collapse

Attributes inherited from Window

#bottom_of_window, #buffer, #columns, #lines, #mode_line, #top_of_window, #window, #x, #y

Instance Method Summary collapse

Methods inherited from Window

beep, #close, colors, columns, current, current=, #current?, #delete, delete_other_windows, delete_window, #deleted?, echo_area, #enlarge, has_colors=, has_colors?, #has_input?, #highlight, lines, list, load_faces, other_window, #read_event, #read_event_nonblock, #recenter, #recenter_if_needed, redisplay, redraw, resize, #restore_point, #save_point, #scroll_down, #scroll_up, set_default_colors, #shrink, #shrink_if_larger_than_buffer, #split, start, update, #wait_input

Constructor Details

#initialize(*args) ⇒ EchoArea

Returns a new instance of EchoArea.



791
792
793
794
795
796
# File 'lib/textbringer/window.rb', line 791

def initialize(*args)
  super
  @message = nil
  @prompt = ""
  @active = false
end

Instance Attribute Details

#active=(value) ⇒ Object (writeonly)

Sets the attribute active

Parameters:

  • value

    the value to set the attribute active to.



789
790
791
# File 'lib/textbringer/window.rb', line 789

def active=(value)
  @active = value
end

#messageObject (readonly)

Returns the value of attribute message.



787
788
789
# File 'lib/textbringer/window.rb', line 787

def message
  @message
end

#promptObject

Returns the value of attribute prompt.



788
789
790
# File 'lib/textbringer/window.rb', line 788

def prompt
  @prompt
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


802
803
804
# File 'lib/textbringer/window.rb', line 802

def active?
  @active
end

#clearObject



806
807
808
809
810
811
# File 'lib/textbringer/window.rb', line 806

def clear
  @buffer.clear
  @top_of_window.location = @buffer.point_min
  @message = nil
  @prompt = ""
end

#clear_messageObject



813
814
815
# File 'lib/textbringer/window.rb', line 813

def clear_message
  @message = nil
end

#echo_area?Boolean

Returns:

  • (Boolean)


798
799
800
# File 'lib/textbringer/window.rb', line 798

def echo_area?
  true
end

#move(y, x) ⇒ Object



865
866
867
868
869
# File 'lib/textbringer/window.rb', line 865

def move(y, x)
  @y = y
  @x = x
  @window.move(y, x)
end

#redisplayObject



821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
# File 'lib/textbringer/window.rb', line 821

def redisplay
  return if @buffer.nil?
  @buffer.save_point do |saved|
    @window.erase
    @window.setpos(0, 0)
    if @message
      @window.addstr(escape(@message))
    else
      prompt = escape(@prompt)
      @window.addstr(prompt)
      framer
      @buffer.point_to_mark(@top_of_window)
      y = x = 0
      while !@buffer.end_of_buffer?
        cury, curx = @window.cury, @window.curx
        if @buffer.point_at_mark?(saved)
          y, x = cury, curx
        end
        c = @buffer.char_after
        if c == "\n"
          break
        end
        s = escape(c)
        newx = curx + Buffer.display_width(s)
        if newx > @columns
          break
        end
        @window.addstr(s)
        break if newx >= @columns
        @buffer.forward_char
      end
      if @buffer.point_at_mark?(saved)
        y, x = @window.cury, @window.curx
      end
      @window.setpos(y, x)
    end
    @window.noutrefresh
  end
end

#redrawObject



861
862
863
# File 'lib/textbringer/window.rb', line 861

def redraw
  @window.redraw
end

#resize(lines, columns) ⇒ Object



871
872
873
874
875
# File 'lib/textbringer/window.rb', line 871

def resize(lines, columns)
  @lines = lines
  @columns = columns
  @window.resize(lines, columns)
end

#show(message) ⇒ Object



817
818
819
# File 'lib/textbringer/window.rb', line 817

def show(message)
  @message = message
end