feat: draw more symbol
parent
23591893b3
commit
3add32406c
2
Makefile
2
Makefile
|
@ -15,7 +15,7 @@ clean:
|
|||
|
||||
draw:
|
||||
curl https://raw.githubusercontent.com/qmk/qmk_firmware/master/keyboards/dztech/dz60rgb_wkl/info.json --output dztech_dz60rgb_wkl/info.json
|
||||
QMK_INFO=dztech_dz60rgb_wkl/info.json QMK_KEYMAP=dztech_dz60rgb_wkl/keymaps_json/haunt98/keymap.json go run ./cmd/asciigen/*.go > dztech_dz60rgb_wkl/asciiart/haunt98.txt
|
||||
QMK_INFO=dztech_dz60rgb_wkl/info.json QMK_KEYMAP=dztech_dz60rgb_wkl/keymaps_json/haunt98/keymap.json OUT=dztech_dz60rgb_wkl/asciiart/haunt98.txt go run ./cmd/asciigen/*.go
|
||||
|
||||
dztech_dz60rgb_wkl:
|
||||
# Copy
|
||||
|
|
|
@ -1,10 +1,42 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
scaleX = 8
|
||||
scaleY = 3
|
||||
)
|
||||
|
||||
var mapSpecialKey = map[string]string{
|
||||
"KC_TRNS": " ",
|
||||
"KC_NO": " ",
|
||||
"KC_LGUI": "⌘",
|
||||
"KC_RGUI": "⌘",
|
||||
"KC_LALT": "⌥",
|
||||
"KC_RALT": "⌥",
|
||||
"KC_LSFT": "⇧",
|
||||
"KC_RSFT": "⇧",
|
||||
"KC_TAB": "↹ ",
|
||||
"KC_CAPS": "⇪",
|
||||
"QK_GESC": "⎋",
|
||||
"CTL_T(KC_ESC)": "⌃",
|
||||
}
|
||||
|
||||
var mapSpecialKeyWidthLimit = map[string]int{
|
||||
"KC_LGUI": 1,
|
||||
"KC_RGUI": 1,
|
||||
"KC_LALT": 1,
|
||||
"KC_RALT": 1,
|
||||
"KC_LSFT": 1,
|
||||
"KC_RSFT": 1,
|
||||
"KC_TAB": 1,
|
||||
"KC_CAPS": 1,
|
||||
"QK_GESC": 1,
|
||||
"CTL_T(KC_ESC)": 1,
|
||||
}
|
||||
|
||||
func Draw(
|
||||
layouts map[string]map[string][]QMKKeyDictionary,
|
||||
keymap QMKKeymap,
|
||||
|
@ -33,7 +65,6 @@ func Draw(
|
|||
keys[i].H = 1
|
||||
}
|
||||
|
||||
// TODO: Better way to handle this
|
||||
// Because 0.25
|
||||
keys[i].NewX = int(keys[i].X * scaleX)
|
||||
keys[i].NewY = int(keys[i].Y * scaleY)
|
||||
|
@ -59,14 +90,27 @@ func Draw(
|
|||
// Fill layout
|
||||
count := 0
|
||||
for _, key := range keys {
|
||||
originalKeyStr := layer[count]
|
||||
keyStr := layer[count]
|
||||
keyWidthLimit := key.NewW - 2
|
||||
|
||||
// TODO: Better way to handle this
|
||||
if len(keyStr) > keyWidthLimit {
|
||||
keyStr = keyStr[:keyWidthLimit]
|
||||
} else {
|
||||
keyWidthLimit = len(keyStr)
|
||||
// Process keyStr
|
||||
if newKeyStr, ok := mapSpecialKey[keyStr]; ok {
|
||||
keyStr = newKeyStr
|
||||
} else if strings.HasPrefix(keyStr, "KC_") {
|
||||
keyStr = strings.TrimPrefix(keyStr, "KC_")
|
||||
} else if strings.HasPrefix(keyStr, "QK_") {
|
||||
keyStr = strings.TrimPrefix(keyStr, "QK_")
|
||||
}
|
||||
|
||||
keyWidthLimit, existKeyWidthLimit := mapSpecialKeyWidthLimit[originalKeyStr]
|
||||
if !existKeyWidthLimit {
|
||||
keyWidthLimit = key.NewW - 3
|
||||
|
||||
if len(keyStr) > keyWidthLimit {
|
||||
keyStr = keyStr[:keyWidthLimit]
|
||||
} else {
|
||||
keyWidthLimit = len(keyStr)
|
||||
}
|
||||
}
|
||||
|
||||
for i := key.NewY; i < key.NewY+key.NewH; i++ {
|
||||
|
@ -81,8 +125,18 @@ func Draw(
|
|||
// Write key in the middle
|
||||
if j == key.NewX {
|
||||
table[i][j] = "|"
|
||||
} else if j < key.NewX+keyWidthLimit+1 {
|
||||
table[i][j] = string(keyStr[j-key.NewX-1])
|
||||
} else if j > key.NewX+1 && j < key.NewX+keyWidthLimit+2 {
|
||||
if existKeyWidthLimit {
|
||||
// Special key can be Unicode
|
||||
// So ignore get single character of keyStr
|
||||
if j == key.NewX+2 {
|
||||
table[i][j] = keyStr
|
||||
} else {
|
||||
table[i][j] = ""
|
||||
}
|
||||
} else {
|
||||
table[i][j] = string(keyStr[j-key.NewX-2])
|
||||
}
|
||||
} else {
|
||||
table[i][j] = " "
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
@ -18,6 +17,11 @@ func main() {
|
|||
log.Fatalln("ENV QMK_KEYMAP empty")
|
||||
}
|
||||
|
||||
filenameOut := os.Getenv("OUT")
|
||||
if filenameOut == "" {
|
||||
log.Fatalln("ENV OUT empty")
|
||||
}
|
||||
|
||||
bytesInfo, err := os.ReadFile(filenameInfo)
|
||||
if err != nil {
|
||||
log.Fatalln("Failed to read file", filenameInfo, err)
|
||||
|
@ -42,5 +46,8 @@ func main() {
|
|||
qmkInfo.Layouts,
|
||||
qmkKeymap,
|
||||
)
|
||||
fmt.Println(result)
|
||||
|
||||
if err := os.WriteFile(filenameOut, []byte(result), 0o644); err != nil {
|
||||
log.Fatalln("Failed to write file", filenameOut, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,36 @@
|
|||
+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
|QK_GES |KC_1 |KC_2 |KC_3 |KC_4 |KC_5 |KC_6 |KC_7 |KC_8 |KC_9 |KC_0 |KC_MIN |KC_EQL |KC_BSL |KC_GRV |
|
||||
| ⎋ | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | MINS | EQL | BSLS | GRV |
|
||||
+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+
|
||||
|KC_TAB |KC_Q |KC_W |KC_E |KC_R |KC_T |KC_Y |KC_U |KC_I |KC_O |KC_P |KC_LBR |KC_RBR |KC_BSPC |
|
||||
| ↹ | Q | W | E | R | T | Y | U | I | O | P | LBRC | RBRC | BSPC |
|
||||
+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+
|
||||
|CTL_T(KC_ESC |KC_A |KC_S |KC_D |KC_F |KC_G |KC_H |KC_J |KC_K |KC_L |KC_SCL |KC_QUO |KC_ENT |
|
||||
| ⌃ | A | S | D | F | G | H | J | K | L | SCLN | QUOT | ENT |
|
||||
+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+
|
||||
|KC_LSFT |KC_Z |KC_X |KC_C |KC_V |KC_B |KC_N |KC_M |KC_COM |KC_DOT |KC_SLS |KC_RSFT |MO(1) |
|
||||
| ⇧ | Z | X | C | V | B | N | M | COMM | DOT | SLSH | ⇧ | MO(1) |
|
||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||
|KC_NO |KC_LAL |KC_LGUI |KC_SPC |KC_RGUI |KC_RAL |KC_NO |
|
||||
| | ⌥ | ⌘ | SPC | ⌘ | ⌥ | |
|
||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||
|
||||
+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
|KC_GRV |KC_F1 |KC_F2 |KC_F3 |KC_F4 |KC_F5 |KC_F6 |KC_F7 |KC_F8 |KC_F9 |KC_F10 |KC_F11 |KC_F12 |KC_TRN |KC_TRN |
|
||||
| GRV | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | |
|
||||
+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+
|
||||
|KC_TRNS |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_UP |KC_TRN |KC_TRNS |
|
||||
| | | | | | | | | | | | UP | | |
|
||||
+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+
|
||||
|KC_TRNS |KC_VOL |KC_VOL |KC_MUT |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_LEF |KC_RGH |KC_TRNS |
|
||||
| | VOLD | VOLU | MUTE | | | | | | | LEFT | RGHT | |
|
||||
+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+
|
||||
|KC_TRNS |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_DOW |KC_TRNS |KC_TRN |
|
||||
| | | | | | | | | | | DOWN | | |
|
||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||
|KC_NO |TG(2) |KC_TRNS |KC_TRNS |KC_TRNS |KC_TRN |KC_NO |
|
||||
| | TG(2) | | | | | |
|
||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||
|
||||
+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
|
||||
|QK_BOO |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |
|
||||
| BOOT | | | | | | | | | | | | | | |
|
||||
+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+
|
||||
|KC_TRNS |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRNS |
|
||||
| | | | | | | | | | | | | | |
|
||||
+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+
|
||||
|KC_CAPS |RGB_HU |RGB_SA |RGB_VA |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_HOM |KC_PGU |KC_TRN |KC_TRN |KC_TRNS |
|
||||
| ⇪ | RGB_H | RGB_S | RGB_V | | | | | HOME | PGUP | | | |
|
||||
+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+
|
||||
|KC_TRNS |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_TRN |KC_END |KC_PGD |KC_TRN |KC_TRNS |KC_TRN |
|
||||
| | | | | | | | | END | PGDN | | | |
|
||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||
|KC_NO |KC_TRN |KC_TRNS |KC_TRNS |RGB_TOG |RGB_MO |KC_NO |
|
||||
| | | | | RGB_TOG | RGB_M | |
|
||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue