391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
|
# File 'lib/textbringer/window.rb', line 391
def redisplay
return if @buffer.nil?
redisplay_mode_line
@buffer.save_point do |saved|
if current?
point = saved
else
point = @point_mark
@buffer.point_to_mark(@point_mark)
end
framer
@cursor.y = @cursor.x = 0
@buffer.point_to_mark(@top_of_window)
highlight
@window.erase
@window.setpos(0, 0)
@window.attrset(0)
if current? && @buffer.visible_mark &&
@buffer.point_after_mark?(@buffer.visible_mark)
@window.attron(Curses::A_REVERSE)
end
while !@buffer.end_of_buffer?
cury = @window.cury
curx = @window.curx
update_cursor_and_attr(point, cury, curx)
if attrs = @highlight_off[@buffer.point]
@window.attroff(attrs)
end
if attrs = @highlight_on[@buffer.point]
@window.attron(attrs)
end
c = @buffer.char_after
if c == "\n"
@window.clrtoeol
break if cury == lines - 2
@window.setpos(cury + 1, 0)
@buffer.forward_char
next
elsif c == "\t"
n = calc_tab_width(curx)
c = " " * n
else
c = compose_character(point, cury, curx, c)
end
s = escape(c)
if curx < columns - 4
newx = nil
else
newx = curx + Buffer.display_width(s)
if newx > columns
if cury == lines - 2
break
else
@window.clrtoeol
@window.setpos(cury + 1, 0)
end
end
end
@window.addstr(s)
break if newx == columns && cury == lines - 2
@buffer.forward_char
end
if current? && @buffer.visible_mark
@window.attroff(Curses::A_REVERSE)
end
@buffer.mark_to_point(@bottom_of_window)
if @buffer.point_at_mark?(point)
@cursor.y = @window.cury
@cursor.x = @window.curx
end
if @cursor.x == columns - 1
c = @buffer.char_after(point.location)
if c && Buffer.display_width(c) > 1
@cursor.y += 1
@cursor.x = 0
end
end
@window.setpos(@cursor.y, @cursor.x)
@window.noutrefresh
end
end
|