-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathscroll_mode.lua
More file actions
122 lines (112 loc) · 4.39 KB
/
scroll_mode.lua
File metadata and controls
122 lines (112 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
local wezterm = require("wezterm")
local act = wezterm.action
local modal = wezterm.plugin.require("https://github.com/MLFlexer/modal.wezterm")
---Create status text with hints
---@param hint_icons {left_seperator: string, key_hint_seperator: string, mod_seperator: string}
---@param hint_colors {key_hint_seperator: string, key: string, hint: string, bg: string, left_bg: string}
---@param mode_colors {bg: string, fg: string}
---@return string
local function get_hint_status_text(hint_icons, hint_colors, mode_colors)
return wezterm.format({
{ Foreground = { Color = hint_colors.bg } },
{ Background = { Color = hint_colors.left_bg } },
{ Text = hint_icons.left_seperator },
{ Background = { Color = hint_colors.bg } },
-- ...
{ Foreground = { Color = hint_colors.key } },
{ Text = "Shift?" },
{ Text = hint_icons.mod_seperator },
{ Text = "jk: " },
{ Foreground = { Color = hint_colors.hint } },
{ Text = "Line scroll" },
{ Foreground = { Color = hint_colors.key_hint_seperator } },
{ Text = hint_icons.key_hint_seperator },
-- ...
{ Foreground = { Color = hint_colors.key } },
{ Text = "Shift?" },
{ Text = hint_icons.mod_seperator },
{ Text = "d/u: " },
{ Foreground = { Color = hint_colors.hint } },
{ Text = "Page scroll" },
{ Foreground = { Color = hint_colors.key_hint_seperator } },
{ Text = hint_icons.key_hint_seperator },
-- ...
{ Foreground = { Color = hint_colors.key } },
{ Text = "{/}, p/n: " },
{ Foreground = { Color = hint_colors.hint } },
{ Text = "Prev/Next prompt" },
{ Foreground = { Color = hint_colors.key_hint_seperator } },
{ Text = hint_icons.key_hint_seperator },
-- ...
{ Foreground = { Color = hint_colors.key } },
{ Text = "g/G: " },
{ Foreground = { Color = hint_colors.hint } },
{ Text = "top/bottom" },
{ Foreground = { Color = hint_colors.key_hint_seperator } },
{ Text = hint_icons.key_hint_seperator },
-- ...
{ Foreground = { Color = hint_colors.key } },
{ Text = "z: " },
{ Foreground = { Color = hint_colors.hint } },
{ Text = "Zoom" },
{ Foreground = { Color = hint_colors.key_hint_seperator } },
{ Text = hint_icons.key_hint_seperator },
-- ...
{ Foreground = { Color = hint_colors.key } },
{ Text = "v: " },
{ Foreground = { Color = hint_colors.hint } },
{ Text = "Copy mode " },
-- ...
{ Attribute = { Intensity = "Bold" } },
{ Foreground = { Color = mode_colors.bg } },
{ Text = hint_icons.left_seperator },
{ Foreground = { Color = mode_colors.fg } },
{ Background = { Color = mode_colors.bg } },
{ Text = "Scroll " },
})
end
---Create mode status text
---@param bg string
---@param fg string
---@param left_seperator string
---@return string
local function get_mode_status_text(left_seperator, bg, fg)
return wezterm.format({
{ Attribute = { Intensity = "Bold" } },
{ Foreground = { Color = bg } },
{ Text = left_seperator },
{ Foreground = { Color = fg } },
{ Background = { Color = bg } },
{ Text = "Scroll " },
})
end
return {
get_mode_status_text = get_mode_status_text,
get_hint_status_text = get_hint_status_text,
key_table = {
-- Cancel the mode by pressing escape
{ key = "Escape", action = modal.exit_mode("scroll_mode") },
{ key = "c", mods = "CTRL", action = modal.exit_mode("scroll_mode") },
{ key = "UpArrow", action = act.ScrollByLine(-1) },
{ key = "DownArrow", action = act.ScrollByLine(1) },
{ key = "k", action = act.ScrollByLine(-1) },
{ key = "j", action = act.ScrollByLine(1) },
{ key = "UpArrow", mods = "SHIFT", action = act.ScrollByLine(-5) },
{ key = "DownArrow", mods = "SHIFT", action = act.ScrollByLine(5) },
{ key = "K", mods = "SHIFT", action = act.ScrollByLine(-5) },
{ key = "J", mods = "SHIFT", action = act.ScrollByLine(5) },
{ key = "u", action = act.ScrollByPage(-0.5) },
{ key = "d", action = act.ScrollByPage(0.5) },
{ key = "U", mods = "SHIFT", action = act.ScrollByPage(-1) },
{ key = "D", mods = "SHIFT", action = act.ScrollByPage(1) },
{ key = "p", action = act.ScrollToPrompt(-1) },
{ key = "n", action = act.ScrollToPrompt(1) },
{ key = "{", action = act.ScrollToPrompt(-1) },
{ key = "}", action = act.ScrollToPrompt(1) },
{ key = "g", action = act.ScrollToTop },
{ key = "G", mods = "SHIFT", action = act.ScrollToBottom },
{ key = "z", action = wezterm.action.TogglePaneZoomState },
{ key = "v", action = modal.activate_mode("copy_mode") },
{ key = "/", action = modal.activate_mode("search_mode") },
},
}