Class: RubyCurses::VimSplit

Inherits:
Widget show all
Defined in:
lib/rbcurse/rvimsplit.rb

Overview

A simpler replacement for the java-esque SplitPane. This can take multiple splits and does not require splits within splits as SplitPane does. This is less functional, but should be easier to use, setup and hack.

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 inherited from Widget

#_object_created, #col_offset, #cols_panned, #config, #curpos, #focussed, #form, #id, #parent_component, #row_offset, #rows_panned, #state

Instance Method Summary collapse

Methods inherited from Widget

#changed, #click, #destroy, #enter, #event_list, #focus, #get_preferred_size, #getvalue, #getvalue_for_paint, #height, #height=, #hide, #leave, #modified?, #move, #override_graphic, #printstring, #process_key, #remove, #repaint_all, #repaint_required, #rowcol, #set_buffer_modified, #set_buffering, #set_form, #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, #warn

Methods included from Utils

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

Methods included from ConfigSetup

#cget, #config_setup, #configure, #variable_set

Methods included from EventHandler

#bind, #fire_handler, #fire_property_change

Constructor Details

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

Returns a new instance of VimSplit.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/rbcurse/rvimsplit.rb', line 47

def initialize form, config={}, &block
  if config[:width] == :EXPAND
    config[:width] = Ncurses.COLS - config[:col]
  end
  if config[:orientation] == nil
    config[:orientation] = :HORIZONTAL_SPLIT
  else
    # if first char is V or H then fill it in.
    char = config[:orientation].to_s[0,1].upcase
    if char == "V"
      config[:orientation] = :VERTICAL_SPLIT
    else
      config[:orientation] = :HORIZONTAL_SPLIT
    end
  end
  @max_weight ||= 0.8
  @min_weight ||= 0.1 # earlier 0.2 but i wanted 0.15, someone may want 0.05 ??
  @suppress_borders = false
  @_use_preferred_sizes = true
  @row_offset = @col_offset = 1
  # type can be :INCREASE, :DECREASE, :EXPAND, :UNEXPAND :EQUAL
  @_events ||= []
  @_events.push :COMPONENT_RESIZE_EVENT
  @_events.push :DRAG_EVENT
  super
  @focusable = true
  @editable = false
  @components = [] # all components
  @c1 =[] # first split's comps
  @c2 =[] # second split's comps
  # coordinates of a split, i calculate and increment row col as i go.
  @c1rc = nil # TODO create once only
  @c2rc = nil

  # hash, keyed on component, contains Split (which side, flow or stack, weight)
  @ch = {}
  @weight ||= 0.50

  init_vars
  bind_key([?\C-w,?o], :expand)  
  bind_key([?\C-w,?1], :expand)  
  bind_key([?\C-w,?2], :unexpand)  
  bind_key([?\C-w,?\C-w], :goto_other_split)  
  bind_key([?\C-w,?-], :decrease_height)  
  bind_key([?\C-w,?+], :increase_height)  
  bind_key([?\C-w,?<], :decrease_width)  
  bind_key([?\C-w,?>], :increase_width)  
  bind_key([?\C-w,?i], :increase_weight)  
  bind_key([?\C-w,?d], :decrease_weight)  
  bind_key([?\C-w,?6], :increase_current_component)
  bind_key([?\C-w,?5], :decrease_current_component)
  # this needs to be set at application level
  bind_key(FFI::NCurses::KEY_F3) {RubyCurses::FocusManager.toggle_focusable}
end

Instance Attribute Details

#current_componentObject (readonly)

Returns the value of attribute current_component.



46
47
48
# File 'lib/rbcurse/rvimsplit.rb', line 46

def current_component
  @current_component
end

Instance Method Details

#add(c, which, weight = :AUTO, type = :AUTO) ⇒ Object

uses intelligent default a vertical split would prefer stacks and a horizontal split would go with flows

Parameters:

  • to (Widget, Array, String, Hash, Variable)

    add

  • (:FIRST, :SECOND)


