Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
JDK 17 jdk.internal.le.jmod - Internal Line Editing Module
JDK 17 jdk.internal.le.jmod is the JMOD file for JDK 17 Internal Line Editing module.
JDK 17 Internal Line Editing module compiled class files are stored in \fyicenter\jdk-17.0.5\jmods\jdk.internal.le.jmod.
JDK 17 Internal Line Editing module compiled class files are also linked and stored in the \fyicenter\jdk-17.0.5\lib\modules JImage file.
JDK 17 Internal Line Editing module source code files are stored in \fyicenter\jdk-17.0.5\lib\src.zip\jdk.internal.le.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ jdk/internal/org/jline/utils/StyleResolver.java
/* * Copyright (c) 2002-2018, 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. * * https://opensource.org/licenses/BSD-3-Clause */ package jdk.internal.org.jline.utils; import java.util.Locale; import java.util.function.Function; //import java.util.logging.Level; //import java.util.logging.Logger; import static java.util.Objects.requireNonNull; import static jdk.internal.org.jline.utils.AttributedStyle.*; // TODO: document style specification /** * Resolves named (or source-referenced) {@link AttributedStyle}. * * @since 3.6 */ public class StyleResolver { // private static final Logger log = Logger.getLogger(StyleResolver.class.getName()); private final Function<String, String> source; public StyleResolver(final Function<String, String> source) { this.source = requireNonNull(source); } /** * Returns the RGB color for the given name. * <p> * Bright color can be specified with: {@code !<color>} or {@code bright-<color>}. * <p> * Full xterm256 color can be specified with: {@code ~<color>}. * RGB colors can be specified with: {@code x<rgb>} or {@code #<rgb>} where {@code rgb} is * a 24 bits hexadecimal color. * * @param name the name of the color * @return color code, or {@code null} if unable to determine. */ private static Integer colorRgb(String name) { name = name.toLowerCase(Locale.US); // check hexadecimal color if (name.charAt(0) == 'x' || name.charAt(0) == '#') { try { return Integer.parseInt(name.substring(1), 16); } catch (NumberFormatException e) { // log.warning("Invalid hexadecimal color: " + name); return null; } } else { // load indexed color Integer color = color(name); if (color != null && color != -1) { color = Colors.DEFAULT_COLORS_256[color]; } return color; } } /** * Returns the color identifier for the given name. * <p> * Bright color can be specified with: {@code !<color>} or {@code bright-<color>}. * <p> * Full xterm256 color can be specified with: {@code ~<color>}. * * @param name the name of the color * @return color code, or {@code null} if unable to determine. */ private static Integer color(String name) { int flags = 0; if (name.equals("default")) { return -1; } // extract bright flag from color name else if (name.charAt(0) == '!') { name = name.substring(1); flags = BRIGHT; } else if (name.startsWith("bright-")) { name = name.substring(7); flags = BRIGHT; } else if (name.charAt(0) == '~') { name = name.substring(1); try { return Colors.rgbColor(name); } catch (IllegalArgumentException e) { // log.warning("Invalid style-color name: " + name); return null; } } switch (name) { case "black": case "k": return flags + BLACK; case "red": case "r": return flags + RED; case "green": case "g": return flags + GREEN; case "yellow": case "y": return flags + YELLOW; case "blue": case "b": return flags + BLUE; case "magenta": case "m": return flags + MAGENTA; case "cyan": case "c": return flags + CYAN; case "white": case "w": return flags + WHITE; } return null; } // TODO: could consider a small cache to reduce style calculations? /** * Resolve the given style specification. * <p> * If for some reason the specification is invalid, then {@link AttributedStyle#DEFAULT} will be used. * * @param spec the specification * @return the style */ public AttributedStyle resolve(final String spec) { requireNonNull(spec); // if (log.isLoggable(Level.FINEST)) { // log.finest("Resolve: " + spec); // } int i = spec.indexOf(":-"); if (i != -1) { String[] parts = spec.split(":-"); return resolve(parts[0].trim(), parts[1].trim()); } return apply(DEFAULT, spec); } /** * Resolve the given style specification. * <p> * If this resolves to {@link AttributedStyle#DEFAULT} then given default specification is used if non-null. * * @param spec the specification * @param defaultSpec the default specifiaction * @return the style */ public AttributedStyle resolve(final String spec, final String defaultSpec) { requireNonNull(spec); // if (log.isLoggable(Level.FINEST)) { // log.finest(String.format("Resolve: %s; default: %s", spec, defaultSpec)); // } AttributedStyle style = apply(DEFAULT, spec); if (style == DEFAULT && defaultSpec != null) { style = apply(style, defaultSpec); } return style; } /** * Apply style specification. * * @param style the style to apply to * @param spec the specification * @return the new style */ private AttributedStyle apply(AttributedStyle style, final String spec) { // if (log.isLoggable(Level.FINEST)) { // log.finest("Apply: " + spec); // } for (String item : spec.split(",")) { item = item.trim(); if (item.isEmpty()) { continue; } if (item.startsWith(".")) { style = applyReference(style, item); } else if (item.contains(":")) { style = applyColor(style, item); } else if (item.matches("[0-9]+(;[0-9]+)*")) { style = applyAnsi(style, item); } else { style = applyNamed(style, item); } } return style; } private AttributedStyle applyAnsi(final AttributedStyle style, final String spec) { // if (log.isLoggable(Level.FINEST)) { // log.finest("Apply-ansi: " + spec); // } return new AttributedStringBuilder() .style(style) .ansiAppend("\033[" + spec + "m") .style(); } /** * Apply source-referenced named style. * * @param style the style to apply to * @param spec the specification * @return the new style */ private AttributedStyle applyReference(final AttributedStyle style, final String spec) { // if (log.isLoggable(Level.FINEST)) { // log.finest("Apply-reference: " + spec); // } if (spec.length() == 1) { // log.warning("Invalid style-reference; missing discriminator: " + spec); } else { String name = spec.substring(1, spec.length()); String resolvedSpec = source.apply(name); if (resolvedSpec != null) { return apply(style, resolvedSpec); } // null is normal if source has not be configured with named style } return style; } /** * Apply default named styles. * * @param style the style to apply to * @param name the named style * @return the new style */ private AttributedStyle applyNamed(final AttributedStyle style, final String name) { // if (log.isLoggable(Level.FINEST)) { // log.finest("Apply-named: " + name); // } // TODO: consider short aliases for named styles switch (name.toLowerCase(Locale.US)) { case "default": return DEFAULT; case "bold": return style.bold(); case "faint": return style.faint(); case "italic": return style.italic(); case "underline": return style.underline(); case "blink": return style.blink(); case "inverse": return style.inverse(); case "inverse-neg": case "inverseneg": return style.inverseNeg(); case "conceal": return style.conceal(); case "crossed-out": case "crossedout": return style.crossedOut(); case "hidden": return style.hidden(); default: // log.warning("Unknown style: " + name); return style; } } // TODO: consider simplify and always using StyleColor, for now for compat with other bits leaving syntax complexity /** * Apply color styles specification. * * @param style The style to apply to * @param spec Color specification: {@code <color-mode>:<color-name>} * @return The new style */ private AttributedStyle applyColor(final AttributedStyle style, final String spec) { // if (log.isLoggable(Level.FINEST)) { // log.finest("Apply-color: " + spec); // } // extract color-mode:color-name String[] parts = spec.split(":", 2); String colorMode = parts[0].trim(); String colorName = parts[1].trim(); // resolve the color-name Integer color; // resolve and apply color-mode switch (colorMode.toLowerCase(Locale.US)) { case "foreground": case "fg": case "f": color = color(colorName); if (color == null) { // log.warning("Invalid color-name: " + colorName); break; } return color >= 0 ? style.foreground(color) : style.foregroundDefault(); case "background": case "bg": case "b": color = color(colorName); if (color == null) { // log.warning("Invalid color-name: " + colorName); break; } return color >= 0 ? style.background(color) : style.backgroundDefault(); case "foreground-rgb": case "fg-rgb": case "f-rgb": color = colorRgb(colorName); if (color == null) { // log.warning("Invalid color-name: " + colorName); break; } return color >= 0 ? style.foregroundRgb(color) : style.foregroundDefault(); case "background-rgb": case "bg-rgb": case "b-rgb": color = colorRgb(colorName); if (color == null) { // log.warning("Invalid color-name: " + colorName); break; } return color >= 0 ? style.backgroundRgb(color) : style.backgroundDefault(); default: // log.warning("Invalid color-mode: " + colorMode); } return style; } }
⏎ jdk/internal/org/jline/utils/StyleResolver.java
Or download all of them as a single archive file:
File name: jdk.internal.le-17.0.5-src.zip File size: 231458 bytes Release date: 2022-09-13 Download
⇒ JDK 17 jdk.internal.opt.jmod - Internal Opt Module
⇐ JDK 17 jdk.internal.jvmstat.jmod - Internal JVM Stat Module
2023-08-25, 3973👍, 0💬
Popular Posts:
The Web Services Description Language for Java Toolkit (WSDL4J), Release 1.6.2, allows the creation,...
How to download and install ojdbc7.jar for Oracle 12c R1? ojdbc8.jar for Oracle 12c R1 is a Java 7 a...
commons-lang-1.0.1.jar is the JAR file for Apache Commons Lang 1.0.1, which provides a host of helpe...
JAX-WS is an API for building web services and clients. It is the next generation Web Services API r...
What Is commons-fileupload-1.3.3 .jar?commons-fileupload-1.3.3 .jaris the JAR file for Apache Common...