Class: RubyCurses::Listbox

Inherits:
Widget
  • Object
show all
Includes:
ListScrollable, ListKeys, ListSelectable
Defined in:
lib/rbcurse/rlistbox.rb

Overview

this is the new LISTBOX, based on new scrollable.

Constant Summary

Constants included from Io

Io::ERROR_COLOR_PAIR, Io::FOOTER_COLOR_PAIR, Io::LINEONE, Io::MAIN_WINDOW_COLOR_PAIR

Instance Attribute Summary collapse

Attributes included from ListSelectable

#column_selection_allowed, #row_selection_allowed

Attributes included from ListScrollable

#find_offset, #find_offset1, #search_found_ix, #show_caret

Attributes inherited from Widget

#col_offset, #cols_panned, #config, #curpos, #ext_col_offset, #ext_row_offset, #form, #id, #parent_component, #row_offset, #rows_panned, #should_create_buffer, #state

Instance Method Summary collapse

Methods included from ListKeys

#install_list_keys

Methods included from ListSelectable

#add_row_selection_interval, #clear_selection, #create_default_list_selection_model, #do_next_selection, #do_prev_selection, #is_row_selected, #list_selection_model, #remove_row_selection_interval, #selected_item, #selected_row, #selected_row_count, #selected_rows, #toggle_row_selection

Methods included from ListScrollable

#OLDscrollable_handle_key, #OLDset_focus_on, #_find_next, #_find_prev, #ask_search, #bounds_check, #find_more, #find_next, #find_prev, #focussed_index, #forward_char, #forward_word, #goto_bottom, #goto_last_position, #goto_top, #install_keys, #next_match, #next_row, #previous_row, #scroll_backward, #scroll_forward, #scroll_left, #scroll_right, #selected_item, #set_focus_on, #set_form_row, #set_selection_for_char, #show_caret_func

Methods inherited from Widget

#OLDbind_key, #buffer_to_screen, #buffer_to_window, #create_buffer, #destroy, #destroy_buffer, #focus, #get_buffer, #get_color, #get_preferred_size, #getvalue_for_paint, #height, #height=, #hide, #is_double_buffered?, #modified?, #move, #on_leave, #override_graphic, #printstring, #process_key, #remove, #repaint_all, #repaint_required, #rowcol, #safe_create_buffer, #set_buffer_modified, #set_form, #set_form_row, #set_modified, #setformrowcol, #setrowcol, #show, #text_variable, #unbind_key, #width, #width=

Methods included from Io

#askchoice, #askyesno, #askyesnocancel, #clear_error, #clear_this, #get_string, #newaskyesno, #old_print_header, #old_print_top_right, #print_action, #print_error, #print_footer_help, #print_header, #print_headers, #print_help, #print_help_page, #print_in_middle, #print_key_labels, #print_key_labels_row, #print_screen_labels, #print_status, #print_this, #print_top_right, #rbgetstr

Methods included from Utils

#_process_key, #bind_key, #clean_string!, #get_color, #keycode_tos, #repeatm, #wrap_text

Methods included from ConfigSetup

#cget, #config_setup, #configure, #variable_set

Methods included from EventHandler

#bind, #fire_handler, #fire_property_change

Methods included from DSL

#OLD_method_missing

Constructor Details

#initialize(form, config = {}, &block) ⇒ Listbox

Returns a new instance of Listbox.



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
# File 'lib/rbcurse/rlistbox.rb', line 416

def initialize form, config={}, &block
  @focusable = true
  @editable = false
  @row = 0
  @col = 0
  # data of listbox
  @list = []
  # any special attribs such as status to be printed in col1, or color (selection)
  @list_attribs = {}
  super
  @current_index ||= 0
  @row_offset = @col_offset = 1
  @content_rows = @list.length
  @selection_mode ||= 'multiple'
  @win = @graphic    # 2010-01-04 12:36 BUFFERED  replace form.window with graphic
  # moving down to repaint so that scrollpane can set should_buffered
  # added 2010-02-17 23:05  RFED16 so we don't need a form.
  @win_left = 0
  @win_top = 0

