chore: better draw this time
parent
ebb4bebfae
commit
258c3966c4
|
@ -93,16 +93,10 @@ func Draw(
|
||||||
|
|
||||||
// Padding to center key
|
// Padding to center key
|
||||||
padding := (key.NewW - len(keyStr)) / 2
|
padding := (key.NewW - len(keyStr)) / 2
|
||||||
if padding == 0 {
|
if padding <= 0 {
|
||||||
padding = 1
|
padding = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
keyWidthLimit := key.NewW - padding
|
|
||||||
|
|
||||||
if len(keyStr) > keyWidthLimit {
|
|
||||||
keyStr = keyStr[:keyWidthLimit]
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := key.NewY; i < key.NewY+key.NewH; i++ {
|
for i := key.NewY; i < key.NewY+key.NewH; i++ {
|
||||||
for j := key.NewX; j < key.NewX+key.NewW; j++ {
|
for j := key.NewX; j < key.NewX+key.NewW; j++ {
|
||||||
if i == key.NewY {
|
if i == key.NewY {
|
||||||
|
@ -115,12 +109,8 @@ func Draw(
|
||||||
// Write key in the middle
|
// Write key in the middle
|
||||||
if j == key.NewX {
|
if j == key.NewX {
|
||||||
table[i][j] = "|"
|
table[i][j] = "|"
|
||||||
} else if j > key.NewX+padding && j <= key.NewX+len(keyStr)+padding {
|
} else if j > key.NewX+padding && j < key.NewX+len(keyStr)+padding+1 && j <= key.NewX+key.NewW-padding {
|
||||||
if j == key.NewX+padding+1 {
|
table[i][j] = string(keyStr[j-key.NewX-padding-1])
|
||||||
table[i][j] = keyStr
|
|
||||||
} else {
|
|
||||||
table[i][j] = ""
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
table[i][j] = " "
|
table[i][j] = " "
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,10 @@
|
||||||
+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+
|
+-----------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------+
|
||||||
| | | | | | | | | | | | | | |
|
| | | | | | | | | | | | | | |
|
||||||
+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+
|
+-------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-----------------+
|
||||||
| CAPSLOCK | RGB_HUI| RGB_SAI| RGB_VAI| | | | | HOME | PGUP | | | |
|
| CAPSLOCK | RGB_HU| RGB_SA| RGB_VA| | | | | HOME | PGUP | | | |
|
||||||
+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+
|
+-----------------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------------+-------+
|
||||||
| | | | | | | | | END | PGDN | | | |
|
| | | | | | | | | END | PGDN | | | |
|
||||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||||
| | | | | RGB_TOG | RGB_MOD| |
|
| | | | | RGB_TOG | RGB_MO| |
|
||||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue