Skip to content

Commit

Permalink
Clean up TTYInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Baltoli committed Oct 24, 2023
1 parent 4601992 commit cac9021
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ public int run(String tool, String[] args, File workingDir, Map<String, String>
requestScope.enter();
Main.seedInjector(requestScope, tool, args, workingDir, env, startTime);
TTYInfo tty = injector.getInstance(TTYInfo.class);
if (!tty.stdout) {
if (!tty.stdout()) {
system_out.init(new PrintStream(system_out.getPrintStream()));
}
if (!tty.stderr) {
if (!tty.stderr()) {
system_err.init(new PrintStream(system_err.getPrintStream()));
}

Expand Down
6 changes: 3 additions & 3 deletions kernel/src/main/java/org/kframework/unparser/KPrint.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ public void prettyPrint(Definition def, Module module, Consumer<byte[]> print, K
}

public void prettyPrint(Definition def, Module module, Consumer<byte[]> print, K result, Sort s) {
print.accept(prettyPrint(def, module, result, s, options.color(tty.stdout, files.getEnv()), options.output));
print.accept(prettyPrint(def, module, result, s, options.color(tty.stdout(), files.getEnv()), options.output));
}

public byte[] prettyPrint(Definition def, Module module, K result) {
return prettyPrint(def, module, result, Sorts.GeneratedTopCell(), options.color(tty.stdout, files.getEnv()), options.output);
return prettyPrint(def, module, result, Sorts.GeneratedTopCell(), options.color(tty.stdout(), files.getEnv()), options.output);
}

public byte[] prettyPrint(Definition def, Module module, K orig, Sort s, ColorSetting colorize, OutputModes outputMode) {
Expand Down Expand Up @@ -182,7 +182,7 @@ public static byte[] serialize(K term, OutputModes outputMode) {
}

public String unparseTerm(K input, Module test) {
return unparseTerm(input, test, options.color(tty.stdout, files.getEnv()));
return unparseTerm(input, test, options.color(tty.stdout(), files.getEnv()));
}

public String unparseTerm(K input, Module test, ColorSetting colorize) {
Expand Down
13 changes: 2 additions & 11 deletions kernel/src/main/java/org/kframework/utils/file/TTYInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,7 @@
* connected to terminals. Essentially, each boolean in this class is
* true if and only if the corresponding stream is one for which
* ultimately the isatty function returns true.
* @author dwightguth
*
* @author dwightguth
*/
public class TTYInfo {

public final boolean stdin, stdout, stderr;

public TTYInfo(boolean stdin, boolean stdout, boolean stderr) {
this.stdin = stdin;
this.stdout = stdout;
this.stderr = stderr;
}
}
public record TTYInfo(boolean stdin, boolean stdout, boolean stderr) {}

0 comments on commit cac9021

Please sign in to comment.