114
115
116
117
118
119
120
121
122
123
124
# File 'lib/rbcurse/rvimsplit.rb', line 114

def add c, which, weight=:AUTO, type=:AUTO
  if type == :AUTO
    if v?
      type = :STACK
    else
      type = :FLOW
    end
  end
  _add type, c, which, weight
  #return self # lets return component created for christ's sake and keep it simple
end

#components_for(which) ⇒ Object

returns list of components for FIRST or SECOND split



266
267
268
# File 'lib/rbcurse/rvimsplit.rb', line 266

def components_for which
  return which == :FIRST ? @c1 : @c2
end

#current_split:FIRST, :SECOND

get the current split focus is on

Returns:

  • (:FIRST, :SECOND)

    which split are we on



257
258
259
# File 'lib/rbcurse/rvimsplit.rb', line 257

def current_split
  split_info_for(@current_component).which
end

#decrease_current_componentObject

FIXME - i can only reduce if i’ve increased



641
642
643
644
645
646
647
648
649
650
# File 'lib/rbcurse/rvimsplit.rb', line 641

def decrease_current_component
  info = split_info_for
  #info.add_weight = 0 if info.add_weight.nil?
  #if info.add_weight > 0.0
    #info.add_weight = info.add_weight - 0.05
  #end
  e = ResizeEvent.new @current_component, :DECREASE
  fire_handler :COMPONENT_RESIZE_EVENT, e
  #@repaint_required = true
end

#decrease_heightObject

fires handler to request app to resize current component



664
665
666
# File 'lib/rbcurse/rvimsplit.rb', line 664

def decrease_height
  resize_component :DECREASE, :HEIGHT
end

#decrease_weightObject

decrease the weight of the split



631
632
633
634
# File 'lib/rbcurse/rvimsplit.rb', line 631

def decrease_weight
  _multiplier = ($multiplier == 0 ? 1 : $multiplier )
  weight(weight - 0.05*_multiplier)
end

#decrease_widthObject

fires handler to request app to resize current component



668
669
670
# File 'lib/rbcurse/rvimsplit.rb', line 668

def decrease_width
  resize_component :DECREASE, :WIDTH
end

#expandObject

calling application need to handle this, since it knows how many windows its has and what the user would mean



691
692
693
694
# File 'lib/rbcurse/rvimsplit.rb', line 691

def expand # maximize 
  e = ResizeEvent.new @current_component, :EXPAND
  fire_handler :COMPONENT_RESIZE_EVENT, e
end

#flow(c, which, weight) ⇒ Object

place components on right of previous. Useful in horizontal split



161
162
163
164
# File 'lib/rbcurse/rvimsplit.rb', line 161

def flow c, which, weight
  _add :FLOW, c, which, weight
  #return self # lets return component created for christ's sake and keep it simple
end

#goto_component(comp) ⇒ Object

set focus on given component Sometimes you have the handle to component, and you want to move focus to it



624
625
626
627
628
629
# File 'lib/rbcurse/rvimsplit.rb', line 624

def goto_component comp
  return if comp == @current_component
  leave_current_component
  @current_component = comp
  set_form_row
end

#goto_next_componentObject



542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/rbcurse/rvimsplit.rb', line 542

def goto_next_component
  if @current_component != nil 
    leave_current_component
    if on_last_component?
      return :UNHANDLED
    end
    @current_index = @components.index(@current_component)
    index = @current_index + 1
    index.upto(@components.length-1) do |i|
      f = @components[i]
      if f.focusable
        @current_index = i
        @current_component = f
        return set_form_row
      end
    end
  end
  return :UNHANDLED
end

#goto_other_splitObject



616
617
618
619
620
621
# File 'lib/rbcurse/rvimsplit.rb', line 616

def goto_other_split
  c = components_for(other_split)
  leave_current_component
  @current_component = c.first
  set_form_row
end

#goto_prev_componentObject



561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
# File 'lib/rbcurse/rvimsplit.rb', line 561