#x      safe_create_buffer # 2010-01-04 12:36 BUFFERED moved here 2010-01-05 18:07 
#x      print_borders unless @win.nil?   # in messagebox we don;t have window as yet!
  # next 2 lines carry a redundancy
  select_default_values   
  # when the combo box has a certain row in focus, the popup should have the same row in focus

  install_keys
  init_vars
  install_list_keys

  if !@list.selected_index.nil? 
    set_focus_on @list.selected_index # the new version
  end
end

Instance Attribute Details

#current_indexObject

Returns the value of attribute current_index.



396
397
398
# File 'lib/rbcurse/rlistbox.rb', line 396

def current_index
  @current_index
end

#one_key_selectionObject

will pressing a single key select or not



414
415
416
# File 'lib/rbcurse/rlistbox.rb', line 414

def one_key_selection
  @one_key_selection
end

#toprowObject (readonly)

dsl_accessor :list # the array of data to be sent by user



389
390
391
# File 'lib/rbcurse/rlistbox.rb', line 389

def toprow
  @toprow
end

Instance Method Details

#ask_search_backwardObject

gets string to search and calls data models find prev



678
679
680
681
682
683
684
685
686
687
# File 'lib/rbcurse/rlistbox.rb', line 678

def ask_search_backward
  regex =  get_string("Enter regex to search (backward)")
  @last_regex = regex
  ix = @list.find_prev regex, @current_index
  if ix.nil?
    alert("No matching data for: #{regex}")
  else
    set_focus_on(ix)
  end
end

#ask_search_forwardObject



668
669
670
671
672
673
674
675
676
# File 'lib/rbcurse/rlistbox.rb', line 668

def ask_search_forward
    regex =  get_string("Enter regex to search")
    ix = @list.find_match regex
    if ix.nil?
      alert("No matching data for: #{regex}")
    else
      set_focus_on(ix)
    end
end

#ask_selection_for_charObject



661
662
663
664
665
666
667
# File 'lib/rbcurse/rlistbox.rb', line 661

def ask_selection_for_char
  ch = @graphic.getch
  if ch < 0 || ch > 255
    return :UNHANDLED
  end
  ret = set_selection_for_char ch.chr
end

#cancel_blockObject

added on 2009-02-19 22:37



928
929
930
931
# File 'lib/rbcurse/rlistbox.rb', line 928

def cancel_block
  @first_index = @last_index = nil
  @inside_block = false
end

#cell_editor(*val) ⇒ Object

getter and setter for cell_editor



782
783
784
785
786
787
788
# File 'lib/rbcurse/rlistbox.rb', line 782

def cell_editor(*val)
  if val.empty?
    @cell_editor ||= create_default_cell_editor
  else
    @cell_editor = val[0] 
  end
end

#cell_renderer(*val) ⇒ Object

getter and setter for cell_renderer



794
795
796
797
798
799
800
# File 'lib/rbcurse/rlistbox.rb', line 794

def cell_renderer(*val)
  if val.empty?
    @cell_renderer ||= create_default_cell_renderer
  else
    @cell_renderer = val[0] 
  end
end

#create_default_cell_editorObject



789
790
791
# File 'lib/rbcurse/rlistbox.rb', line 789

def create_default_cell_editor
  return RubyCurses::CellEditor.new RubyCurses::Field.new nil, {"focusable"=>false, "visible"=>false, "display_length"=> @width-2-@left_margin}
end

#create_default_cell_rendererObject



801
802
803
# File 'lib/rbcurse/rlistbox.rb', line 801

def create_default_cell_renderer
  return RubyCurses::ListCellRenderer.new "", {"color"=>@color, "bgcolor"=>@bgcolor, "parent" => self, "display_length"=> @width-2-@left_margin}
end

#edit_row_at(arow) ⇒ Object



725
726
727
728
729
730
731
# File 'lib/rbcurse/rlistbox.rb', line 725

def edit_row_at arow
  if @cell_editing_allowed
    #$log.debug " cell editor on enter #{arow} val of list[row]: #{@list[arow]}"
    editor = cell_editor
    prepare_editor editor, arow
  end
end

#editing_canceled(arow = @current_index) ⇒ Object



