1 33 34 package edu.rice.cs.drjava.model.definitions.indent; 35 36 import javax.swing.text.*; 37 import edu.rice.cs.util.UnexpectedException; 38 import edu.rice.cs.drjava.model.AbstractDJDocument; 39 40 45 class ActionStartPrevLinePlus extends IndentRuleAction { 46 private String _suffix; 47 48 52 public ActionStartPrevLinePlus(String suffix) { 53 _suffix = suffix; 54 } 55 56 63 public boolean indentLine(AbstractDJDocument doc, int reason) { 64 boolean supResult = super.indentLine(doc, reason); 65 try { 66 int here = doc.getCurrentLocation(); 68 int startLine = doc.getLineStartPos(here); 69 70 if (startLine > AbstractDJDocument.DOCSTART) { 71 int startPrevLine = doc.getLineStartPos(startLine - 1); 73 int firstChar = doc.getLineFirstCharPos(startPrevLine); 74 String prefix = doc.getText(startPrevLine, firstChar - startPrevLine); 75 doc.setTab(prefix + _suffix, here); 76 } 77 else { 78 doc.setTab(_suffix, here); 80 } 81 return supResult; 82 } 83 catch (BadLocationException e) { 84 throw new UnexpectedException(e); 86 } 87 } 88 } 89 | Popular Tags |