Skip to content

Commit

Permalink
Don't remove lines while selecting text
Browse files Browse the repository at this point in the history
  • Loading branch information
ME1312 committed Jan 6, 2019
1 parent d4e5eeb commit 4879751
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Expand Up @@ -70,14 +70,16 @@ public void write(int b) throws IOException {
scache.write(b);
if (b == '\n') {
try {
int lines;
String content;
while (countLines(content = log.getDocument().getText(0, log.getDocument().getLength())) > MAX_SCROLLBACK + 2) {
int lineBreak = content.indexOf('\n', 2);
if (lineBreak >= 0) {
while (log.getSelectionStart() == log.getSelectionEnd() && (lines = countLines(content = log.getDocument().getText(0, log.getDocument().getLength()))) > MAX_SCROLLBACK) {
int lineBreak = 1;
for (lines -= MAX_SCROLLBACK; lines > 0; lines--) lineBreak = content.indexOf('\n', lineBreak + 1);
if (lineBreak >= 2) {
log.getDocument().remove(2, lineBreak);
}
} else break;
}

} catch (Exception e) {} try {
HTMLEditorKit kit = (HTMLEditorKit) log.getEditorKit();
HTMLDocument doc = (HTMLDocument) log.getDocument();
kit.insertHTML(doc, doc.getLength() - 2, new String(scache.toByteArray(), "UTF-8"), 0, 0, null);
Expand All @@ -87,9 +89,7 @@ public void run() {
hScroll();
}
});
} catch (BadLocationException e) {
e.printStackTrace();
}
} catch (Exception e) {}
scache = new ByteArrayOutputStream();
}
}
Expand Down
Expand Up @@ -15,7 +15,7 @@ public final class GalaxiOption<T> extends Container<T> {
public static final GalaxiOption<File> APPLICATION_DIRECTORY = new GalaxiOption<>("user.dir", File::new);
public static final GalaxiOption<Boolean> ENABLE_RELOAD = new GalaxiOption<>(() -> false);
public static final GalaxiOption<File> LOG_DIRECTORY = new GalaxiOption<>(() -> new File(APPLICATION_DIRECTORY.get(), "Logs"));
public static final GalaxiOption<Integer> MAX_CONSOLE_WINDOW_SCROLLBACK = new GalaxiOption<Integer>("galaxi.ui.console.max_scrollback", usr -> (Util.getDespiteException(() -> Integer.parseInt(usr), 0) > 0)?Integer.parseInt(usr):15000);
public static final GalaxiOption<Integer> MAX_CONSOLE_WINDOW_SCROLLBACK = new GalaxiOption<Integer>("galaxi.ui.console.max_scrollback", usr -> (Util.getDespiteException(() -> Integer.parseInt(usr), 0) >= 128)?Integer.parseInt(usr):15000);
public static final GalaxiOption<Boolean> SHOW_CONSOLE_WINDOW = new GalaxiOption<>("galaxi.ui.console", usr -> usr.length() == 0 || usr.equalsIgnoreCase("true"));
public static final GalaxiOption<Boolean> USE_RAW_LOG = new GalaxiOption<>("galaxi.log.raw", usr -> usr.equalsIgnoreCase("true") || (usr.length() == 0 && GraphicsEnvironment.isHeadless()));

Expand Down

0 comments on commit 4879751

Please sign in to comment.