~chrisppy/titan

ref: 17021ce9af427a5abc0c22eb490324b3b383a007 titan/help.go -rw-r--r-- 3.3 KiB
17021ce9Chris Palmer add theming for tabs and scroll bar 3 months ago
                                                                                
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// This file is part of titan.
//
// Copyright © 2020-2021 Chris Palmer <chris@red-oxide.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package main

import (
	"fmt"

	"code.rocketnine.space/tslocum/cview"
	"github.com/gdamore/tcell/v2"
)

const helpText = `titan v%s is available under the terms of the GPL-3.0 license.
Copyright © 2020-2021  Chris Palmer <chris@red-oxide.org>
https://git.sr.ht/~chrisppy/titan

KEYS:
	%s
		display browser page

	%s
		display help page

	%s
		move to the left section (if applicable)

	%s
		navigate down in the current section (if applicable)

	%s
		navigate up in the current section (if applicable)

	%s
		move the the right section (if applicable)

	%s
		navigate upward quicker (if applicable)

	%s
		navigate downward quicker (if applicable)

	%s
		enter command mode with :open
	
	%s
		enter command mode with :open-tab

	%s
		close current tab

	%s
		navigate to the previous page on the current tab

	%s
		navigate to the next page on the current tab
	
	0-9
		navigate to the link with the corresponding number
	
	:
		enter command mode

COMMANDS:
	open gemini://url
		opens gemini capsule in current tab
	
	open 0
		opens [0] capsule on current capsule in current tab
	
	open-tab gemini://url
		opens gemini capsule in new tab
	
	open-tab 0
		opens [0] capsule on current capsule in new tab

	help,h
		display help page

	quit,q
		exit the application

SEE ALSO:
	Additional information can be found in the manual pages:
		titan(1)
		titan-config(5)
`

func (a *app) loadHelpPanel() {
	content := fmt.Sprintf(helpText,
		Version,
		a.Config.BrowserPage.Text,
		a.Config.HelpPage.Text,
		a.Config.NavLeft.Text,
		a.Config.NavDown.Text,
		a.Config.NavUp.Text,
		a.Config.NavRight.Text,
		a.Config.NavPageUp.Text,
		a.Config.NavPageDown.Text,
		a.Config.Open.Text,
		a.Config.OpenTab.Text,
		a.Config.CloseTab.Text,
		a.Config.Back.Text,
		a.Config.Forward.Text,
	)

	a.UI.HelpPanel.Content = cview.NewTextView()
	a.UI.HelpPanel.Content.SetTextAlign(cview.AlignLeft)
	a.UI.HelpPanel.Content.SetScrollable(true)
	a.UI.HelpPanel.Content.SetWrap(true)
	a.UI.HelpPanel.Content.SetWordWrap(true)
	a.UI.HelpPanel.Content.SetDynamicColors(true)
	a.UI.HelpPanel.Content.SetBackgroundColor(a.Config.Theme.ContentBGColor)
	a.UI.HelpPanel.Content.SetTextColor(a.Config.Theme.ContentTextColor)
	a.UI.HelpPanel.Content.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { return nil })
	a.UI.HelpPanel.Content.SetText(content)
	a.UI.HelpPanel.Content.ScrollToBeginning()

	a.UI.HelpPanel.View = cview.NewFlex()
	a.UI.HelpPanel.View.SetDirection(cview.FlexColumn)
	a.UI.HelpPanel.View.AddItem(a.UI.HelpPanel.Content, 0, 1, false)

	a.UI.Panels.AddPanel("help", a.UI.HelpPanel.View, true, true)
}