Skip to content

Commit e655bf7

Browse files
committed
support customize every buttons' attributes and add new layout example
1 parent fb80e2f commit e655bf7

7 files changed

Lines changed: 256 additions & 74 deletions

File tree

layouts/40.tvkl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#border_color = @($255, $255, $255)
22
#highlight = @($225, $225, $225)
3+
#tab_len = $6
34

4-
:| Tab [$6] | Q | W | E | R | T | Y | U | I | O | P | Back [$7] |-
5+
:| Tab [#tab_len] | Q | W | E | R | T | Y | U | I | O | P | Back [$7] |-
56
:| Caps [$7] | A | S | D | F | G | H | J | K | L | Enter [$8] |-
67
:| LShift [$8] | '/' | Z | X | C | V | B | N | M | ',' | '.' | RShift [$8] |-
78
:| LCtrl [$7] | Win [$6] | LAlt [$7] | Space | RAlt [$7] | App [$6] | RCtrl [$7] |-

layouts/60.tvkl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
:| Esc [$5] | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | '-' | '=' | Back [$8] |-
1+
#border_color = @($255, $255, $255)
2+
#highlight = @($225, $225, $225)
3+
#esc_len = $5
4+
#esc_color = @($201, $113, $217)
5+
6+
:| Esc [#esc_len,,#esc_color] | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | '-' | '=' | Back [$8] |-
27
:| Tab [$7] | Q | W | E | R | T | Y | U | I | O | P | '[' | ']' | '\' [$6] |-
38
:| Caps [$8] | A | S | D | F | G | H | J | K | L | ';' | "'" | Enter [$9] |-
49
:| LShift [$10] | Z | X | C | V | B | N | M | ',' | '.' | '/' | RShift [$11] |-
510
:| LCtrl [$7] | Win [$5] | LAlt [$6] | Space [$20] | RAlt [$6] | Win [$5] | App [$5] | RCtrl [$7] |-
11+
12+

layouts/60_2.tvkl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#border_color = @($60, $60, $60)
2+
#highlight = @($0, $255, $255)
3+
4+
#fn_border = @($100, $100, $100)
5+
#fn_highlight = @($255, $0, $255)
6+
#esc_color = @($201, $113, $217)
7+
#enter_color = @($255, $150, $0)
8+
9+
#esc_len = $6
10+
#mod_len = $7
11+
#space_len = $21
12+
13+
:| Esc [#esc_len,,#esc_color] | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | '-' | '=' | Back [$9,,#fn_border] |-
14+
:| Tab [$8,,#fn_border] | Q | W | E | R | T | Y | U | I | O | P | '[' | ']' | '\' [$7,,#fn_border] |-
15+
:| Caps [$10,,#fn_border] | A | S | D | F | G | H | J | K | L | ';' | "'" | Enter [$10,,#enter_color] |-
16+
:| LShift [$12,,#fn_border] | Z | X | C | V | B | N | M | ',' | '.' | '/' | RShift [$13,,#fn_border] |-
17+
:| LCtrl [#mod_len,,#fn_border] | Win [$5,,#fn_border] | LAlt [#mod_len,,#fn_border] | Space [#space_len] | RAlt [#mod_len,,#fn_border] | Win [$5,,#fn_border] | App [$6,,#fn_border] | RCtrl [#mod_len,,#fn_border] |-

src/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::sync::Arc;
22
use std::collections::HashMap;
33

4-
#[derive(Debug)]
4+
#[derive(Debug, Copy, Clone)]
55
pub enum Value {
66
Number(u16),
77
RGB(u8, u8, u8)

src/layout.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
1+
use ratatui::style::Color;
12
use rdev::Key;
23
use std::sync::Arc;
34

45
#[derive(Debug)]
56
pub struct Layout {
6-
pub layer: Vec<Vec<Button>>
7+
pub layer: Vec<Vec<Button>>,
78
}
89

910
#[derive(Debug)]
10-
pub struct Button {
11+
pub struct Attr {
1112
pub width: u16,
12-
pub binds: Vec<(Arc<str>, Option<Key>)>
13+
pub height: u16,
14+
pub border_color: Option<Color>,
15+
pub highlight: Option<Color>,
16+
}
17+
18+
impl Attr {
19+
pub fn default(name: &str) -> Self {
20+
let width = match name.to_lowercase().as_str() {
21+
"space" => 20,
22+
_ => 4,
23+
};
24+
Self {
25+
width,
26+
height: 3,
27+
border_color: None,
28+
highlight: None,
29+
}
30+
}
1331
}
1432

33+
#[derive(Debug)]
34+
pub struct Button {
35+
pub attr: Attr,
36+
pub binds: Vec<(Arc<str>, Option<Key>)>,
37+
}

0 commit comments

Comments
 (0)