11package consts
22
33import (
4+ "fmt"
5+
46 "github.com/charmbracelet/bubbles/key"
7+ "github.com/seth-shi/go-v2ex/v2/styles"
58)
69
710type KeyMap struct {
@@ -34,7 +37,7 @@ func (k KeyMap) FullHelp() [][]key.Binding {
3437 {
3538 k .Up , k .Down , k .Left , k .Right ,
3639 k .Tab , k .ShiftTab ,
37- k .KeyE , k .KeyQ , k .KeyR ,
40+ k .KeyQ , k .KeyE , k .KeyR ,
3841 }, // first column
3942 {
4043 k .CtrlQuit , k .HelpPage , k .SettingPage ,
@@ -44,6 +47,13 @@ func (k KeyMap) FullHelp() [][]key.Binding {
4447 }
4548}
4649
50+ var (
51+ topicPageTitle = styles .Active .Bold (true ).Render ("[主题页]" )
52+ allPageTitle = styles .Active .Underline (true ).Render ("[任意页]" )
53+ detailPageTitle = styles .Err .Bold (true ).Render ("[详情页]" )
54+ settingPageTitle = styles .Err .Underline (true ).Render ("[配置页]" )
55+ )
56+
4757// AppKeyMap
4858// vim key bind style : https://github.com/philc/vimium#keyboard-bindings
4959// ? show the help dialog for a list of all available keys
@@ -54,66 +64,66 @@ func (k KeyMap) FullHelp() [][]key.Binding {
5464var AppKeyMap = KeyMap {
5565 Up : key .NewBinding (
5666 key .WithKeys ("w" , "up" , "k" ),
57- key .WithHelp ("w/↑" , "[主题页]列表上一个" ),
67+ key .WithHelp ("w/↑" , fmt . Sprintf ( "%s列表上一个" , topicPageTitle ) ),
5868 ),
5969 Down : key .NewBinding (
6070 key .WithKeys ("s" , "down" , "j" ),
61- key .WithHelp ("s/↓" , "[主题页]列表下一个" ),
71+ key .WithHelp ("s/↓" , fmt . Sprintf ( "%s列表下一个" , topicPageTitle ) ),
6272 ),
6373 Left : key .NewBinding (
6474 key .WithKeys ("a" , "left" , "h" ),
65- key .WithHelp ("a/←" , "[主题页]上一页" ),
75+ key .WithHelp ("a/←" , fmt . Sprintf ( "%s上一页" , topicPageTitle ) ),
6676 ),
6777 Right : key .NewBinding (
6878 key .WithKeys ("d" , "right" , "l" ),
69- key .WithHelp ("d/→" , "[主题页]下一页" ),
79+ key .WithHelp ("d/→" , fmt . Sprintf ( "%s下一页" , topicPageTitle ) ),
7080 ),
7181 KeyQ : key .NewBinding (
7282 key .WithKeys ("q" , "H" ),
73- key .WithHelp ("q" , "返回上一页" ),
83+ key .WithHelp ("q" , fmt . Sprintf ( "%s返回上一页" , allPageTitle ) ),
7484 ),
7585 HelpPage : key .NewBinding (
7686 key .WithKeys ("?" ),
77- key .WithHelp ("?" , "查看帮助页面 (再按一次返回首页)" ),
87+ key .WithHelp ("?" , fmt . Sprintf ( "%s查看帮助页面 (再按一次返回首页)", allPageTitle ) ),
7888 ),
7989 SettingPage : key .NewBinding (
8090 key .WithKeys ("`" ),
81- key .WithHelp ("`" , "[反引号]进入配置页面 (再按一次返回首页)" ),
91+ key .WithHelp ("`" , fmt . Sprintf ( "%s反引号:查看帮助页面 (再按一次返回首页)", allPageTitle ) ),
8292 ),
8393 Tab : key .NewBinding (
8494 key .WithKeys ("tab" ),
85- key .WithHelp ("tab" , "[主题页]下一个节点" ),
86- ),
87- Space : key .NewBinding (
88- key .WithKeys (" " ),
89- key .WithHelp ("空格" , "老板键" ),
95+ key .WithHelp ("tab" , fmt .Sprintf ("%s下一个节点" , topicPageTitle )),
9096 ),
9197 ShiftTab : key .NewBinding (
9298 key .WithKeys ("shift+tab" ),
93- key .WithHelp ("shift+tab" , "[主题页]上一个切点" ),
99+ key .WithHelp ("shift+tab" , fmt .Sprintf ("%s上一个切点" , topicPageTitle )),
100+ ),
101+ Space : key .NewBinding (
102+ key .WithKeys (" " ),
103+ key .WithHelp ("空格" , fmt .Sprintf ("%s老板键" , allPageTitle )),
94104 ),
95105 CtrlQuit : key .NewBinding (
96106 key .WithKeys ("esc" , "ctrl+c" ),
97- key .WithHelp ("esc" , "退出程序" ),
98- ),
99- KeyE : key .NewBinding (
100- key .WithKeys ("e" , "enter" , "o" ),
101- key .WithHelp ("e/enter" , "[主题页]查看主题详情 / [详情页]加载评论" ),
107+ key .WithHelp ("esc" , fmt .Sprintf ("%s退出程序" , allPageTitle )),
102108 ),
103109 SwitchShowMode : key .NewBinding (
104110 key .WithKeys ("=" ),
105- key .WithHelp ("=" , "[等于号]切换底部显示隐藏" ),
111+ key .WithHelp ("=" , fmt .Sprintf ("%s等于号:切换底部显示隐藏" , allPageTitle )),
112+ ),
113+ KeyE : key .NewBinding (
114+ key .WithKeys ("e" , "enter" , "o" ),
115+ key .WithHelp ("e/enter" , fmt .Sprintf ("%s查看主题详情 / %s加载评论" , topicPageTitle , detailPageTitle )),
106116 ),
107117 KeyR : key .NewBinding (
108118 key .WithKeys ("r" ),
109- key .WithHelp ("r" , "[主题页]切换接口版本 / [详情页]加载图片" ),
119+ key .WithHelp ("r" , fmt . Sprintf ( "%s切换接口版本 / %s解码内容(图片/base64)" , topicPageTitle , detailPageTitle ) ),
110120 ),
111121 UpgradeApp : key .NewBinding (
112- key .WithKeys ("ctrl+ u" ),
113- key .WithHelp ("ctrl+ u" , "更新应用(需要网络可以访问 github)" ),
122+ key .WithKeys ("u" ),
123+ key .WithHelp ("u" , fmt . Sprintf ( "%s更新应用" , allPageTitle ) ),
114124 ),
115125 F1 : key .NewBinding (
116126 key .WithKeys ("f1" ),
117- key .WithHelp ("f1" , "[详情页]打开链接 / [配置页]打开配置文件" ),
127+ key .WithHelp ("f1" , fmt . Sprintf ( "%s浏览器打开 / %s打开配置文件" , topicPageTitle , settingPageTitle ) ),
118128 ),
119129}
0 commit comments