Skip to content

Commit 36d386d

Browse files
authored
Merge pull request #82 from hboutemy/javadoc
improved javadoc
2 parents bb3d538 + e3748a2 commit 36d386d

File tree

2 files changed

+169
-4
lines changed

2 files changed

+169
-4
lines changed

jansi/src/main/java/org/fusesource/jansi/AnsiOutputStream.java

+168-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424

2525
/**
2626
* A ANSI output stream extracts ANSI escape codes written to
27-
* an output stream.
27+
* an output stream and calls corresponding <code>process*</code> methods.
2828
*
2929
* For more information about ANSI escape codes, see:
3030
* http://en.wikipedia.org/wiki/ANSI_escape_code
3131
*
3232
* This class just filters out the escape codes so that they are not
33-
* sent out to the underlying OutputStream. Subclasses should
34-
* actually perform the ANSI escape behaviors.
33+
* sent out to the underlying OutputStream: <code>process*</code> methods
34+
* are empty. Subclasses should actually perform the ANSI escape behaviors
35+
* by implementing active code in <code>process*</code> methods.
3536
*
3637
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
3738
* @author Joris Kuipers
@@ -407,29 +408,53 @@ private boolean processOperatingSystemCommand(ArrayList<Object> options) throws
407408
return false;
408409
}
409410

411+
/**
412+
* Process <code>CSI u</code> ANSI code, corresponding to <code>RCP – Restore Cursor Position</code>
413+
* @throws IOException
414+
*/
410415
protected void processRestoreCursorPosition() throws IOException {
411416
}
412417

418+
/**
419+
* Process <code>CSI s</code> ANSI code, corresponding to <code>SCP – Save Cursor Position</code>
420+
* @throws IOException
421+
*/
413422
protected void processSaveCursorPosition() throws IOException {
414423
}
415424

425+
/**
426+
* Process <code>CSI n T</code> ANSI code, corresponding to <code>SD – Scroll Down</code>
427+
* @throws IOException
428+
*/
416429
protected void processScrollDown(int optionInt) throws IOException {
417430
}
418431

432+
/**
433+
* Process <code>CSI n U</code> ANSI code, corresponding to <code>SU – Scroll Up</code>
434+
* @throws IOException
435+
*/
419436
protected void processScrollUp(int optionInt) throws IOException {
420437
}
421438

422439
protected static final int ERASE_SCREEN_TO_END = 0;
423440
protected static final int ERASE_SCREEN_TO_BEGINING = 1;
424441
protected static final int ERASE_SCREEN = 2;
425442

443+
/**
444+
* Process <code>CSI n J</code> ANSI code, corresponding to <code>ED – Erase in Display</code>
445+
* @throws IOException
446+
*/
426447
protected void processEraseScreen(int eraseOption) throws IOException {
427448
}
428449

429450
protected static final int ERASE_LINE_TO_END = 0;
430451
protected static final int ERASE_LINE_TO_BEGINING = 1;
431452
protected static final int ERASE_LINE = 2;
432453

454+
/**
455+
* Process <code>CSI n K</code> ANSI code, corresponding to <code>ED – Erase in Line</code>
456+
* @throws IOException
457+
*/
433458
protected void processEraseLine(int eraseOption) throws IOException {
434459
}
435460

