NoteBookView.st
changeset 5761 eaacf63f0cb3
parent 5736 32183f299b87
child 5882 7c3471a43007
equal deleted inserted replaced
5760:d689b29b69cc 5761:eaacf63f0cb3
  2718 
  2718 
  2719 makeToBaseLine:aLnNr
  2719 makeToBaseLine:aLnNr
  2720     "rotate lines to make the line #aLnNr be the new base line (i.e.
  2720     "rotate lines to make the line #aLnNr be the new base line (i.e.
  2721      subtract (aLnNr-1) from all lines and take modulu the number of lines"
  2721      subtract (aLnNr-1) from all lines and take modulu the number of lines"
  2722 
  2722 
  2723     |lineTopsOrLefts isHorizontal|
  2723     |listLocal lineTopsOrLefts isHorizontal|
  2724 
  2724 
  2725     isHorizontal := self isHorizontal.
  2725     isHorizontal := self isHorizontal.
       
  2726 
       
  2727     "sr: keep the list as a local copy,
       
  2728      because list is an instance variable,
       
  2729      which can be changed during the processing of this method.
       
  2730      which did happend to me.
       
  2731      calling #at: with an index fetched by #findFirst: 
       
  2732      will fail, if the list has been modified in the meanwhile"
       
  2733     listLocal := list copy.     
  2726 
  2734 
  2727     "collect per-lineNr offsets"
  2735     "collect per-lineNr offsets"
  2728     lineTopsOrLefts := (1 to:self numberOfLines) collect:[:lnr |
  2736     lineTopsOrLefts := (1 to:self numberOfLines) collect:[:lnr |
  2729                             |tabNr layout|
  2737                             |tabNr layout|
  2730 
  2738 
  2731                             tabNr := list findFirst:[:aTab| aTab lineNr == lnr].
  2739                             "sr: calling #at: with an index fetched by #findFirst: 
  2732                             layout := (list at:tabNr) unselectedLayout.
  2740                              will fail, if the list has been modified in the meanwhile"
       
  2741                             tabNr := listLocal findFirst:[:aTab| aTab lineNr == lnr].
       
  2742                             layout := (listLocal at:tabNr) unselectedLayout.
  2733                             isHorizontal ifTrue:[
  2743                             isHorizontal ifTrue:[
  2734                                 layout top.
  2744                                 layout top.
  2735                             ] ifFalse:[
  2745                             ] ifFalse:[
  2736                                 layout left.
  2746                                 layout left.
  2737                             ].
  2747                             ].
  2738                        ].
  2748                        ].
  2739 
  2749 
  2740     "change offsets of all tabs"
  2750     "change offsets of all tabs"
  2741     list do:[:el |
  2751     listLocal do:[:el |
  2742         |layout topOrLeft nr newNr|
  2752         |layout topOrLeft nr newNr|
  2743 
  2753 
  2744         nr := el lineNr.
  2754         nr := el lineNr.
  2745         newNr := nr - aLnNr + 1.
  2755         newNr := nr - aLnNr + 1.
  2746         newNr <= 0 ifTrue:[ newNr := newNr + numberOfLines].
  2756         newNr <= 0 ifTrue:[ newNr := newNr + numberOfLines].
  2759 
  2769 
  2760         el lineNr:newNr.
  2770         el lineNr:newNr.
  2761     ].
  2771     ].
  2762 
  2772 
  2763     self invalidate.
  2773     self invalidate.
       
  2774 
       
  2775     "Modified: / 03-05-2018 / 11:40:04 / sr"
  2764 !
  2776 !
  2765 
  2777 
  2766 recomputeList
  2778 recomputeList
  2767     "recompute list"
  2779     "recompute list"
  2768 
  2780