");
for (int y = 0; y < height; y++) {
int wx = 0;
for (int x = 0; x < width; x++) {
long d = screen[y][x];
int c = (int) (d & 0xffffffff);
int a = (int) (d >> 32);
if (cy == y && cx == x && vt100_mode_cursor) {
a = a & 0xfff0 | 0x000c;
}
if (a != prev_attr) {
if (prev_attr != -1) {
sb.append("");
}
int bg = a & 0x000000ff;
int fg = (a & 0x0000ff00) >> 8;
boolean inv = (a & 0x00020000) != 0;
boolean inv2 = vt100_mode_inverse;
if (inv && !inv2 || inv2 && !inv) {
int i = fg;
fg = bg;
bg = i;
}
if ((a & 0x00040000) != 0) {
fg = 0x0c;
}
String ul;
if ((a & 0x00010000) != 0) {
ul = " ul";
} else {
ul = "";
}
String b;
if ((a & 0x00080000) != 0) {
b = " b";
} else {
b = "";
}
sb.append("");
prev_attr = a;
}
switch (c) {
case '&':
sb.append("&");
break;
case '<':
sb.append("<");
break;
case '>':
sb.append(">");
break;
default:
wx += utf8_charwidth(c);
if (wx <= width) {
sb.append((char) c);
}
break;
}
}
sb.append("\n");
}
sb.append("
");
return sb.toString();
}
return null;
}
public String toString() {
StringBuilder sb = new StringBuilder();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
sb.appendCodePoint((int) (screen[y][x] & 0xffffffffL));
}
sb.append("\n");
}
return sb.toString();
}
}
jline3-jline-3.3.1/builtins/src/main/java/org/jline/builtins/Source.java 0000664 0000000 0000000 00000004750 13115447101 0026115 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2002-2016, 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.
*
* http://www.opensource.org/licenses/bsd-license.php
*/
package org.jline.builtins;
import java.io.File;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
public interface Source {
String getName();
InputStream read() throws IOException;
class URLSource implements Source {
final URL url;
final String name;
public URLSource(URL url, String name) {
this.url = Objects.requireNonNull(url);
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public InputStream read() throws IOException {
return url.openStream();
}
}
class PathSource implements Source {
final Path path;
final String name;
public PathSource(File file, String name) {
this(Objects.requireNonNull(file).toPath(), name);
}
public PathSource(Path path, String name) {
this.path = Objects.requireNonNull(path);
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public InputStream read() throws IOException {
return Files.newInputStream(path);
}
}
class InputStreamSource implements Source {
final InputStream in;
final String name;
public InputStreamSource(InputStream in, boolean close, String name) {
Objects.requireNonNull(in);
if (close) {
this.in = in;
} else {
this.in = new FilterInputStream(in) {
@Override
public void close() throws IOException {
}
};
}
this.name = name;
}
@Override
public String getName() {
return name;
}
@Override
public InputStream read() throws IOException {
return in;
}
}
class StdInSource extends InputStreamSource {
public StdInSource() {
super(System.in, false, null);
}
}
}
jline3-jline-3.3.1/builtins/src/main/java/org/jline/builtins/TTop.java 0000664 0000000 0000000 00000060357 13115447101 0025550 0 ustar 00root root 0000000 0000000 /*
* Copyright (c) 2002-2016, 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.
*
* http://www.opensource.org/licenses/bsd-license.php
*/
package org.jline.builtins;
import org.jline.keymap.BindingReader;
import org.jline.keymap.KeyMap;
import org.jline.terminal.Attributes;
import org.jline.terminal.Size;
import org.jline.terminal.Terminal;
import org.jline.utils.*;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.management.*;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static org.jline.builtins.TTop.Align.Left;
import static org.jline.builtins.TTop.Align.Right;
/**
* Thread Top implementation.
*
* TODO: option modification at runtime (such as implemented in less) is not currently supported
* TODO: one possible addition would be to detect deadlock threads and display them in a specific way
*/
public class TTop {
public static final String STAT_UPTIME = "uptime";
public static final String STAT_TID = "tid";
public static final String STAT_NAME = "name";
public static final String STAT_STATE = "state";
public static final String STAT_BLOCKED_TIME = "blocked_time";
public static final String STAT_BLOCKED_COUNT = "blocked_count";
public static final String STAT_WAITED_TIME = "waited_time";
public static final String STAT_WAITED_COUNT = "waited_count";
public static final String STAT_LOCK_NAME = "lock_name";
public static final String STAT_LOCK_OWNER_ID = "lock_owner_id";
public static final String STAT_LOCK_OWNER_NAME = "lock_owner_name";
public static final String STAT_USER_TIME = "user_time";
public static final String STAT_USER_TIME_PERC = "user_time_perc";
public static final String STAT_CPU_TIME = "cpu_time";
public static final String STAT_CPU_TIME_PERC = "cpu_time_perc";
public List