774
775
776
777
778
# File 'lib/rbcurse/rlistbox.rb', line 774

def editing_canceled arow=@current_index
  return unless @cell_editing_allowed
  prepare_editor @cell_editor, arow
  @repaint_required = true
end

#editing_completed(arow) ⇒ Object



762
763
764
765
766
767
768
769
770
771
772
773
# File 'lib/rbcurse/rlistbox.rb', line 762

def editing_completed arow
  if @cell_editing_allowed
    if !@cell_editor.nil?
  #    $log.debug " cell editor (leave) setting value row: #{arow} val: #{@cell_editor.getvalue}"
      $log.debug " cell editor #{@cell_editor.component.form.window} (leave) setting value row: #{arow} val: #{@cell_editor.getvalue}"
      @list[arow] = @cell_editor.getvalue #.dup 2009-01-10 21:42 boolean can't duplicate
    else
      $log.debug "CELL EDITOR WAS NIL, #{arow} "
    end
  end
  @repaint_required = true
end

#end_blockObject

sets marker for end of block added on 2009-02-19 22:37



940
941
942
943
944
945
946
947
# File 'lib/rbcurse/rlistbox.rb', line 940

def end_block #selection
  @last_index = current_index
  lower = [@first_index, @last_index].min
  higher = [@first_index, @last_index].max
  #lower.upto(higher) do |i| @list.toggle_row_selection i; end
  add_row_selection_interval(lower, higher)
  @repaint_required = true
end

#get_contentObject

START FOR scrollable ###



545
546
547
548
# File 'lib/rbcurse/rlistbox.rb', line 545

def get_content
  #@list 2008-12-01 23:13 
  @list_variable && @list_variable.value || @list 
end

#get_windowObject



549
550
551
# File 'lib/rbcurse/rlistbox.rb', line 549

def get_window
  @graphic # 2010-01-04 12:37 BUFFERED
end

#getvalueObject

END FOR scrollable ### override widgets text



554
555
556
# File 'lib/rbcurse/rlistbox.rb', line 554

def getvalue
  selected_rows
end

#handle_key(ch) ⇒ Object

Listbox



558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
# File 'lib/rbcurse/rlistbox.rb', line 558

