Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved javadoc #82

Merged
merged 1 commit into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 168 additions & 3 deletions jansi/src/main/java/org/fusesource/jansi/AnsiOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@

/**
* A ANSI output stream extracts ANSI escape codes written to
* an output stream.
* an output stream and calls corresponding <code>process*</code> methods.
*
* For more information about ANSI escape codes, see:
* http://en.wikipedia.org/wiki/ANSI_escape_code
*
* This class just filters out the escape codes so that they are not
* sent out to the underlying OutputStream. Subclasses should
* actually perform the ANSI escape behaviors.
* sent out to the underlying OutputStream: <code>process*</code> methods
* are empty. Subclasses should actually perform the ANSI escape behaviors
* by implementing active code in <code>process*</code> methods.
*
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
* @author Joris Kuipers
Expand Down Expand Up @@ -405,29 +406,53 @@ private boolean processOperatingSystemCommand(ArrayList<Object> options) throws
return false;
}

/**
* Process <code>CSI u</code> ANSI code, corresponding to <code>RCP – Restore Cursor Position</code>
* @throws IOException
*/
protected void processRestoreCursorPosition() throws IOException {
}

/**
* Process <code>CSI s</code> ANSI code, corresponding to <code>SCP – Save Cursor Position</code>
* @throws IOException
*/
protected void processSaveCursorPosition() throws IOException {
}

/**
* Process <code>CSI n T</code> ANSI code, corresponding to <code>SD – Scroll Down</code>
* @throws IOException
*/
protected void processScrollDown(int optionInt) throws IOException {
}

/**
* Process <code>CSI n U</code> ANSI code, corresponding to <code>SU – Scroll Up</code>
* @throws IOException
*/
protected void processScrollUp(int optionInt) throws IOException {
}

protected static final int ERASE_SCREEN_TO_END = 0;
protected static final int ERASE_SCREEN_TO_BEGINING = 1;
protected static final int ERASE_SCREEN = 2;

/**
* Process <code>CSI n J</code> ANSI code, corresponding to <code>ED – Erase in Display</code>
* @throws IOException
*/
protected void processEraseScreen(int eraseOption) throws IOException {
}

protected static final int ERASE_LINE_TO_END = 0;
protected static final int ERASE_LINE_TO_BEGINING = 1;
protected static final int ERASE_LINE = 2;

/**
* Process <code>CSI n K</code> ANSI code, corresponding to <code>ED – Erase in Line</code>
* @throws IOException
*/
protected void processEraseLine(int eraseOption) throws IOException {
}

