Method: RubyCurses::TextView#paint
- Defined in:
- lib/rbcurse/core/widgets/rtextview.rb
#paint ⇒ Object
NOTE: earlier print_border was called only once in constructor, but when + a window is resized, and destroyed, then this was never called again, so the + border would not be seen in splitpane unless the width coincided exactly with + what is calculated in divider_location.
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
# File 'lib/rbcurse/core/widgets/rtextview.rb', line 464 def paint #:nodoc: $log.debug "XXX TEXTVIEW repaint HAPPENING #{@current_index} " my_win = nil if @form my_win = @form.window else my_win = @target_window end @graphic = my_win unless @graphic if @formatted_text $log.debug "XXX: INSIDE FORMATTED TEXT " # I don't want to do this in 20 places and then have to change # it and retest. Let me push it to util. l = RubyCurses::Utils.parse_formatted_text(@color_parser, @formatted_text) #cp = Chunks::ColorParser.new @color_parser #l = [] #@formatted_text.each { |e| l << cp.convert_to_chunk(e) } @old_content_type = @content_type text(l) @formatted_text = nil end print_borders if (@suppress_borders == false && @repaint_all) # do this once only, unless everything changes rc = row_count maxlen = @maxlen || @width-@internal_width #$log.debug " #{@name} textview repaint width is #{@width}, height is #{@height} , maxlen #{maxlen}/ #{@maxlen}, #{@graphic.name} roff #{@row_offset} coff #{@col_offset}" tm = get_content tr = @toprow acolor = get_color $datacolor h = scrollatrow() r,c = rowcol @longest_line = @width-@internal_width #maxlen 0.upto(h) do |hh| crow = tr+hh if crow < rc #focussed = @current_index == crow ? true : false #selected = is_row_selected crow content = tm[crow] # next call modified string. you may wanna dup the string. # rlistbox does # scrolling fails if you do not dup, since content gets truncated if content.is_a? String content = content.dup sanitize(content) if @sanitization_required truncate content @graphic.printstring r+hh, c, "%-*s" % [@width-@internal_width,content], acolor, @attr elsif content.is_a? Chunks::ChunkLine # clear the line first @graphic.printstring r+hh, c, " "* (@width-@internal_width), acolor, @attr # move back @graphic.wmove r+hh, c # either we have to loop through and put in default color and attr # or pass it to show_col a = get_attrib @attrib # FIXME this does not clear till the eol @graphic.show_colored_chunks content, acolor, a, @width-@internal_width, @pcol elsif content.is_a? Chunks::Chunk raise "TODO chunk in textview" elsif content.is_a? Array # several chunks in one row - NOTE Very experimental may change if content[0].is_a? Array # clearing the line since colored_chunks does not yet XXX FIXME if possible @graphic.printstring r+hh, c, " "* (@width-@internal_width), acolor, @attr @graphic.wmove r+hh, c # either we have to loop through and put in default color and attr # or pass it to show_col a = get_attrib @attrib # FIXME this does not clear till the eol # # NOTE 2013-03-08 - 17:37 pls add width to avoid overflow @graphic.show_colored_chunks content, acolor, a, @width-@internal_width #@graphic.show_colored_chunks content, acolor, a else # a single row chunk - NOTE Very experimental may change text = content[1].dup sanitize(text) if @sanitization_required truncate text @graphic.printstring r+hh, c, "%-*s" % [@width-@internal_width,text], content[0] || acolor, content[2] || @attr end end # highlighting search results. if @search_found_ix == tr+hh if !@find_offset.nil? # handle exceed bounds, and if scrolling if @find_offset1 < maxlen+@pcol and @find_offset > @pcol @graphic.mvchgat(y=r+hh, x=c+@find_offset-@pcol, @find_offset1-@find_offset, Ncurses::A_NORMAL, $reversecolor, nil) end end end else # clear rows @graphic.printstring r+hh, c, " " * (@width-@internal_width), acolor,@attr end end @repaint_required = false = true @repaint_all = false # 2011-10-15 = false @record_changed = false @property_changed = false @old_pcol = @pcol end |