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.



808
809
810
811
812
813
# File 'lib/textbringer/window.rb', line 808

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.



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

def active=(value)
  @active = value
end

#messageObject (readonly)

Returns the value of attribute message.



804
805
806
# File 'lib/textbringer/window.rb', line 804

def message
  @message
end

#promptObject

Returns the value of attribute prompt.



805
806
807
# File 'lib/textbringer/window.rb', line 805

def prompt
  @prompt
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


819
820
821
# File 'lib/textbringer/window.rb', line 819

def active?
  @active
end

#clearObject



823
824
825
826
827
828
# File 'lib/textbringer/window.rb', line 823

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

#clear_messageObject



830
831
832
# File 'lib/textbringer/window.rb', line 830

def clear_message
  @message = nil
end

#echo_area?Boolean

Returns:

  • (Boolean)


815
816
817
# File 'lib/textbringer/window.rb', line 815

def echo_area?
  true
end

#move(y, x) ⇒ Object



882
883
884
885
886
# File 'lib/textbringer/window.rb', line 882

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

#redisplayObject



838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'lib/textbringer/window.rb', line 838

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



878
879
880
# File 'lib/textbringer/window.rb', line 878

def redraw
  @window.redraw
end

#resize(lines, columns) ⇒ Object



888
889
890
891
892
# File 'lib/textbringer/window.rb', line 888

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

#show(message) ⇒ Object



834
835
836
# File 'lib/textbringer/window.rb', line 834

def show(message)
  @message = message
end