コード例 #1
0
 public void follow(File sourceFile, Line sourceLine) {
   Line line = findLineForOccurrence(sourceFile, sourceLine);
   if (line == null) return;
   for (EditorIterator it = new EditorIterator(); it.hasNext(); ) {
     Editor ed = it.next();
     if (ed.getBuffer() == this) {
       ed.moveDotTo(line, 0);
       ed.updateDisplay();
     }
   }
 }
コード例 #2
0
 // Move dot to line (in all editors) and call findOccurrenceAtDot().
 private void findOccurrence(Editor editor, Line line) {
   if (line instanceof OccurrenceLine) {
     for (EditorIterator it = new EditorIterator(); it.hasNext(); ) {
       Editor ed = it.next();
       if (ed.getBuffer() == this) {
         ed.moveDotTo(line, 0);
         ed.updateDisplay();
       }
     }
     findOccurrenceAtDot(editor, false);
   }
 }
コード例 #3
0
 public void findOccurrenceAtDot(Editor editor, boolean killList) {
   Position pos = editor.getDotCopy();
   if (pos == null) return;
   Line sourceLine = null;
   int sourceLineNumber = 0;
   Buffer buf = null;
   String canonicalPath = null;
   setLastDotPos(pos);
   final Line line = pos.getLine();
   if ((line instanceof OccurrenceLine)) {
     sourceLine = ((OccurrenceLine) line).getSourceLine();
     Line ln = line;
     if (!ln.getText().startsWith("File: "))
       sourceLineNumber = Utilities.parseInt(ln.getText()) - 1;
     while (ln != null) {
       if (ln.getText().startsWith("File: ")) {
         canonicalPath = ln.getText().substring(6);
         break;
       }
       ln = ln.previous();
     }
   } else if (line instanceof FileLine) canonicalPath = ((FileLine) line).getCanonicalPath();
   if (buf == null && canonicalPath != null)
     buf = Editor.getBuffer(File.getInstance(canonicalPath));
   if (buf != null) {
     if (!buf.isLoaded()) {
       if (!buf.initialized()) buf.initialize();
       buf.load();
       if (!buf.isLoaded()) {
         editor.status("Unable to load buffer");
         return;
       }
     }
     if (line instanceof FileLine) {
       // Mark file visited.
       ((FileLine) line).markVisited();
       // Advance dot to next line.
       Position dot = editor.getDot();
       if (dot.equals(pos) && dot.getNextLine() != null) {
         dot.moveTo(dot.getNextLine(), 0);
         editor.moveCaretToDotCol();
       }
     }
     Line target;
     if (sourceLine != null) {
       if (buf.contains(sourceLine)) target = sourceLine;
       else target = buf.getLine(sourceLine.lineNumber());
     } else target = buf.getLine(sourceLineNumber);
     gotoSource(editor, buf, target, killList);
   }
 }