Skip to content

Commit a20d3ca

Browse files
authored
Merge pull request #226 from Kray-G/develop
Updated for v1.0.0
2 parents cf0c16e + f9ae44b commit a20d3ca

File tree

19 files changed

+294
-73
lines changed

19 files changed

+294
-73
lines changed

.gitignore

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*.output
99
*.c.parser
1010
*.o
11+
*.a
1112
*.so*
1213
*.dep
1314
*.zip
@@ -18,6 +19,9 @@ myacc
1819
/kinxpkg
1920
/benchmark
2021
/bench
22+
src/opt*.c
23+
src/extlib/onig
24+
src/extlib/libclipboard
2125
timeit.dat
2226
/x86.ins
2327
/x64.ins
@@ -34,13 +38,19 @@ kx.tab.h
3438
package_win64.zip
3539
temp*
3640
TEMP*
37-
src/opt*.c
38-
/KiTTy_jp.json
39-
/KiTTy_jp.pdf
4041
/memo.*
4142
/kinx
43+
/kxkitty
4244
/kxrepl
45+
/kxsel
4346
/kxtest
47+
/main_kxcmd
48+
/build/kinx
49+
/build/kxkitty
50+
/build/kxrepl
51+
/build/kxsel
52+
/build/kxtest
53+
/build/main_kxcmd
4454
/*.so*
4555
/TEST.md
4656
/*.deb

build/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ DOCDIR = ../docs
88
DEPFILE = Makefile.dep
99
CDIR = $(PWD)
1010

11+
VER_HASH := $(shell git rev-parse HEAD)
1112
CC = gcc
1213
GCCV8 := $(shell expr `gcc -dumpversion | cut -f1 -d.` \>= 8)
1314
#CFLAGS = -DKX_PROFILE -DKX_DIRECT_THREAD -DYYMALLOC=kx_malloc -DYYFREE=kx_free -I$(INCDIR) -O2 \
1415
-fno-crossjumping -Wno-unused-result -Wno-missing-braces -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast
15-
CFLAGS = -DKX_DIRECT_THREAD -DYYMALLOC=kx_malloc -DYYFREE=kx_free -I$(INCDIR) -O2 \
16+
CFLAGS = -DKX_DIRECT_THREAD -DYYMALLOC=kx_malloc -DYYFREE=kx_free -DVER_HASH=$(VER_HASH) -I$(INCDIR) -O2 \
1617
-fno-crossjumping -Wno-trigraphs -Wno-unused-result -Wno-missing-braces \
1718
-Wno-int-to-pointer-cast -Wno-pointer-to-int-cast
1819
ifeq "$(GCCV8)" "1"

build/Makefile.msc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ SRCDIR = ..\src
22
INCDIR = ../include
33
CC = cl
44
RC = rc
5-
CFLAGS = /nologo /O2 /MT /I$(INCDIR) /I$(SRCDIR)/jit /DYYMALLOC=kx_malloc /DYYFREE=kx_free
5+
CFLAGS = /nologo /O2 /MT /I$(INCDIR) /I$(SRCDIR)/jit /DYYMALLOC=kx_malloc /DYYFREE=kx_free /DVER_HASH=$(VER_HASH)
66
OBJS = \
77
$(SRCDIR)/allocator.obj \
88
$(SRCDIR)/alloccore.obj \

build/kinx.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
KINXICO ICON "kinxi.ico"
44

55
VS_VERSION_INFO VERSIONINFO
6-
FILEVERSION 0,23,0,0
7-
PRODUCTVERSION 0,23,0,0
6+
FILEVERSION 1,0,0,0
7+
PRODUCTVERSION 1,0,0,0
88
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
99
FILEFLAGS 0x00000000L
1010
FILEOS VOS__WINDOWS32
@@ -22,12 +22,12 @@ BEGIN
2222
BEGIN
2323
VALUE "CompanyName", "-"
2424
VALUE "FileDescription", "The Script Kinx"
25-
VALUE "FileVersion", "0.23.0.0\0"
25+
VALUE "FileVersion", "1.0.0.0\0"
2626
VALUE "InternalName", "Kinx\0"
2727
VALUE "LegalCopyright", "Copyright (C) 2019-2021 Kray-G\0"
2828
VALUE "OriginalFilename", "kinx.exe\0"
2929
VALUE "ProductName", "Kinx\0"
30-
VALUE "ProductVersion", "0.23.0.0\0"
30+
VALUE "ProductVersion", "1.0.0.0\0"
3131
END
3232
END
3333
END

build/make.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
if "%1" == "" (
44
if exist "..\kinx.exe" (
5-
..\kinx.exe utility\VersionSetup.kx 0.23.0
5+
..\kinx.exe utility\VersionSetup.kx 1.0.0
66
)
77
cl.exe /DWINMAIN /Feaddpath.exe utility\src\addpath.c Advapi32.lib User32.lib /link /SUBSYSTEM:WINDOWS
88
cl.exe /Feaddpathc.exe utility\src\addpath.c Advapi32.lib User32.lib
99
cl.exe /Feecho.exe utility\src\kecho.c
1010
)
11+
for /f "usebackq" %%A in (`git rev-parse HEAD`) do set VER_HASH=%%A
1112

1213
if "%1" == "rebuild" goto REBUILD
1314
nmake -f Makefile.msc %*

build/mkdeb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ checkinstall -D -y \
99
--nodoc \
1010
--reset-uids=yes \
1111
--pkgname=kinx \
12-
--pkgversion="0.23.0" \
12+
--pkgversion="1.0.0" \
1313
--pkgrelease="0" \
1414
--pkggroup="kinx" \
1515
--arch=amd64 \

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ The functionality is very simple but powerful, so a lot of developpers will use
152152
* [System](spec/lib/basic/system.md)
153153
* [Getopt](spec/lib/basic/getopt.md)
154154
* [Iconv](spec/lib/basic/iconv.md)
155+
* [Colorize](spec/lib/basic/colorize.md)
155156
* [Math](spec/lib/basic/imath.md)
156157
* [File](spec/lib/basic/file.md)
157158
* [Directory](spec/lib/basic/directory.md)
23.1 KB
Loading

docs/spec/lib/basic/colorize.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Colorize
2+
3+
## Overview
4+
5+
`Colorize` is a library of coloring and decorating a string by Escape Sequence.
6+
There are 2 ways of decoration.
7+
8+
1. Use a `String` methods directly.
9+
2. Use a `Colorize` class.
10+
11+
Here it is described about `Colorize` class.
12+
See [String](../primitive/string.md) for how to use `String` methods directly.
13+
14+
## Colorize
15+
16+
### Method Chain
17+
18+
`Colorize` have following methods to change an attribute of a string.
19+
20+
| Method | Meaning |
21+
| ------------- | ---------------------------------------------- |
22+
| `black()` | Sets black as a foreground color. |
23+
| `red()` | Sets red as a foreground color. |
24+
| `green()` | Sets green as a foreground color. |
25+
| `yellow()` | Sets yellow as a foreground color. |
26+
| `blue()` | Sets blue as a foreground color. |
27+
| `magenta()` | Sets magenta as a foreground color. |
28+
| `cyan()` | Sets cyan as a foreground color. |
29+
| `white()` | Sets white as a foreground color. |
30+
| `onBlack()` | Sets black as a background color. |
31+
| `onRed()` | Sets red as a background color. |
32+
| `onGreen()` | Sets green as a background color. |
33+
| `onYellow()` | Sets yellow as a background color. |
34+
| `onBlue()` | Sets blue as a background color. |
35+
| `onMagenta()` | Sets magenta as a background color. |
36+
| `onCyan()` | Sets cyan as a background color. |
37+
| `onWhite()` | Sets white as a background color. |
38+
| `bold()` | Sets a bold style. |
39+
| `underline()` | Sets an uderline. |
40+
| `reverse()` | Exchanges a foreground and a background color. |
41+
| `clear()` | Clears all attributes. |
42+
| `end()` | Ends a right previous attribute change. |
43+
| `text(str)` | Sets a text with a changed attribute. |
44+
45+
### Parsing String
46+
47+
The `parse` method of a `Colorize` instance will recognize some tags for coloring and decorating.
48+
49+
| Method | Meaning |
50+
| ---------------------------- | ---------------------------------------------- |
51+
| `<black>...</black>` | Sets black as a foreground color. |
52+
| `<red>...</red>` | Sets red as a foreground color. |
53+
| `<green>...</green>` | Sets green as a foreground color. |
54+
| `<yellow>...</yellow>` | Sets yellow as a foreground color. |
55+
| `<blue>...</blue>` | Sets blue as a foreground color. |
56+
| `<magenta>...</magenta>` | Sets magenta as a foreground color. |
57+
| `<cyan>...</cyan>` | Sets cyan as a foreground color. |
58+
| `<white>...</white>` | Sets white as a foreground color. |
59+
| `<onBlack>...</onBlack>` | Sets black as a background color. |
60+
| `<onRed>...</onRed>` | Sets red as a background color. |
61+
| `<onGreen>...</onGreen>` | Sets green as a background color. |
62+
| `<onYellow>...</onYellow>` | Sets yellow as a background color. |
63+
| `<onBlue>...</onBlue>` | Sets blue as a background color. |
64+
| `<onMagenta>...</onMagenta>` | Sets magenta as a background color. |
65+
| `<onCyan>...</onCyan>` | Sets cyan as a background color. |
66+
| `<onWhite>...</onWhite>` | Sets white as a background color. |
67+
| `<bold>..</bold>` | Sets a bold style. |
68+
| `<underline>..</underline>` | Sets an uderline. |
69+
| `<reverse>..</reverse>` | Exchanges a foreground and a background color. |
70+
71+
You can use tags above as follows.
72+
73+
```javascript
74+
var colorize = new Colorize();
75+
System.println(colorize.parse("<yellow><bold>Yellow</bold> Text</yellow>"));
76+
```
77+
78+
## Output Example
79+
80+
Here is an example.
81+
82+
```javascript
83+
var colorize = new Colorize();
84+
System.println(
85+
"Head:" +
86+
colorize
87+
.red()
88+
.text("Red")
89+
.bold()
90+
.text("Red/Bold")
91+
.yellow()
92+
.text("Yellow/Bold")
93+
.onRed()
94+
.underline()
95+
.text("Yellow/Bold/Underlined")
96+
.end() // Underline ended
97+
.text("<-->")
98+
.end() // BgColor
99+
.end() // Yellow ended
100+
.text("Red/Bold")
101+
.end() // Bold ended
102+
.text("Red")
103+
+ ":Tail"
104+
);
105+
106+
System.println(
107+
colorize.parse(
108+
"<red>"
109+
"Yes, "
110+
"<yellow>"
111+
"<underline>\\<bv\\></underline>"
112+
" at <bold>the <onRed>bottom,"
113+
" or <reverse><blink>top</blink></reverse></onRed></bold>"
114+
" of <underline>row</underline>"
115+
"</yellow>"
116+
"</red>"
117+
)
118+
);
119+
```
120+
121+
Here is an actual result.
122+
123+
![](../../images/colorize_example.png)
124+

docs/utility/repl.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ You can also use `!` with the history number to execute the line by selecting th
305305

306306
```
307307
kinx[ 36]> !34
308-
=> "sample.sum();"
308+
=> "sample.sum()"
309309
=> 270
310310
```
311311

0 commit comments

Comments
 (0)