Skip to content

Commit

Permalink
Fix conemu problems with less / clearscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jan 30, 2019
1 parent 8b054e4 commit 8bb13a8
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2018, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -33,6 +33,7 @@
import org.jline.terminal.Attributes.ControlChar;
import org.jline.terminal.Terminal.Signal;
import org.jline.terminal.Terminal.SignalHandler;
import org.jline.terminal.impl.AbstractWindowsTerminal;
import org.jline.utils.AttributedString;
import org.jline.utils.AttributedStringBuilder;
import org.jline.utils.AttributedStyle;
Expand Down Expand Up @@ -5247,6 +5248,11 @@ public boolean clear() {
*/
public boolean clearScreen() {
if (terminal.puts(Capability.clear_screen)) {
// ConEMU extended fonts support
if (AbstractWindowsTerminal.TYPE_WINDOWS_CONEMU.equals(terminal.getType())
&& !Boolean.getBoolean("org.jline.terminal.conemu.disable-activate")) {
terminal.writer().write("\u001b[9999E");
}
Status status = Status.getStatus(terminal, false);
if (status != null) {
status.reset();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2018, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -37,7 +37,7 @@ public static JansiWinSysTerminal createTerminal(String name, String type, boole
Writer writer;
if (ansiPassThrough) {
if (type == null) {
type = OSUtils.IS_CONEMU ? TYPE_WINDOWS_256_COLOR : TYPE_WINDOWS;
type = OSUtils.IS_CONEMU ? TYPE_WINDOWS_CONEMU : TYPE_WINDOWS;
}
writer = new JansiWinConsoleWriter();
} else {
Expand All @@ -53,7 +53,7 @@ public static JansiWinSysTerminal createTerminal(String name, String type, boole
writer = new JansiWinConsoleWriter();
} else if (OSUtils.IS_CONEMU) {
if (type == null) {
type = TYPE_WINDOWS_256_COLOR;
type = TYPE_WINDOWS_CONEMU;
}
writer = new JansiWinConsoleWriter();
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2018, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -33,7 +33,7 @@ public static JnaWinSysTerminal createTerminal(String name, String type, boolean
Writer writer;
if (ansiPassThrough) {
if (type == null) {
type = OSUtils.IS_CONEMU ? TYPE_WINDOWS_256_COLOR : TYPE_WINDOWS;
type = OSUtils.IS_CONEMU ? TYPE_WINDOWS_CONEMU : TYPE_WINDOWS;
}
writer = new JnaWinConsoleWriter(consoleOut);
} else {
Expand All @@ -48,7 +48,7 @@ public static JnaWinSysTerminal createTerminal(String name, String type, boolean
} catch (LastErrorException e) {
if (OSUtils.IS_CONEMU) {
if (type == null) {
type = TYPE_WINDOWS_256_COLOR;
type = TYPE_WINDOWS_CONEMU;
}
writer = new JnaWinConsoleWriter(consoleOut);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2018, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -32,9 +32,6 @@
import org.jline.utils.Log;
import org.jline.utils.OSUtils;

import static org.jline.terminal.impl.AbstractWindowsTerminal.TYPE_WINDOWS;
import static org.jline.terminal.impl.AbstractWindowsTerminal.TYPE_WINDOWS_256_COLOR;

/**
* Builder class to create terminals.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2018, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand All @@ -21,12 +21,10 @@
import org.jline.utils.Signals;
import org.jline.utils.WriterOutputStream;

import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
Expand All @@ -49,6 +47,7 @@ public abstract class AbstractWindowsTerminal extends AbstractTerminal {

public static final String TYPE_WINDOWS = "windows";
public static final String TYPE_WINDOWS_256_COLOR = "windows-256color";
public static final String TYPE_WINDOWS_CONEMU = "windows-conemu";
public static final String TYPE_WINDOWS_VTP = "windows-vtp";

public static final int ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004;
Expand Down Expand Up @@ -109,9 +108,8 @@ public AbstractWindowsTerminal(Writer writer, String name, String type, Charset
closer = this::close;
ShutdownHooks.add(closer);
// ConEMU extended fonts support
if (TYPE_WINDOWS_256_COLOR.equals(getType())
if (TYPE_WINDOWS_CONEMU.equals(getType())
&& !Boolean.getBoolean("org.jline.terminal.conemu.disable-activate")) {
strings.replace(InfoCmp.Capability.clear_screen, "\\E[H\\E[J", "\\E[H\\E[J\\E[9999E");
writer.write("\u001b[9999E");
writer.flush();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2016, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -54,7 +54,8 @@ public String toAnsi(Terminal terminal) {
if (max_colors != null) {
colors = max_colors;
}
force256colors = AbstractWindowsTerminal.TYPE_WINDOWS_256_COLOR.equals(terminal.getType());
force256colors = AbstractWindowsTerminal.TYPE_WINDOWS_256_COLOR.equals(terminal.getType())
|| AbstractWindowsTerminal.TYPE_WINDOWS_CONEMU.equals(terminal.getType());
if (!DISABLE_ALTERNATE_CHARSET) {
alternateIn = Curses.tputs(terminal.getStringCapability(Capability.enter_alt_charset_mode));
alternateOut = Curses.tputs(terminal.getStringCapability(Capability.exit_alt_charset_mode));
Expand Down
4 changes: 2 additions & 2 deletions terminal/src/main/java/org/jline/utils/InfoCmp.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2016, the original author or authors.
* Copyright (c) 2002-2019, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
Expand Down Expand Up @@ -614,7 +614,7 @@ static String loadDefaultInfoCmp(String name) {

static {
for (String s : Arrays.asList("dumb", "ansi", "xterm", "xterm-256color",
"windows", "windows-256color", "windows-vtp",
"windows", "windows-256color", "windows-conemu", "windows-vtp",
"screen", "screen-256color")) {
setDefaultInfoCmp(s, () -> loadDefaultInfoCmp(s));
}
Expand Down
27 changes: 27 additions & 0 deletions terminal/src/main/resources/org/jline/utils/windows-conemu.caps
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
windows-conemu|conemu windows terminal,
am, mc5i, mir, msgr,
colors#256, cols#80, it#8, lines#24, ncv#3, pairs#64,
bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, clear=\E[H\E[J,
cr=^M, cub=\E[%p1%dD, cub1=\E[D, cud=\E[%p1%dB, cud1=\E[B,
cuf=\E[%p1%dC, cuf1=\E[C, cup=\E[%i%p1%d;%p2%dH,
cuu=\E[%p1%dA, cuu1=\E[A,
il=\E[%p1%dL, il1=\E[L,
dl=\E[%p1%dM, dl1=\E[M,
ech=\E[%p1%dX,
el=\E[K, ed=\E[2K,
el1=\E[1K, home=\E[H, hpa=\E[%i%p1%dG,
ind=^J,
invis=\E[8m, kbs=^H, kcbt=\E[Z,
kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,
khome=\E[H,
op=\E[39;49m,
rev=\E[7m,
rmacs=\E[10m, rmpch=\E[10m, rmso=\E[m, rmul=\E[m,
setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
sgr=\E[0;10%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;%?%p7%t;8%;%?%p9%t;11%;m,
sgr0=\E[0;10m,
smso=\E[7m,
smul=\E[4m,
kdch1=\E[3~, kich1=\E[2~, kend=\E[4~, knp=\E[6~, kpp=\E[5~,
kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, kf5=\E[15~, kf6=\E[17~,
kf7=\E[18~, kf8=\E[19~, kf9=\E[20~, kf10=\E[21~, kf11=\E[23~, kf12=\E[24~,

0 comments on commit 8bb13a8

Please sign in to comment.