def goto_prev_component
  if @current_component != nil 
    leave_current_component
    if on_first_component?
      return :UNHANDLED
    end
    @current_index = @components.index(@current_component)
    index = @current_index -= 1
    index.downto(0) do |i|
      f = @components[i]
      if f.focusable
        @current_index = i
        @current_component = f
        return set_form_row
      end
    end
  end
  return :UNHANDLED
end

#h?Boolean

Returns:

  • (Boolean)


369
370
371
# File 'lib/rbcurse/rvimsplit.rb', line 369

def h?
  !@orientation == :VERTICAL_SPLIT
end

#handle_key(ch) ⇒ Object

called by parent or form, otherwise its private



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

def handle_key ch
  $log.debug " VIMSPLIT handle_key #{ch} "
  _multiplier = ($multiplier == 0 ? 1 : $multiplier )
  if ch == KEY_TAB
    $log.debug " GOTO NEXT"
    return goto_next_component
  elsif ch == KEY_BTAB
    return goto_prev_component
  end
  comp = @current_component
  $log.debug " VIMSPL handle_k #{ch}: #{comp}" 
  if comp
    ret = comp.handle_key(ch) 
    if ret != :UNHANDLED
      comp.repaint # NOTE: if we don;t do this, then it won't get repainted. I will have to repaint ALL
      # in repaint of this.
      return ret 
    end
  end
  $log.debug "XXX VIM key unhandled by comp #{comp.name} "
  case ch
  when ?\C-c.getbyte(0)
    $multiplier = 0
    return 0
  when ?0.getbyte(0)..?9.getbyte(0)
    $log.debug " VIM coming here to set multiplier #{$multiplier} "
    $multiplier *= 10 ; $multiplier += (ch-48)
    return 0
  end
  ret = process_key ch, self
  # allow user to map left and right if he wants
  if ret == :UNHANDLED
    case ch
    when KEY_UP
      # form will pick this up and do needful
      return goto_prev_component #unless on_first_component?
    when KEY_LEFT
      # if i don't check for first component, key will go back to form,
      # but not be processes. so focussed remain here, but be false.
      # In case of returnign an unhandled TAB, on_leave will happen and cursor will move to 
      # previous component outside of this.
      return goto_prev_component unless on_first_component?
    when KEY_RIGHT
      return goto_next_component #unless on_last_component?
    when KEY_DOWN
      return goto_next_component #unless on_last_component?
    else 
      return :UNHANDLED
    end
  end

  $multiplier = 0
  return 0
end

#increase_current_componentObject



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

def increase_current_component
  info = split_info_for
  #info.add_weight = 0 if info.add_weight.nil?
  #if info.add_weight < 0.3
    #info.add_weight = info.add_weight + 0.05
  #end
  e = ResizeEvent.new @current_component, :INCREASE
  fire_handler :COMPONENT_RESIZE_EVENT, e
  #@repaint_required = true
end

#increase_heightObject

fires handler to request app to resize current component



676
677
678
# File 'lib/rbcurse/rvimsplit.rb', line 676

def increase_height
  resize_component :INCREASE, :HEIGHT
end

#increase_weightObject

increase the weight of the split



636
637
638
639
# File 'lib/rbcurse/rvimsplit.rb', line 636

def increase_weight
  _multiplier = ($multiplier == 0 ? 1 : $multiplier )
  weight(weight + 0.05*_multiplier)
end

#increase_widthObject

fires handler to request app to resize current component



672
673
674
# File 'lib/rbcurse/rvimsplit.rb', line 672

def increase_width
  resize_component :INCREASE, :WIDTH
end

#init_varsObject



101
102
103
104
105
106
107
108
109
# File 'lib/rbcurse/rvimsplit.rb', line 101

def init_vars
  @repaint_required = true
  @recalculate_splits = true # convert weight to size
  @row_offset = @col_offset = 0 if @suppress_borders # FIXME supposed to use this !!

  @internal_width = 2
  @internal_width = 1 if @suppress_borders

end

#leave_current_componentObject

