+++ /dev/null
-package com.sun.vlsi.chips.marina.test;
-
-public class Indenter {
- private static char NL = '\n';
- private int indent = 0;
- private boolean beginLine = true;
-
- private void spaces(int n) {
- StringBuffer sb = new StringBuffer();
- for (int i=0; i<n; i++) sb.append(" ");
- System.out.print(sb.toString());
- }
- private void indentIfNeeded() {
- if (beginLine) spaces(indent);
- beginLine = false;
- }
- private void printLines(String msg) {
- while (true) {
- int nl = msg.indexOf(NL);
- if (nl==-1) {
- indentIfNeeded();
- System.out.print(msg);
- return;
- } else {
- // found a new line.
- String line = msg.substring(0, nl);
- indentIfNeeded();
- System.out.println(line);
- beginLine = true;
- if (nl==msg.length()-1) {
- // nothing left after the newline
- return;
- }
- msg = msg.substring(nl+1);
- }
- }
- }
- public void prln(String msg) {printLines(msg+NL);}
- public void pr(String msg) {printLines(msg);}
- public void adjustIndent(int n) {
- indent += n;
- }
-
-
-}