feat: draw layer
parent
fc19297f77
commit
30037dde36
|
@ -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]
|
||||
|
|
|
@ -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 | | | | | | | | | | | | | | |
|
||||
+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+
|
||||
|
|
Loading…
Reference in New Issue