leave the component we are on. This should be followed by all containers, so that the on_leave action of earlier comp can be displayed, such as dimming components selections



598
599
600
601
602
603
604
605
606
# File 'lib/rbcurse/rvimsplit.rb', line 598

def leave_current_component
  @current_component.on_leave
  # NOTE this is required, since repaint will just not happen otherwise
  # Some components are erroneously repainting all, after setting this to true so it is 
  # working there. 
  @current_component.repaint_required true
  $log.debug " after on_leave VIMS XXX #{@current_component.focussed}   #{@current_component.name}"
  @current_component.repaint
end

#on_enterObject

private



528
529
530
531
532
533
534
535
536
537
538
# File 'lib/rbcurse/rvimsplit.rb', line 528

def on_enter
  # TODO if BTAB the last comp
  if $current_key == KEY_BTAB
    # FIXME last is not focusable, then ??
    @current_component = @components.last
  else
    @current_component = @components.first
  end
  $log.debug " VIM came to on_enter #{@current_component} "
  set_form_row
end

#on_first_component?Boolean

is focus on first component

Returns:

  • (Boolean)


609
610
611
# File 'lib/rbcurse/rvimsplit.rb', line 609

def on_first_component?
  @current_component == @components.first
end

#on_last_component?Boolean

is focus on last component

Returns:

  • (Boolean)


613
614
615
# File 'lib/rbcurse/rvimsplit.rb', line 613

def on_last_component?
  @current_component == @components.last
end

#on_leaveObject



539
540
541
# File 'lib/rbcurse/rvimsplit.rb', line 539

def on_leave
  super
end

#other_splitObject

returns the other split.



261
262
263
264
# File 'lib/rbcurse/rvimsplit.rb', line 261

def other_split
  which = current_split
  return which == :FIRST ? :SECOND : :FIRST
end

#recalculate_splits(use_preferred_sizes = false) ⇒ Object



381
382
383
384
385
386
387
388
389
390
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
# File 'lib/rbcurse/rvimsplit.rb', line 381

def recalculate_splits use_preferred_sizes=false 
  @recalculate_splits = false
  [@c1,@c2].each_with_index do |c,i| 
    rca = @c1rc
    if i == 1
      #$log.debug " XXX VIM moving to second"
      rca = @c2rc
    end
    totalw = 0 # accumulative weight
    totalwd = 0 # accumulative weight for width (in case someone switches)
    totalht = 0 # accumulative weight for height (in case someone switches)
    sz = c.size
    auto = 1.0/sz
    c.each do |e| 
      r    = rca.row
      c    = rca.col
      info = @ch[e] 
      type = info.type
      wt   = info.weight
      wt = auto if wt == :AUTO
      e.row = r
      e.col = c
      if type == :STACK
        # store actual weight that was calculated, so if user reduces or increases
        # we can use this, although ... we have no method that uses actual weights
        # NOTE: If calling program increases one comp's weight, will have to reduce other.
        info.act_weight = wt

        e.width = (rca.w * (1 - totalwd)).to_i
        # recaclulate height only in this case, otherwise we will overwrite changes
        # made by user
        if use_preferred_sizes
          if wt != 0
            if wt
              e.height = ((rca.h * wt).to_i)
            else
              a = 0
              a = 1 if @suppress_borders
              e.height = rca.h - rca.row + a # take exactly rows left
            end
            # else use its own height
          end
        end
        rca.row += e.height
        totalht += wt if wt
      else
        # TODO THIS PART AS PER ABOVE CASE ,  TO TEST
        # this is a horizontal split or flow
        info.act_weight = wt
        #e.height = rca.h
        e.height = (rca.h * (1- totalht)).to_i
        if use_preferred_sizes
          if wt != 0
            if wt
              e.width = ((rca.w * wt).to_i)
            else
              a = 0
              a = 1 if @suppress_borders
              e.width = rca.w - rca.col + a # take exactly rows left
            end
          end
        end
        rca.col += e.width
        totalwd += wt if wt
      end
      e.set_buffering(:target_window => @target_window || @form.window, :bottom => e.height-1, :right => e.width-1, :form => @form ) # removed on 2011-09-29 
      $log.debug " XXXXX VIMS R #{e.row} C #{e.col} H #{e.height} W #{e.width} "
      e.repaint
      e._object_created = true # added 2010-09-16 13:02 now prop handlers can be fired
    end
  end
  @_use_preferred_sizes = false
