Skip to content

Commit 3d98fb3

Browse files
a4
1 parent 07d2669 commit 3d98fb3

File tree

13 files changed

+249
-109
lines changed

13 files changed

+249
-109
lines changed

src/docs/md/SUPPORT.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22

33
*Please help improve this table.
44

5-
|Code|Name |Windows 10 cmd|Idea run output|
6-
|----|----------|--------------|---------------|
7-
|b |Bold |No |Yes |
8-
|f |Faint |No |No |
9-
|i |Italics |No |Yes |
10-
|u |Underline |Yes |Yes |
11-
| |Blink |No |No |
12-
|rev |Reverse |Yes |Yes |
13-
| |Hide |No |No |
14-
|- |Strike |No |Yes |
15-
| |Fraktur |No |No |
16-
|tu |Underline |No |Yes |
17-
|frm |Frame |No |Yes |
18-
|cir |Encircle |No |Yes |
19-
|o |Overline |No |No |
20-
| |Superscrpt|No |No |
21-
| |Subscrpt |No |No |
5+
| Code | Name | Windows 10 cmd | Idea run output | Html |
6+
|------|---------------|----------------|-----------------|------|
7+
| b | Bold | No | Yes | Yes |
8+
| f | Faint | No | No | Yes |
9+
| i | Italics | No | Yes | Yes |
10+
| u | Underline | Yes | Yes | Yes |
11+
| | Blink | No | No | Yes |
12+
| rev | Reverse | Yes | Yes | No |
13+
| | Hide | No | No | Yes |
14+
| - | Strike | No | Yes | Yes |
15+
| | Fraktur | No | No | Yes |
16+
| bs | Slow Blinking | No | No | Yes |
17+
| bf | Fast Blinking | No | No | Yes |
18+
| tu | Underline | No | Yes | Yes |
19+
| frm | Frame | No | Yes | Yes |
20+
| cir | Encircle | No | Yes | Yes |
21+
| o | Overline | No | No | Yes |
22+
| sup | Superscript | No | No | No |
23+
| sub | Subscript | No | No | No |
2224

2325

2426

src/docs/md/WRITING_A_FORMAT_FOR_DECORATION.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -41,48 +41,48 @@ to create a `Decoration` object to be used for formatting the input text.
4141

4242
*Html not yet supported*
4343