Expand All @@ -448,6 +473,20 @@ protected void processEraseLine(int eraseOption) throws IOException {
protected static final int ATTRIBUTE_NEGATIVE_OFF = 27; // Image; Positive
protected static final int ATTRIBUTE_CONCEAL_OFF = 28; // Reveal conceal off

/**
* process <code>SGR</code> other than <code>0</code> (reset), <code>30-39</code> (foreground),
* <code>40-49</code> (background), <code>90-97</code> (foreground high intensity) or
* <code>100-107</code> (background high intensity)
* @param attribute
* @throws IOException
* @see #processAttributeRest()
* @see #processSetForegroundColor(int)
* @see #processSetForegroundColor(int, boolean)
* @see #processSetForegroundColorExt(int)
* @see #processSetForegroundColorExt(int, int, int)
* @see #processDefaultTextColor()
* @see #processDefaultBackgroundColor()
*/
protected void processSetAttribute(int attribute) throws IOException {
}

Expand All @@ -460,87 +499,213 @@ protected void processSetAttribute(int attribute) throws IOException {
protected static final int CYAN = 6;
protected static final int WHITE = 7;

/**
* process <code>SGR 30-37</code> corresponding to <code>Set text color (foreground)</code>.
* @param color the text color
* @throws IOException
*/
protected void processSetForegroundColor(int color) throws IOException {
processSetForegroundColor(color, false);
}

/**
* process <code>SGR 30-37</code> or <code>SGR 90-97</code> corresponding to
* <code>Set text color (foreground)</code> either in normal mode or high intensity.
* @param color the text color
* @param bright is high intensity?
* @throws IOException
*/
protected void processSetForegroundColor(int color, boolean bright) throws IOException {
}

/**
* process <code>SGR 38</code> corresponding to <code>extended set text color (foreground)</code>
* with a palette of 255 colors.
* @param paletteIndex the text color in the palette
* @throws IOException
*/
protected void processSetForegroundColorExt(int paletteIndex) throws IOException {
}

/**
* process <code>SGR 38</code> corresponding to <code>extended set text color (foreground)</code>
* with a 24 bits RGB definition of the color.
* @param r red
* @param g green
* @param b blue
* @throws IOException
*/
protected void processSetForegroundColorExt(int r, int g, int b) throws IOException {
}

/**
* process <code>SGR 40-47</code> corresponding to <code>Set background color</code>.
* @param color the background color
* @throws IOException
*/
protected void processSetBackgroundColor(int color) throws IOException {
processSetBackgroundColor(color, false);
}

/**
* process <code>SGR 40-47</code> or <code>SGR 100-107</code> corresponding to
* <code>Set background color</code> either in normal mode or high intensity.
* @param color the background color
* @param bright is high intensity?
* @throws IOException
*/
protected void processSetBackgroundColor(int color, boolean bright) throws IOException {
}

/**
* process <code>SGR 48</code> corresponding to <code>extended set background color</code>
* with a palette of 255 colors.
* @param paletteIndex the background color in the palette
* @throws IOException
*/
protected void processSetBackgroundColorExt(int paletteIndex) throws IOException {
}

/**
* process <code>SGR 48</code> corresponding to <code>extended set background color</code>
* with a 24 bits RGB definition of the color.
* @param r red
* @param g green
* @param b blue
* @throws IOException
*/
protected void processSetBackgroundColorExt(int r, int g, int b) throws IOException {
}

/**
* process <code>SGR 39</code> corresponding to <code>Default text color (foreground)</code>
* @throws IOException
*/
protected void processDefaultTextColor() throws IOException {
}

/**
* process <code>SGR 49</code> corresponding to <code>Default background color</code>
* @throws IOException
*/
protected void processDefaultBackgroundColor() throws IOException {
}

/**
* process <code>SGR 0</code> corresponding to <code>Reset / Normal</code>
* @throws IOException
*/
protected void processAttributeRest() throws IOException {
}

/**
* process <code>CSI n ; m H</code> corresponding to <code>CUP – Cursor Position</code> or
* <code>CSI n ; m f</code> corresponding to <code>HVP – Horizontal and Vertical Position</code>
* @param row
* @param col
* @throws IOException
*/
protected void processCursorTo(int row, int col) throws IOException {
}

/**
* process <code>CSI n G</code> corresponding to <code>CHA – Cursor Horizontal Absolute</code>
* @param x the column
* @throws IOException
*/
protected void processCursorToColumn(int x) throws IOException {
}

/**
* process <code>CSI n F</code> corresponding to <code>CPL – Cursor Previous Line</code>
* @param count line count
* @throws IOException
*/
protected void processCursorUpLine(int count) throws IOException {
}

/**
* process <code>CSI n E</code> corresponding to <code>CNL – Cursor Next Line</code>
* @param count line count
* @throws IOException
*/
protected void processCursorDownLine(int count) throws IOException {
// Poor mans impl..
for (int i = 0; i < count; i++) {
out.write('\n');
}
}

/**
* process <code>CSI n D</code> corresponding to <code>CUB – Cursor Back</code>
* @param count
* @throws IOException
*/
protected void processCursorLeft(int count) throws IOException {
}

/**
* process <code>CSI n C</code> corresponding to <code>CUF – Cursor Forward</code>
* @param count
* @throws IOException
*/
protected void processCursorRight(int count) throws IOException {
// Poor mans impl..
for (int i = 0; i < count; i++) {
out.write(' ');
}
}

/**
* process <code>CSI n B</code> corresponding to <code>CUD – Cursor Down</code>
* @param count
* @throws IOException
*/
protected void processCursorDown(int count) throws IOException {
}

/**
* process <code>CSI n A</code> corresponding to <code>CUU – Cursor Up</code>
* @param count
* @throws IOException
*/
protected void processCursorUp(int count) throws IOException {
}

protected void processUnknownExtension(ArrayList<Object> options, int command) {
}

/**
* process <code>OSC 0;text BEL</code> corresponding to <code>Change Window and Icon label</code>
* @param label
* @throws IOException
*/
protected void processChangeIconNameAndWindowTitle(String label) {
processChangeIconName(label);
processChangeWindowTitle(label);
}

/**
* process <code>OSC 1;text BEL</code> corresponding to <code>Change Icon label</code>
* @param label
* @throws IOException
*/
protected void processChangeIconName(String label) {
}

/**
* process <code>OSC 2;text BEL</code> corresponding to <code>Change Window title</code>
* @param label
* @throws IOException
*/
protected void processChangeWindowTitle(String label) {
}

/**
* Process unknown <code>OSC</code> command.
* @param command
* @param param
*/
protected void processUnknownOperatingSystemCommand(int command, String param) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import org.fusesource.jansi.internal.Kernel32.COORD;

/**
* A Windows ANSI escape processor, uses JNA to access native platform
* A Windows ANSI escape processor, that uses JNA to access native platform
* API's to change the console attributes.
*
* @since 1.0
Expand Down