summaryrefslogtreecommitdiffstats
path: root/.gitattributes
AgeCommit message (Expand)Author
2016-10-07.gitattributes: set git diff driver for C source code filesJean Delvare
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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
package main

import (
	"strings"
)

// GenerateSetCommandHelpSections generates help documentation for the set command
func GenerateSetCommandHelpSections(config Config) (helpSections []*HelpSection) {
	description := []HelpSectionText{
		{text: "set", themeComponentID: CmpHelpViewSectionSubTitle},
		{},
		{text: "The set command allows configuration variables to be set. It has the form:"},
		{},
		{text: "set variable value", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "For example, to set the tab width to tab width to 4, the currently active theme to \"mytheme\" and enable mouse support:"},
		{},
		{text: "set tabwidth 4", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "set theme mytheme", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "set mouse true", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "GRV currently has the following themes available:"},
		{},
		{text: " - solarized"},
		{text: " - classic"},
		{text: " - cold"},
		{},
		{text: "The solarized theme is the default theme for GRV and does not respect the terminals colour palette."},
		{text: "The classic and cold themes do respect the terminals colour palette."},
	}

	return []*HelpSection{
		{
			description: description,
		},
	}
}

// GenerateThemeCommandHelpSections generates help documentation for the theme command
func GenerateThemeCommandHelpSections(config Config) (helpSections []*HelpSection) {
	description := []HelpSectionText{
		{text: "theme", themeComponentID: CmpHelpViewSectionSubTitle},
		{},
		{text: "The theme command allows a custom theme to be defined."},
		{text: "This theme can then be activated using the theme config variable described above."},
		{text: "The form of the theme command is:"},
		{},
		{text: "theme --name [ThemeName] --component [ComponentId] --bgcolor [BackgroundColor] --fgcolor [ForegroundColor]", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: " - ThemeName: The name of the theme to be created/updated."},
		{text: " - ComponentId: The Id of the screen component (the part of the display to change)."},
		{text: " - BackgroundColor: The background color."},
		{text: " - ForegroundColor: The foreground color."},
		{},
		{text: "Using a sequence of theme commands it is possible to define a theme."},
		{text: "For example, to define a new theme \"mytheme\" and set it as the active theme:"},
		{},
		{text: "theme --name mytheme --component CommitView.Date      --bgcolor None --fgcolor Red", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "theme --name mytheme --component RefView.Tag          --bgcolor Blue --fgcolor 36", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "theme --name mytheme --component StatusBarView.Normal --bgcolor None --fgcolor f14a98", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "set theme mytheme", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "GRV supports 256 colors (when available). Provided colors will be mapped to the nearest available color."},
		{text: "The allowed color values are:"},
		{},
		{text: "System colors:"},
		{},
		{text: "None", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "Black", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "Red", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "Green", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "Yellow", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "Blue", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "Magenta", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "Cyan", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "White", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "Terminal Color Numbers:"},
		{},
		{text: "0 - 255", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "Hex Colors:"},
		{},
		{text: "000000 - ffffff", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "The set of screen components that can be customised is:"},
		{},
	}

	var prevPrefix string
	for _, themeComponent := range ThemeComponentNames() {
		prefix := strings.Split(themeComponent, ".")[0]

		if prevPrefix != "" && prevPrefix != prefix {
			description = append(description, HelpSectionText{themeComponentID: CmpHelpViewSectionCodeBlock})
		}

		prevPrefix = prefix
		description = append(description, HelpSectionText{text: themeComponent, themeComponentID: CmpHelpViewSectionCodeBlock})
	}

	return []*HelpSection{
		{
			description: description,
		},
	}
}

