Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Solve the problem that the icons are colored even after using the '--no-colors' option #7

Merged
merged 1 commit into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/com/anas/javautils/jls/output/FileInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public String getCreationTime(final boolean withColor) {
return withColor ? str.toString() : str.getNormalString();
}

public Icon getIcon(final boolean withColor) {
public Icon getIcon() {
Icon icon = Icon.getCorrectIcon(getName());

if (icon != null) return icon;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/anas/javautils/jls/output/Icon.java
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,8 @@ public String toString() {
new String(color.getForegroundSGRSequence(), StandardCharsets.UTF_8) + "m" +
icon + "\033[0m";
}

public String getNoColoredIcon() {
return icon + "";
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/anas/javautils/jls/output/ListOfFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ private String getShortFormat(
(withSize ? " %s" : "%s");

return String.format(format,
IS_NO_ICONS ? "" : fileInfo.getIcon(IS_WITH_NO_COLORS),
IS_NO_ICONS ? "" : (IS_WITH_NO_COLORS ?
fileInfo.getIcon().toString() : fileInfo.getIcon().getNoColoredIcon()),
fileInfo.getName(IS_WITH_NO_COLORS),
fileInfo.isSymlink() ? fileInfo.getSymlinkTarget(IS_WITH_NO_COLORS) : "",
withSize ? fileInfo.getSize(IS_HUMAN_READABLE, IS_WITH_NO_COLORS) : ""
Expand Down