Class: Textbringer::EchoArea

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

Constant Summary

Constants inherited from Window

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_char, #read_char_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.



821
822
823
824
825
826
# File 'lib/textbringer/window.rb', line 821

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.



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

def active=(value)
  @active = value
end

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end

#promptObject

Returns the value of attribute prompt.



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

def prompt
  @prompt
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


832
833
834
# File 'lib/textbringer/window.rb', line 832

def active?
  @active
end

#clearObject



836
837
838
839
840
841
# File 'lib/textbringer/window.rb', line 836

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

#clear_messageObject



843
844
845
# File 'lib/textbringer/window.rb', line 843

def clear_message
  @message = nil
end

#echo_area?Boolean

Returns:

  • (Boolean)


828
829
830
# File 'lib/textbringer/window.rb', line 828

def echo_area?
  true
end

#move(y, x) ⇒ Object



895
896
897
898
899
# File 'lib/textbringer/window.rb', line 895

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

#redisplayObject



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
877
878
879
880
881
882
883
884
885
886
887
888
889
# File 'lib/textbringer/window.rb', line 851

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



891
892
893
# File 'lib/textbringer/window.rb', line 891

def redraw
  @window.redraw
end

#resize(lines, columns) ⇒ Object



901
902
903
904
905
# File 'lib/textbringer/window.rb', line 901

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

#show(message) ⇒ Object



847
848
849
# File 'lib/textbringer/window.rb', line 847

def show(message)
  @message = message
end