Class: RubyCurses::VimSplit
- Inherits:
-
Widget
- Object
- Widget
- RubyCurses::VimSplit
- Defined in:
- lib/rbcurse/extras/widgets/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.
Instance Attribute Summary collapse
-
#current_component ⇒ Object
readonly
Returns the value of attribute current_component.
Instance Method Summary collapse
-
#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.
-
#components_for(which) ⇒ Object
returns list of components for FIRST or SECOND split.
-
#current_split ⇒ :FIRST, :SECOND
get the current split focus is on.
-
#decrease_current_component ⇒ Object
FIXME - i can only reduce if i’ve increased.
-
#decrease_height ⇒ Object
fires handler to request app to resize current component.
-
#decrease_weight ⇒ Object
decrease the weight of the split.
-
#decrease_width ⇒ Object
fires handler to request app to resize current component.
-
#expand ⇒ Object
calling application need to handle this, since it knows how many windows its has and what the user would mean.
-
#flow(c, which, weight) ⇒ Object
place components on right of previous.
-
#goto_component(comp) ⇒ Object
set focus on given component Sometimes you have the handle to component, and you want to move focus to it.
- #goto_next_component ⇒ Object
- #goto_other_split ⇒ Object
- #goto_prev_component ⇒ Object
- #h? ⇒ Boolean
-
#handle_key(ch) ⇒ Object
called by parent or form, otherwise its private.
- #increase_current_component ⇒ Object
-
#increase_height ⇒ Object
fires handler to request app to resize current component.
-
#increase_weight ⇒ Object
increase the weight of the split.
-
#increase_width ⇒ Object
fires handler to request app to resize current component.
- #init_vars ⇒ Object
-
#initialize(form, config = {}, &block) ⇒ VimSplit
constructor
A new instance of VimSplit.
-
#leave_current_component ⇒ Object
leave the component we are on.
-
#on_enter ⇒ Object
private.
-
#on_first_component? ⇒ Boolean
is focus on first component.
-
#on_last_component? ⇒ Boolean
is focus on last component.
- #on_leave ⇒ Object
-
#other_split ⇒ Object
returns the other split.
- #recalculate_splits(use_preferred_sizes = false) ⇒ Object
-
#repaint ⇒ Object
repaint object called by Form, and sometimes parent component (if not form).
-
#reset_to_preferred_size ⇒ Object
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..
-
#resize_component(incdec, hw) ⇒ Object
fires handler to request app to resize component.
-
#set_form_col ⇒ Object
private.
-
#set_form_row ⇒ Object
private.
- #split_info_for(c = @current_component) ⇒ Object
-
#stack(c, which, weight) ⇒ Object
stack components, one over another, useful in a vertical split.
-
#unexpand ⇒ Object
calling application need to handle this, since it knows how many windows its has and what the user would mean.
- #v? ⇒ Boolean
-
#weight(*val) ⇒ Object
set the weight of outer split.
Constructor Details
#initialize(form, config = {}, &block) ⇒ VimSplit
Returns a new instance of VimSplit.
46 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 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 46 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_component ⇒ Object (readonly)
Returns the value of attribute current_component.
45 46 47 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 45 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
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 113 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/extras/widgets/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
257 258 259 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 257 def current_split split_info_for(@current_component).which end |
#decrease_current_component ⇒ Object
FIXME - i can only reduce if i’ve increased
681 682 683 684 685 686 687 688 689 690 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 681 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_height ⇒ Object
fires handler to request app to resize current component
704 705 706 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 704 def decrease_height resize_component :DECREASE, :HEIGHT end |
#decrease_weight ⇒ Object
decrease the weight of the split
671 672 673 674 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 671 def decrease_weight _multiplier = ($multiplier == 0 ? 1 : $multiplier ) weight(weight - 0.05*_multiplier) end |
#decrease_width ⇒ Object
fires handler to request app to resize current component
708 709 710 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 708 def decrease_width resize_component :DECREASE, :WIDTH end |
#expand ⇒ Object
calling application need to handle this, since it knows how many windows its has and what the user would mean
731 732 733 734 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 731 def # 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
160 161 162 163 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 160 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
664 665 666 667 668 669 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 664 def goto_component comp return if comp == @current_component leave_current_component @current_component = comp set_form_row end |
#goto_next_component ⇒ Object
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 582 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_split ⇒ Object
656 657 658 659 660 661 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 656 def goto_other_split c = components_for(other_split) leave_current_component @current_component = c.first set_form_row end |
#goto_prev_component ⇒ Object
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 601 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
372 373 374 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 372 def h? !@orientation == :VERTICAL_SPLIT end |
#handle_key(ch) ⇒ Object
called by parent or form, otherwise its private
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 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 513 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_component ⇒ Object
719 720 721 722 723 724 725 726 727 728 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 719 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_height ⇒ Object
fires handler to request app to resize current component
716 717 718 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 716 def increase_height resize_component :INCREASE, :HEIGHT end |
#increase_weight ⇒ Object
increase the weight of the split
676 677 678 679 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 676 def increase_weight _multiplier = ($multiplier == 0 ? 1 : $multiplier ) weight(weight + 0.05*_multiplier) end |
#increase_width ⇒ Object
fires handler to request app to resize current component
712 713 714 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 712 def increase_width resize_component :INCREASE, :WIDTH end |
#init_vars ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 100 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_component ⇒ Object
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
638 639 640 641 642 643 644 645 646 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 638 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_enter ⇒ Object
private
568 569 570 571 572 573 574 575 576 577 578 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 568 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
649 650 651 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 649 def on_first_component? @current_component == @components.first end |
#on_last_component? ⇒ Boolean
is focus on last component
653 654 655 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 653 def on_last_component? @current_component == @components.last end |
#on_leave ⇒ Object
579 580 581 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 579 def on_leave super end |
#other_split ⇒ Object
returns the other split.
261 262 263 264 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 261 def other_split which = current_split return which == :FIRST ? :SECOND : :FIRST end |
#recalculate_splits(use_preferred_sizes = false) ⇒ Object
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 454 455 456 457 458 459 460 461 462 463 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 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 384 def recalculate_splits use_preferred_sizes=false # i've made it true so that moving the divider can recalculate all, otherwise # testvimsplit was failing to recalc 2 lists. 2011-12-29 use_preferred_sizes=true @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 # even this is wrong since we have stacks and flows mixed # calculate a more accurate auto than just an average # SHIT this won't work since c contains flow and stacks, all objects #used = 0.0 #usedct = 0 #c.each {|e| info = @ch[e]; wt = info.weight; #if wt && wt != :AUTO #used += wt #usedct += 1 #end #} #if usedct > 0 #$log.debug "XXX: COMES HERE 1.0 - #{used} / #{sz} - #{usedct} " #auto = (1.0 - used) / (sz - usedct) #end frem = srem = 0 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 if e.row <= @row # TODO do something here !! $log.warn "XXX: WARN VIMPSPLIT row #{e.row} going less than #{@row} " end 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 m = rca.h * wt mf = m.floor srem += (m - mf) if srem >= 1 mf += 1 srem = 0 end e.height = mf #((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 $log.warn "XXX: WARN VIMSPLIT height = 0 " if e.height == 0 rca.row += e.height totalht += wt if wt else # FLOW # 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 m = rca.w * wt mf = m.floor frem += (m - mf) if frem >= 1 mf += 1 frem = 0 end e.width = mf # ((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 #{@row} : #{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 |
#repaint ⇒ Object
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 366 367 368 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 273 def repaint my_win = @form ? @form.window : @target_window @graphic = my_win unless @graphic raise " #{@name} NO GRAPHIC set as yet VIMSPLIT paint " unless @graphic #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) ## The following calculations are only calcing the 2 split areas ## and divider locations based on V or H and weight. @gbwid ||= 0 # grabbar width roffset = 1 loffset = 2 if @suppress_borders loffset = roffset = 0 end # vertical split if v? @rc ||= (@width * @weight).to_i rc = @rc # divider location $log.debug "SPLP #{@name} prtingign split vline divider 1, rc: #{rc}, h:#{@height} - 2 " unless @vb # if grabbar not created @gbwid = 1 _create_divider else # created, so set it @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 ## calculate cordinated of both split areas/boxes @c1rc = Coord.new(@row,@col, @height -0, rc-@gbwid) @c2rc = Coord.new(@row,rc+@col+@gbwid,@height-0, @width - rc-@gbwid) else # horizontal split @rc ||= (@height * @weight).to_i rc = @rc # dividers row col location $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 against border #@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_size ⇒ Object
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.
381 382 383 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 381 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
694 695 696 697 698 699 700 701 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 694 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_col ⇒ Object
private
630 631 632 633 634 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 630 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_row ⇒ Object
private
621 622 623 624 625 626 627 628 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 621 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/extras/widgets/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
155 156 157 158 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 155 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 |
#unexpand ⇒ Object
calling application need to handle this, since it knows how many windows its has and what the user would mean
737 738 739 740 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 737 def e = ResizeEvent.new @current_component, :UNEXPAND fire_handler :COMPONENT_RESIZE_EVENT, e end |
#v? ⇒ Boolean
369 370 371 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 369 def v? @orientation == :VERTICAL_SPLIT end |
#weight(*val) ⇒ Object
set the weight of outer split
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rbcurse/extras/widgets/rvimsplit.rb', line 125 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 |