lib/textbringer/window.rb in textbringer-0.2.1 vs lib/textbringer/window.rb in textbringer-0.2.2

- old
+ new

@@ -320,11 +320,11 @@ def current? self == @@current end - def read_char + def read_event key = get_char if key.is_a?(Integer) if PDCurses.dll_loaded? if PDCurses::ALT_0 <= key && key <= PDCurses::ALT_9 @key_buffer.push((key - PDCurses::ALT_NUMBER_BASE).chr) @@ -338,14 +338,14 @@ else key&.encode(Encoding::UTF_8) end end - def read_char_nonblock + def read_event_nonblock @window.nodelay = true begin - read_char + read_event ensure @window.nodelay = false end end @@ -551,21 +551,21 @@ end end def scroll_up if @bottom_of_window.location == @buffer.point_max - raise EditorError, "End of buffer" + raise RangeError, "End of buffer" end @buffer.point_to_mark(@bottom_of_window) @buffer.previous_line @buffer.beginning_of_line @buffer.mark_to_point(@top_of_window) end def scroll_down if @top_of_window.location == @buffer.point_min - raise EditorError, "Beginning of buffer" + raise RangeError, "Beginning of buffer" end @buffer.point_to_mark(@top_of_window) @buffer.next_line @buffer.beginning_of_line @top_of_window.location = 0 @@ -926,10 +926,11 @@ width += Buffer.display_width(escape(c)) end if width > max_width @buffer.forward_char break - elsif width == max_width || @buffer.beginning_of_line? + elsif width == max_width || @buffer.beginning_of_line? || + @buffer.point_at_mark?(@top_of_window) break end @buffer.backward_char end @top_of_window.location = @buffer.point