1 22 23 package org.gjt.sp.jedit.textarea; 24 25 30 abstract class Anchor 31 { 32 DisplayManager displayManager; 33 TextArea textArea; 34 35 int physicalLine; 36 int scrollLine; 37 boolean callChanged; 38 boolean callReset; 39 40 Anchor(DisplayManager displayManager, 42 TextArea textArea) 43 { 44 this.displayManager = displayManager; 45 this.textArea = textArea; 46 } 48 abstract void reset(); 49 abstract void changed(); 50 51 public String toString() 53 { 54 return getClass().getName() + "[" + physicalLine + "," 55 + scrollLine + "]"; 56 } 58 void contentInserted(int startLine, int numLines) 60 { 61 if(this.physicalLine >= startLine) 62 { 63 if(this.physicalLine != startLine) 64 this.physicalLine += numLines; 65 this.callChanged = true; 66 } 67 } 69 void preContentRemoved(int startLine, int numLines) 71 { 72 if(this.physicalLine >= startLine) 73 { 74 if(this.physicalLine == startLine) 75 this.callChanged = true; 76 else 77 { 78 int end = Math.min(startLine + numLines, 79 this.physicalLine); 80 for(int i = startLine + 1; i <= end; i++) 81 { 82 if(displayManager.isLineVisible(i - 1)) 84 { 85 this.scrollLine -= 86 displayManager 87 .screenLineMgr 88 .getScreenLineCount(i); 89 } 90 } 91 this.physicalLine -= (end - startLine); 92 this.callChanged = true; 93 } 94 } 95 } } 97 | Popular Tags |