コード例 #1
0
 private LineSegmentList formatFileLine(FileLine line) {
   final String text = getDetabbedText(line);
   int index = text.indexOf(':');
   if (index > 0) {
     addSegment(text, 0, index + 1, FORMAT_HEADER_NAME);
     addSegment(text, index + 1, FORMAT_HEADER_VALUE);
   } else addSegment(text, line.visited() ? FORMAT_VISITED : FORMAT_TEXT);
   return segmentList;
 }
コード例 #2
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);
   }
 }