Logo Search packages:      
Sourcecode: jmk version File versions  Download package

void edu::neu::ccs::jmk::awt::MakeWindow::appendLongLine ( String  line  )  [inline, package]

This routine breaks long lines as they are added to the panel. This routine should only be called by a MakeWriter.

Parameters:
line the line to be broken

Definition at line 96 of file MakeWindow.java.

References appendLine().

                                   {
    int columns = getColumns() - 5;
    String prefix = "";       // String to add at start of line
    int cc = 0;               // Current column
    int ls = 0;               // Index of the last space
    int s = 0;                // Start index
    int n = line.length();    // End index
    for (int i = 0; i < n; i++) {
      if (line.charAt(i) == '\n') {
      cc = 0;
      ls = i + 1;       // Advance ls to this line
      }
      else if (Character.isSpaceChar(line.charAt(i))) {
      ls = i;
      cc++;
      }
      else if (cc >= columns && Character.isSpaceChar(line.charAt(ls))) {
      appendLine(prefix + line.substring(s, ls) + " \\");
      cc = 0;                 // Break a line
      i = ls;                 // Reset line index here!
      ls = i + 1;       // Advance ls to this line
      s = ls;                 // New start
      prefix = "  ";          // Set continuation prefix
      }
      else
      cc++;
    }
    if (s < n) {        // Insert the remainder
      appendLine(prefix + line.substring(s, n));
    }
  }


Generated by  Doxygen 1.6.0   Back to index