Remove obsolete init files, switch from Terminus to monocraft, implement the ability to use bold (fix regression), italic (new feature), bold italic (new feature), implement SGR 90-97 and 100-107, fix background unable to be properly set to 40 (dim or normal), fix minor alt buffer issue, new test script for new colors.

This commit is contained in:
JacksonAbney
2025-04-17 20:11:19 -08:00
parent 3389aa6634
commit 7a2db0fb45
24 changed files with 201 additions and 350 deletions

View File

@@ -27,6 +27,7 @@ import java.util.Collections;
import java.util.Set;
import java.util.WeakHashMap;
@SuppressWarnings("unused")
public final class FileImportExportCardItemDevice extends AbstractItemRPCDevice implements DocumentedDevice {
public static final int MAX_TRANSFERRED_FILE_SIZE = Constants.MEGABYTE - 1;

View File

@@ -43,8 +43,11 @@ public class Terminal {
public static final int STYLE_BLINK_MASK = 1 << 3;
public static final int STYLE_INVERT_MASK = 1 << 4;
public static final int STYLE_HIDDEN_MASK = 1 << 5;
public static final int STYLE_ITALIC_MASK = 1 << 6;
// Default Styles
public static final ColorData DEFAULT_BACKGROUND_COLOR = new ColorData(Color.WHITE, Color.BLACK, 0, ColorMode.DEFAULT_BACKGROUND);
public static final ColorData DEFAULT_BRIGHT_COLORS = new ColorData(Color.WHITE, Color.BLACK, 0, ColorMode.SIXTEEN_COLOR_BRIGHT);
public static final ColorData DEFAULT_COLORS = new ColorData(Color.WHITE, Color.BLACK, 0, ColorMode.SIXTEEN_COLOR);
public static final byte DEFAULT_STYLE = 0;
public static final ColorData DEFAULT_256_COLORS = new ColorData(Color.WHITE, Color.BLACK, 0, ColorMode.TWO_FIFTY_SIX_COLOR);
@@ -56,6 +59,7 @@ public class Terminal {
public ColorMode currentForegroundColorMode = ColorMode.SIXTEEN_COLOR;
public ColorMode currentBackgroundColorMode = ColorMode.SIXTEEN_COLOR;
public ColorData sixteenColor;
public ColorData sixteenColorBright;
// 256 Color
public ColorData twoFiftySixColor;
// True Color
@@ -103,12 +107,16 @@ public class Terminal {
// Related Enums
public enum ColorMode {
@SerializedName("4")
DEFAULT_BACKGROUND,
@SerializedName("0")
SIXTEEN_COLOR,
@SerializedName("1")
TWO_FIFTY_SIX_COLOR,
@SerializedName("2")
TRUE_COLOR
TRUE_COLOR,
@SerializedName("3")
SIXTEEN_COLOR_BRIGHT
}
public static final class CursorMode {
@@ -261,16 +269,17 @@ public class Terminal {
// Terminal Management
public void clear() {
ColorData c;
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
case SIXTEEN_COLOR_BRIGHT -> c = sixteenColorBright;
default -> c = Terminal.DEFAULT_BACKGROUND_COLOR;
}
if (currentPrivateModeState.isAltBufferEnabled()) {
Arrays.fill(altBuffer, ' ');
Arrays.fill(altColors, DEFAULT_COLORS.Copy());
ColorData c;
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
default -> c = DEFAULT_COLORS.Copy();
}
Arrays.fill(altColorsBackground, c.Copy());
Arrays.fill(altStyles, DEFAULT_STYLE);
} else {
@@ -278,13 +287,6 @@ public class Terminal {
int endIndex = startIndex + (HEIGHT * WIDTH);
Arrays.fill(buffer, startIndex, endIndex, ' ');
Arrays.fill(colors, startIndex, endIndex, DEFAULT_COLORS.Copy());
ColorData c;
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
default -> c = DEFAULT_COLORS.Copy();
}
Arrays.fill(colorsBackground, startIndex, endIndex, c.Copy());
Arrays.fill(styles, startIndex, endIndex, DEFAULT_STYLE);
}
@@ -300,6 +302,7 @@ public class Terminal {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
case SIXTEEN_COLOR_BRIGHT -> c = sixteenColorBright;
default -> c = DEFAULT_COLORS.Copy();
}
Arrays.fill(altColorsBackground, c.Copy());
@@ -312,29 +315,23 @@ public class Terminal {
public void clearLine(final int y, final int fromIndex, final int toIndex) {
currentForegroundColorMode = ColorMode.SIXTEEN_COLOR;
ColorData c;
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
case SIXTEEN_COLOR_BRIGHT -> c = sixteenColorBright;
default -> c = Terminal.DEFAULT_BACKGROUND_COLOR;
}
if (currentPrivateModeState.isAltBufferEnabled()) {
Arrays.fill(altBuffer, y * WIDTH + fromIndex, y * WIDTH + toIndex, ' ');
Arrays.fill(altColors, y * WIDTH + fromIndex, y * WIDTH + toIndex, DEFAULT_COLORS.Copy());
ColorData c;
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
default -> c = DEFAULT_COLORS.Copy();
}
Arrays.fill(altColorsBackground, y * WIDTH + fromIndex, y * WIDTH + toIndex, c.Copy());
Arrays.fill(altStyles, y * WIDTH + fromIndex, y * WIDTH + toIndex, DEFAULT_STYLE);
} else {
int correctedY = (y + (lastRowToDisplayMax - HEIGHT));
Arrays.fill(buffer, correctedY * WIDTH + fromIndex, correctedY * WIDTH + toIndex, ' ');
Arrays.fill(colors, correctedY * WIDTH + fromIndex, correctedY * WIDTH + toIndex, DEFAULT_COLORS.Copy());
ColorData c;
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
default -> c = DEFAULT_COLORS.Copy();
}
Arrays.fill(colorsBackground, correctedY * WIDTH + fromIndex, correctedY * WIDTH + toIndex, c.Copy());
Arrays.fill(styles, correctedY * WIDTH + fromIndex, correctedY * WIDTH + toIndex, DEFAULT_STYLE);
}
@@ -638,6 +635,14 @@ public class Terminal {
final int srcIndex = firstLine * WIDTH;
final int charCount = (lastLine + 1) * WIDTH - srcIndex;
final int dstIndex = srcIndex + count * WIDTH;
ColorData c;
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
case SIXTEEN_COLOR_BRIGHT -> c = sixteenColorBright;
default -> c = Terminal.DEFAULT_BACKGROUND_COLOR;
}
if (currentPrivateModeState.isAltBufferEnabled()) {
System.arraycopy(altBuffer, srcIndex, altBuffer, dstIndex, charCount);
System.arraycopy(altColors, srcIndex, altColors, dstIndex, charCount);
@@ -650,13 +655,6 @@ public class Terminal {
// TODO Copy color and style from last line.
// TODO Copy color and style from last line.
Arrays.fill(altColors, clearIndex, clearIndex + clearCount, DEFAULT_COLORS.Copy());
ColorData c;
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
default -> c = DEFAULT_COLORS.Copy();
}
Arrays.fill(altColorsBackground, clearIndex, clearIndex + clearCount, c.Copy());
Arrays.fill(altStyles, clearIndex, clearIndex + clearCount, DEFAULT_STYLE);
@@ -680,13 +678,6 @@ public class Terminal {
// TODO Copy color and style from last line.
// TODO Copy color and style from last line.
Arrays.fill(colors, clearIndex, clearIndex + clearCount, DEFAULT_COLORS.Copy());
ColorData c;
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = twoFiftySixColor;
case TRUE_COLOR -> c = backgroundColor;
default -> c = DEFAULT_COLORS.Copy();
}
Arrays.fill(colorsBackground, clearIndex, clearIndex + clearCount, c.Copy());
Arrays.fill(styles, clearIndex, clearIndex + clearCount, DEFAULT_STYLE);
@@ -749,12 +740,14 @@ public class Terminal {
case SIXTEEN_COLOR -> altColors[index] = sixteenColor.Copy();
case TWO_FIFTY_SIX_COLOR -> altColors[index] = twoFiftySixColor.Copy();
case TRUE_COLOR -> altColors[index] = foregroundColor.Copy();
case SIXTEEN_COLOR_BRIGHT -> altColors[index] = sixteenColorBright.Copy();
}
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> altColorsBackground[index] = sixteenColor.Copy();
case TWO_FIFTY_SIX_COLOR -> altColorsBackground[index] = twoFiftySixColor.Copy();
case TRUE_COLOR -> altColorsBackground[index] = backgroundColor.Copy();
case SIXTEEN_COLOR_BRIGHT -> altColorsBackground[index] = sixteenColorBright.Copy();
}
altStyles[index] = style;
@@ -769,12 +762,14 @@ public class Terminal {
case SIXTEEN_COLOR -> colors[index] = sixteenColor.Copy();
case TWO_FIFTY_SIX_COLOR -> colors[index] = twoFiftySixColor.Copy();
case TRUE_COLOR -> colors[index] = foregroundColor.Copy();
case SIXTEEN_COLOR_BRIGHT -> colors[index] = sixteenColorBright.Copy();
}
switch (currentBackgroundColorMode) {
case SIXTEEN_COLOR -> colorsBackground[index] = sixteenColor.Copy();
case TWO_FIFTY_SIX_COLOR -> colorsBackground[index] = twoFiftySixColor.Copy();
case TRUE_COLOR -> colorsBackground[index] = backgroundColor.Copy();
case SIXTEEN_COLOR_BRIGHT -> colorsBackground[index] = sixteenColorBright.Copy();
}
styles[index] = style;
@@ -787,6 +782,17 @@ public class Terminal {
// Renderer
@OnlyIn(Dist.CLIENT)
public static final class Renderer implements RendererModel, RendererView {
public static final int[] BRIGHT_COLORS = {
0x7B7B7B, // Black
0xFF4524, // Red
0x3AFF5B, // Green
0xFFDB10, // Yellow
0x1281FF, // Blue
0xFF3ADE, // Magenta
0x27DDFF, // Cyan
0xFFFFFF, // White
};
public static final int[] COLORS = {
0x555555, // Black
0xEE3322, // Red
@@ -799,7 +805,7 @@ public class Terminal {
};
public static final int[] DIM_COLORS = {
0x010101, // Black
0x000000, // Black
0x772211, // Red
0x116622, // Green
0x886611, // Yellow
@@ -810,7 +816,7 @@ public class Terminal {
};
public static final int[] COLORS_256 = {
0x010101, 0x772211, 0x116622, 0x886611, 0x115588, 0x771177, 0x116677, 0x777777,
0x000000, 0x772211, 0x116622, 0x886611, 0x115588, 0x771177, 0x116677, 0x777777,
0x555555, 0xEE3322, 0x33DD44, 0xFFCC11, 0x1188EE, 0xDD33CC, 0x22CCDD, 0xEEEEEE,
0x000000, 0x00005f, 0x000087, 0x0000af, 0x0000d7, 0x0000ff, 0x005f00, 0x005f5f,
0x005f87, 0x005faf, 0x005fd7, 0x005fff, 0x008700, 0x00875f, 0x008787, 0x0087af,
@@ -985,10 +991,12 @@ public class Terminal {
case SIXTEEN_COLOR -> palette[!invertBackground ? color.G : color.R];
case TWO_FIFTY_SIX_COLOR -> COLORS_256[!invertBackground ? color.G : color.R];
case TRUE_COLOR -> color.ToInt();
case SIXTEEN_COLOR_BRIGHT -> BRIGHT_COLORS[!invertBackground ? color.G : color.R];
case DEFAULT_BACKGROUND -> 0x000000;
};
final boolean hadBackground = backgroundStartX >= 0;
final boolean hasBackground = background != palette[0];
final boolean hasBackground = background != 0x000000;
if (!hadBackground && hasBackground) {
backgroundStartX = tx;
backgroundColor = background;
@@ -1037,6 +1045,8 @@ public class Terminal {
case SIXTEEN_COLOR -> palette[!invertBackground ? color.R : color.G];
case TWO_FIFTY_SIX_COLOR -> COLORS_256[!invertBackground ? color.R : color.G];
case TRUE_COLOR -> color.ToInt();
case SIXTEEN_COLOR_BRIGHT -> BRIGHT_COLORS[!invertBackground ? color.R : color.G];
case DEFAULT_BACKGROUND -> throw new IllegalStateException("Unexpected value for foreground: " + color.Mode);
};
final int character = (useAltBuffer) ? terminal.altBuffer[index] : terminal.buffer[index];
@@ -1053,12 +1063,23 @@ public class Terminal {
final float b = (color & 0xFF) / 255f;
if (isPrintableCharacter(character)) {
Glyph glyph = FontHandling.getGlyph(character);
FontHandling.FontStyle font = getFontStyle(style);
buffer.vertex(matrix, offset, CHAR_HEIGHT, 0).color(r, g, b, 1).uv(glyph.uStart, glyph.vEnd).endVertex();
buffer.vertex(matrix, offset + CHAR_WIDTH, CHAR_HEIGHT, 0).color(r, g, b, 1).uv(glyph.uEnd, glyph.vEnd).endVertex();
buffer.vertex(matrix, offset + CHAR_WIDTH, 0, 0).color(r, g, b, 1).uv(glyph.uEnd, glyph.vStart).endVertex();
buffer.vertex(matrix, offset, 0, 0).color(r, g, b, 1).uv(glyph.uStart, glyph.vStart).endVertex();
Glyph glyph = FontHandling.getGlyph(character, font);
if (font == FontHandling.FontStyle.ITALIC || font == FontHandling.FontStyle.BOLD_ITALIC) { // Italic
buffer.vertex(matrix, offset, CHAR_HEIGHT, 0).color(r, g, b, 1).uv(glyph.uStart, glyph.vEnd).endVertex();
buffer.vertex(matrix, offset + CHAR_WIDTH + 8, CHAR_HEIGHT, 0).color(r, g, b, 1).uv(glyph.uEnd, glyph.vEnd).endVertex();
buffer.vertex(matrix, offset + CHAR_WIDTH + 8, 0, 0).color(r, g, b, 1).uv(glyph.uEnd, glyph.vStart).endVertex();
buffer.vertex(matrix, offset, 0, 0).color(r, g, b, 1).uv(glyph.uStart, glyph.vStart).endVertex();
}
else
{
buffer.vertex(matrix, offset, CHAR_HEIGHT, 0).color(r, g, b, 1).uv(glyph.uStart, glyph.vEnd).endVertex();
buffer.vertex(matrix, offset + CHAR_WIDTH, CHAR_HEIGHT, 0).color(r, g, b, 1).uv(glyph.uEnd, glyph.vEnd).endVertex();
buffer.vertex(matrix, offset + CHAR_WIDTH, 0, 0).color(r, g, b, 1).uv(glyph.uEnd, glyph.vStart).endVertex();
buffer.vertex(matrix, offset, 0, 0).color(r, g, b, 1).uv(glyph.uStart, glyph.vStart).endVertex();
}
}
if ((style & STYLE_UNDERLINE_MASK) != 0) {
@@ -1069,6 +1090,20 @@ public class Terminal {
}
}
private FontHandling.FontStyle getFontStyle(byte style) {
FontHandling.FontStyle font;
if ((style & STYLE_BOLD_MASK) != 0 && (style & STYLE_ITALIC_MASK) != 0) {
font = FontHandling.FontStyle.BOLD_ITALIC;
} else if ((style & STYLE_BOLD_MASK) != 0) {
font = FontHandling.FontStyle.BOLD;
} else if ((style & STYLE_ITALIC_MASK) != 0) {
font = FontHandling.FontStyle.ITALIC;
} else {
font = FontHandling.FontStyle.REGULAR;
}
return font;
}
public void renderCursor(final PoseStack stack) {
BufferUploader.reset();
if (!terminal.currentPrivateModeState.DECTCEM) return;

View File

@@ -9,9 +9,10 @@ import java.util.Arrays;
public class RIS {
public static void execute(Terminal terminal) {
terminal.currentForegroundColorMode = Terminal.ColorMode.SIXTEEN_COLOR;
terminal.currentBackgroundColorMode = Terminal.ColorMode.SIXTEEN_COLOR;
terminal.currentBackgroundColorMode = Terminal.ColorMode.DEFAULT_BACKGROUND;
terminal.Use1006 = false;
terminal.sixteenColor = Terminal.DEFAULT_COLORS.Copy();
terminal.sixteenColorBright = Terminal.DEFAULT_BRIGHT_COLORS.Copy();
terminal.backgroundColor = Terminal.DEFAULT_TRUE_COLOR_BACKGROUND.Copy();
terminal.foregroundColor = Terminal.DEFAULT_TRUE_COLOR_FOREGROUND.Copy();
terminal.twoFiftySixColor = Terminal.DEFAULT_256_COLORS.Copy();
@@ -27,11 +28,11 @@ public class RIS {
terminal.clearAlt();
Arrays.fill(terminal.buffer, ' ');
Arrays.fill(terminal.colors, Terminal.DEFAULT_COLORS.Copy());
Arrays.fill(terminal.colorsBackground, Terminal.DEFAULT_COLORS.Copy());
Arrays.fill(terminal.colorsBackground, Terminal.DEFAULT_BACKGROUND_COLOR.Copy());
Arrays.fill(terminal.styles, Terminal.DEFAULT_STYLE);
Arrays.fill(terminal.altBuffer, ' ');
Arrays.fill(terminal.altColors, Terminal.DEFAULT_COLORS.Copy());
Arrays.fill(terminal.altColorsBackground, Terminal.DEFAULT_COLORS.Copy());
Arrays.fill(terminal.altColorsBackground, Terminal.DEFAULT_BACKGROUND_COLOR.Copy());
Arrays.fill(terminal.altStyles, Terminal.DEFAULT_STYLE);
Arrays.fill(terminal.tabs, false);
Arrays.fill(terminal.altTabs, false);

View File

@@ -18,6 +18,14 @@ public class CH10 extends CSISequenceHandler { // Combined Handler 10 (DCH and X
int startIndex = ((terminal.currentPrivateModeState.isAltBufferEnabled()) ? terminal.y * Terminal.WIDTH : (terminal.y + (terminal.lastRowToDisplayMax - Terminal.HEIGHT)) * Terminal.WIDTH) + terminal.x;
int count = (Terminal.WIDTH - terminal.x) - chars;
int endIndex = startIndex + count;
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
case SIXTEEN_COLOR_BRIGHT -> c = terminal.sixteenColorBright;
default -> c = Terminal.DEFAULT_BACKGROUND_COLOR;
}
if (terminal.currentPrivateModeState.isAltBufferEnabled()) {
System.arraycopy(terminal.altBuffer, startIndex + chars, terminal.altBuffer, startIndex, count);
System.arraycopy(terminal.altColors, startIndex + chars, terminal.altColors, startIndex, count);
@@ -25,14 +33,7 @@ public class CH10 extends CSISequenceHandler { // Combined Handler 10 (DCH and X
System.arraycopy(terminal.altStyles, startIndex + chars, terminal.altStyles, startIndex, count);
Arrays.fill(terminal.altBuffer, endIndex, endIndex + chars + 1, ' ');
Arrays.fill(terminal.altColors, endIndex, endIndex + chars + 1, Terminal.DEFAULT_COLORS.Copy());
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
default -> c = Terminal.DEFAULT_COLORS;
}
Arrays.fill(terminal.altColors, endIndex, endIndex + chars + 1, c.Copy());
Arrays.fill(terminal.altColorsBackground, endIndex, endIndex + chars + 1, c.Copy());
Arrays.fill(terminal.altStyles, endIndex, endIndex + chars + 1, Terminal.DEFAULT_STYLE);
} else {
System.arraycopy(terminal.buffer, startIndex + chars, terminal.buffer, startIndex, count);
@@ -41,13 +42,6 @@ public class CH10 extends CSISequenceHandler { // Combined Handler 10 (DCH and X
System.arraycopy(terminal.styles, startIndex + chars, terminal.styles, startIndex, count);
Arrays.fill(terminal.buffer, endIndex, endIndex + chars + 1, ' ');
Arrays.fill(terminal.colors, endIndex, endIndex + chars + 1, Terminal.DEFAULT_COLORS.Copy());
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
default -> c = Terminal.DEFAULT_COLORS;
}
Arrays.fill(terminal.colorsBackground, endIndex, endIndex + chars + 1, c.Copy());
Arrays.fill(terminal.styles, endIndex, endIndex + chars + 1, Terminal.DEFAULT_STYLE);
}

View File

@@ -30,6 +30,14 @@ public class CH11 extends CSISequenceHandler { // Combined Handler 10 (ICH and S
int startIndex = ((terminal.currentPrivateModeState.isAltBufferEnabled()) ? y * Terminal.WIDTH : (y + (terminal.lastRowToDisplayMax - Terminal.HEIGHT)) * Terminal.WIDTH);
int count = (Terminal.WIDTH) - chars;
int endIndex = startIndex + count;
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
case SIXTEEN_COLOR_BRIGHT -> c = terminal.sixteenColorBright;
default -> c = Terminal.DEFAULT_BACKGROUND_COLOR;
}
if (terminal.currentPrivateModeState.isAltBufferEnabled()) {
System.arraycopy(terminal.altBuffer, startIndex + chars, terminal.altBuffer, startIndex, count);
System.arraycopy(terminal.altColors, startIndex + chars, terminal.altColors, startIndex, count);
@@ -38,14 +46,7 @@ public class CH11 extends CSISequenceHandler { // Combined Handler 10 (ICH and S
Arrays.fill(terminal.altBuffer, endIndex, endIndex + chars, ' ');
Arrays.fill(terminal.altColors, endIndex, endIndex + chars, Terminal.DEFAULT_COLORS.Copy());
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
default -> c = Terminal.DEFAULT_COLORS;
}
Arrays.fill(terminal.altColors, endIndex, endIndex + chars, c.Copy());
Arrays.fill(terminal.altColorsBackground, endIndex, endIndex + chars, c.Copy());
Arrays.fill(terminal.altStyles, endIndex, endIndex + chars, Terminal.DEFAULT_STYLE);
} else {
System.arraycopy(terminal.buffer, startIndex + chars, terminal.buffer, startIndex, count);
@@ -55,13 +56,7 @@ public class CH11 extends CSISequenceHandler { // Combined Handler 10 (ICH and S
Arrays.fill(terminal.buffer, endIndex, endIndex + chars, ' ');
Arrays.fill(terminal.colors, endIndex, endIndex + chars, Terminal.DEFAULT_COLORS.Copy());
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
default -> c = Terminal.DEFAULT_COLORS;
}
Arrays.fill(terminal.colorsBackground, endIndex, endIndex + chars, c.Copy());
Arrays.fill(terminal.styles, endIndex, endIndex + chars, Terminal.DEFAULT_STYLE);
}
@@ -72,6 +67,14 @@ public class CH11 extends CSISequenceHandler { // Combined Handler 10 (ICH and S
private void shiftRight(int chars) {
int startIndex = ((terminal.currentPrivateModeState.isAltBufferEnabled()) ? terminal.y * Terminal.WIDTH : (terminal.y + (terminal.lastRowToDisplayMax - Terminal.HEIGHT)) * Terminal.WIDTH) + terminal.x;
int count = (Terminal.WIDTH - terminal.x) - chars;
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
case SIXTEEN_COLOR_BRIGHT -> c = terminal.sixteenColorBright;
default -> c = Terminal.DEFAULT_BACKGROUND_COLOR;
}
if (terminal.currentPrivateModeState.isAltBufferEnabled()) {
System.arraycopy(terminal.altBuffer, startIndex, terminal.altBuffer, startIndex + chars, count);
System.arraycopy(terminal.altColors, startIndex, terminal.altColors, startIndex + chars, count);
@@ -79,14 +82,7 @@ public class CH11 extends CSISequenceHandler { // Combined Handler 10 (ICH and S
System.arraycopy(terminal.altStyles, startIndex, terminal.altStyles, startIndex + chars, count);
Arrays.fill(terminal.altBuffer, startIndex, startIndex + chars, ' ');
Arrays.fill(terminal.altColors, startIndex, startIndex + chars, Terminal.DEFAULT_COLORS.Copy());
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
default -> c = Terminal.DEFAULT_COLORS;
}
Arrays.fill(terminal.altColors, startIndex, startIndex + chars, c.Copy());
Arrays.fill(terminal.altColorsBackground, startIndex, startIndex + chars, c.Copy());
Arrays.fill(terminal.altStyles, startIndex, startIndex + chars, Terminal.DEFAULT_STYLE);
} else {
System.arraycopy(terminal.buffer, startIndex, terminal.buffer, startIndex + chars, count);
@@ -95,13 +91,6 @@ public class CH11 extends CSISequenceHandler { // Combined Handler 10 (ICH and S
System.arraycopy(terminal.styles, startIndex, terminal.styles, startIndex + chars, count);
Arrays.fill(terminal.buffer, startIndex, startIndex + chars, ' ');
Arrays.fill(terminal.colors, startIndex, startIndex + chars, Terminal.DEFAULT_COLORS.Copy());
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
default -> c = Terminal.DEFAULT_COLORS;
}
Arrays.fill(terminal.colorsBackground, startIndex, startIndex + chars, c.Copy());
Arrays.fill(terminal.styles, startIndex, startIndex + chars, Terminal.DEFAULT_STYLE);
}

View File

@@ -104,8 +104,6 @@ public class CSIManager {
terminal.state = Terminal.State.NORMAL;
System.out.println("Control sequence sent: " + ch);
CSISequenceHandler handler = sequences.get(ch);
CSIState state = new CSIState(questionMark, greaterThan, dollarSign, hash, quote, singleQuote, space, exclamation);

View File

@@ -11,18 +11,19 @@ public class ECH extends CSISequenceHandler {
public void execute(int[] args, int argCount, CSIState state) {
int chars = args[0];
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
case SIXTEEN_COLOR_BRIGHT -> c = terminal.sixteenColorBright;
default -> c = Terminal.DEFAULT_BACKGROUND_COLOR;
}
if (terminal.currentPrivateModeState.isAltBufferEnabled()) {
int fromIndex = terminal.x + terminal.y * Terminal.WIDTH;
int toIndex = fromIndex + Math.max(Math.min(Math.max(chars, 1), Terminal.WIDTH - terminal.x), 1);
Arrays.fill(terminal.altBuffer, fromIndex, toIndex, ' ');
Arrays.fill(terminal.altColors, fromIndex, toIndex, Terminal.DEFAULT_COLORS.Copy());
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
default -> c = Terminal.DEFAULT_COLORS;
}
Arrays.fill(terminal.altColorsBackground, fromIndex, toIndex, c.Copy());
Arrays.fill(terminal.altStyles, fromIndex, toIndex, Terminal.DEFAULT_STYLE);
} else {
@@ -30,13 +31,6 @@ public class ECH extends CSISequenceHandler {
int toIndex = fromIndex + Math.max(Math.min(Math.max(chars, 1), Terminal.WIDTH - terminal.x), 1);
Arrays.fill(terminal.buffer, fromIndex, toIndex, ' ');
Arrays.fill(terminal.colors, fromIndex, toIndex, Terminal.DEFAULT_COLORS.Copy());
Terminal.ColorData c;
switch (terminal.currentBackgroundColorMode) {
case SIXTEEN_COLOR -> c = terminal.sixteenColor;
case TWO_FIFTY_SIX_COLOR -> c = terminal.twoFiftySixColor;
case TRUE_COLOR -> c = terminal.backgroundColor;
default -> c = Terminal.DEFAULT_COLORS.Copy();
}
Arrays.fill(terminal.colorsBackground, fromIndex, toIndex, c.Copy());
Arrays.fill(terminal.styles, fromIndex, toIndex, Terminal.DEFAULT_STYLE);
}

View File

@@ -40,9 +40,10 @@ public class SGR extends CSISequenceHandler {
switch (arg) {
case 0 -> { // Reset / Normal
terminal.sixteenColor = Terminal.DEFAULT_COLORS.Copy();
terminal.sixteenColorBright = Terminal.DEFAULT_BRIGHT_COLORS.Copy();
terminal.style = Terminal.DEFAULT_STYLE;
terminal.currentForegroundColorMode = Terminal.ColorMode.SIXTEEN_COLOR;
terminal.currentBackgroundColorMode = Terminal.ColorMode.SIXTEEN_COLOR;
terminal.currentBackgroundColorMode = Terminal.ColorMode.DEFAULT_BACKGROUND;
terminal.twoFiftySixColor = Terminal.DEFAULT_256_COLORS.Copy();
terminal.foregroundColor = Terminal.DEFAULT_TRUE_COLOR_FOREGROUND.Copy();
terminal.backgroundColor = Terminal.DEFAULT_TRUE_COLOR_BACKGROUND.Copy();
@@ -51,6 +52,8 @@ public class SGR extends CSISequenceHandler {
terminal.style |= Terminal.STYLE_BOLD_MASK;
case 2 -> // Faint or decreased intensity
terminal.style |= Terminal.STYLE_DIM_MASK;
case 3 ->
terminal.style |= Terminal.STYLE_ITALIC_MASK;
case 4 -> // Underscore
terminal.style |= Terminal.STYLE_UNDERLINE_MASK;
case 5 -> // Blink
@@ -61,6 +64,8 @@ public class SGR extends CSISequenceHandler {
terminal.style |= Terminal.STYLE_HIDDEN_MASK;
case 22 -> // Normal color or intensity
terminal.style &= ~(Terminal.STYLE_BOLD_MASK | Terminal.STYLE_DIM_MASK);
case 23 ->
terminal.style &= ~Terminal.STYLE_ITALIC_MASK;
case 24 -> // Underline off
terminal.style &= ~Terminal.STYLE_UNDERLINE_MASK;
case 25 -> // Blink off
@@ -73,10 +78,18 @@ public class SGR extends CSISequenceHandler {
terminal.currentForegroundColorMode = Terminal.ColorMode.SIXTEEN_COLOR;
terminal.sixteenColor.R = arg - 30;
}
case 40, 41, 42, 43, 44, 45, 46, 47 -> { //47 Set background color
case 40, 41, 42, 43, 44, 45, 46, 47 -> { // Set background color
terminal.currentBackgroundColorMode = Terminal.ColorMode.SIXTEEN_COLOR;
terminal.sixteenColor.G = arg - 40;
}
case 90, 91, 92, 93, 94, 95, 96, 97 -> { // Set foreground color
terminal.currentForegroundColorMode = Terminal.ColorMode.SIXTEEN_COLOR_BRIGHT;
terminal.sixteenColorBright.R = arg - 90;
}
case 100, 101, 102, 103, 104, 105, 106, 107 -> { // Set background color
terminal.currentBackgroundColorMode = Terminal.ColorMode.SIXTEEN_COLOR_BRIGHT;
terminal.sixteenColorBright.G = arg - 100;
}
}
}
}

View File

@@ -26,12 +26,12 @@ public class FontAtlas {
private int currentX = 0; // X coordinate to place next glyph
private int currentY = 0; // Y coordinate to place next glyph
public FontAtlas(int initialWidth, int initialHeight) {
public FontAtlas(int initialWidth, int initialHeight, String fontAtlasName) {
this.atlasWidth = initialWidth;
this.atlasHeight = initialHeight;
this.atlasImage = new NativeImage(atlasWidth, atlasHeight, false);
this.dynamicTexture = new DynamicTexture(atlasImage);
this.resources = ResourceLocation.fromNamespaceAndPath("oc2r", "terminus_font_atlas");
this.resources = ResourceLocation.fromNamespaceAndPath("oc2r", fontAtlasName);
Minecraft.getInstance().getTextureManager().register(resources, dynamicTexture);
this.glyphs = new ArrayList<>();

View File

@@ -8,15 +8,31 @@ import java.io.IOException;
import java.io.InputStream;
public class FontHandling {
public static final Font TerminusFont = loadFont("/assets/oc2r/fonts/terminus.ttf", 32f);
public static final UnicodeFontRenderer unicodeFontRenderer = new UnicodeFontRenderer(TerminusFont);
public static final FontAtlas FontAtlas = new FontAtlas(1024, 1024, "font_atlas");
// Regular
public static final Font RegularFont = loadFont("/assets/oc2r/fonts/monocraft-r.ttf", 32f);
public static final UnicodeFontRenderer regularFontRenderer = new UnicodeFontRenderer(RegularFont, false);
// Bold
public static final Font BoldFont = loadFont("/assets/oc2r/fonts/monocraft-b.ttf", 32f);
public static final UnicodeFontRenderer boldFontRenderer = new UnicodeFontRenderer(BoldFont, false);
// Italic
public static final Font ItalicFont = loadFont("/assets/oc2r/fonts/monocraft-i.ttf", 32f);
public static final UnicodeFontRenderer italicFontRenderer = new UnicodeFontRenderer(ItalicFont, true);
// Bold
public static final Font BoldItalicFont = loadFont("/assets/oc2r/fonts/monocraft-bi.ttf", 32f);
public static final UnicodeFontRenderer boldItalicFontRenderer = new UnicodeFontRenderer(BoldItalicFont, true);
public static Glyph getGlyph(int character) {
return unicodeFontRenderer.getGlyph(character);
public static Glyph getGlyph(int character, FontStyle style) {
return switch (style) {
case REGULAR -> regularFontRenderer.getGlyph(character);
case ITALIC -> italicFontRenderer.getGlyph(character);
case BOLD -> boldFontRenderer.getGlyph(character);
case BOLD_ITALIC -> boldItalicFontRenderer.getGlyph(character);
};
}
public static ResourceLocation getAtlas() {
return unicodeFontRenderer.TerminusFontAtlas.getTextureId();
return FontAtlas.getTextureId();
}
public static Font loadFont(String path, float size) {
@@ -26,8 +42,14 @@ public class FontHandling {
}
return Font.createFont(Font.TRUETYPE_FONT, is).deriveFont(size);
} catch (FontFormatException | IOException e) {
e.printStackTrace();
return new Font("Arial", Font.PLAIN, (int) size); // fallback
}
}
public enum FontStyle {
REGULAR,
ITALIC,
BOLD,
BOLD_ITALIC
}
}

View File

@@ -9,12 +9,13 @@ import java.util.Map;
public class UnicodeFontRenderer {
public final Font font;
public final FontAtlas TerminusFontAtlas = new FontAtlas(512, 512);
private final Map<Integer, Glyph> glyphCache = new HashMap<>();
private final FontRenderContext frc = new FontRenderContext(null, false, false);
private final FontRenderContext frc = new FontRenderContext(null, true, false);
private final boolean isItalic;
public UnicodeFontRenderer(Font font) {
public UnicodeFontRenderer(Font font, boolean isItalic) {
this.font = font;
this.isItalic = isItalic;
String initialSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_+-=_.,:;<>?;':\"\\|`~[]{}1234567890△▽ ";
int[] characters = initialSet.codePoints().toArray();
@@ -29,10 +30,9 @@ public class UnicodeFontRenderer {
private Glyph rasterizeGlyph(int character) {
GlyphVector gv = font.createGlyphVector(frc, Character.toChars(character));
BufferedImage img = new BufferedImage(16, 32, BufferedImage.TYPE_INT_ARGB); // size can be dynamic
BufferedImage img = new BufferedImage((isItalic) ? 44 : 20, 32, BufferedImage.TYPE_INT_ARGB); // size can be dynamic
Graphics2D g = img.createGraphics();
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
g.setFont(font);
g.setColor(Color.WHITE);
@@ -42,9 +42,9 @@ public class UnicodeFontRenderer {
g.drawGlyphVector(gv, 0, ascent - 1);
g.dispose();
Glyph glyph = new Glyph(img, 16, 32, (int) gv.getGlyphMetrics(0).getAdvance());
Glyph glyph = new Glyph(img, (isItalic) ? 44 : 20, 32, (int) gv.getGlyphMetrics(0).getAdvance());
TerminusFontAtlas.addGlyph(glyph);
FontHandling.FontAtlas.addGlyph(glyph);
return glyph;
}
}

View File

@@ -1,9 +1,10 @@
Copyright (c) 2014, Ryan L McIntyre (https://ryanlmcintyre.com).
Copyright (c) 2022, Idrees Hassan (https://github.com/IdreesInc/Monocraft)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
@@ -17,7 +18,7 @@ with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,94 +0,0 @@
Copyright (c) 2019 Dimitar Toshkov Zhekov,
with Reserved Font Name "Terminus Font".
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

View File

@@ -0,0 +1,19 @@
#!/bin/bash
for bg in {40..47}; do
[[ $bg -le 42 ]] && fg=97 || fg=30
printf "\e[2;%s;%sm %3s \e[0m" "$fg" "$bg" "$bg"
done
echo
for bg in {40..47}; do
[[ $bg -le 42 ]] && fg=97 || fg=30
printf "\e[%s;%sm %3s \e[0m" "$fg" "$bg" "$bg"
done
echo
for bg in {100..107}; do
[[ $bg -le 102 ]] && fg=97 || fg=30
printf "\e[%s;%sm %3s \e[0m" "$fg" "$bg" "$bg"
done
echo

View File

@@ -1,36 +0,0 @@
#!/bin/sh
TERMINFO_PROFILE="/etc/profile.d/terminfo.sh"
# Registers terminfo environment variables in global profile config if they don't exist yet
start() {
if [ ! -f $TERMINFO_PROFILE ]; then
echo "TERMINFO=/usr/lib/terminfo/v/vt100" >$TERMINFO_PROFILE
echo "COLUMNS=80" >>$TERMINFO_PROFILE
echo "LINES=24" >>$TERMINFO_PROFILE
fi
return 0
}
stop() {
return 0
}
reload() {
return 0
}
case "$1" in
start | stop | reload)
"$1"
;;
restart)
reload
;;
*)
echo "Usage: $0 {start|stop|reload|restart}"
exit 1
;;
esac
exit $?

View File

@@ -1,43 +0,0 @@
#!/bin/sh
PROFILE_D_PATH="/etc/profile.d"
INIT_SCRIPT_NAME="lua_path.sh"
start() {
INIT_SCRIPT_PATH="$PROFILE_D_PATH/$INIT_SCRIPT_NAME"
if [ ! -f "$INIT_SCRIPT_PATH" ]; then
THIS_SCRIPT_PATH=$(readlink -f "$0")
THIS_SCRIPT_DIR=$(dirname "$THIS_SCRIPT_PATH")
LUA_LIB_PATH=$(readlink -f "$THIS_SCRIPT_DIR/../lib/lua")
echo 'if [ -z "$LUA_PATH" ]; then' >>"$INIT_SCRIPT_PATH"
echo ' export LUA_PATH="/usr/share/lua/5.4/?.lua;'$LUA_LIB_PATH'/?.lua;'$LUA_LIB_PATH'/?/init.lua"' >>"$INIT_SCRIPT_PATH"
echo 'else' >>"$INIT_SCRIPT_PATH"
echo ' export LUA_PATH="$LUA_PATH;/usr/share/lua/5.4/?.lua;'$LUA_LIB_PATH'/?.lua;'$LUA_LIB_PATH'/?/init.lua"' >>"$INIT_SCRIPT_PATH"
echo 'fi' >>"$INIT_SCRIPT_PATH"
fi
return 0
}
stop() {
return 0
}
reload() {
return 0
}
case "$1" in
start | stop | reload)
"$1"
;;
restart)
reload
;;
*)
echo "Usage: $0 {start|stop|reload|restart}"
exit 1
;;
esac
exit $?

View File

@@ -1,43 +0,0 @@
#!/bin/sh
PROFILE_D_PATH="/etc/profile.d"
INIT_SCRIPT_NAME="python_path.sh"
start() {
INIT_SCRIPT_PATH="$PROFILE_D_PATH/$INIT_SCRIPT_NAME"
if [ ! -f "$INIT_SCRIPT_PATH" ]; then
THIS_SCRIPT_PATH=$(readlink -f "$0")
THIS_SCRIPT_DIR=$(dirname "$THIS_SCRIPT_PATH")
PYTHON_LIB_PATH=$(readlink -f "$THIS_SCRIPT_DIR/../lib/micropython")
echo 'if [ -z "$MICROPYPATH" ]; then' >>"$INIT_SCRIPT_PATH"
echo ' export MICROPYPATH="'$PYTHON_LIB_PATH'"' >>"$INIT_SCRIPT_PATH"
echo 'else' >>"$INIT_SCRIPT_PATH"
echo ' export MICROPYPATH="$MICROPYPATH:'$PYTHON_LIB_PATH'"' >>"$INIT_SCRIPT_PATH"
echo 'fi' >>"$INIT_SCRIPT_PATH"
fi
return 0
}
stop() {
return 0
}
reload() {
return 0
}
case "$1" in
start | stop | reload)
"$1"
;;
restart)
reload
;;
*)
echo "Usage: $0 {start|stop|reload|restart}"
exit 1
;;
esac
exit $?