diff options
Diffstat (limited to 'base')
| -rw-r--r-- | base/src/main/java/bjc/utils/ioutils/ReportWriter.java | 84 | ||||
| -rw-r--r-- | base/src/main/java/bjc/utils/parserutils/TokenUtils.java | 4 |
2 files changed, 68 insertions, 20 deletions
diff --git a/base/src/main/java/bjc/utils/ioutils/ReportWriter.java b/base/src/main/java/bjc/utils/ioutils/ReportWriter.java index 01f4a34..a9a2eae 100644 --- a/base/src/main/java/bjc/utils/ioutils/ReportWriter.java +++ b/base/src/main/java/bjc/utils/ioutils/ReportWriter.java @@ -19,7 +19,8 @@ public class ReportWriter extends Writer { private Writer contained; // # of character positions indentStr occupies - private int indentLevel; + private int indentLevel; + private int indentPos = 0; private DefaultList<IndentVal> iVals; private IndentVal defIVal; @@ -29,6 +30,10 @@ public class ReportWriter extends Writer { private int linesWritten = 0; private int linePos = 0; + private int pageLine = 0; + private int pageNum = 0; + private int linesPerPage = 20; + private boolean printTabsAsSpaces; private boolean lastCharWasNL; @@ -40,6 +45,22 @@ public class ReportWriter extends Writer { return indentLevel; } + public int getPageLine() { + return pageLine; + } + + public int getPageNum() { + return pageNum; + } + + public int getLinesPerPage() { + return linesPerPage; + } + + public int getIndentPos() { + return indentPos; + } + public String getString() { return defIVal.indentStr; } @@ -83,6 +104,14 @@ public class ReportWriter extends Writer { refreshIndents(-1); } + public void setLinesPerPage(int lines) { + linesPerPage = lines; + + while (pageLine > linesPerPage) { + writePage(); + } + } + public void setLevel(int level) { indentLevel = level; } @@ -158,6 +187,7 @@ public class ReportWriter extends Writer { rw.defIVal = defIVal; rw.indentLevel = indentLevel; + rw.indentPos = indentPos; rw.tabEqv = tabEqv; @@ -166,6 +196,10 @@ public class ReportWriter extends Writer { rw.printTabsAsSpaces = printTabsAsSpaces; + rw.pageLine = pageLine; + rw.pageNum = pageNum; + rw.linesPerPage = linesPerPage; + // @NOTE 9/5/18 // // Not sure if the lastChar* properties are things we should @@ -218,6 +252,36 @@ public class ReportWriter extends Writer { sb.delete(0, sb.length()); } + // @NOTE 9/17/18 + // + // Need to make some decision about how to handle doing a new page, and + // whether we want to simulate it with simply newlines until we hit the + // next page, or just printing the actual form-feed and hoping whatever + // reading software handles it properly + private void writePage() { + pageNum += 1; + pageLine -= linesPerPage; + } + + private void writeNL(char c) { + // Count lines written + if(c == '\r' || (c == '\n' && lastChar != '\r') || c == '\f') { + linesWritten += 1; + pageLine += 1; + + if (pageLine > linesPerPage || c == '\f') { + writePage(); + } + } + + lastCharWasNL = true; + + contained.write(c); + + linePos = 0; + indentPos = 0; + } + @Override public void write(char[] cbuf, int off, int len) throws IOException { // Skip empty writes @@ -236,21 +300,8 @@ public class ReportWriter extends Writer { char c = cbuf[idx]; if(c == '\n' || c == '\r') { - // Count lines written - if(c == '\r') linesWritten++; - if(c == '\n' && lastChar != '\r') linesWritten++; - - lastCharWasNL = true; - - contained.write(c); - - linePos = 0; + writeNL(c); } else { - // @CopyPaste from above. - // - // No real point in pulling it out to a method - // yet, but if :IndentStr happens, it might - // warrant it. if(lastCharWasNL) { lastCharWasNL = false; @@ -280,7 +331,8 @@ public class ReportWriter extends Writer { if (printTabsAsSpaces) contained.write(ival.indentStrSpacedTabs); else contained.write(ival.indentStr); - linePos += ival.indentStrPos; + linePos += ival.indentStrPos; + indentPos += ival.indentStrPos; } } diff --git a/base/src/main/java/bjc/utils/parserutils/TokenUtils.java b/base/src/main/java/bjc/utils/parserutils/TokenUtils.java index c1a68a8..bcce97e 100644 --- a/base/src/main/java/bjc/utils/parserutils/TokenUtils.java +++ b/base/src/main/java/bjc/utils/parserutils/TokenUtils.java @@ -69,11 +69,7 @@ public class TokenUtils { * Splits a string around instances of java-style double-quoted strings. * * @param inp -<<<<<<< Updated upstream * The string to split. -======= - * The string to split. ->>>>>>> Stashed changes * * @return * An list containing alternating bits of the string and the embedded double-quoted |
