From cb1f44064f485a6d067ba45c14409f5a37b23d2a Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Sun, 23 Jul 2023 16:01:42 +0700 Subject: [PATCH] chore: draw + better --- cmd/asciigen/draw.go | 17 +++++++-- dztech_dz60rgb_wkl/asciiart/haunt98.txt | 50 ++++++++++++------------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/cmd/asciigen/draw.go b/cmd/asciigen/draw.go index 784f658..b6d65ba 100644 --- a/cmd/asciigen/draw.go +++ b/cmd/asciigen/draw.go @@ -92,7 +92,7 @@ func Draw( } } - // Each kemap has many layers + // Each keymap has many layers layersStr := make([]string, 0, len(keymap.Layers)) for iLayer, layer := range keymap.Layers { // Preprocess table @@ -118,7 +118,9 @@ func Draw( } // 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 { padding = 1 } @@ -149,7 +151,7 @@ func Draw( count++ } - // Postprocess table + // Process new table newTable := make([][]string, 0, newMaxY+1) for i := 0; i < len(table); i++ { @@ -186,6 +188,15 @@ func Draw( } 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) for i := range newTable { for j := range newTable[i] { diff --git a/dztech_dz60rgb_wkl/asciiart/haunt98.txt b/dztech_dz60rgb_wkl/asciiart/haunt98.txt index 27f4453..876cdf1 100644 --- a/dztech_dz60rgb_wkl/asciiart/haunt98.txt +++ b/dztech_dz60rgb_wkl/asciiart/haunt98.txt @@ -1,39 +1,39 @@ Layout LAYOUT_60_tsangan_hhkb Layer 0 +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| GESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | \ | ` | -+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+ -| 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 | -+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+ -| SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | MO(1) | -+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ -| | ALT | CMD | SPACE | CMD | ALT | | +| GESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | \ | ` | ++-------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+ +| 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 | ++-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+ +| SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | MO(1) | ++-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+ +| | ALT | CMD | SPACE | CMD | ALT | | +-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ Layer 1 +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | | -+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+ -| | | | | | | | | | | | UP | | | -+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+ -| | VOLD | VOLU | MUTE | | | | | | | LEFT | RGHT | | -+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+ -| | | | | | | | | | | DOWN | | | -+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ +| ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | | ++-------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+ +| | | | | | | | | | | | UP | | | ++-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+ +| | VOLD | VOLU | MUTE | | | | | | | LEFT | RGHT | | ++-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+ +| | | | | | | | | | | DOWN | | | ++-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+ | | TG(2) | | | | | | +-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ Layer 2 +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ -| BOOT | | | | | | | | | | | | | | | -+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+ +| BOOT | | | | | | | | | | | | | | | ++-------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+ | | | | | | | | | | | | | | | -+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+ -| CAPSLOCK | RGBH | RGBS | RGBV | | | | | HOME | PGUP | | | | -+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+ -| | | | | | | | | END | PGDN | | | | -+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ -| | | | | RGBTO | RGBMO | | ++-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+ +| CAPSLOCK | RGBH | RGBS | RGBV | | | | | HOME | PGUP | | | | ++-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+ +| | | | | | | | | END | PGDN | | | | ++-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+ +| | | | | RGBTO | RGBMO | | +-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+