}
public Control createBody(Composite parent, MiniBrowser.Context context) {
- Browser browser = new Browser(parent, SWT.WEBKIT);
+ Browser browser = new Browser(parent, SWT.NONE);
browser.addLocationListener(new LocationAdapter() {
@Override
public void changing(LocationEvent event) {
- if (!context.getUrl().equals(event.location))
+// if (event.top && !context.getUrl().equals(event.location))
+// context.setUrl(event.location);
+ }
+
+ @Override
+ public void changed(LocationEvent event) {
+ if (event.top && !context.getUrl().equals(event.location))
context.setUrl(event.location);
}
+
});
browser.addTitleListener(e -> context.setTitle(e.title));
context.addObserver((o, v) -> {
String url = ((Context) o).getUrl();
- if (!url.equals(browser.getUrl()))
+ if (url != null && !url.equals(browser.getUrl()))
browser.setUrl(url.toString());
});
return browser;
private String host = "localhost";
private String username;
+ // Sub process
+ private Process process;
private boolean running = false;
private OutputStream stdIn = null;
+ private Thread readOut;
+
public MiniTerminal(Composite parent, int style) {
charset = StandardCharsets.UTF_8;
userInput.setLength(userInput.length() - 1);
if (!running && buf.length() > 0)
buf.setLength(buf.length() - 1);
+ } else if (e.stateMask == 0x40000 && e.keyCode == 0x63) {// Ctrl+C
+ if (process != null)
+ process.destroy();
+ } else if (e.stateMask == 0x40000 && e.keyCode == 0xdf) {// Ctrl+\
+ if (process != null) {
+ process.destroyForcibly();
+ }
} else {
// if (!running)
buf.append(e.character);
pb.redirectErrorStream(true);
pb.directory(currentDir.toFile());
// Process process = Runtime.getRuntime().exec(input, null, currentPath.toFile());
- Process process = pb.start();
+ process = pb.start();
stdIn = process.getOutputStream();
- Thread readOut = new Thread("Read out") {
+ readOut = new Thread("MinitTerminal read out") {
@Override
public void run() {
running = true;
stdIn = null;
displayPrompt();
running = false;
+ readOut = null;
+ process = null;
}
};
readOut.start();