def handle_key(ch)
  @current_index ||= 0
  @toprow ||= 0
  h = scrollatrow()
  rc = row_count
  $log.debug " listbxo got ch #{ch}"
  #$log.debug " when kps #{@KEY_PREV_SELECTION}  "
  case ch
  when KEY_UP  # show previous value
    previous_row
  when KEY_DOWN  # show previous value
    next_row
  when @KEY_ROW_SELECTOR # 32
    return if is_popup and @selection_mode == 'single' # not allowing select this way since there will be a difference 
    toggle_row_selection @current_index #, @current_index
    @repaint_required = true
  when @KEY_SCROLL_FORWARD # ?\C-n
    scroll_forward
  when @KEY_SCROLL_BACKWARD #  ?\C-p
    scroll_backward
  when @KEY_GOTO_TOP # 48, ?\C-[
    # please note that C-[ gives 27, same as esc so will respond after ages
    goto_top
  when @KEY_GOTO_BOTTOM # ?\C-]
    goto_bottom
  when @KEY_NEXT_SELECTION # ?'
    $log.debug "insdie next selection"
    @oldrow = @current_index
    do_next_selection #if @select_mode == 'multiple'
    bounds_check
  when @KEY_PREV_SELECTION # ?"
    @oldrow = @current_index
    $log.debug "insdie prev selection"
    do_prev_selection #if @select_mode == 'multiple'
    bounds_check
  when @KEY_CLEAR_SELECTION
    clear_selection #if @select_mode == 'multiple'
    @repaint_required = true
  when 27, ?\C-c.getbyte(0)
    editing_canceled @current_index if @cell_editing_allowed
    cancel_block # block
    $multiplier = 0
  when @KEY_ASK_FIND_FORWARD
  # ask_search_forward
  when @KEY_ASK_FIND_BACKWARD
  # ask_search_backward
  when @KEY_FIND_NEXT
  # find_next
  when @KEY_FIND_PREV
  # find_prev
  when @KEY_ASK_FIND
    ask_search
  when @KEY_FIND_MORE
    find_more
  when @KEY_BLOCK_SELECTOR
    mark_block #selection
  #when ?\C-u.getbyte(0)
    # multiplier. Series is 4 16 64
    # TESTING @multiplier = (@multiplier == 0 ? 4 : @multiplier *= 4)
  #  return 0
  when ?\C-c.getbyte(0)
    @multiplier = 0
    return 0
  else
    # this has to be fixed, if compo does not handle key it has to continue into next part FIXME
    ret = :UNHANDLED # changed on 2009-01-27 13:14 not going into unhandled, tab not released
    if @cell_editing_allowed
      @repaint_required = true
      # hack - on_enter_row should fire when this widget gets focus. first row that is DONE
      begin
        ret = @cell_editor.component.handle_key(ch)
      rescue
        on_enter_row @current_index
        ret = @cell_editor.component.handle_key(ch)
      end
    end
    if ret == :UNHANDLED
      if @one_key_selection
        case ch
        when ?A.getbyte(0)..?Z.getbyte(0), ?a.getbyte(0)..?z.getbyte(0), ?0.getbyte(0)..?9.getbyte(0)
          # simple motion, key press defines motion
          ret = set_selection_for_char ch.chr
        else
          ret = process_key ch, self
          @multiplier = 0
          return :UNHANDLED if ret == :UNHANDLED
        end
      else
        # no motion on single key, we can freak out like in vim, pref f <char> for set_selection
        case ch
        when ?0.getbyte(0)..?9.getbyte(0)
          $multiplier *= 10 ; $multiplier += (ch-48)
          #$log.debug " setting mult to #{$multiplier} in list "
          return 0
        end
        ret = process_key ch, self
        $multiplier = 0
        return :UNHANDLED if ret == :UNHANDLED
      end
    end
  end
  $multiplier = 0
end

#init_varsObject



450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/rbcurse/rlistbox.rb', line 450

def init_vars
  @to_print_borders ||= 1
  @repaint_required = true
  @toprow = @pcol = 0
  if @show_selector
    @row_selected_symbol ||= '>'
    @row_unselected_symbol ||= ' '
    @left_margin ||= @row_selected_symbol.length
  end
  @left_margin ||= 0
  @one_key_selection ||= true
  bind_key(?f){ ask_selection_for_char() }
  bind_key(?\M-v){ @one_key_selection = false }
  bind_key(?j){ next_row() }
  bind_key(?k){ previous_row() }
  bind_key(?G){ goto_bottom() }
  bind_key([?g,?g]){ goto_top() }
  bind_key(?/){ ask_search() }
  bind_key(?n){ find_more() }

end

#install_bindingsObject



471
472
473
# File 'lib/rbcurse/rlistbox.rb', line 471

def install_bindings

end

#list(alist = nil) ⇒ Object

2010-01-04 15:30 BUFFERED HEIGHT



494
495
496
497
498
499
500
# File 'lib/rbcurse/rlistbox.rb', line 494

def list alist=nil
  return @list if alist.nil?
  @list = RubyCurses::ListDataModel.new(alist)
  # added on 2009-01-13 23:19 since updates are not automatic now
  @list.bind(:LIST_DATA_EVENT) { |e| list_data_changed() }
  create_default_list_selection_model
end

#list_data_changedObject



884
885
886
887
888
889
890
891
# File 'lib/rbcurse/rlistbox.rb', line 884

def list_data_changed
  if row_count == 0 # added on 2009-02-02 17:13 so cursor not hanging on last row which could be empty
    init_vars
    @current_index = 0
    set_form_row
  end
  @repaint_required = true
end

#list_data_model(ldm = nil) ⇒ Object



508
509
510
511
512
513
514
515
# File 'lib/rbcurse/rlistbox.rb', line 508

def list_data_model ldm=nil
  return @list if ldm.nil?
  raise "Expecting list_data_model" unless ldm.is_a? RubyCurses::ListDataModel
  @list = ldm
  # added on 2009-01-13 23:19 since updates are not automatic now
  @list.bind(:LIST_DATA_EVENT) { |e| list_data_changed() }
  create_default_list_selection_model