// GenerateMapCommandHelpSections generates help documentation for the map command
func GenerateMapCommandHelpSections(config Config) (helpSections []*HelpSection) {
	description := []HelpSectionText{
		{text: "map", themeComponentID: CmpHelpViewSectionSubTitle},
		{},
		{text: "The map command allows a key sequence to be mapped to an action, another key sequence or a shell command for a specified view."},
		{text: "The form of the map command is:"},
		{},
		{text: "map view fromkeys tokeys", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "For example, to map the key 'a' to the keys 'gg' in the Ref View:"},
		{},
		{text: "map RefView a gg", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "When pressing 'a' in the Ref View, the first line would then become the selected line, as 'gg' moves the cursor to the first line."},
		{text: "All is a valid view argument when a binding should apply to all views."},
		{},
		{text: "GRV also has a text representation of actions that are independent of key bindings."},
		{text: "For example, the following commands can be used to make the <Up> key move a line down and the <Down> key move a line up:"},
		{},
		{text: "map All <Up> <grv-next-line>", themeComponentID: CmpHelpViewSectionCodeBlock},
		{text: "map All <Down> <grv-prev-line>", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "The map command also allows a key sequence to be mapped directly to a shell command."},
		{text: "Prefix a shell command with the '!' character. For example, to map the key 'a' to the shell command 'ls -lh':"},
		{},
		{text: "map All a !ls -lh", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "The set of actions available is described in the key binding tables above."},
	}

	return []*HelpSection{
		{
			description: description,
		},
	}
}

// GenerateUnmapCommandHelpSections generates help documentation for the unmap command
func GenerateUnmapCommandHelpSections(config Config) (helpSections []*HelpSection) {
	description := []HelpSectionText{
		{text: "unmap", themeComponentID: CmpHelpViewSectionSubTitle},
		{},
		{text: "The unmap command removes any defined key binding for a key sequence in the specified view."},
		{text: "The form of the unmap command is:"},
		{},
		{text: "unmap view fromkeys", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "For example, to unmap the key 'c' in the Ref View:"},
		{},
		{text: "unmap RefView c", themeComponentID: CmpHelpViewSectionCodeBlock},
	}

	return []*HelpSection{
		{
			description: description,
		},
	}
}

// GenerateQuitCommandHelpSections generates help documentation for the quit command
func GenerateQuitCommandHelpSections(config Config) (helpSections []*HelpSection) {
	description := []HelpSectionText{
		{text: "q", themeComponentID: CmpHelpViewSectionSubTitle},
		{},
		{text: "The quit command is used to exit GRV and can be used with the following keys:"},
		{},
		{text: ":q<Enter>", themeComponentID: CmpHelpViewSectionCodeBlock},
	}

	return []*HelpSection{
		{
			description: description,
		},
	}
}

// GenerateAddTabCommandHelpSections generates help documentation for the addtab command
func GenerateAddTabCommandHelpSections(config Config) (helpSections []*HelpSection) {
	description := []HelpSectionText{
		{text: "addtab", themeComponentID: CmpHelpViewSectionSubTitle},
		{},
		{text: "The addtab command creates a new named empty tab and switches to this new tab."},
		{text: "The format of the command is:"},
		{},
		{text: "addtab tabname", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "For example, to add a new tab titled \"mycustomtab\" the following command can be used:"},
		{},
		{text: "addtab mycustomtab", themeComponentID: CmpHelpViewSectionCodeBlock},
	}

	return []*HelpSection{
		{
			description: description,
		},
	}
}

// GenerateRmTabCommandHelpSections generates help documentation for the rmtab command
func GenerateRmTabCommandHelpSections(config Config) (helpSections []*HelpSection) {
	description := []HelpSectionText{
		{text: "rmtab", themeComponentID: CmpHelpViewSectionSubTitle},
		{},
		{text: "The rmtab removes the currently active tab. If the tab removed is the last tab then GRV will exit."},
	}

	return []*HelpSection{
		{
			description: description,
		},
	}
}

// GenerateAddViewCommandHelpSections generates help documentation for the addview command
func GenerateAddViewCommandHelpSections(config Config) (helpSections []*HelpSection) {
	description := []HelpSectionText{
		{text: "addview", themeComponentID: CmpHelpViewSectionSubTitle},
		{},
		{text: "The addview command allows a view to be added to the currently active tab."},
		{text: "The form of the command is:"},
		{},
		{text: "addview view viewargs...", themeComponentID: CmpHelpViewSectionCodeBlock},
		{},
		{text: "Each view accepts a different set of arguments. This is described in the table below:"},
	}

	helpSections = append(helpSections, &HelpSection{
		<