44-
|Token |Usage |Console|Tag |~HTML~ |Note |
45-
|------------------|--------------|-------|-------|-------|-----|
46-
|pre-prefix |here:: |Yes |Yes |Yes | A prefix staying unaffected by format. |
47-
|prefix |::here: |Yes |Yes |Yes | A prefix affected by format. |
48-
|content |:here: |Yes |Yes |Yes | Format codes to be put here. |
49-
|suffix |:here:: |Yes |Yes |Yes | A suffix affected by format. |
50-
|suf-suffix |::here |Yes |Yes |Yes | A suffix staying unaffected by format. |
51-
|Color Tag |$code |Yes |Yes |Yes | To choose a format or color from a set of 16 predefined colors. |
52-
|6 digit hex color |#RRGGBB |Yes |Yes |Yes | To assign a font color using a 6 digit hex number as #RRGGBB. |
53-
|3 digit hex color |#RGB |Yes |Yes |Yes | To assign a font color using a 6 digit hex number as #RGB. |
54-
|1 digit hex color |#G |Yes |Yes |Yes | To assign a font color using a 6 digit hex number as #Grey Scale Value from 0-F. |
55-
|6 digit hex bg |@RRGGBB |Yes |Yes |Yes | To assign a background color using a 6 digit hex number as #RRGGBB. |
56-
|3 digit hex bg |@RGB |Yes |Yes |Yes | To assign a background color using a 6 digit hex number as #RGB. |
57-
|1 digit hex bg |@G |Yes |Yes |Yes | To assign a background color using a 6 digit hex number as #Grey Scale Value from 0-F. |
58-
|Bracket Formats |[code] |Yes |Yes |No | To assign a font color as [RRGGBB]or[RRGGBBAA], background color as [@RRGGBB]or[@RRGGBBAA] or a format as [UNDERLINE],[STRIKE]. |
59-
|Time Format |<format>|Yes |Yes |Yes | To define a time format and put a time string formatted accordingly as pre-prefix. |
60-
|Default Time |T |Yes |Yes |Yes | To put a time string as pre-prefix. |
61-
|Bold |b |Yes |No |Yes | Bold Text |
62-
|Faint |f |No |No |? | Faint/Condensed Text |
63-
|Italics |i |Yes |No |Yes | Italics Text |
64-
|Underline |u |Yes |No |Yes | Underlined Text |
65-
|Reverse |rev |Yes |No |No | Reverses the font and background color |
66-
|Strike |- |Yes |No |Yes | Strikethrough |
67-
|Double Underline |tu |Yes |No |Yes | Thick Underlined Text |
68-
|Frame |frm |Yes |No |? | Put text in a box |
69-
|Encircle |cir |Yes |No |? | Put text in a box* |
70-
|Overline |o |No |No |? | Put a line over the text |
71-
|Format Repeater |~ |Yes |Yes |Yes | To repeat the format for unmatched input strings. |
72-
|String Formatter |%ns |Yes |Yes |? | To format a string to fit 'n' characters, right aligned if positive, left aligned if negative. Give in a * for center align. |
73-
|New Line |n |Yes |Yes |? | To append a new line. |
74-
|Tab Space |t |Yes |Yes |? | To prepend a tab space |
75-
|Word Wrap |wnw |Yes |Yes |? | Word Wrap input to fit a width of 'n' and apply the same format to each line. |
76-
|Splitter |xcx |Yes |Yes |? | Split the given input about each occurrance of 'c'. |
77-
|Repeater |R |Yes |Yes |Yes | Reuse the decorators from start when input exceeds them. |
78-
|Meta Data |P C or M |Yes |Yes |Yes | P -> package name, C -> class name, M -> method name. |
44+
| Token | Usage | Console | Tag | HTML | Note |
45+
|-------------------|--------------------|---------|-----|---------|---------------------------------------------------------------------------------------------------------------------------------|
46+
| pre-prefix | here:: | Yes | Yes | Yes | A prefix staying unaffected by format. |
47+
| prefix | ::here: | Yes | Yes | Yes | A prefix affected by format. |
48+
| content | :here: | Yes | Yes | Yes | Format codes to be put here. |
49+
| suffix | :here:: | Yes | Yes | Yes | A suffix affected by format. |
50+
| suf-suffix | ::here | Yes | Yes | Yes | A suffix staying unaffected by format. |
51+
| Color Tag | $code | Yes | Yes | Yes | To choose a format or color from a set of 16 predefined colors. |
52+
| 6 digit hex color | #RRGGBB | Yes | Yes | Yes | To assign a font color using a 6 digit hex number as #RRGGBB. |
53+
| 3 digit hex color | #RGB | Yes | Yes | Yes | To assign a font color using a 6 digit hex number as #RGB. |
54+
| 1 digit hex color | #G | Yes | Yes | Yes | To assign a font color using a 6 digit hex number as #Grey Scale Value from 0-F. |
55+
| 6 digit hex bg | @RRGGBB | Yes | Yes | Yes | To assign a background color using a 6 digit hex number as #RRGGBB. |
56+
| 3 digit hex bg | @RGB | Yes | Yes | Yes | To assign a background color using a 6 digit hex number as #RGB. |
57+
| 1 digit hex bg | @G | Yes | Yes | Yes | To assign a background color using a 6 digit hex number as #Grey Scale Value from 0-F. |
58+
| Bracket Formats | [code] | Yes | Yes | Yes | To assign a font color as [RRGGBB]or[RRGGBBAA], background color as [@RRGGBB]or[@RRGGBBAA] or a format as [UNDERLINE],[STRIKE]. |
59+
| Time Format | <format> | Yes | Yes | Yes | To define a time format and put a time string formatted accordingly as pre-prefix. |
60+
| Default Time | T | Yes | Yes | Yes | To put a time string as pre-prefix. |
61+
| Bold | b | Yes | No | Yes | Bold Text |
62+
| Faint | f | No | No | Not Yet | Faint/Condensed Text |
63+
| Italics | i | Yes | No | Yes | Italics Text |
64+
| Underline | u | Yes | No | Yes | Underlined Text |
65+
| Reverse | rev | Yes | No | No | Reverses the font and background color |
66+
| Strike | - | Yes | No | Yes | Strikethrough |
67+
| Double Underline | tu | Yes | No | Yes | Thick Underlined Text |
68+
| Frame | frm | Yes | No | Yes | Put text in a box |
69+
| Encircle | cir | Yes | No | Yes | Put text in a box* |
70+
| Overline | o | No | No | Yes | Put a line over the text |
71+
| Format Repeater | ~ | Yes | Yes | Yes | To repeat the format for unmatched input strings. |
72+
| String Formatter | %ns | Yes | Yes | Yes | To format a string to fit 'n' characters, right aligned if positive, left aligned if negative. Give in a * for center align. |
73+
| New Line | n | Yes | Yes | Yes | To append a new line. |
74+
| Tab Space | t | Yes | Yes | Yes | To prepend a tab space |
75+
| Word Wrap | wnw | Yes | Yes | Yes | Word Wrap input to fit a width of 'n' and apply the same format to each line. |
76+
| Splitter | xcx | Yes | Yes | Yes | Split the given input about each occurrance of 'c'. |
77+
| Repeater | R | Yes | Yes | Yes | Reuse the decorators from start when input exceeds them. |
78+
| Meta Data | P C or M | Yes | Yes | Yes | P -> package name, C -> class name, M -> method name. |
79+
7980

8081
* Console -> a Formatting Style to decorate the console outputs.
8182
* Raw -> Just like console but no color/bold/underline... formatting.
8283
* Tags -> a Formatting Style consisting of appending bracketed tags to the input to inform a parser about the text
8384
format. An example of this formatting is used in HyperLap2D to apply simple formatting in it's Console.
84-
* HTML -> currently it's not supported at all... As such it's in my To-Do list, but it's lack of use is kinda pushing it
85-
behind of other features.
85+
* HTML -> Most features are supported, though it needs some perfection.
8686