end

#list_variable(alist = nil) ⇒ Object



501
502
503
504
505
506
507
# File 'lib/rbcurse/rlistbox.rb', line 501

def list_variable alist=nil
  return @list if alist.nil?
  @list = RubyCurses::ListDataModel.new(alist.value)
  # added on 2009-01-13 23:19 since updates are not automatic now
  @list.bind(:LIST_DATA_EVENT) { |e| list_data_changed() }
  create_default_list_selection_model
end

#mark_blockObject

end experimental selection of multiple rows via block specify a block start and then a block end usage: bind mark_selection to a key. It works as a toggle. C-c will cancel any selection that has begun. added on 2009-02-19 22:37



918
919
920
921
922
923
924
925
926
# File 'lib/rbcurse/rlistbox.rb', line 918

def mark_block #selection
  if @inside_block
    @inside_block = false
    end_block #selection
  else
    @inside_block = true
    start_block #selection
  end
end

#OLDfind_nextObject

table find_next



701
702
703
704
705
706
707
708
709
# File 'lib/rbcurse/rlistbox.rb', line 701

def OLDfind_next
    ix = @list.find_next
    regex = @last_regex 
    if ix.nil?
      alert("No more matching data for: #{regex}")
    else
      set_focus_on(ix) unless ix.nil?
    end
end

#OLDfind_prevObject

listbox find_prev



689
690
691
692
693
694
695
696
697
698
699
# File 'lib/rbcurse/rlistbox.rb', line 689

def OLDfind_prev
    ix = @list.find_prev
    regex = @last_regex 
    if ix.nil?
      alert("No previous matching data for: #{regex}")
    else
      @oldrow = @current_index
      @current_index = ix
      bounds_check
    end
end

#on_enterObject



710
711
712
713
714
715
716
# File 'lib/rbcurse/rlistbox.rb', line 710

def on_enter
  on_enter_row @current_index
  set_form_row # added 2009-01-11 23:41 
  #$log.debug " ONE ENTER LIST #{@current_index}, #{@form.row}"
  @repaint_required = true
  fire_handler :ENTER, self
end

#on_enter_row(arow) ⇒ Object



717
718
719
720
721
722
723
724
# File 'lib/rbcurse/rlistbox.rb', line 717

def on_enter_row arow
  #$log.debug " Listbox #{self} ENTER_ROW with curr #{@current_index}. row: #{arow} H: #{@handler.keys}"
  #fire_handler :ENTER_ROW, arow
  fire_handler :ENTER_ROW, self
  @list.on_enter_row self
  edit_row_at arow
  @repaint_required = true
end

#on_leave_row(arow) ⇒ Object

set original value so we can cancel set row and col, set value and other things, color and bgcolor



755
756
757
758
759
760
761
# File 'lib/rbcurse/rlistbox.rb', line 755

def on_leave_row arow
  #$log.debug " Listbox #{self} leave with (cr: #{@current_index}) #{arow}: list[row]:#{@list[arow]}"
  #$log.debug " Listbox #{self} leave with (cr: #{@current_index}) #{arow}: "
  #fire_handler :LEAVE_ROW, arow
  fire_handler :LEAVE_ROW, self
  editing_completed arow
end

#prepare_editor(editor, row) ⇒ Object

private



734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
# File 'lib/rbcurse/rlistbox.rb', line 734

def prepare_editor editor, row
  r,c = rowcol
  value =  @list[row] # .chomp
  value = value.dup rescue value # so we can cancel
  row = r + (row - @toprow) #  @form.row
  col = c+@left_margin # @form.col
  # unfortunately 2009-01-11 19:47 combo boxes editable allows changing value
  editor.prepare_editor self, row, col, value
  editor.component.curpos = 0 # reset it after search, if user scrols down
  #editor.component.graphic = @graphic #  2010-01-05 00:36 TRYING OUT BUFFERED
  ## override is required if the listbox uses a buffer
  if @should_create_buffer
    $log.debug " overriding editors comp with GRAPHIC #{@graphic} "
    editor.component.override_graphic(@graphic) #  2010-01-05 00:36 TRYING OUT BUFFERED
  end
  set_form_col 0 #@left_margin

  # set original value so we can cancel
  # set row and col,
  # set value and other things, color and bgcolor
