Skip to content

Commit

Permalink
Add a bit of doc for the various supported keys, #293
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet authored and ppalaga committed Jan 9, 2021
1 parent 7a102fa commit 9b4172f
Showing 1 changed file with 35 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,35 @@
*/
public class TerminalOutput implements ClientOutput {

public static final int CTRL_B = 'B' & 0x1f;
public static final int CTRL_L = 'L' & 0x1f;
public static final int CTRL_M = 'M' & 0x1f;
/**
* The '+' key is used to increase the number of lines displayed per project.
*/
public static final int KEY_PLUS = '+';
/**
* The '-' key is used to decrease the number of lines displayed per project.
*/
public static final int KEY_MINUS = '-';
/**
* The Ctrl+B key switches between the no-buffering / buffering modes.
* In no-buffering mode, the output of concurrent builds will be interleaved and
* each line will be prepended with the module name in order to distinguish them.
* In buffering mode, the list of modules being built is displayed and update
* continuously. In this mode, pressing '+' one or more times will open a rolling
* window for each module with the related output.
*/
public static final int KEY_CTRL_B = 'B' & 0x1f;
/**
* The Ctrl+L key forces a redisplay of the output.
*/
public static final int KEY_CTRL_L = 'L' & 0x1f;
/**
* The Ctrl+M (or enter) switches between full-buffering and module-buffering.
* In the full-buffering mode, all the build output is buffered and displayed
* at the end of the build, while the module-buffering mode will output in
* the terminal the log for a given module once it's finished.
*/
public static final int KEY_CTRL_M = 'M' & 0x1f;

private static final AttributedStyle GREEN_FOREGROUND = new AttributedStyle().foreground(AttributedStyle.GREEN);
private static final AttributedStyle CYAN_FOREGROUND = new AttributedStyle().foreground(AttributedStyle.CYAN);

Expand Down Expand Up @@ -340,24 +366,24 @@ private boolean doAccept(Message entry) {
case Message.KEYBOARD_INPUT: {
char keyStroke = ((StringMessage) entry).getMessage().charAt(0);
switch (keyStroke) {
case '+':
case KEY_PLUS:
linesPerProject = Math.min(10, linesPerProject + 1);
break;
case '-':
case KEY_MINUS:
linesPerProject = Math.max(0, linesPerProject - 1);
break;
case CTRL_B:
case KEY_CTRL_B:
noBuffering = !noBuffering;
if (noBuffering) {
applyNoBuffering();
} else {
clearDisplay();
}
break;
case CTRL_L:
case KEY_CTRL_L:
clearDisplay();
break;
case CTRL_M:
case KEY_CTRL_M:
displayDone = !displayDone;
displayDone();
break;
Expand Down Expand Up @@ -419,7 +445,7 @@ void readInputLoop() {
if (c == -1) {
break;
}
if (c == '+' || c == '-' || c == CTRL_L || c == CTRL_M || c == CTRL_B) {
if (c == KEY_PLUS || c == KEY_MINUS || c == KEY_CTRL_L || c == KEY_CTRL_M || c == KEY_CTRL_B) {
daemonReceive.accept(Message.keyboardInput((char) c));
}
readInput.readLock().unlock();
Expand All @@ -438,7 +464,6 @@ private void clearDisplay() {
if (!noBuffering && !dumb) {
display.update(Collections.emptyList(), 0);
}

}

private void displayDone() {
Expand Down

0 comments on commit 9b4172f

Please sign in to comment.