chore: draw + better

main
sudo pacman -Syu 2023-07-23 16:01:42 +07:00
parent ebcdd26a02
commit cb1f44064f
2 changed files with 39 additions and 28 deletions

View File

@ -92,7 +92,7 @@ func Draw(
} }
} }
// Each kemap has many layers // Each keymap has many layers
layersStr := make([]string, 0, len(keymap.Layers)) layersStr := make([]string, 0, len(keymap.Layers))
for iLayer, layer := range keymap.Layers { for iLayer, layer := range keymap.Layers {
// Preprocess table // Preprocess table
@ -118,7 +118,9 @@ func Draw(
} }
// Padding to center key // Padding to center key
padding := (key.NewW - len(keyStr)) / 2 // Why / 2, why - 1 ?
// Base on my feeling of course
padding := (key.NewW-len(keyStr))/2 - 1
if padding <= 0 { if padding <= 0 {
padding = 1 padding = 1
} }
@ -149,7 +151,7 @@ func Draw(
count++ count++
} }
// Postprocess table // Process new table
newTable := make([][]string, 0, newMaxY+1) newTable := make([][]string, 0, newMaxY+1)
for i := 0; i < len(table); i++ { for i := 0; i < len(table); i++ {
@ -186,6 +188,15 @@ func Draw(
} }
newTable = append(newTable, append(paddingRow, "+")) newTable = append(newTable, append(paddingRow, "+"))
// Postprocess new table
for i := 1; i < len(newTable); i++ {
for j := 0; j < len(newTable[i]); j++ {
if newTable[i-1][j] == "|" {
newTable[i][j] = "+"
}
}
}
layerStr := fmt.Sprintf("Layer %d\n", iLayer) layerStr := fmt.Sprintf("Layer %d\n", iLayer)
for i := range newTable { for i := range newTable {
for j := range newTable[i] { for j := range newTable[i] {

View File

@ -2,38 +2,38 @@ Layout LAYOUT_60_tsangan_hhkb
Layer 0 Layer 0
+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| GESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | \ | ` | | GESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | \ | ` |
+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+ +-------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+
| TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | BACKSPACE | | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | BACKSPACE |
+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+ +-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+
| CTRL ESC | A | S | D | F | G | H | J | K | L | ; | ' | SHIFT ENTER | | CTRL ESC | A | S | D | F | G | H | J | K | L | ; | ' | SHIFT ENTER |
+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+ +-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+
| SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | MO(1) | | SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | MO(1) |
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ +-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+
| | ALT | CMD | SPACE | CMD | ALT | | | | ALT | CMD | SPACE | CMD | ALT | |
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ +-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
Layer 1 Layer 1
+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | | | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | |
+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+ +-------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+
| | | | | | | | | | | | UP | | | | | | | | | | | | | | | UP | | |
+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+ +-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+
| | VOLD | VOLU | MUTE | | | | | | | LEFT | RGHT | | | | VOLD | VOLU | MUTE | | | | | | | LEFT | RGHT | |
+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+ +-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+
| | | | | | | | | | | DOWN | | | | | | | | | | | | | | DOWN | | |
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ +-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+
| | TG(2) | | | | | | | | TG(2) | | | | | |
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ +-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
Layer 2 Layer 2
+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| BOOT | | | | | | | | | | | | | | | | BOOT | | | | | | | | | | | | | | |
+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+ +-------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+ +-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+
| CAPSLOCK | RGBH | RGBS | RGBV | | | | | HOME | PGUP | | | | | CAPSLOCK | RGBH | RGBS | RGBV | | | | | HOME | PGUP | | | |
+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+ +-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+
| | | | | | | | | END | PGDN | | | | | | | | | | | | | END | PGDN | | | |
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ +-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+
| | | | | RGBTO | RGBMO | | | | | | | RGBTO | RGBMO | |
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ +-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+