8787
#### Structure of a formatting code
8888

src/main/java/com/mcxiv/logger/decorations/ConsoleDecoration.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ public ConsoleDecoration(Decorations.Tag tag, String... codes) {
4949

5050
if (tag != null) {
5151
String brush = "";
52-
if (sp.content.contains("P")) brush += "[" + tag.packageName + "]";
53-
if (sp.content.contains("C")) brush += "[" + tag.className + "]";
54-
if (sp.content.contains("M")) brush += "[" + tag.executableName + "]";
52+
String subcont = sp.content.replaceAll("<.*>", "");
53+
if (subcont.contains("P")) brush += "[" + tag.packageName + "]";
54+
if (subcont.contains("C")) brush += "[" + tag.className + "]";
55+
if (subcont.contains("M")) brush += "[" + tag.executableName + "]";
5556
if (!brush.equals("")) sp.prepre = brush + " " + sp.prepre;
5657
}
5758
format.append(sp.prepre);
@@ -126,12 +127,18 @@ public ConsoleDecoration(Decorations.Tag tag, String... codes) {
126127
// Parsing other formatting chars
127128

128129
if (sp.content.contains("rev")) format.append(C.FR);
130+
sp.content = sp.content.replace("rev", "");
129131
if (sp.content.contains("frm")) format.append(C.FFr);
132+
sp.content = sp.content.replace("frm", "");
130133
if (sp.content.contains("cir")) format.append(C.FCr);
134+
sp.content = sp.content.replace("cir", "");
131135

132136
// if (sp.content.contains("bs")) format.append(C.BlS);
133-
// if (sp.content.contains("bf")) format.append(C.BlS);
137+
sp.content = sp.content.replace("bs", "");
138+
// if (sp.content.contains("bf")) format.append(C.BlF);
139+
sp.content = sp.content.replace("bf", "");
134140
if (sp.content.contains("tu")) format.append(C.FUt);
141+
sp.content = sp.content.replace("tu", "");
135142

136143
if (sp.content.contains("b")) format.append(C.FB);
137144
if (sp.content.contains("f")) format.append(C.FFa);
@@ -186,7 +193,7 @@ else if (sp.content.contains("~")) {
186193

187194

188195
// Applying Basic post Formatting
189-
decorates[i] = DecorationCommonResolvers.CommonFormattingResolver(m, sp.content, decorates[i], "\n");
196+
decorates[i] = DecorationCommonResolvers.CommonFormattingResolver(m, sp.content, decorates[i], " ", "\n");
190197

191198

192199
}

src/main/java/com/mcxiv/logger/decorations/Decoration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public Decoration(Decorations.Tag tag, String... codes) {
3838
static Pattern re_SBcolor = Pattern.compile("([\\[][@]([A-Fa-f0-9]{6,8})[]])");
3939

4040

41-
public static String center(int len, String txt) {
41+
public static String center(int len, String txt, String space) {
4242
txt = String.format("%" + (len - txt.length()) / 2 + "s", " ") + txt;
43-
return String.format("%-" + len + "s", txt);
43+
return String.format("%-" + len + "s", txt).replace(" ", space);
4444
}
4545

4646
public String decorate(String... input) {

src/main/java/com/mcxiv/logger/decorations/DecorationCommonResolvers.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010
public class DecorationCommonResolvers {
1111

1212

13-
public static Decorate CommonFormattingResolver(Matcher m, String content, Decorate decorate, String new_line) {
14-
decorate = CenterFormattingResolver(m, content, decorate);
13+
public static Decorate CommonFormattingResolver(Matcher m, String content, Decorate decorate, String space, String new_line) {
14+
decorate = CenterFormattingResolver(m, content, decorate, space);
1515
decorate = WordWarpFormattingResolver(m, content, decorate, new_line);
1616
decorate = SplittingFormattingResolver(m, content, decorate);
1717
return decorate;
1818
}
1919

20-
public static Decorate CenterFormattingResolver(Matcher m, String content, Decorate decorate) {
20+
public static Decorate CenterFormattingResolver(Matcher m, String content, Decorate decorate, String space) {
2121
if ((m = re_centerFormatting.matcher(content)).find()) {
2222
int len = Integer.parseInt(m.group(1));
2323
final Decorate new_d = decorate;
24-
return s -> new_d.decorate(Decoration.center(len, s));
24+
return s -> new_d.decorate(Decoration.center(len, s, space));
2525
}
2626
return decorate;
2727
}
@@ -75,7 +75,7 @@ public static Decorate WordRepeaterFormattingResolver(Matcher m, String content,
7575
if ((m = re_wordRepeater.matcher(content)).find()) {
7676
int len = Integer.parseInt(m.group(1));
7777
final Decorate new_d = decorate;
78-
return s -> new_d.decorate(Decoration.center(len, s));
78+
return s -> new_d.decorate(Decoration.center(len, s, " "));
7979
}
8080
return decorate;
8181
}

0 commit comments

Comments
 (0)