1 21 22 package org.armedbear.j; 23 24 import java.awt.event.AdjustmentEvent ; 25 import java.awt.event.AdjustmentListener ; 26 27 public final class HorizontalScrollBarListener implements AdjustmentListener 28 { 29 private Editor editor; 30 31 public HorizontalScrollBarListener(Editor editor) 32 { 33 this.editor = editor; 34 } 35 36 public void adjustmentValueChanged(AdjustmentEvent e) 37 { 38 if (editor.inScrollBarUpdate) 39 return; 40 final Display display = editor.getDisplay(); 41 int value = e.getValue() / display.getCharWidth(); 42 if (value != display.shift) { 43 int absCaretCol = display.getShift() + display.getCaretCol(); 44 display.setShift(value); 45 display.setCaretCol(absCaretCol - value); 46 display.repaint(); 47 } 48 } 49 } 50 | Popular Tags |