lib/textbringer/window.rb in textbringer-0.1.3 vs lib/textbringer/window.rb in textbringer-0.1.4

- old
+ new

@@ -135,10 +135,11 @@ Curses.close_screen end end def self.redisplay + return if Window.current.has_input? @@windows.each do |window| window.redisplay unless window.current? end current.redisplay update @@ -314,11 +315,10 @@ @window.nodelay = false end end def redisplay - return if has_input? return if @buffer.nil? redisplay_mode_line @buffer.save_point do |saved| if current? point = saved @@ -535,17 +535,13 @@ tw = @buffer[:tab_width] n = tw - column % tw n.nonzero? || tw end - def beginning_of_line_and_count(max_lines) + def beginning_of_line_and_count(max_lines, columns = @columns) e = @buffer.point @buffer.beginning_of_line - if e - @buffer.point < @columns - return 0 - end - s = @buffer.substring(@buffer.point, e) bols = [@buffer.point] column = 0 while @buffer.point < e c = @buffer.char_after if c == ?\t @@ -553,18 +549,18 @@ str = " " * n else str = escape(c) end column += Buffer.display_width(str) - if column > @columns - # Don't forward_char if column > @window.columns + if column > columns + # Don't forward_char if column > columns # to handle multibyte characters across the end of lines. bols.push(@buffer.point) column = 0 else @buffer.forward_char - if column == @columns + if column == columns bols.push(@buffer.point) column = 0 end end end @@ -662,20 +658,24 @@ @window.erase @window.setpos(0, 0) if @message @window.addstr(escape(@message)) else - @window.addstr(escape(@prompt)) - @buffer.beginning_of_line + prompt = escape(@prompt) + @window.addstr(prompt) + y = x = 0 + columns = @columns - Buffer.display_width(prompt) + beginning_of_line_and_count(1, columns) while !@buffer.end_of_buffer? if @buffer.point_at_mark?(saved) y, x = @window.cury, @window.curx end c = @buffer.char_after if c == "\n" break end @window.addstr(escape(c)) + break if @window.curx == @columns @buffer.forward_char end if @buffer.point_at_mark?(saved) y, x = @window.cury, @window.curx end