From 30037dde369cc3ab81355bbc6ab354bb930fb257 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Sun, 23 Jul 2023 06:55:16 +0700 Subject: [PATCH] feat: draw layer --- cmd/asciigen/draw.go | 13 +++++++------ dztech_dz60rgb_wkl/asciiart/haunt98.txt | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/asciigen/draw.go b/cmd/asciigen/draw.go index a89e0a6..38bf813 100644 --- a/cmd/asciigen/draw.go +++ b/cmd/asciigen/draw.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "strings" ) @@ -86,7 +87,7 @@ func Draw( } } - for _, layer := range keymap.Layers { + for iLayer, layer := range keymap.Layers { // Preprocess table table := make([][]string, newMaxY) for i := 0; i < newMaxY; i++ { @@ -139,11 +140,11 @@ func Draw( count++ } - // Postprecess table + // Postprocess table newTable := make([][]string, 0, newMaxY+1) - // Remove empty row for i := 0; i < len(table); i++ { + // Remove empty row isEmptyRow := true for j := 0; j < len(table[i]); j++ { if table[i][j] != " " { @@ -156,7 +157,7 @@ func Draw( continue } - // Padding + // Padding on most right paddingRight := "|" if table[i][len(table[i])-1] == "-" { paddingRight = "+" @@ -165,7 +166,7 @@ func Draw( newTable = append(newTable, append(table[i], paddingRight)) } - // Padding + // Padding on bottom paddingRow := make([]string, 0, newMaxX) for j := 0; j < newMaxX; j++ { paddingBottom := "-" @@ -176,7 +177,7 @@ func Draw( } newTable = append(newTable, append(paddingRow, "+")) - str := "" + str := fmt.Sprintf("Layer %d\n", iLayer) for i := range newTable { for j := range newTable[i] { str += newTable[i][j] diff --git a/dztech_dz60rgb_wkl/asciiart/haunt98.txt b/dztech_dz60rgb_wkl/asciiart/haunt98.txt index 8f51fae..45ba894 100644 --- a/dztech_dz60rgb_wkl/asciiart/haunt98.txt +++ b/dztech_dz60rgb_wkl/asciiart/haunt98.txt @@ -1,3 +1,4 @@ +Layer 0 +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ | GESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | \ | ` | +-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+ @@ -10,6 +11,7 @@ | | ALT | CMD | SPACE | CMD | ALT | | +-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ +Layer 1 +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | | | +-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+ @@ -22,6 +24,7 @@ | | TG(2) | | | | | | +-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+ +Layer 2 +-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+ | BOOT | | | | | | | | | | | | | | | +-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+