@@ -450,6 +475,20 @@ protected void processEraseLine(int eraseOption) throws IOException {
450475
protected static final int ATTRIBUTE_NEGATIVE_OFF = 27; // Image; Positive
451476
protected static final int ATTRIBUTE_CONCEAL_OFF = 28; // Reveal conceal off
452477

478+
/**
479+
* process <code>SGR</code> other than <code>0</code> (reset), <code>30-39</code> (foreground),
480+
* <code>40-49</code> (background), <code>90-97</code> (foreground high intensity) or
481+
* <code>100-107</code> (background high intensity)
482+
* @param attribute
483+
* @throws IOException
484+
* @see #processAttributeRest()
485+
* @see #processSetForegroundColor(int)
486+
* @see #processSetForegroundColor(int, boolean)
487+
* @see #processSetForegroundColorExt(int)
488+
* @see #processSetForegroundColorExt(int, int, int)
489+
* @see #processDefaultTextColor()
490+
* @see #processDefaultBackgroundColor()
491+
*/
453492
protected void processSetAttribute(int attribute) throws IOException {
454493
}
455494

@@ -462,87 +501,213 @@ protected void processSetAttribute(int attribute) throws IOException {
462501
protected static final int CYAN = 6;
463502
protected static final int WHITE = 7;
464503

504+
/**
505+
* process <code>SGR 30-37</code> corresponding to <code>Set text color (foreground)</code>.
506+
* @param color the text color
507+
* @throws IOException
508+
*/
465509
protected void processSetForegroundColor(int color) throws IOException {
466510
processSetForegroundColor(color, false);
467511
}
468512

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

523+
/**
524+
* process <code>SGR 38</code> corresponding to <code>extended set text color (foreground)</code>
525+
* with a palette of 255 colors.
526+
* @param paletteIndex the text color in the palette
527+
* @throws IOException
528+
*/
472529
protected void processSetForegroundColorExt(int paletteIndex) throws IOException {
473530
}
474531

532+
/**
533+
* process <code>SGR 38</code> corresponding to <code>extended set text color (foreground)</code>
534+
* with a 24 bits RGB definition of the color.
535+
* @param r red
536+
* @param g green
537+
* @param b blue
538+
* @throws IOException
539+
*/
475540
protected void processSetForegroundColorExt(int r, int g, int b) throws IOException {
476541
}
477542

543+
/**
544+
* process <code>SGR 40-47</code> corresponding to <code>Set background color</code>.
545+
* @param color the background color
546+
* @throws IOException
547+
*/
478548
protected void processSetBackgroundColor(int color) throws IOException {
479549
processSetBackgroundColor(color, false);
480550
}
481551

552+
/**
553+
* process <code>SGR 40-47</code> or <code>SGR 100-107</code> corresponding to
554+
* <code>Set background color</code> either in normal mode or high intensity.
555+
* @param color the background color
556+
* @param bright is high intensity?
557+
* @throws IOException
558+
*/
482559
protected void processSetBackgroundColor(int color, boolean bright) throws IOException {
483560
}
484561

562+
/**
563+
* process <code>SGR 48</code> corresponding to <code>extended set background color</code>
564+
* with a palette of 255 colors.
565+
* @param paletteIndex the background color in the palette
566+
* @throws IOException
567+
*/
485568
protected void processSetBackgroundColorExt(int paletteIndex) throws IOException {
486569
}
487570

571+
/**
572+
* process <code>SGR 48</code> corresponding to <code>extended set background color</code>
573+
* with a 24 bits RGB definition of the color.
574+
* @param r red
575+
* @param g green
576+
* @param b blue
577+
* @throws IOException
578+
*/
488579
protected void processSetBackgroundColorExt(int r, int g, int b) throws IOException {
489580
}
490581

582+
/**
583+
* process <code>SGR 39</code> corresponding to <code>Default text color (foreground)</code>
584+
* @throws IOException
585+
*/
491586
protected void processDefaultTextColor() throws IOException {
492587
}
493588

589+
/**
590+
* process <code>SGR 49</code> corresponding to <code>Default background color</code>
591+
* @throws IOException
592+
*/
494593
protected void processDefaultBackgroundColor() throws IOException {
495594
}
496595

596+
/**
597+
* process <code>SGR 0</code> corresponding to <code>Reset / Normal</code>
598+
* @throws IOException
599+
*/
497600
protected void processAttributeRest() throws IOException {
498601
}
499602

603+
/**
604+
* process <code>CSI n ; m H</code> corresponding to <code>CUP – Cursor Position</code> or
605+
* <code>CSI n ; m f</code> corresponding to <code>HVP – Horizontal and Vertical Position</code>
606+
* @param row
607+
* @param col
608+
* @throws IOException
609+
*/
500610
protected void processCursorTo(int row, int col) throws IOException {
501611
}
502612

613+
/**
614+
* process <code>CSI n G</code> corresponding to <code>CHA – Cursor Horizontal Absolute</code>
615+
* @param x the column
616+
* @throws IOException
617+
*/
503618
protected void processCursorToColumn(int x) throws IOException {
504619
}
505620

621+
/**
622+
* process <code>CSI n F</code> corresponding to <code>CPL – Cursor Previous Line</code>
623+
* @param count line count
624+
* @throws IOException
625+
*/
506626
protected void processCursorUpLine(int count) throws IOException {
507627
}
508628

629+
/**
630+
* process <code>CSI n E</code> corresponding to <code>CNL – Cursor Next Line</code>
631+
* @param count line count
632+
* @throws IOException
633+
*/
509634
protected void processCursorDownLine(int count) throws IOException {
510635
// Poor mans impl..
511636
for (int i = 0; i < count; i++) {
512637
out.write('\n');
513638
}
514639
}
515640

641+
/**
642+
* process <code>CSI n D</code> corresponding to <code>CUB – Cursor Back</code>
643+
* @param count
644+
* @throws IOException
645+
*/
516646
protected void processCursorLeft(int count) throws IOException {
517647
}
518648

649+
/**
650+
* process <code>CSI n C</code> corresponding to <code>CUF – Cursor Forward</code>
651+
* @param count
652+
* @throws IOException
653+
*/
519654
protected void processCursorRight(int count) throws IOException {
520655
// Poor mans impl..
521656
for (int i = 0; i < count; i++) {
522657
out.write(' ');
523658
}
524659
}
525660

661+
/**
662+
* process <code>CSI n B</code> corresponding to <code>CUD – Cursor Down</code>
663+
* @param count
664+
* @throws IOException
665+
*/
526666
protected void processCursorDown(int count) throws IOException {
527667
}
528668

669+
/**
670+
* process <code>CSI n A</code> corresponding to <code>CUU – Cursor Up</code>
671+
* @param count
672+
* @throws IOException
673+
*/
529674
protected void processCursorUp(int count) throws IOException {
530675
}
531676

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

680+
/**
681+
* process <code>OSC 0;text BEL</code> corresponding to <code>Change Window and Icon label</code>
682+
* @param label
683+
* @throws IOException
684+
*/
535685
protected void processChangeIconNameAndWindowTitle(String label) {
536686
processChangeIconName(label);
537687
processChangeWindowTitle(label);
538688
}
539689

690+
/**
691+
* process <code>OSC 1;text BEL</code> corresponding to <code>Change Icon label</code>
692+
* @param label
693+
* @throws IOException
694+
*/
540695
protected void processChangeIconName(String label) {
541696
}
542697

698+
/**
699+
* process <code>OSC 2;text BEL</code> corresponding to <code>Change Window title</code>
700+
* @param label
701+
* @throws IOException
702+
*/
543703
protected void processChangeWindowTitle(String label) {
544704
}
545705

706+
/**
707+
* Process unknown <code>OSC</code> command.
708+
* @param command
709+
* @param param
710+
*/
546711
protected void processUnknownOperatingSystemCommand(int command, String param) {
547712
}
548713

jansi/src/main/java/org/fusesource/jansi/WindowsAnsiOutputStream.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import org.fusesource.jansi.internal.Kernel32.COORD;
4141

4242
/**
43-
* A Windows ANSI escape processor, uses JNA to access native platform
43+
* A Windows ANSI escape processor, that uses JNA to access native platform
4444
* API's to change the console attributes.
4545
*
4646
* @since 1.0

0 commit comments

Comments
 (0)