end


525
526
527
528
529
530
531
532
533
534
535
# File 'lib/rbcurse/rlistbox.rb', line 525

def print_borders
  width = @width
  height = @height-1 # 2010-01-04 15:30 BUFFERED HEIGHT
  window = @graphic  # 2010-01-04 12:37 BUFFERED
  startcol = @col 
  startrow = @row 
  @color_pair = get_color($datacolor)
  #$log.debug "rlistb:  window.print_border #{startrow}, #{startcol} , #{height} , #{width} , @color_pair, @attr "
  window.print_border startrow, startcol, height, width, @color_pair, @attr
  print_title
end


536
537
538
539
540
541
542
543
# File 'lib/rbcurse/rlistbox.rb', line 536

def print_title
  #printstring(@graphic, @row, @col+(@[email protected])/2, @title, @color_pair, @title_attrib) unless @title.nil?
  # 2010-01-04 15:53 BUFFERED
  # I notice that the old version would print a title that was longer than width,
  #+ but the new version won't print anything if it exceeds width.
  # TODO check title.length and truncate if exceeds width
  @graphic.printstring( @row, @col+(@width-@title.length)/2, @title, @color_pair, @title_attrib) unless @title.nil?
end

#repaintObject

this method chops the data to length before giving it to the renderer, this can cause problems if the renderer does some processing. also, it pans the data horizontally giving the renderer a section of it.



809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
# File 'lib/rbcurse/rlistbox.rb', line 809

def repaint
  safe_create_buffer # 2010-01-04 12:36 BUFFERED moved here 2010-01-05 18:07 
  return unless @repaint_required
  # not sure where to put this, once for all or repeat 2010-02-17 23:07 RFED16
  my_win = @form ? @form.window : @target_window
  @graphic = my_win unless @graphic
  #$log.warn "neither form not target window given!!! TV paint 368" unless my_win
  raise " #{@name} neither form, nor target window given TV paint " unless my_win
  raise " #{@name} NO GRAPHIC set as yet                 TV paint " unless @graphic
  @win_left = my_win.left
  @win_top = my_win.top

  $log.debug " rlistbox repaint graphic #{@graphic} "
  print_borders if @to_print_borders == 1 # do this once only, unless everything changes
  rc = row_count
  maxlen = @maxlen ||= @width-2
  tm = list()
  tr = @toprow
  acolor = get_color $datacolor
  h = scrollatrow()
  r,c = rowcol
  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]   # 2009-01-17 18:37 chomp giving error in some cases says frozen
        if content.is_a? String
          content = content.dup
          content.chomp!
          content.gsub!(/\t/, '  ') # don't display tab
          content.gsub!(/[^[:print:]]/, '')  # don't display non print characters
          if !content.nil? 
            if content.length > maxlen # only show maxlen
              content = content[@pcol..@pcol+maxlen-1] 
            else
              content = content[@pcol..-1]
            end
          end
        elsif content.is_a? TrueClass or content.is_a? FalseClass
        else
          content = content.to_s
        end
        ## set the selector symbol if requested
        selection_symbol = ''
        if @show_selector
          if selected
            selection_symbol = @row_selected_symbol
          else
            selection_symbol =  @row_unselected_symbol
          end
          @graphic.printstring r+hh, c, selection_symbol, acolor,@attr
        end
        #renderer = get_default_cell_renderer_for_class content.class.to_s
        renderer = cell_renderer()
        #renderer.show_selector @show_selector
        #renderer.row_selected_symbol @row_selected_symbol
        #renderer.left_margin @left_margin
        #renderer.repaint @graphic, r+hh, c+(colix*11), content, focussed, selected
        ## added crow on 2009-02-06 23:03 
        # since data is being truncated and renderer may need index
        renderer.repaint @graphic, r+hh, c+@left_margin, crow, content, focussed, selected
    else
      # clear rows
      @graphic.printstring r+hh, c, " " * (@width-2), acolor,@attr
    end
  end
  if @cell_editing_allowed
    @cell_editor.component.repaint unless @cell_editor.nil? or @cell_editor.component.form.nil?
  end
  @table_changed = false
  @repaint_required = false
  @buffer_modified = true # required by form to call buffer_to_screen BUFFERED
  buffer_to_window # RFED16 2010-02-17 23:16 
