mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-27 10:28:14 -05:00
Made ECR diffs more preview-friendly in future commits
This commit is contained in:
Binary file not shown.
@ -45,6 +45,9 @@ import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.awt.event.ActionEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.Element;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.gui.TeaVMBinaries.MissingJARsException;
|
||||
import net.lax1dude.eaglercraft.v1_8.buildtools.task.init.FFMPEG;
|
||||
@ -1155,7 +1158,7 @@ public class CompileLatestClientFrame {
|
||||
txtpnLogOutput.setAutoscrolls(false);
|
||||
txtpnLogOutput.setMargin(new Insets(10, 10, 10, 10));
|
||||
txtpnLogOutput.setContentType("text/html");
|
||||
txtpnLogOutput.setText("<html><head><title>shit</title></head><body></body></html>");
|
||||
txtpnLogOutput.setText("<html><head><title>shit</title><style type=\"text/css\">pre{font-family:\"Consolas\",\"Andale Mono\",monospace;}</style></head><body id=\"logContainer\" style=\"margin:0px;\"><pre></pre></body></html>");
|
||||
txtpnLogOutput.setEditable(false);
|
||||
scrollPane.setViewportView(txtpnLogOutput);
|
||||
|
||||
@ -1192,18 +1195,30 @@ public class CompileLatestClientFrame {
|
||||
panel_29.setLayout(null);
|
||||
}
|
||||
|
||||
private final StringBuilder logAccum = new StringBuilder();
|
||||
private StringBuilder logAccumPrev = new StringBuilder();
|
||||
private StringBuilder logAccum = new StringBuilder();
|
||||
private Element logAccumBody = null;
|
||||
private volatile boolean logDirty = false;
|
||||
private volatile boolean isError = false;
|
||||
|
||||
public void logInfo(String line) {
|
||||
line = htmlentities2(line);
|
||||
synchronized(logAccum) {
|
||||
if(isError) {
|
||||
isError = false;
|
||||
logAccum.append("</pre><pre>");
|
||||
if(logAccum.length() > 0) {
|
||||
if(isError) {
|
||||
isError = false;
|
||||
logAccum.append("</pre><pre>");
|
||||
}
|
||||
logAccum.append(line);
|
||||
}else {
|
||||
if(isError) {
|
||||
isError = false;
|
||||
logAccum.append("<pre>");
|
||||
logAccum.append(line);
|
||||
}else {
|
||||
logAccumPrev.append(line);
|
||||
}
|
||||
}
|
||||
logAccum.append(line);
|
||||
logDirty = true;
|
||||
}
|
||||
}
|
||||
@ -1211,11 +1226,21 @@ public class CompileLatestClientFrame {
|
||||
public void logError(String line) {
|
||||
line = htmlentities2(line);
|
||||
synchronized(logAccum) {
|
||||
if(!isError) {
|
||||
isError = true;
|
||||
logAccum.append("</pre><pre style=\"color:#BB0000;\">");
|
||||
if(logAccum.length() > 0) {
|
||||
if(!isError) {
|
||||
isError = true;
|
||||
logAccum.append("</pre><pre style=\"color:#BB0000;\">");
|
||||
}
|
||||
logAccum.append(line);
|
||||
}else {
|
||||
if(!isError) {
|
||||
isError = true;
|
||||
logAccum.append("<pre style=\"color:#BB0000;\">");
|
||||
logAccum.append(line);
|
||||
}else {
|
||||
logAccumPrev.append(line);
|
||||
}
|
||||
}
|
||||
logAccum.append(line);
|
||||
logDirty = true;
|
||||
}
|
||||
}
|
||||
@ -1226,12 +1251,31 @@ public class CompileLatestClientFrame {
|
||||
public void run() {
|
||||
while(true) {
|
||||
try {
|
||||
Thread.sleep(150l);
|
||||
Thread.sleep(100l);
|
||||
synchronized(logAccum) {
|
||||
if(logDirty) {
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
public void run() {
|
||||
txtpnLogOutput.setText("<html><head><title>shit</title><style type=\"text/css\">pre{font-family:\"Consolas\",\"Andale Mono\",monospace;}</style></head><body><p style=\"margin:0px;\"><pre>" + logAccum + "</pre></p></body></html>");
|
||||
HTMLDocument ee = ((HTMLDocument)txtpnLogOutput.getDocument());
|
||||
if(logAccumBody == null) {
|
||||
logAccumBody = ee.getElement("logContainer");
|
||||
}
|
||||
if(logAccumPrev.length() > 0) {
|
||||
try {
|
||||
ee.insertString(logAccumBody.getElement(logAccumBody.getElementCount() - 1).getEndOffset() - 1, logAccumPrev.toString(), null);
|
||||
} catch (BadLocationException e) {
|
||||
}
|
||||
logAccumPrev = new StringBuilder();
|
||||
}
|
||||
if(logAccum.length() > 0) {
|
||||
logAccum.append("</pre>");
|
||||
try {
|
||||
ee.insertBeforeEnd(logAccumBody, logAccum.toString());
|
||||
} catch (BadLocationException e) {
|
||||
} catch (IOException e) {
|
||||
}
|
||||
logAccum = new StringBuilder();
|
||||
}
|
||||
}
|
||||
});
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
|
@ -41,7 +41,9 @@ public class EaglerContextRedacted {
|
||||
output.println("# Version: 1.0");
|
||||
output.println("# Author: lax1dude");
|
||||
output.println();
|
||||
|
||||
|
||||
int lastSourcePos = 0;
|
||||
int lastTargetPos = 0;
|
||||
List<AbstractDelta<String>> deltas = patch.getDeltas();
|
||||
delta_itr: for(int i = 0, l = deltas.size(); i < l; ++i) {
|
||||
AbstractDelta<String> delta = deltas.get(i);
|
||||
@ -72,13 +74,17 @@ public class EaglerContextRedacted {
|
||||
int sourcePos = source.getPosition();
|
||||
int sourceLen = source.getLines().size();
|
||||
|
||||
int sourcePosRelative = sourcePos - lastSourcePos;
|
||||
|
||||
Chunk<String> target = delta.getTarget();
|
||||
int targetPos = target.getPosition();
|
||||
List<String> linesToWrite = target.getLines();
|
||||
int targetLen = linesToWrite.size();
|
||||
|
||||
output.println(blockType + " " + targetPos + (targetLen > 0 ? " : " + (targetPos + targetLen) : "") + " @ "
|
||||
+ sourcePos + (sourceLen > 0 ? " : " + (sourcePos + sourceLen) : ""));
|
||||
int targetPosRelative = targetPos - lastTargetPos;
|
||||
|
||||
output.println(blockType + " " + targetPosRelative + (targetLen > 0 ? " : " + (targetPosRelative + targetLen) : "") + " @ "
|
||||
+ sourcePosRelative + (sourceLen > 0 ? " : " + (sourcePosRelative + sourceLen) : ""));
|
||||
|
||||
output.println();
|
||||
|
||||
@ -89,6 +95,9 @@ public class EaglerContextRedacted {
|
||||
|
||||
output.println();
|
||||
}
|
||||
|
||||
lastSourcePos = sourcePos;
|
||||
lastTargetPos = targetPos;
|
||||
}
|
||||
|
||||
output.println("> EOF");
|
||||
@ -104,6 +113,8 @@ public class EaglerContextRedacted {
|
||||
int targetLen = 0;
|
||||
List<String> targetLines = null;
|
||||
|
||||
int lastSourcePos = 0;
|
||||
int lastTargetPos = 0;
|
||||
String line;
|
||||
readLinesLoop: while((line = reader.readLine()) != null) {
|
||||
if(line.length() < 2) {
|
||||
@ -145,7 +156,9 @@ public class EaglerContextRedacted {
|
||||
}
|
||||
|
||||
if(currentDeltaType != null) {
|
||||
newPatch.addDelta(makeDelta(currentDeltaType, sourceStart, sourceLen, targetStart, targetLen, context, targetLines));
|
||||
lastSourcePos += sourceStart;
|
||||
lastTargetPos += targetStart;
|
||||
newPatch.addDelta(makeDelta(currentDeltaType, lastSourcePos, sourceLen, lastTargetPos, targetLen, context, targetLines));
|
||||
}
|
||||
|
||||
switch(split[0]) {
|
||||
@ -214,7 +227,9 @@ public class EaglerContextRedacted {
|
||||
}
|
||||
|
||||
if(currentDeltaType != null) {
|
||||
newPatch.addDelta(makeDelta(currentDeltaType, sourceStart, sourceLen, targetStart, targetLen, context, targetLines));
|
||||
lastSourcePos += sourceStart;
|
||||
lastTargetPos += targetStart;
|
||||
newPatch.addDelta(makeDelta(currentDeltaType, lastSourcePos, sourceLen, lastTargetPos, targetLen, context, targetLines));
|
||||
}
|
||||
|
||||
return newPatch;
|
||||
|
@ -209,6 +209,7 @@ public class DecompileMinecraft {
|
||||
ApplyPatchesToZip.applyPatches(formatOut, null, new File(EaglerBuildTools.repositoryRoot, "patches/minecraft"), patchOut, true, true);
|
||||
}catch(Throwable t) {
|
||||
System.err.println("ERROR: Could not apply 'patches' directory to: " + patchOut.getName());
|
||||
t.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2022 LAX1DUDE. All Rights Reserved.
|
||||
@ -27,6 +29,10 @@ public class JARSubprocess {
|
||||
classPathSeperator = System.getProperty("os.name").toLowerCase().contains("windows") ? ';' : ':';
|
||||
}
|
||||
|
||||
private static final List<Process> activeProcesses = new ArrayList();
|
||||
|
||||
private static boolean shutdownThreadStarted = false;
|
||||
|
||||
public static int runJava(File directory, String[] javaExeArguments, String logPrefix) throws IOException {
|
||||
if(logPrefix.length() > 0 && !logPrefix.endsWith(" ")) {
|
||||
logPrefix = logPrefix + " ";
|
||||
@ -60,6 +66,28 @@ public class JARSubprocess {
|
||||
exec.directory(directory);
|
||||
|
||||
Process ps = exec.start();
|
||||
|
||||
synchronized(activeProcesses) {
|
||||
if(!shutdownThreadStarted) {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
|
||||
public void run() {
|
||||
synchronized(activeProcesses) {
|
||||
for(Process proc : activeProcesses) {
|
||||
try {
|
||||
if(proc.isAlive()) {
|
||||
proc.destroy();
|
||||
}
|
||||
}catch(Throwable t) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "Subprocess Exit Thread"));
|
||||
shutdownThreadStarted = true;
|
||||
}
|
||||
activeProcesses.add(ps);
|
||||
}
|
||||
|
||||
InputStream is = ps.getInputStream();
|
||||
InputStream ise = ps.getErrorStream();
|
||||
BufferedReader isb = new BufferedReader(new InputStreamReader(is));
|
||||
|
Reference in New Issue
Block a user