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::FALLBACK_CHARACTERS, 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.



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

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.



885
886
887
# File 'lib/textbringer/window.rb', line 885

def active=(value)
  @active = value
end

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end

#promptObject

Returns the value of attribute prompt.



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

def prompt
  @prompt
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


898
899
900
# File 'lib/textbringer/window.rb', line 898

def active?
  @active
end

#clearObject



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

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

#clear_messageObject



909
910
911
# File 'lib/textbringer/window.rb', line 909

def clear_message
  @message = nil
end

#echo_area?Boolean

Returns:

  • (Boolean)


894
895
896
# File 'lib/textbringer/window.rb', line 894

def echo_area?
  true
end

#editable_columnsObject



978
979
980
981
982
983
984
# File 'lib/textbringer/window.rb', line 978

def editable_columns
  if @buffer.input_method_status == "--"
    @columns
  else
    @columns - Buffer.display_width(@buffer.input_method_status) - 1
  end
end

#move(y, x) ⇒ Object



966
967
968
969
970
# File 'lib/textbringer/window.rb', line 966

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

#redisplayObject



917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
# File 'lib/textbringer/window.rb', line 917

def redisplay
  return if @buffer.nil?
  @buffer.save_point do |point|
    @window.erase
    if @buffer.input_method_status != "--"
      @window.setpos(@window.cury, editable_columns + 1)
      @window.addstr(@buffer.input_method_status)
    end
    @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)
      @cursor.y = @cursor.x = 0
      while !@buffer.end_of_buffer?
        cury = @window.cury
        curx = @window.curx
        update_cursor_and_attr(point, cury, curx)
        c = @buffer.char_after
        if c == "\n"
          break
        end
        c = compose_character(point, cury, curx, c)
        s = escape(c)
        newx = curx + Buffer.display_width(s)
        if newx > editable_columns
          break
        end
        @window.addstr(s)
        @buffer.forward_char
        break if newx >= editable_columns
      end
      if @buffer.point_at_mark?(point)
        @cursor.y = @window.cury
        @cursor.x = @window.curx
      end
      @window.setpos(@cursor.y, @cursor.x)
    end
    @window.noutrefresh
  end
end

#redrawObject



962
963
964
# File 'lib/textbringer/window.rb', line 962

def redraw
  @window.redraw
end

#resize(lines, columns) ⇒ Object



972
973
974
975
976
# File 'lib/textbringer/window.rb', line 972

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

#show(message) ⇒ Object



913
914
915
# File 'lib/textbringer/window.rb', line 913

def show(message)
  @message = message
end