end

#repaintObject

repaint object called by Form, and sometimes parent component (if not form).



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/rbcurse/rvimsplit.rb', line 273

def repaint
  my_win = @form ? @form.window : @target_window
  @graphic = my_win unless @graphic
  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

  #return unless @repaint_required
  @recalculate_splits = true if @rc.nil?

  # if some major change has happened then repaint everything
  if @repaint_required
    $log.debug " VIM repaint graphic #{@graphic} "
    print_borders unless @suppress_borders # do this once only, unless everything changes
    r,c = rowcol

    bordercolor = @border_color || $datacolor
    borderatt = @border_attrib || Ncurses::A_NORMAL


    @graphic.attron(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
    @gbwid ||= 0
    roffset = 1
    loffset = 2
    if @suppress_borders
      loffset = roffset = 0
    end
    if v?
      @rc ||= (@width * @weight).to_i
      rc = @rc
      $log.debug "SPLP #{@name} prtingign split vline divider 1, rc: #{rc}, h:#{@height} - 2 "
      unless @vb
        @gbwid = 1
        _create_divider
      else
        @vb.row @row+roffset
        @vb.col rc+@col
        #@vb.repaint
      end
      #@graphic.mvvline(@row+1, rc+@col, 0, @height-2)
      # TODO don;t keep recreating, if present, reset values
      @c1rc = Coord.new(@row,@col, @height -0, rc-@gbwid)
      @c2rc = Coord.new(@row,rc+@col+@gbwid,@height-0, @width - rc-@gbwid)
    else
      @rc ||= (@height * @weight).to_i
      rc = @rc
      $log.debug "SPLP #{@name} prtingign split hline divider rc: #{rc} , 1 , w:#{@width} - 2"
      unless @vb
        @gbwid = 1
        _create_divider
      else
        #@vb = Divider.new nil, :row => @row+rc-1, :col => @col+1, :length => @width-loffset, :side => :bottom
        @vb.row @row+@rc-1
        @vb.col @col+roffset
        #@vb.repaint # getting wiped out by vimsplit ?
      end
      #@graphic.mvhline(rc+@row, @col+1, 0, @width-@internal_width)
      #@neat = true
      if @neat
        a = 1
        @c1rc = Coord.new(@row+a,@col+a, rc-a, @width-@internal_width)
        @c2rc = Coord.new(@row+rc+a,@col+a, @height-rc-2, @width - @internal_width)
      else
        # flush
      #@c1rc = Coord.new(@row,@col, @height -0, rc-@gbwid)
      #@c2rc = Coord.new(@row,rc+@col+@gbwid,@height-0, @width - rc-@gbwid)
        a = 0
        @c1rc = Coord.new(@row,@col, rc-@gbwid, @width)
        @c2rc = Coord.new(@row+rc, @col, @height-rc-@gbwid, @width)
      end
    end
    @graphic.attroff(Ncurses.COLOR_PAIR(bordercolor) | borderatt)
    @components.each { |e| e.repaint_all(true) }
    $log.debug " XXX VIM REPAINT ALL "
    # FIXME do this only once, or when major change happends, otherwise
    # i cannot increase decrease size on user request.
    recalculate_splits @_use_preferred_sizes if @recalculate_splits
    # vimsplit often overwrites this while divider is being moved so we must
    # again call it.
    @vb.repaint if @vb
  else
    # only repaint those that are needing repaint
    # 2010-09-22 18:09 its possible somenoe has updated an internal
    # component, but this container does not know. So we've got to call
    # repaint on all components, only those which are changed will
    # actually be repainted
    @components.each { |e| e.repaint }
  end # if repaint_required
  # NOTE: at present one cannot change from flow to stack inside a pane

  @repaint_required = false
end

#reset_to_preferred_sizeObject

convert weight to height and length we should only do this once, or if major change otherwise changes that user may have effected in size will be lost NOTE: this resets all components to preferred weights (given when component was added. If user has resized components then those changes in size will be lost.



378
379
380
# File 'lib/rbcurse/rvimsplit.rb', line 378

def reset_to_preferred_size  
  recalculate_splits use_preferred_sizes=true
end

#resize_component(incdec, hw) ⇒ Object

fires handler to request app to resize component

Parameters:

  • (:INCREASE, :DECREASE)
  • (:HEIGHT, :WIDTH)


654
655
656
657
658
659
660
661
# File 'lib/rbcurse/rvimsplit.rb', line 654

def resize_component incdec, hw  #:nodoc:
  type = incdec.to_s + '_' + hw.to_s
  #info = split_info_for
  #info.add_weight = 0 if info.add_weight.nil?
  e = ResizeEvent.new @current_component, type.to_sym
  fire_handler :COMPONENT_RESIZE_EVENT, e
  #@repaint_required = true
end

#set_form_colObject

private



590
591
592
593
594
# File 'lib/rbcurse/rvimsplit.rb', line 590

def set_form_col
  return if @current_component.nil?
  $log.debug " #{@name} set_form_col calling sfc for #{@current_component.name} "
  @current_component.set_form_col 
end

#set_form_rowObject

private



581
582
583
584
585
586
587
588
# File 'lib/rbcurse/rvimsplit.rb', line 581

def set_form_row
  #return :UNHANDLED if @current_component.nil?
  $log.debug " VIM on enter sfr #{@current_component} "
  @current_component.on_enter
  @current_component.set_form_col # XXX 
  @current_component.repaint
  # XXX compo should do set_form_row and col if it has that
end

#split_info_for(c = @current_component) ⇒ Object



252
253
254
# File 'lib/rbcurse/rvimsplit.rb', line 252

def split_info_for(c = @current_component)
  @ch[c]
end

#stack(c, which, weight) ⇒ Object

stack components, one over another, useful in a vertical split

Parameters:

  • component (Widget)
  • first (:FIRST :SECOND)

    or second split

  • weight (Float, nil, :AUTO)

    of object, nil for last will expand it to full :AUTO will give equal weight to all



156
157
158
159
# File 'lib/rbcurse/rvimsplit.rb', line 156

def stack c, which, weight
  _add :STACK, c, which, weight
  #return self # lets return component created for christ's sake and keep it simple
end

#unexpandObject

calling application need to handle this, since it knows how many windows its has and what the user would mean



697
698
699
700
# File 'lib/rbcurse/rvimsplit.rb', line 697

def unexpand
  e = ResizeEvent.new @current_component, :UNEXPAND
  fire_handler :COMPONENT_RESIZE_EVENT, e
end

#v?Boolean

Returns:

  • (Boolean)


366
367
368
# File 'lib/rbcurse/rvimsplit.rb', line 366

def v?
  @orientation == :VERTICAL_SPLIT
end

#weight(*val) ⇒ Object

set the weight of outer split



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/rbcurse/rvimsplit.rb', line 126

def weight(*val)
  if val.empty?
    return @weight
  else
    # raise ArgumentError
    newval = val[0]
    # this is since, using numeric multipliers he can go beyond, so lets give him the best
    if val[0] < @min_weight 
      newval = @min_weight
    elsif val[0] > @max_weight
      newval = @max_weight
    end 
    oldvalue = @weight
    @weight = newval
    # orientation can be nil, so we cannot calculate rc here
    #if v?
      #@rc = (@width * @weight).to_i
    #else
      #@rc = (@height * @weight).to_i
    #end
    @rc = nil # so recalculated in repaint
    fire_property_change(:weight, oldvalue, @weight)
  end
  self
end