end

#row_countObject



486
487
488
# File 'lib/rbcurse/rlistbox.rb', line 486

def row_count
  @list.length
end

#scrollatrowObject

added 2009-01-07 13:05 so new scrollable can use



490
491
492
493
# File 'lib/rbcurse/rlistbox.rb', line 490

def scrollatrow
  #@height - 2
  @height - 3 # 2010-01-04 15:30 BUFFERED HEIGHT
end

#select_default_valuesObject



517
518
519
520
521
522
523
524
# File 'lib/rbcurse/rlistbox.rb', line 517

def select_default_values
  return if @default_values.nil?
  @default_values.each do |val|
    row = @list.index val
    #do_select(row) unless row.nil?
    add_row_selection_interval row, row unless row.nil?
  end
end

#selection_mode(*val) ⇒ Object

getter and setter for selection_mode Must be called after creating model, so no duplicate. Since one may set in model directly.



478
479
480
481
482
483
484
485
# File 'lib/rbcurse/rlistbox.rb', line 478

def selection_mode(*val)
  raise "ListSelectionModel not yet created!" if @list_selection_model.nil?
  if val.empty?
    @list_selection_model.selection_mode
  else
    @list_selection_model.selection_mode = val[0] 
  end
end

#set_buffering(params) ⇒ Object

2010-02-18 11:40 TRYING OUT - canceling editing if resized otherwise drawing errors can occur the earlier painted edited comp in yellow keeps showing until a key is pressed



952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
# File 'lib/rbcurse/rlistbox.rb', line 952

def set_buffering params
  super
  ## Ensuring that changes to top get reflect in editing comp
  #+ otherwise it raises an exception. Still the earlier cell_edit is being
  #+ printed where it was , until a key is moved
  # FIXME - do same for col
  if @cell_editor
    r,c = rowcol
    if @cell_editor.component.row < @row_offset + @buffer_params[:screen_top]
      @cell_editor.component.row = @row_offset +  @buffer_params[:screen_top]
    end
    # TODO next block to be tested by placing a listbox in right split of vertical
    if @cell_editor.component.col < @col_offset + @buffer_params[:screen_left]
      @cell_editor.component.col = @col_offset +  @buffer_params[:screen_left]
    end
    #editing_canceled @current_index if @cell_editing_allowed and @cell_editor
  end
  #set_form_row
  @repaint_required = true
end

#set_form_col(col1 = 0) ⇒ Object



892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
# File 'lib/rbcurse/rlistbox.rb', line 892

def set_form_col col1=0
  # TODO BUFFERED use setrowcol @form.row, col
  # TODO BUFFERED use cols_panned
  @cols_panned ||= 0 # RFED16 2010-02-17 23:40 
  # editable listboxes will involve changing cursor and the form issue
  ## added win_col on 2010-01-04 23:28 for embedded forms BUFFERED TRYING OUT
  #[email protected]
  win_col = 0 # 2010-02-17 23:19 RFED16
  #col = win_col + @orig_col + @col_offset + @curpos + @form.cols_panned
  col2 = win_col + @col + @col_offset + col1 + @cols_panned + @left_margin
  $log.debug " set_form_col in rlistbox #{@col}+ left_margin #{@left_margin} ( #{col2} ) "
  #super col+@left_margin
  #@form.setrowcol @form.row, col2   # added 2009-12-29 18:50 BUFFERED
  setrowcol nil, col2 # 2010-02-17 23:19 RFED16
end

#start_blockObject

sets marker for start of block added on 2009-02-19 22:37



934
935
936
937
# File 'lib/rbcurse/rlistbox.rb', line 934

def start_block #selection
  @first_index = @current_index
  @last_index = nil
end