Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
79 additions
and
123 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/com/uddernetworks/mspaint/cmd/Commandline.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.uddernetworks.mspaint.cmd; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.function.Consumer; | ||
|
||
public class Commandline { | ||
|
||
public static void runCommand(String command, boolean async, File directory, Consumer<String> result) { | ||
Runnable commandRunnable = () -> { | ||
try { | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
Runtime runtime = Runtime.getRuntime(); | ||
Process process = runtime.exec(command, null, directory); | ||
|
||
try (BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()))) { | ||
String line; | ||
while ((line = input.readLine()) != null) { | ||
stringBuilder.append(line); | ||
} | ||
} | ||
|
||
result.accept(stringBuilder.toString()); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
result.accept(""); | ||
} | ||
}; | ||
|
||
if (async) { | ||
CompletableFuture.runAsync(commandRunnable); | ||
} else { | ||
commandRunnable.run(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
...java/com/uddernetworks/mspaint/code/languages/brainfuck/BrainfuckLanguageHighlighter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
src/main/java/com/uddernetworks/mspaint/code/languages/java/JavaLanguageHighlighter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
src/main/java/com/uddernetworks/mspaint/code/languages/python/PythonLanguageHighlighter.java
This file was deleted.
Oops, something went wrong.