mirror of
https://github.com/cheat/cheat.git
synced 2025-09-01 17:48:30 +02:00
Compare commits
67 Commits
Author | SHA1 | Date | |
---|---|---|---|
e3764b81e7 | |||
3786ac96a5 | |||
4cb7a3b42c | |||
ff6a866abe | |||
2e7ccb2a68 | |||
126231db1f | |||
91f0d02de2 | |||
815e714fb4 | |||
bd3986a051 | |||
f47b75edc0 | |||
180ee20f77 | |||
9b86c583f8 | |||
e1f7828869 | |||
7f3ae2ab30 | |||
bbd03a1bb8 | |||
326c54147b | |||
efcedaedec | |||
301cbefb0c | |||
9a481f7e75 | |||
e2920bd922 | |||
973a1f59ea | |||
3afea0972c | |||
f86633ca1c | |||
a01a3491a4 | |||
daa43d3867 | |||
e94a1e22df | |||
5046975a0f | |||
198156a299 | |||
a7067279df | |||
a8e6fdb18a | |||
bbfa4efdb7 | |||
741ad91389 | |||
573d43a7e6 | |||
879e8f2be4 | |||
eab3c14f1f | |||
9a6130b6b7 | |||
aeaf01e1de | |||
09c29a322f | |||
0525b2331b | |||
27a4991a3a | |||
4dda412dcb | |||
bfb60764ad | |||
3a97c680bb | |||
edc0fe41ef | |||
9e49bf8e9c | |||
50dc3c8b29 | |||
e08a4f3cec | |||
d6ebe0799d | |||
51aaaf3423 | |||
197ff58796 | |||
b8f512aae8 | |||
e7a1a296e3 | |||
f7c093bec0 | |||
c47b7f81aa | |||
52081b97ac | |||
1dda796e7c | |||
67469b0afa | |||
4f8431a600 | |||
5301442f7c | |||
cd45efcdec | |||
c31786fc5b | |||
934c36ad77 | |||
2c0099c28a | |||
33ac3d34d1 | |||
749173f1f6 | |||
33e33dc7b7 | |||
201cd1d629 |
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Submit a bug report
|
||||||
|
title: ''
|
||||||
|
labels: 'bug'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Thanks for submitting a bug report. Please provide the following information:
|
||||||
|
|
||||||
|
**A description of the problem**
|
||||||
|
Describe the problem here.
|
||||||
|
|
||||||
|
**cheat version info**
|
||||||
|
Please paste the output of `cheat -v` here.
|
||||||
|
|
||||||
|
**cheat configuration info**
|
||||||
|
If your bug pertains to how cheatsheets are loaded and/or displayed, please
|
||||||
|
paste here the following information:
|
||||||
|
|
||||||
|
1. The output of `cheat -d`
|
||||||
|
2. The contents of your `conf.yml` file
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: 'enhancement'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
dist
|
dist
|
||||||
|
tags
|
||||||
|
@ -2,3 +2,10 @@ language: go
|
|||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.13.x
|
- 1.13.x
|
||||||
|
|
||||||
|
env:
|
||||||
|
- GO111MODULE=on
|
||||||
|
|
||||||
|
install: true
|
||||||
|
|
||||||
|
script: make ci
|
||||||
|
154
Makefile
Normal file
154
Makefile
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
# paths
|
||||||
|
makefile := $(realpath $(lastword $(MAKEFILE_LIST)))
|
||||||
|
cmd_dir := ./cmd/cheat
|
||||||
|
dist_dir := ./dist
|
||||||
|
|
||||||
|
# executables
|
||||||
|
CAT := cat
|
||||||
|
COLUMN := column
|
||||||
|
CTAGS := ctags
|
||||||
|
GO := go
|
||||||
|
GREP := grep
|
||||||
|
GZIP := gzip --best
|
||||||
|
LINT := revive
|
||||||
|
MKDIR := mkdir -p
|
||||||
|
RM := rm
|
||||||
|
SCC := scc
|
||||||
|
SED := sed
|
||||||
|
SORT := sort
|
||||||
|
ZIP := zip -m
|
||||||
|
|
||||||
|
# build flags
|
||||||
|
BUILD_FLAGS := -ldflags="-s -w" -mod vendor -trimpath
|
||||||
|
GOBIN :=
|
||||||
|
|
||||||
|
# release binaries
|
||||||
|
releases := \
|
||||||
|
$(dist_dir)/cheat-darwin-amd64 \
|
||||||
|
$(dist_dir)/cheat-linux-amd64 \
|
||||||
|
$(dist_dir)/cheat-linux-arm5 \
|
||||||
|
$(dist_dir)/cheat-linux-arm6 \
|
||||||
|
$(dist_dir)/cheat-linux-arm7 \
|
||||||
|
$(dist_dir)/cheat-windows-amd64.exe
|
||||||
|
|
||||||
|
## build: builds an executable for your architecture
|
||||||
|
.PHONY: build
|
||||||
|
build: $(dist_dir)
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $(dist_dir)/cheat $(cmd_dir)
|
||||||
|
|
||||||
|
## build-release: builds release executables
|
||||||
|
.PHONY: build-release
|
||||||
|
build-release: $(releases)
|
||||||
|
|
||||||
|
## ci: builds a "release" executable for the current architecture (used in ci)
|
||||||
|
.PHONY: ci
|
||||||
|
ci: | setup prepare build
|
||||||
|
|
||||||
|
# cheat-darwin-amd64
|
||||||
|
$(dist_dir)/cheat-darwin-amd64: prepare
|
||||||
|
GOARCH=amd64 GOOS=darwin \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@
|
||||||
|
|
||||||
|
# cheat-linux-amd64
|
||||||
|
$(dist_dir)/cheat-linux-amd64: prepare
|
||||||
|
GOARCH=amd64 GOOS=linux \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@
|
||||||
|
|
||||||
|
# cheat-linux-arm5
|
||||||
|
$(dist_dir)/cheat-linux-arm5: prepare
|
||||||
|
GOARCH=arm GOOS=linux GOARM=5 \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@
|
||||||
|
|
||||||
|
# cheat-linux-arm6
|
||||||
|
$(dist_dir)/cheat-linux-arm6: prepare
|
||||||
|
GOARCH=arm GOOS=linux GOARM=6 \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@
|
||||||
|
|
||||||
|
# cheat-linux-arm7
|
||||||
|
$(dist_dir)/cheat-linux-arm7: prepare
|
||||||
|
GOARCH=arm GOOS=linux GOARM=7 \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(GZIP) $@
|
||||||
|
|
||||||
|
# cheat-windows-amd64
|
||||||
|
$(dist_dir)/cheat-windows-amd64.exe: prepare
|
||||||
|
GOARCH=amd64 GOOS=windows \
|
||||||
|
$(GO) build $(BUILD_FLAGS) -o $@ $(cmd_dir) && $(ZIP) $@.zip $@
|
||||||
|
|
||||||
|
# ./dist
|
||||||
|
$(dist_dir):
|
||||||
|
$(MKDIR) $(dist_dir)
|
||||||
|
|
||||||
|
.PHONY: generate
|
||||||
|
generate:
|
||||||
|
$(GO) generate $(cmd_dir)
|
||||||
|
|
||||||
|
## install: builds and installs cheat on your PATH
|
||||||
|
.PHONY: install
|
||||||
|
install:
|
||||||
|
$(GO) install $(BUILD_FLAGS) $(GOBIN) $(cmd_dir)
|
||||||
|
|
||||||
|
## clean: removes compiled executables
|
||||||
|
.PHONY: clean
|
||||||
|
clean: $(dist_dir)
|
||||||
|
$(RM) -f $(dist_dir)/*
|
||||||
|
|
||||||
|
## distclean: removes the tags file
|
||||||
|
.PHONY: distclean
|
||||||
|
distclean:
|
||||||
|
$(RM) tags
|
||||||
|
|
||||||
|
## setup: installs revive (linter) and scc (sloc tool)
|
||||||
|
.PHONY: setup
|
||||||
|
setup:
|
||||||
|
GO111MODULE=off $(GO) get -u github.com/boyter/scc github.com/mgechev/revive
|
||||||
|
|
||||||
|
## sloc: counts "semantic lines of code"
|
||||||
|
.PHONY: sloc
|
||||||
|
sloc:
|
||||||
|
$(SCC) --exclude-dir=vendor
|
||||||
|
|
||||||
|
## tags: builds a tags file
|
||||||
|
.PHONY: tags
|
||||||
|
tags:
|
||||||
|
$(CTAGS) -R . --exclude=vendor
|
||||||
|
|
||||||
|
## vendor: downloads, tidies, and verifies dependencies
|
||||||
|
.PHONY: vendor
|
||||||
|
vendor:
|
||||||
|
$(GO) mod vendor && $(GO) mod tidy && $(GO) mod verify
|
||||||
|
|
||||||
|
## fmt: runs go fmt
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
$(GO) fmt ./...
|
||||||
|
|
||||||
|
## lint: lints go source files
|
||||||
|
.PHONY: lint
|
||||||
|
lint: vendor
|
||||||
|
$(LINT) -exclude vendor/... ./...
|
||||||
|
|
||||||
|
## vet: vets go source files
|
||||||
|
.PHONY: vet
|
||||||
|
vet:
|
||||||
|
$(GO) vet ./...
|
||||||
|
|
||||||
|
## test: runs unit-tests
|
||||||
|
.PHONY: test
|
||||||
|
test:
|
||||||
|
$(GO) test ./...
|
||||||
|
|
||||||
|
## check: formats, lints, vets, vendors, and run unit-tests
|
||||||
|
.PHONY: check
|
||||||
|
check: | vendor fmt lint vet test
|
||||||
|
|
||||||
|
.PHONY: prepare
|
||||||
|
prepare: | $(dist_dir) clean generate vendor fmt lint vet test
|
||||||
|
|
||||||
|
## help: displays this help text
|
||||||
|
.PHONY: help
|
||||||
|
help:
|
||||||
|
@$(CAT) $(makefile) | \
|
||||||
|
$(SORT) | \
|
||||||
|
$(GREP) "^##" | \
|
||||||
|
$(SED) 's/## //g' | \
|
||||||
|
$(COLUMN) -t -s ':'
|
@ -125,6 +125,11 @@ If a user attempts to edit a cheatsheet on a read-only cheatpath, `cheat` will
|
|||||||
transparently copy that sheet to a writeable directory before opening it for
|
transparently copy that sheet to a writeable directory before opening it for
|
||||||
editing.
|
editing.
|
||||||
|
|
||||||
|
### Directory-scoped Cheatpaths ###
|
||||||
|
At times, it can be useful to closely associate cheatsheets with a directory on
|
||||||
|
your filesystem. `cheat` facilitates this by searching for a `.cheat` folder in
|
||||||
|
the current working directory. If found, the `.cheat` directory will
|
||||||
|
(temporarily) be added to the cheatpaths.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
@ -178,11 +183,11 @@ To search (by regex) for cheatsheets that contain an IP address:
|
|||||||
cheat -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
cheat -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
||||||
```
|
```
|
||||||
|
|
||||||
Flags may be combined in inuitive ways. Example: to search sheets on the
|
Flags may be combined in intuitive ways. Example: to search sheets on the
|
||||||
"personal" cheatpath that are tagged with "networking" and match a regex:
|
"personal" cheatpath that are tagged with "networking" and match a regex:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cheat -p personal -t networking -s --regex '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
cheat -p personal -t networking --regex -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# TODO: this script has been made obsolete by the Makefile, yet downstream
|
||||||
|
# package managers plausibly rely on it for compiling locally. Remove this file
|
||||||
|
# after downstream maintainers have had time to modify their packages to simply
|
||||||
|
# invoke `make` in the project root.
|
||||||
|
|
||||||
# locate the cheat project root
|
# locate the cheat project root
|
||||||
BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
APPDIR=$(readlink -f "$BINDIR/..")
|
APPDIR=$(readlink -f "$BINDIR/..")
|
||||||
|
|
||||||
# compile the executable
|
# compile the executable
|
||||||
cd "$APPDIR/cmd/cheat"
|
cd $APPDIR
|
||||||
go clean && go generate && go build -mod vendor
|
|
||||||
mv "$APPDIR/cmd/cheat/cheat" "$APPDIR/dist/cheat"
|
|
||||||
|
|
||||||
# display a build checksum
|
make
|
||||||
md5sum "$APPDIR/dist/cheat"
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# locate the cheat project root
|
|
||||||
BINDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
APPDIR=$(readlink -f "$BINDIR/..")
|
|
||||||
|
|
||||||
# build embeds
|
|
||||||
cd "$APPDIR/cmd/cheat"
|
|
||||||
go clean && go generate
|
|
||||||
|
|
||||||
# compile AMD64 for Linux, OSX, and Windows
|
|
||||||
env GOOS=darwin GOARCH=amd64 go build -mod vendor -o \
|
|
||||||
"$APPDIR/dist/cheat-darwin-amd64" "$APPDIR/cmd/cheat"
|
|
||||||
|
|
||||||
env GOOS=linux GOARCH=amd64 go build -mod vendor -o \
|
|
||||||
"$APPDIR/dist/cheat-linux-amd64" "$APPDIR/cmd/cheat"
|
|
||||||
|
|
||||||
env GOOS=windows GOARCH=amd64 go build -mod vendor -o \
|
|
||||||
"$APPDIR/dist/cheat-win-amd64.exe" "$APPDIR/cmd/cheat"
|
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
@ -45,6 +46,39 @@ func cmdList(opts map[string]interface{}, conf config.Config) {
|
|||||||
return flattened[i].Title < flattened[j].Title
|
return flattened[i].Title < flattened[j].Title
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// filter if <cheatsheet> was specified
|
||||||
|
// NB: our docopt specification is misleading here. When used in conjunction
|
||||||
|
// with `-l`, `<cheatsheet>` is really a pattern against which to filter
|
||||||
|
// sheet titles.
|
||||||
|
if opts["<cheatsheet>"] != nil {
|
||||||
|
|
||||||
|
// initialize a slice of filtered sheets
|
||||||
|
filtered := []sheet.Sheet{}
|
||||||
|
|
||||||
|
// initialize our filter pattern
|
||||||
|
pattern := "(?i)" + opts["<cheatsheet>"].(string)
|
||||||
|
|
||||||
|
// compile the regex
|
||||||
|
reg, err := regexp.Compile(pattern)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(
|
||||||
|
os.Stderr,
|
||||||
|
fmt.Sprintf("failed to compile regexp: %s, %v", pattern, err),
|
||||||
|
)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate over each cheatsheet, and pass-through those which match the
|
||||||
|
// filter pattern
|
||||||
|
for _, s := range flattened {
|
||||||
|
if reg.MatchString(s.Title) {
|
||||||
|
filtered = append(filtered, s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
flattened = filtered
|
||||||
|
}
|
||||||
|
|
||||||
// exit early if no cheatsheets are available
|
// exit early if no cheatsheets are available
|
||||||
if len(flattened) == 0 {
|
if len(flattened) == 0 {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
55
cmd/cheat/cmd_remove.go
Normal file
55
cmd/cheat/cmd_remove.go
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/cheat/cheat/internal/config"
|
||||||
|
"github.com/cheat/cheat/internal/sheets"
|
||||||
|
)
|
||||||
|
|
||||||
|
// cmdRemove opens a cheatsheet for editing (or creates it if it doesn't exist).
|
||||||
|
func cmdRemove(opts map[string]interface{}, conf config.Config) {
|
||||||
|
|
||||||
|
cheatsheet := opts["--rm"].(string)
|
||||||
|
|
||||||
|
// load the cheatsheets
|
||||||
|
cheatsheets, err := sheets.Load(conf.Cheatpaths)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, fmt.Sprintf("failed to list cheatsheets: %v", err))
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// filter cheatcheats by tag if --tag was provided
|
||||||
|
if opts["--tag"] != nil {
|
||||||
|
cheatsheets = sheets.Filter(
|
||||||
|
cheatsheets,
|
||||||
|
strings.Split(opts["--tag"].(string), ","),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// consolidate the cheatsheets found on all paths into a single map of
|
||||||
|
// `title` => `sheet` (ie, allow more local cheatsheets to override less
|
||||||
|
// local cheatsheets)
|
||||||
|
consolidated := sheets.Consolidate(cheatsheets)
|
||||||
|
|
||||||
|
// fail early if the requested cheatsheet does not exist
|
||||||
|
sheet, ok := consolidated[cheatsheet]
|
||||||
|
if !ok {
|
||||||
|
fmt.Fprintln(os.Stderr, fmt.Sprintf("no cheatsheet found for '%s'.\n", cheatsheet))
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// fail early if the sheet is read-only
|
||||||
|
if sheet.ReadOnly {
|
||||||
|
fmt.Fprintln(os.Stderr, fmt.Sprintf("cheatsheet '%s' is read-only.", cheatsheet))
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise, attempt to delete the sheet
|
||||||
|
if err := os.Remove(sheet.Path); err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, fmt.Sprintf("failed to delete sheet: %s, %v", sheet.Title, err))
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
@ -38,12 +38,6 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
|||||||
// sort the cheatsheets alphabetically, and search for matches
|
// sort the cheatsheets alphabetically, and search for matches
|
||||||
for _, sheet := range sheets.Sort(consolidated) {
|
for _, sheet := range sheets.Sort(consolidated) {
|
||||||
|
|
||||||
// colorize output?
|
|
||||||
colorize := false
|
|
||||||
if conf.Colorize == true || opts["--colorize"] == true {
|
|
||||||
colorize = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// assume that we want to perform a case-insensitive search for <phrase>
|
// assume that we want to perform a case-insensitive search for <phrase>
|
||||||
pattern := "(?i)" + phrase
|
pattern := "(?i)" + phrase
|
||||||
|
|
||||||
@ -55,12 +49,12 @@ func cmdSearch(opts map[string]interface{}, conf config.Config) {
|
|||||||
// compile the regex
|
// compile the regex
|
||||||
reg, err := regexp.Compile(pattern)
|
reg, err := regexp.Compile(pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Errorf("failed to compile regexp: %s, %v", pattern, err)
|
fmt.Fprintln(os.Stderr, fmt.Sprintf("failed to compile regexp: %s, %v", pattern, err))
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// search the sheet
|
// search the sheet
|
||||||
matches := sheet.Search(reg, colorize)
|
matches := sheet.Search(reg, conf.Color(opts))
|
||||||
|
|
||||||
// display the results
|
// display the results
|
||||||
if len(matches) > 0 {
|
if len(matches) > 0 {
|
||||||
|
25
cmd/cheat/cmd_tags.go
Normal file
25
cmd/cheat/cmd_tags.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/cheat/cheat/internal/config"
|
||||||
|
"github.com/cheat/cheat/internal/sheets"
|
||||||
|
)
|
||||||
|
|
||||||
|
// cmdTags lists all tags in use.
|
||||||
|
func cmdTags(opts map[string]interface{}, conf config.Config) {
|
||||||
|
|
||||||
|
// load the cheatsheets
|
||||||
|
cheatsheets, err := sheets.Load(conf.Cheatpaths)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr, fmt.Sprintf("failed to list cheatsheets: %v", err))
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// write sheet tags to stdout
|
||||||
|
for _, tag := range sheets.Tags(cheatsheets) {
|
||||||
|
fmt.Println(tag)
|
||||||
|
}
|
||||||
|
}
|
@ -43,8 +43,7 @@ func cmdView(opts map[string]interface{}, conf config.Config) {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if colorization is not desired, output un-colorized text and exit
|
if !conf.Color(opts) {
|
||||||
if conf.Colorize == false && opts["--colorize"] == false {
|
|
||||||
fmt.Print(sheet.Text)
|
fmt.Print(sheet.Text)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
@ -5,13 +5,15 @@ Options:
|
|||||||
--init Write a default config file to stdout
|
--init Write a default config file to stdout
|
||||||
-c --colorize Colorize output
|
-c --colorize Colorize output
|
||||||
-d --directories List cheatsheet directories
|
-d --directories List cheatsheet directories
|
||||||
-e --edit=<sheet> Edit cheatsheet
|
-e --edit=<sheet> Edit <sheet>
|
||||||
-l --list List cheatsheets
|
-l --list List cheatsheets
|
||||||
-p --path=<name> Return only sheets found on path <name>
|
-p --path=<name> Return only sheets found on path <name>
|
||||||
-r --regex Treat search <phrase> as a regex
|
-r --regex Treat search <phrase> as a regex
|
||||||
-s --search=<phrase> Search cheatsheets for <phrase>
|
-s --search=<phrase> Search cheatsheets for <phrase>
|
||||||
-t --tag=<tag> Return only sheets matching <tag>
|
-t --tag=<tag> Return only sheets matching <tag>
|
||||||
|
-T --tags List all tags in use
|
||||||
-v --version Print the version number
|
-v --version Print the version number
|
||||||
|
--rm=<sheet> Remove (delete) <sheet>
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
@ -33,6 +35,12 @@ Examples:
|
|||||||
To list all available cheatsheets:
|
To list all available cheatsheets:
|
||||||
cheat -l
|
cheat -l
|
||||||
|
|
||||||
|
To list all cheatsheets whose titles match "apt":
|
||||||
|
cheat -l apt
|
||||||
|
|
||||||
|
To list all tags in use:
|
||||||
|
cheat -T
|
||||||
|
|
||||||
To list available cheatsheets that are tagged as "personal":
|
To list available cheatsheets that are tagged as "personal":
|
||||||
cheat -l -t personal
|
cheat -l -t personal
|
||||||
|
|
||||||
@ -41,3 +49,6 @@ Examples:
|
|||||||
|
|
||||||
To search (by regex) for cheatsheets that contain an IP address:
|
To search (by regex) for cheatsheets that contain an IP address:
|
||||||
cheat -c -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
cheat -c -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
||||||
|
|
||||||
|
To remove (delete) the foo/bar cheatsheet:
|
||||||
|
cheat --rm foo/bar
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/cheat/cheat/internal/config"
|
"github.com/cheat/cheat/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "3.0.2"
|
const version = "3.3.2"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// initialize the configs
|
// initialize the configs
|
||||||
conf, err := config.New(opts, confpath)
|
conf, err := config.New(opts, confpath, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed to load config: %v\n", err)
|
fmt.Fprintf(os.Stderr, "failed to load config: %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@ -76,9 +76,15 @@ func main() {
|
|||||||
case opts["--list"].(bool):
|
case opts["--list"].(bool):
|
||||||
cmd = cmdList
|
cmd = cmdList
|
||||||
|
|
||||||
|
case opts["--tags"].(bool):
|
||||||
|
cmd = cmdTags
|
||||||
|
|
||||||
case opts["--search"] != nil:
|
case opts["--search"] != nil:
|
||||||
cmd = cmdSearch
|
cmd = cmdSearch
|
||||||
|
|
||||||
|
case opts["--rm"] != nil:
|
||||||
|
cmd = cmdRemove
|
||||||
|
|
||||||
case opts["<cheatsheet>"] != nil:
|
case opts["<cheatsheet>"] != nil:
|
||||||
cmd = cmdView
|
cmd = cmdView
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@ formatter: terminal16m
|
|||||||
# "upstream" cheatsheets.
|
# "upstream" cheatsheets.
|
||||||
#
|
#
|
||||||
# But what if you want to view the "upstream" cheatsheets instead of your own?
|
# But what if you want to view the "upstream" cheatsheets instead of your own?
|
||||||
# Cheatsheets may be filtered via 'cheat -f <tag>' in combination with other
|
# Cheatsheets may be filtered via 'cheat -t <tag>' in combination with other
|
||||||
# commands. So, if you want to view the 'tar' cheatsheet that is tagged as
|
# commands. So, if you want to view the 'tar' cheatsheet that is tagged as
|
||||||
# 'community' rather than your own, you can use: cheat tar -f community
|
# 'community' rather than your own, you can use: cheat tar -t community
|
||||||
cheatpaths:
|
cheatpaths:
|
||||||
|
|
||||||
# Paths that come earlier are considered to be the most "global", and will
|
# Paths that come earlier are considered to be the most "global", and will
|
||||||
@ -61,5 +61,15 @@ cheatpaths:
|
|||||||
path: ~/.dotfiles/cheat/personal
|
path: ~/.dotfiles/cheat/personal
|
||||||
tags: [ personal ]
|
tags: [ personal ]
|
||||||
readonly: false
|
readonly: false
|
||||||
|
|
||||||
|
# While it requires no specific configuration here, it's also worth noting
|
||||||
|
# that 'cheat' will automatically append directories named '.cheat' within
|
||||||
|
# the current working directory to the 'cheatpath'. This can be very useful
|
||||||
|
# if you'd like to closely associate cheatsheets with, for example, a
|
||||||
|
# directory containing source code.
|
||||||
|
#
|
||||||
|
# Such "directory-scoped" cheatsheets will be treated as the most "local"
|
||||||
|
# cheatsheets, and will override less "local" cheatsheets. Likewise,
|
||||||
|
# directory-scoped cheatsheets will always be editable ('readonly: false').
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,15 @@ Options:
|
|||||||
--init Write a default config file to stdout
|
--init Write a default config file to stdout
|
||||||
-c --colorize Colorize output
|
-c --colorize Colorize output
|
||||||
-d --directories List cheatsheet directories
|
-d --directories List cheatsheet directories
|
||||||
-e --edit=<sheet> Edit cheatsheet
|
-e --edit=<sheet> Edit <sheet>
|
||||||
-l --list List cheatsheets
|
-l --list List cheatsheets
|
||||||
-p --path=<name> Return only sheets found on path <name>
|
-p --path=<name> Return only sheets found on path <name>
|
||||||
-r --regex Treat search <phrase> as a regex
|
-r --regex Treat search <phrase> as a regex
|
||||||
-s --search=<phrase> Search cheatsheets for <phrase>
|
-s --search=<phrase> Search cheatsheets for <phrase>
|
||||||
-t --tag=<tag> Return only sheets matching <tag>
|
-t --tag=<tag> Return only sheets matching <tag>
|
||||||
|
-T --tags List all tags in use
|
||||||
-v --version Print the version number
|
-v --version Print the version number
|
||||||
|
--rm=<sheet> Remove (delete) <sheet>
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
@ -42,6 +44,12 @@ Examples:
|
|||||||
To list all available cheatsheets:
|
To list all available cheatsheets:
|
||||||
cheat -l
|
cheat -l
|
||||||
|
|
||||||
|
To list all cheatsheets whose titles match "apt":
|
||||||
|
cheat -l apt
|
||||||
|
|
||||||
|
To list all tags in use:
|
||||||
|
cheat -T
|
||||||
|
|
||||||
To list available cheatsheets that are tagged as "personal":
|
To list available cheatsheets that are tagged as "personal":
|
||||||
cheat -l -t personal
|
cheat -l -t personal
|
||||||
|
|
||||||
@ -50,5 +58,8 @@ Examples:
|
|||||||
|
|
||||||
To search (by regex) for cheatsheets that contain an IP address:
|
To search (by regex) for cheatsheets that contain an IP address:
|
||||||
cheat -c -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
cheat -c -r -s '(?:[0-9]{1,3}\.){3}[0-9]{1,3}'
|
||||||
|
|
||||||
|
To remove (delete) the foo/bar cheatsheet:
|
||||||
|
cheat --rm foo/bar
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,9 @@ formatter: terminal16m
|
|||||||
# "upstream" cheatsheets.
|
# "upstream" cheatsheets.
|
||||||
#
|
#
|
||||||
# But what if you want to view the "upstream" cheatsheets instead of your own?
|
# But what if you want to view the "upstream" cheatsheets instead of your own?
|
||||||
# Cheatsheets may be filtered via 'cheat -f <tag>' in combination with other
|
# Cheatsheets may be filtered via 'cheat -t <tag>' in combination with other
|
||||||
# commands. So, if you want to view the 'tar' cheatsheet that is tagged as
|
# commands. So, if you want to view the 'tar' cheatsheet that is tagged as
|
||||||
# 'community' rather than your own, you can use: cheat tar -f community
|
# 'community' rather than your own, you can use: cheat tar -t community
|
||||||
cheatpaths:
|
cheatpaths:
|
||||||
|
|
||||||
# Paths that come earlier are considered to be the most "global", and will
|
# Paths that come earlier are considered to be the most "global", and will
|
||||||
@ -52,3 +52,13 @@ cheatpaths:
|
|||||||
path: ~/.dotfiles/cheat/personal
|
path: ~/.dotfiles/cheat/personal
|
||||||
tags: [ personal ]
|
tags: [ personal ]
|
||||||
readonly: false
|
readonly: false
|
||||||
|
|
||||||
|
# While it requires no specific configuration here, it's also worth noting
|
||||||
|
# that 'cheat' will automatically append directories named '.cheat' within
|
||||||
|
# the current working directory to the 'cheatpath'. This can be very useful
|
||||||
|
# if you'd like to closely associate cheatsheets with, for example, a
|
||||||
|
# directory containing source code.
|
||||||
|
#
|
||||||
|
# Such "directory-scoped" cheatsheets will be treated as the most "local"
|
||||||
|
# cheatsheets, and will override less "local" cheatsheets. Likewise,
|
||||||
|
# directory-scoped cheatsheets will always be editable ('readonly: false').
|
||||||
|
8
go.mod
8
go.mod
@ -3,12 +3,12 @@ module github.com/cheat/cheat
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/alecthomas/chroma v0.6.7
|
github.com/alecthomas/chroma v0.7.1
|
||||||
github.com/davecgh/go-spew v1.1.1
|
github.com/davecgh/go-spew v1.1.1
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
|
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
|
||||||
|
github.com/mattn/go-isatty v0.0.12
|
||||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
|
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
github.com/tj/front v0.0.0-20170212063142-739be213b0a1
|
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0
|
||||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 // indirect
|
gopkg.in/yaml.v2 v2.2.8
|
||||||
gopkg.in/yaml.v2 v2.2.4
|
|
||||||
)
|
)
|
||||||
|
30
go.sum
30
go.sum
@ -1,18 +1,12 @@
|
|||||||
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
|
|
||||||
github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0=
|
|
||||||
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
|
||||||
github.com/alecthomas/chroma v0.6.7 h1:1hKci+AyKOxJrugR9veaocu9DQGR2/GecI72BpaO0Rg=
|
github.com/alecthomas/chroma v0.7.1 h1:G1i02OhUbRi2nJxcNkwJaY/J1gHXj9tt72qN6ZouLFQ=
|
||||||
github.com/alecthomas/chroma v0.6.7/go.mod h1:zVlgtbRS7BJDrDY9SB238RmpoCBCYFlLmcfZ3durxTk=
|
github.com/alecthomas/chroma v0.7.1/go.mod h1:gHw09mkX1Qp80JlYbmN9L3+4R5o6DJJ3GRShh+AICNc=
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
||||||
github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
|
||||||
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
||||||
github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8/go.mod h1:MRgZdU3vrFd05IQ89AxUZ0aYdF39BYoNFa324SodPCA=
|
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
||||||
github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E=
|
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -22,23 +16,17 @@ github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg
|
|||||||
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
|
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
|
||||||
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
|
||||||
github.com/gorilla/csrf v1.6.0/go.mod h1:7tSf8kmjNYr7IWDCYhd3U8Ck34iQ/Yw5CJu7bAkHEGI=
|
|
||||||
github.com/gorilla/handlers v1.4.1/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
|
||||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
|
||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
|
||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
|
||||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
|
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||||
|
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
|
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
|
||||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E=
|
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
@ -48,15 +36,13 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/tj/front v0.0.0-20170212063142-739be213b0a1 h1:lA+aPRvltlx2fwv/BnxyYSDQo3pIeqzHgMO5GvK0T9E=
|
|
||||||
github.com/tj/front v0.0.0-20170212063142-739be213b0a1/go.mod h1:deJrtusCTptAW4EUn5vBLpl3dhNqPqUwEjWJz5UNxpQ=
|
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
|
||||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
|
||||||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
|
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
|
||||||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
||||||
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU=
|
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU=
|
||||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
||||||
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
|
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
@ -2,8 +2,8 @@ package cheatpath
|
|||||||
|
|
||||||
// Cheatpath encapsulates cheatsheet path information
|
// Cheatpath encapsulates cheatsheet path information
|
||||||
type Cheatpath struct {
|
type Cheatpath struct {
|
||||||
Name string `yaml:name`
|
Name string `yaml:"name"`
|
||||||
Path string `yaml:path`
|
Path string `yaml:"path"`
|
||||||
ReadOnly bool `yaml:readonly`
|
ReadOnly bool `yaml:"readonly"`
|
||||||
Tags []string `yaml:tags`
|
Tags []string `yaml:"tags"`
|
||||||
}
|
}
|
||||||
|
26
internal/config/color.go
Normal file
26
internal/config/color.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/mattn/go-isatty"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Color indicates whether colorization should be applied to the output
|
||||||
|
func (c *Config) Color(opts map[string]interface{}) bool {
|
||||||
|
|
||||||
|
// default to the colorization specified in the configs...
|
||||||
|
colorize := c.Colorize
|
||||||
|
|
||||||
|
// ... however, only apply colorization if we're writing to a tty...
|
||||||
|
if !isatty.IsTerminal(os.Stdout.Fd()) && !isatty.IsCygwinTerminal(os.Stdout.Fd()) {
|
||||||
|
colorize = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ... *unless* the --colorize flag was passed
|
||||||
|
if opts["--colorize"] == true {
|
||||||
|
colorize = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return colorize
|
||||||
|
}
|
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
cp "github.com/cheat/cheat/internal/cheatpath"
|
cp "github.com/cheat/cheat/internal/cheatpath"
|
||||||
|
|
||||||
@ -13,15 +14,15 @@ import (
|
|||||||
|
|
||||||
// Config encapsulates configuration parameters
|
// Config encapsulates configuration parameters
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Colorize bool `yaml:colorize`
|
Colorize bool `yaml:"colorize"`
|
||||||
Editor string `yaml:editor`
|
Editor string `yaml:"editor"`
|
||||||
Cheatpaths []cp.Cheatpath `yaml:cheatpaths`
|
Cheatpaths []cp.Cheatpath `yaml:"cheatpaths"`
|
||||||
Style string `yaml:style`
|
Style string `yaml:"style"`
|
||||||
Formatter string `yaml:formatter`
|
Formatter string `yaml:"formatter"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new Config struct
|
// New returns a new Config struct
|
||||||
func New(opts map[string]interface{}, confPath string) (Config, error) {
|
func New(opts map[string]interface{}, confPath string, resolve bool) (Config, error) {
|
||||||
|
|
||||||
// read the config file
|
// read the config file
|
||||||
buf, err := ioutil.ReadFile(confPath)
|
buf, err := ioutil.ReadFile(confPath)
|
||||||
@ -38,14 +39,52 @@ func New(opts map[string]interface{}, confPath string) (Config, error) {
|
|||||||
return Config{}, fmt.Errorf("could not unmarshal yaml: %v", err)
|
return Config{}, fmt.Errorf("could not unmarshal yaml: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// expand ~ in config paths
|
// if a .cheat directory exists locally, append it to the cheatpaths
|
||||||
|
cwd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return Config{}, fmt.Errorf("failed to get cwd: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
local := filepath.Join(cwd, ".cheat")
|
||||||
|
if _, err := os.Stat(local); err == nil {
|
||||||
|
path := cp.Cheatpath{
|
||||||
|
Name: "cwd",
|
||||||
|
Path: local,
|
||||||
|
ReadOnly: false,
|
||||||
|
Tags: []string{},
|
||||||
|
}
|
||||||
|
|
||||||
|
conf.Cheatpaths = append(conf.Cheatpaths, path)
|
||||||
|
}
|
||||||
|
|
||||||
|
// process cheatpaths
|
||||||
for i, cheatpath := range conf.Cheatpaths {
|
for i, cheatpath := range conf.Cheatpaths {
|
||||||
|
|
||||||
|
// expand ~ in config paths
|
||||||
expanded, err := homedir.Expand(cheatpath.Path)
|
expanded, err := homedir.Expand(cheatpath.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Config{}, fmt.Errorf("failed to expand ~: %v", err)
|
return Config{}, fmt.Errorf("failed to expand ~: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// follow symlinks
|
||||||
|
//
|
||||||
|
// NB: `resolve` is an ugly kludge that exists for the sake of unit-tests.
|
||||||
|
// It's necessary because `EvalSymlinks` will error if the symlink points
|
||||||
|
// to a non-existent location on the filesystem. When unit-testing,
|
||||||
|
// however, we don't want to have dependencies on the filesystem. As such,
|
||||||
|
// `resolve` is a switch that allows us to turn off symlink resolution when
|
||||||
|
// running the config tests.
|
||||||
|
if resolve {
|
||||||
|
expanded, err = filepath.EvalSymlinks(expanded)
|
||||||
|
if err != nil {
|
||||||
|
return Config{}, fmt.Errorf(
|
||||||
|
"failed to resolve symlink: %s, %v",
|
||||||
|
expanded,
|
||||||
|
err,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
conf.Cheatpaths[i].Path = expanded
|
conf.Cheatpaths[i].Path = expanded
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import (
|
|||||||
func TestConfigSuccessful(t *testing.T) {
|
func TestConfigSuccessful(t *testing.T) {
|
||||||
|
|
||||||
// initialize a config
|
// initialize a config
|
||||||
conf, err := New(map[string]interface{}{}, mock.Path("conf/conf.yml"))
|
conf, err := New(map[string]interface{}{}, mock.Path("conf/conf.yml"), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to parse config file: %v", err)
|
t.Errorf("failed to parse config file: %v", err)
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ func TestConfigSuccessful(t *testing.T) {
|
|||||||
func TestConfigFailure(t *testing.T) {
|
func TestConfigFailure(t *testing.T) {
|
||||||
|
|
||||||
// attempt to read a non-existent config file
|
// attempt to read a non-existent config file
|
||||||
_, err := New(map[string]interface{}{}, "/does-not-exit")
|
_, err := New(map[string]interface{}{}, "/does-not-exit", false)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("failed to error on unreadable config")
|
t.Errorf("failed to error on unreadable config")
|
||||||
}
|
}
|
||||||
@ -84,14 +84,14 @@ func TestEmptyEditor(t *testing.T) {
|
|||||||
os.Setenv("EDITOR", "")
|
os.Setenv("EDITOR", "")
|
||||||
|
|
||||||
// initialize a config
|
// initialize a config
|
||||||
conf, err := New(map[string]interface{}{}, mock.Path("conf/empty.yml"))
|
conf, err := New(map[string]interface{}{}, mock.Path("conf/empty.yml"), false)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("failed to return an error on empty editor")
|
t.Errorf("failed to return an error on empty editor")
|
||||||
}
|
}
|
||||||
|
|
||||||
// set editor, and assert that it is respected
|
// set editor, and assert that it is respected
|
||||||
os.Setenv("EDITOR", "foo")
|
os.Setenv("EDITOR", "foo")
|
||||||
conf, err = New(map[string]interface{}{}, mock.Path("conf/empty.yml"))
|
conf, err = New(map[string]interface{}{}, mock.Path("conf/empty.yml"), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to init configs: %v", err)
|
t.Errorf("failed to init configs: %v", err)
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ func TestEmptyEditor(t *testing.T) {
|
|||||||
|
|
||||||
// set visual, and assert that it overrides editor
|
// set visual, and assert that it overrides editor
|
||||||
os.Setenv("VISUAL", "bar")
|
os.Setenv("VISUAL", "bar")
|
||||||
conf, err = New(map[string]interface{}{}, mock.Path("conf/empty.yml"))
|
conf, err = New(map[string]interface{}{}, mock.Path("conf/empty.yml"), false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("failed to init configs: %v", err)
|
t.Errorf("failed to init configs: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -23,36 +23,21 @@ func Path(sys string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return expanded, nil
|
return expanded, nil
|
||||||
|
}
|
||||||
|
|
||||||
// OSX config paths
|
switch sys {
|
||||||
} else if sys == "darwin" {
|
case "darwin", "linux", "freebsd":
|
||||||
|
|
||||||
paths = []string{
|
paths = []string{
|
||||||
path.Join(os.Getenv("XDG_CONFIG_HOME"), "/cheat/conf.yml"),
|
path.Join(os.Getenv("XDG_CONFIG_HOME"), "/cheat/conf.yml"),
|
||||||
path.Join(os.Getenv("HOME"), ".config/cheat/conf.yml"),
|
path.Join(os.Getenv("HOME"), ".config/cheat/conf.yml"),
|
||||||
path.Join(os.Getenv("HOME"), ".cheat/conf.yml"),
|
path.Join(os.Getenv("HOME"), ".cheat/conf.yml"),
|
||||||
}
|
}
|
||||||
|
case "windows":
|
||||||
// Linux config paths
|
|
||||||
} else if sys == "linux" {
|
|
||||||
|
|
||||||
paths = []string{
|
|
||||||
path.Join(os.Getenv("XDG_CONFIG_HOME"), "/cheat/conf.yml"),
|
|
||||||
path.Join(os.Getenv("HOME"), ".config/cheat/conf.yml"),
|
|
||||||
path.Join(os.Getenv("HOME"), ".cheat/conf.yml"),
|
|
||||||
"/etc/cheat/conf.yml",
|
|
||||||
}
|
|
||||||
|
|
||||||
// Windows config paths
|
|
||||||
} else if sys == "windows" {
|
|
||||||
|
|
||||||
paths = []string{
|
paths = []string{
|
||||||
fmt.Sprintf("%s/cheat/conf.yml", os.Getenv("APPDATA")),
|
fmt.Sprintf("%s/cheat/conf.yml", os.Getenv("APPDATA")),
|
||||||
fmt.Sprintf("%s/cheat/conf.yml", os.Getenv("PROGRAMDATA")),
|
fmt.Sprintf("%s/cheat/conf.yml", os.Getenv("PROGRAMDATA")),
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
// Unsupported platforms
|
|
||||||
} else {
|
|
||||||
return "", fmt.Errorf("unsupported os: %s", sys)
|
return "", fmt.Errorf("unsupported os: %s", sys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
internal/frontmatter/frontmatter.go
Normal file
34
internal/frontmatter/frontmatter.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package frontmatter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"gopkg.in/yaml.v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Frontmatter encapsulates cheatsheet frontmatter data
|
||||||
|
type Frontmatter struct {
|
||||||
|
Tags []string
|
||||||
|
Syntax string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse parses cheatsheet frontmatter
|
||||||
|
func Parse(markdown string) (string, Frontmatter, error) {
|
||||||
|
|
||||||
|
// specify the frontmatter delimiter
|
||||||
|
delim := "---"
|
||||||
|
|
||||||
|
// initialize a frontmatter struct
|
||||||
|
var fm Frontmatter
|
||||||
|
|
||||||
|
// if the markdown does not contain frontmatter, pass it through unmodified
|
||||||
|
if !strings.HasPrefix(markdown, delim) {
|
||||||
|
return strings.TrimSpace(markdown), fm, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise, split the frontmatter and cheatsheet text
|
||||||
|
parts := strings.SplitN(markdown, delim, 3)
|
||||||
|
err := yaml.Unmarshal([]byte(parts[1]), &fm)
|
||||||
|
|
||||||
|
return strings.TrimSpace(parts[2]), fm, err
|
||||||
|
}
|
71
internal/frontmatter/frontmatter_test.go
Normal file
71
internal/frontmatter/frontmatter_test.go
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package frontmatter
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestHasFrontmatter asserts that markdown is properly parsed when it contains
|
||||||
|
// frontmatter
|
||||||
|
func TestHasFrontmatter(t *testing.T) {
|
||||||
|
|
||||||
|
// stub our cheatsheet content
|
||||||
|
markdown := `---
|
||||||
|
syntax: go
|
||||||
|
tags: [ test ]
|
||||||
|
---
|
||||||
|
To foo the bar: baz`
|
||||||
|
|
||||||
|
// parse the frontmatter
|
||||||
|
text, fm, err := Parse(markdown)
|
||||||
|
|
||||||
|
// assert expectations
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed to parse markdown: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
want := "To foo the bar: baz"
|
||||||
|
if text != want {
|
||||||
|
t.Errorf("failed to parse text: want: %s, got: %s", want, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
want = "go"
|
||||||
|
if fm.Syntax != want {
|
||||||
|
t.Errorf("failed to parse syntax: want: %s, got: %s", want, fm.Syntax)
|
||||||
|
}
|
||||||
|
|
||||||
|
want = "test"
|
||||||
|
if fm.Tags[0] != want {
|
||||||
|
t.Errorf("failed to parse tags: want: %s, got: %s", want, fm.Tags[0])
|
||||||
|
}
|
||||||
|
if len(fm.Tags) != 1 {
|
||||||
|
t.Errorf("failed to parse tags: want: len 0, got: len %d", len(fm.Tags))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestHasFrontmatter asserts that markdown is properly parsed when it does not
|
||||||
|
// contain frontmatter
|
||||||
|
func TestHasNoFrontmatter(t *testing.T) {
|
||||||
|
|
||||||
|
// stub our cheatsheet content
|
||||||
|
markdown := "To foo the bar: baz"
|
||||||
|
|
||||||
|
// parse the frontmatter
|
||||||
|
text, fm, err := Parse(markdown)
|
||||||
|
|
||||||
|
// assert expectations
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed to parse markdown: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if text != markdown {
|
||||||
|
t.Errorf("failed to parse text: want: %s, got: %s", markdown, text)
|
||||||
|
}
|
||||||
|
|
||||||
|
if fm.Syntax != "" {
|
||||||
|
t.Errorf("failed to parse syntax: want: '', got: %s", fm.Syntax)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(fm.Tags) != 0 {
|
||||||
|
t.Errorf("failed to parse tags: want: len 0, got: len %d", len(fm.Tags))
|
||||||
|
}
|
||||||
|
}
|
@ -4,17 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/tj/front"
|
"github.com/cheat/cheat/internal/frontmatter"
|
||||||
)
|
)
|
||||||
|
|
||||||
// frontmatter is an un-exported helper struct used in parsing cheatsheets
|
|
||||||
type frontmatter struct {
|
|
||||||
Tags []string
|
|
||||||
Syntax string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sheet encapsulates sheet information
|
// Sheet encapsulates sheet information
|
||||||
type Sheet struct {
|
type Sheet struct {
|
||||||
Title string
|
Title string
|
||||||
@ -39,9 +32,8 @@ func New(
|
|||||||
return Sheet{}, fmt.Errorf("failed to read file: %s, %v", path, err)
|
return Sheet{}, fmt.Errorf("failed to read file: %s, %v", path, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse the front-matter
|
// parse the cheatsheet frontmatter
|
||||||
var fm frontmatter
|
text, fm, err := frontmatter.Parse(string(markdown))
|
||||||
text, err := front.Unmarshal(markdown, &fm)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Sheet{}, fmt.Errorf("failed to parse front-matter: %v", err)
|
return Sheet{}, fmt.Errorf("failed to parse front-matter: %v", err)
|
||||||
}
|
}
|
||||||
@ -56,7 +48,7 @@ func New(
|
|||||||
return Sheet{
|
return Sheet{
|
||||||
Title: title,
|
Title: title,
|
||||||
Path: path,
|
Path: path,
|
||||||
Text: strings.TrimSpace(string(text)) + "\n",
|
Text: text + "\n",
|
||||||
Tags: tags,
|
Tags: tags,
|
||||||
Syntax: fm.Syntax,
|
Syntax: fm.Syntax,
|
||||||
ReadOnly: readOnly,
|
ReadOnly: readOnly,
|
||||||
|
@ -45,11 +45,16 @@ func Load(cheatpaths []cp.Cheatpath) ([]map[string]sheet.Sheet, error) {
|
|||||||
// accessed. Eg: `cheat tar` - `tar` is the title)
|
// accessed. Eg: `cheat tar` - `tar` is the title)
|
||||||
title := strings.TrimPrefix(
|
title := strings.TrimPrefix(
|
||||||
strings.TrimPrefix(path, cheatpath.Path),
|
strings.TrimPrefix(path, cheatpath.Path),
|
||||||
"/",
|
string(os.PathSeparator),
|
||||||
)
|
)
|
||||||
|
|
||||||
// ignore dotfiles. Otherwise, we'll likely load .git/*
|
// ignore hidden files and directories. Otherwise, we'll likely load
|
||||||
if strings.HasPrefix(title, ".") {
|
// .git/* and .DS_Store.
|
||||||
|
//
|
||||||
|
// NB: this is still somewhat brittle in that it will miss files
|
||||||
|
// contained within hidden directories in the middle of a path, though
|
||||||
|
// that should not realistically occur.
|
||||||
|
if strings.HasPrefix(title, ".") || strings.HasPrefix(info.Name(), ".") {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
internal/sheets/tags.go
Normal file
36
internal/sheets/tags.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package sheets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sort"
|
||||||
|
|
||||||
|
"github.com/cheat/cheat/internal/sheet"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Tags returns a slice of all tags in use in any sheet
|
||||||
|
func Tags(cheatpaths []map[string]sheet.Sheet) []string {
|
||||||
|
|
||||||
|
// create a map of all tags in use in any sheet
|
||||||
|
tags := make(map[string]bool)
|
||||||
|
|
||||||
|
// iterate over all tags on all sheets on all cheatpaths
|
||||||
|
for _, path := range cheatpaths {
|
||||||
|
for _, sheet := range path {
|
||||||
|
for _, tag := range sheet.Tags {
|
||||||
|
tags[tag] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// restructure the map into a slice
|
||||||
|
sorted := []string{}
|
||||||
|
for tag := range tags {
|
||||||
|
sorted = append(sorted, tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
// sort the slice
|
||||||
|
sort.Slice(sorted, func(i, j int) bool {
|
||||||
|
return sorted[i] < sorted[j]
|
||||||
|
})
|
||||||
|
|
||||||
|
return sorted
|
||||||
|
}
|
51
internal/sheets/tags_test.go
Normal file
51
internal/sheets/tags_test.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package sheets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
|
"github.com/cheat/cheat/internal/sheet"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestTags asserts that cheetsheet tags are properly returned
|
||||||
|
func TestTags(t *testing.T) {
|
||||||
|
|
||||||
|
// mock cheatsheets available on multiple cheatpaths
|
||||||
|
cheatpaths := []map[string]sheet.Sheet{
|
||||||
|
|
||||||
|
// mock community cheatsheets
|
||||||
|
map[string]sheet.Sheet{
|
||||||
|
"foo": sheet.Sheet{Title: "foo", Tags: []string{"alpha"}},
|
||||||
|
"bar": sheet.Sheet{Title: "bar", Tags: []string{"alpha", "bravo"}},
|
||||||
|
},
|
||||||
|
|
||||||
|
// mock local cheatsheets
|
||||||
|
map[string]sheet.Sheet{
|
||||||
|
"bar": sheet.Sheet{Title: "bar", Tags: []string{"bravo", "charlie"}},
|
||||||
|
"baz": sheet.Sheet{Title: "baz", Tags: []string{"delta"}},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// consolidate the cheatsheets
|
||||||
|
tags := Tags(cheatpaths)
|
||||||
|
|
||||||
|
// specify the expected output
|
||||||
|
want := []string{
|
||||||
|
"alpha",
|
||||||
|
"bravo",
|
||||||
|
"charlie",
|
||||||
|
"delta",
|
||||||
|
}
|
||||||
|
|
||||||
|
// assert that the cheatsheets properly consolidated
|
||||||
|
if !reflect.DeepEqual(tags, want) {
|
||||||
|
t.Errorf(
|
||||||
|
"failed to return tags: want:\n%s, got:\n%s",
|
||||||
|
spew.Sdump(want),
|
||||||
|
spew.Sdump(tags),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9
scripts/cheat-autocompletion.bash
Executable file
9
scripts/cheat-autocompletion.bash
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
function _cheat_autocomplete {
|
||||||
|
sheets=$(cheat -l | sed -n '2,$p'|cut -d' ' -f1)
|
||||||
|
COMPREPLY=()
|
||||||
|
if [ $COMP_CWORD = 1 ]; then
|
||||||
|
COMPREPLY=(`compgen -W "$sheets" -- $2`)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _cheat_autocomplete cheat
|
13
scripts/cheat-autocompletion.fish
Executable file
13
scripts/cheat-autocompletion.fish
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
complete -c cheat -f -a "(cheat -l | tail -n +2 | cut -d ' ' -f 1)"
|
||||||
|
complete -c cheat -l init -d "Write a default config file to stdout"
|
||||||
|
complete -c cheat -s c -l colorize -d "Colorize output"
|
||||||
|
complete -c cheat -s d -l directories -d "List cheatsheet directories"
|
||||||
|
complete -c cheat -s e -l edit -x -a "(cheat -l | tail -n +2 | cut -d ' ' -f 1)" -d "Edit cheatsheet"
|
||||||
|
complete -c cheat -s l -l list -d "List cheatsheets"
|
||||||
|
complete -c cheat -s p -l path -x -a "(cheat -d | cut -d ':' -f 1)" -d "Return only sheets found on given path"
|
||||||
|
complete -c cheat -s r -l regex -d "Treat search phrase as a regex"
|
||||||
|
complete -c cheat -s s -l search -x -d "Search cheatsheets for given phrase"
|
||||||
|
complete -c cheat -s t -l tag -x -a "(cheat -T)" -d "Return only sheets matching the given tag"
|
||||||
|
complete -c cheat -s T -l tags -d "List all tags in use"
|
||||||
|
complete -c cheat -s v -l version -d "Print the version number"
|
||||||
|
complete -c cheat -l rm -x -a "(cheat -l | tail -n +2 | cut -d ' ' -f 1)" -d "Remove (delete) cheatsheet"
|
10
vendor/github.com/alecthomas/chroma/.golangci.yml
generated
vendored
10
vendor/github.com/alecthomas/chroma/.golangci.yml
generated
vendored
@ -15,6 +15,11 @@ linters:
|
|||||||
- gocyclo
|
- gocyclo
|
||||||
- dupl
|
- dupl
|
||||||
- gochecknoglobals
|
- gochecknoglobals
|
||||||
|
- funlen
|
||||||
|
- godox
|
||||||
|
- wsl
|
||||||
|
- gomnd
|
||||||
|
- gocognit
|
||||||
|
|
||||||
linters-settings:
|
linters-settings:
|
||||||
govet:
|
govet:
|
||||||
@ -43,3 +48,8 @@ issues:
|
|||||||
- 'Potential file inclusion via variable'
|
- 'Potential file inclusion via variable'
|
||||||
- 'should have comment or be unexported'
|
- 'should have comment or be unexported'
|
||||||
- 'comment on exported var .* should be of the form'
|
- 'comment on exported var .* should be of the form'
|
||||||
|
- 'at least one file in a package should have a package comment'
|
||||||
|
- 'string literal contains the Unicode'
|
||||||
|
- 'methods on the same type should have the same receiver name'
|
||||||
|
- '_TokenType_name should be _TokenTypeName'
|
||||||
|
- '`_TokenType_map` should be `_TokenTypeMap`'
|
||||||
|
4
vendor/github.com/alecthomas/chroma/.travis.yml
generated
vendored
4
vendor/github.com/alecthomas/chroma/.travis.yml
generated
vendored
@ -1,8 +1,10 @@
|
|||||||
sudo: false
|
sudo: false
|
||||||
language: go
|
language: go
|
||||||
|
go:
|
||||||
|
- "1.13.x"
|
||||||
script:
|
script:
|
||||||
- go test -v ./...
|
- go test -v ./...
|
||||||
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s v1.15.0
|
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s v1.22.2
|
||||||
- ./bin/golangci-lint run
|
- ./bin/golangci-lint run
|
||||||
- git clean -fdx .
|
- git clean -fdx .
|
||||||
after_success:
|
after_success:
|
||||||
|
19
vendor/github.com/alecthomas/chroma/Makefile
generated
vendored
Normal file
19
vendor/github.com/alecthomas/chroma/Makefile
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
.PHONY: chromad upload all
|
||||||
|
|
||||||
|
all: README.md tokentype_string.go
|
||||||
|
|
||||||
|
README.md: lexers/*/*.go
|
||||||
|
./table.py
|
||||||
|
|
||||||
|
tokentype_string.go: types.go
|
||||||
|
go generate
|
||||||
|
|
||||||
|
chromad:
|
||||||
|
(cd ./cmd/chromad && go get github.com/GeertJohan/go.rice/rice@master && go install github.com/GeertJohan/go.rice/rice)
|
||||||
|
rm -f chromad
|
||||||
|
(export CGOENABLED=0 GOOS=linux ; cd ./cmd/chromad && go build -o ../../chromad .)
|
||||||
|
rice append -i ./cmd/chromad --exec=./chromad
|
||||||
|
|
||||||
|
upload: chromad
|
||||||
|
scp chromad root@swapoff.org: && \
|
||||||
|
ssh root@swapoff.org 'install -m755 ./chromad /srv/http/swapoff.org/bin && service chromad restart'
|
9
vendor/github.com/alecthomas/chroma/README.md
generated
vendored
9
vendor/github.com/alecthomas/chroma/README.md
generated
vendored
@ -44,17 +44,17 @@ F | Factor, Fish, Forth, Fortran, FSharp
|
|||||||
G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groovy
|
G | GAS, GDScript, Genshi, Genshi HTML, Genshi Text, GLSL, Gnuplot, Go, Go HTML Template, Go Text Template, GraphQL, Groovy
|
||||||
H | Handlebars, Haskell, Haxe, HCL, Hexdump, HTML, HTTP, Hy
|
H | Handlebars, Haskell, Haxe, HCL, Hexdump, HTML, HTTP, Hy
|
||||||
I | Idris, INI, Io
|
I | Idris, INI, Io
|
||||||
J | Java, JavaScript, JSON, Julia, Jungle
|
J | J, Java, JavaScript, JSON, Julia, Jungle
|
||||||
K | Kotlin
|
K | Kotlin
|
||||||
L | Lighttpd configuration file, LLVM, Lua
|
L | Lighttpd configuration file, LLVM, Lua
|
||||||
M | Mako, markdown, Mason, Mathematica, Matlab, MiniZinc, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL
|
M | Mako, markdown, Mason, Mathematica, Matlab, MiniZinc, MLIR, Modula-2, MonkeyC, MorrowindScript, Myghty, MySQL
|
||||||
N | NASM, Newspeak, Nginx configuration file, Nim, Nix
|
N | NASM, Newspeak, Nginx configuration file, Nim, Nix
|
||||||
O | Objective-C, OCaml, Octave, OpenSCAD, Org Mode
|
O | Objective-C, OCaml, Octave, OpenSCAD, Org Mode
|
||||||
P | PacmanConf, Perl, PHP, Pig, PkgConfig, PL/pgSQL, plaintext, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, Protocol Buffer, Puppet, Python, Python 3
|
P | PacmanConf, Perl, PHP, Pig, PkgConfig, PL/pgSQL, plaintext, PostgreSQL SQL dialect, PostScript, POVRay, PowerShell, Prolog, Protocol Buffer, Puppet, Python, Python 3
|
||||||
Q | QBasic
|
Q | QBasic
|
||||||
R | R, Racket, Ragel, react, reg, reStructuredText, Rexx, Ruby, Rust
|
R | R, Racket, Ragel, react, reg, reStructuredText, Rexx, Ruby, Rust
|
||||||
S | Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, Snobol, Solidity, SPARQL, SQL, SquidConf, Swift, SYSTEMD, systemverilog
|
S | Sass, Scala, Scheme, Scilab, SCSS, Smalltalk, Smarty, SML, Snobol, Solidity, SPARQL, SQL, SquidConf, Swift, SYSTEMD, systemverilog
|
||||||
T | TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData
|
T | TableGen, TASM, Tcl, Tcsh, Termcap, Terminfo, Terraform, TeX, Thrift, TOML, TradingView, Transact-SQL, Turing, Turtle, Twig, TypeScript, TypoScript, TypoScriptCssData, TypoScriptHtmlData
|
||||||
V | VB.net, verilog, VHDL, VimL, vue
|
V | VB.net, verilog, VHDL, VimL, vue
|
||||||
W | WDTE
|
W | WDTE
|
||||||
X | XML, Xorg
|
X | XML, Xorg
|
||||||
@ -183,6 +183,7 @@ following constructor options:
|
|||||||
- `ClassPrefix(prefix)` - prefix each generated CSS class.
|
- `ClassPrefix(prefix)` - prefix each generated CSS class.
|
||||||
- `TabWidth(width)` - Set the rendered tab width, in characters.
|
- `TabWidth(width)` - Set the rendered tab width, in characters.
|
||||||
- `WithLineNumbers()` - Render line numbers (style with `LineNumbers`).
|
- `WithLineNumbers()` - Render line numbers (style with `LineNumbers`).
|
||||||
|
- `LinkableLineNumbers()` - Make the line numbers linkable.
|
||||||
- `HighlightLines(ranges)` - Highlight lines in these ranges (style with `LineHighlight`).
|
- `HighlightLines(ranges)` - Highlight lines in these ranges (style with `LineHighlight`).
|
||||||
- `LineNumbersInTable()` - Use a table for formatting line numbers and code, rather than spans.
|
- `LineNumbersInTable()` - Use a table for formatting line numbers and code, rather than spans.
|
||||||
|
|
||||||
|
2
vendor/github.com/alecthomas/chroma/delegate.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/delegate.go
generated
vendored
@ -34,7 +34,7 @@ type insertion struct {
|
|||||||
tokens []Token
|
tokens []Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *delegatingLexer) Tokenise(options *TokeniseOptions, text string) (Iterator, error) {
|
func (d *delegatingLexer) Tokenise(options *TokeniseOptions, text string) (Iterator, error) { // nolint: gocognit
|
||||||
tokens, err := Tokenise(Coalesce(d.language), options, text)
|
tokens, err := Tokenise(Coalesce(d.language), options, text)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
4
vendor/github.com/alecthomas/chroma/formatters/api.go
generated
vendored
4
vendor/github.com/alecthomas/chroma/formatters/api.go
generated
vendored
@ -6,6 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alecthomas/chroma"
|
"github.com/alecthomas/chroma"
|
||||||
"github.com/alecthomas/chroma/formatters/html"
|
"github.com/alecthomas/chroma/formatters/html"
|
||||||
|
"github.com/alecthomas/chroma/formatters/svg"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -19,7 +20,8 @@ var (
|
|||||||
return nil
|
return nil
|
||||||
}))
|
}))
|
||||||
// Default HTML formatter outputs self-contained HTML.
|
// Default HTML formatter outputs self-contained HTML.
|
||||||
htmlFull = Register("html", html.New(html.Standalone(), html.WithClasses())) // nolint
|
htmlFull = Register("html", html.New(html.Standalone(true), html.WithClasses(true))) // nolint
|
||||||
|
SVG = Register("svg", svg.New(svg.EmbedFont("Liberation Mono", svg.FontLiberationMono, svg.WOFF)))
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fallback formatter.
|
// Fallback formatter.
|
||||||
|
141
vendor/github.com/alecthomas/chroma/formatters/html/html.go
generated
vendored
141
vendor/github.com/alecthomas/chroma/formatters/html/html.go
generated
vendored
@ -14,32 +14,56 @@ import (
|
|||||||
type Option func(f *Formatter)
|
type Option func(f *Formatter)
|
||||||
|
|
||||||
// Standalone configures the HTML formatter for generating a standalone HTML document.
|
// Standalone configures the HTML formatter for generating a standalone HTML document.
|
||||||
func Standalone() Option { return func(f *Formatter) { f.standalone = true } }
|
func Standalone(b bool) Option { return func(f *Formatter) { f.standalone = b } }
|
||||||
|
|
||||||
// ClassPrefix sets the CSS class prefix.
|
// ClassPrefix sets the CSS class prefix.
|
||||||
func ClassPrefix(prefix string) Option { return func(f *Formatter) { f.prefix = prefix } }
|
func ClassPrefix(prefix string) Option { return func(f *Formatter) { f.prefix = prefix } }
|
||||||
|
|
||||||
// WithClasses emits HTML using CSS classes, rather than inline styles.
|
// WithClasses emits HTML using CSS classes, rather than inline styles.
|
||||||
func WithClasses() Option { return func(f *Formatter) { f.Classes = true } }
|
func WithClasses(b bool) Option { return func(f *Formatter) { f.Classes = b } }
|
||||||
|
|
||||||
// TabWidth sets the number of characters for a tab. Defaults to 8.
|
// TabWidth sets the number of characters for a tab. Defaults to 8.
|
||||||
func TabWidth(width int) Option { return func(f *Formatter) { f.tabWidth = width } }
|
func TabWidth(width int) Option { return func(f *Formatter) { f.tabWidth = width } }
|
||||||
|
|
||||||
// PreventSurroundingPre prevents the surrounding pre tags around the generated code
|
// PreventSurroundingPre prevents the surrounding pre tags around the generated code.
|
||||||
func PreventSurroundingPre() Option { return func(f *Formatter) { f.preventSurroundingPre = true } }
|
func PreventSurroundingPre(b bool) Option {
|
||||||
|
return func(f *Formatter) {
|
||||||
|
if b {
|
||||||
|
f.preWrapper = nopPreWrapper
|
||||||
|
} else {
|
||||||
|
f.preWrapper = defaultPreWrapper
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithPreWrapper allows control of the surrounding pre tags.
|
||||||
|
func WithPreWrapper(wrapper PreWrapper) Option {
|
||||||
|
return func(f *Formatter) {
|
||||||
|
f.preWrapper = wrapper
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithLineNumbers formats output with line numbers.
|
// WithLineNumbers formats output with line numbers.
|
||||||
func WithLineNumbers() Option {
|
func WithLineNumbers(b bool) Option {
|
||||||
return func(f *Formatter) {
|
return func(f *Formatter) {
|
||||||
f.lineNumbers = true
|
f.lineNumbers = b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// LineNumbersInTable will, when combined with WithLineNumbers, separate the line numbers
|
// LineNumbersInTable will, when combined with WithLineNumbers, separate the line numbers
|
||||||
// and code in table td's, which make them copy-and-paste friendly.
|
// and code in table td's, which make them copy-and-paste friendly.
|
||||||
func LineNumbersInTable() Option {
|
func LineNumbersInTable(b bool) Option {
|
||||||
return func(f *Formatter) {
|
return func(f *Formatter) {
|
||||||
f.lineNumbersInTable = true
|
f.lineNumbersInTable = b
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkableLineNumbers decorates the line numbers HTML elements with an "id"
|
||||||
|
// attribute so they can be linked.
|
||||||
|
func LinkableLineNumbers(b bool, prefix string) Option {
|
||||||
|
return func(f *Formatter) {
|
||||||
|
f.linkableLineNumbers = b
|
||||||
|
f.lineNumbersIDPrefix = prefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +88,7 @@ func BaseLineNumber(n int) Option {
|
|||||||
func New(options ...Option) *Formatter {
|
func New(options ...Option) *Formatter {
|
||||||
f := &Formatter{
|
f := &Formatter{
|
||||||
baseLineNumber: 1,
|
baseLineNumber: 1,
|
||||||
|
preWrapper: defaultPreWrapper,
|
||||||
}
|
}
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
option(f)
|
option(f)
|
||||||
@ -71,17 +96,59 @@ func New(options ...Option) *Formatter {
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PreWrapper defines the operations supported in WithPreWrapper.
|
||||||
|
type PreWrapper interface {
|
||||||
|
// Start is called to write a start <pre> element.
|
||||||
|
// The code flag tells whether this block surrounds
|
||||||
|
// highlighted code. This will be false when surrounding
|
||||||
|
// line numbers.
|
||||||
|
Start(code bool, styleAttr string) string
|
||||||
|
|
||||||
|
// End is called to write the end </pre> element.
|
||||||
|
End(code bool) string
|
||||||
|
}
|
||||||
|
|
||||||
|
type preWrapper struct {
|
||||||
|
start func(code bool, styleAttr string) string
|
||||||
|
end func(code bool) string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p preWrapper) Start(code bool, styleAttr string) string {
|
||||||
|
return p.start(code, styleAttr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p preWrapper) End(code bool) string {
|
||||||
|
return p.end(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
nopPreWrapper = preWrapper{
|
||||||
|
start: func(code bool, styleAttr string) string { return "" },
|
||||||
|
end: func(code bool) string { return "" },
|
||||||
|
}
|
||||||
|
defaultPreWrapper = preWrapper{
|
||||||
|
start: func(code bool, styleAttr string) string {
|
||||||
|
return fmt.Sprintf("<pre%s>", styleAttr)
|
||||||
|
},
|
||||||
|
end: func(code bool) string {
|
||||||
|
return "</pre>"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// Formatter that generates HTML.
|
// Formatter that generates HTML.
|
||||||
type Formatter struct {
|
type Formatter struct {
|
||||||
standalone bool
|
standalone bool
|
||||||
prefix string
|
prefix string
|
||||||
Classes bool // Exported field to detect when classes are being used
|
Classes bool // Exported field to detect when classes are being used
|
||||||
preventSurroundingPre bool
|
preWrapper PreWrapper
|
||||||
tabWidth int
|
tabWidth int
|
||||||
lineNumbers bool
|
lineNumbers bool
|
||||||
lineNumbersInTable bool
|
lineNumbersInTable bool
|
||||||
highlightRanges highlightRanges
|
linkableLineNumbers bool
|
||||||
baseLineNumber int
|
lineNumbersIDPrefix string
|
||||||
|
highlightRanges highlightRanges
|
||||||
|
baseLineNumber int
|
||||||
}
|
}
|
||||||
|
|
||||||
type highlightRanges [][2]int
|
type highlightRanges [][2]int
|
||||||
@ -91,11 +158,6 @@ func (h highlightRanges) Swap(i, j int) { h[i], h[j] = h[j], h[i] }
|
|||||||
func (h highlightRanges) Less(i, j int) bool { return h[i][0] < h[j][0] }
|
func (h highlightRanges) Less(i, j int) bool { return h[i][0] < h[j][0] }
|
||||||
|
|
||||||
func (f *Formatter) Format(w io.Writer, style *chroma.Style, iterator chroma.Iterator) (err error) {
|
func (f *Formatter) Format(w io.Writer, style *chroma.Style, iterator chroma.Iterator) (err error) {
|
||||||
defer func() {
|
|
||||||
if perr := recover(); perr != nil {
|
|
||||||
err = perr.(error)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
return f.writeHTML(w, style, iterator.Tokens())
|
return f.writeHTML(w, style, iterator.Tokens())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,9 +196,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
|
|||||||
fmt.Fprintf(w, "<div%s>\n", f.styleAttr(css, chroma.Background))
|
fmt.Fprintf(w, "<div%s>\n", f.styleAttr(css, chroma.Background))
|
||||||
fmt.Fprintf(w, "<table%s><tr>", f.styleAttr(css, chroma.LineTable))
|
fmt.Fprintf(w, "<table%s><tr>", f.styleAttr(css, chroma.LineTable))
|
||||||
fmt.Fprintf(w, "<td%s>\n", f.styleAttr(css, chroma.LineTableTD))
|
fmt.Fprintf(w, "<td%s>\n", f.styleAttr(css, chroma.LineTableTD))
|
||||||
if !f.preventSurroundingPre {
|
fmt.Fprintf(w, f.preWrapper.Start(false, f.styleAttr(css, chroma.Background)))
|
||||||
fmt.Fprintf(w, "<pre%s>", f.styleAttr(css, chroma.Background))
|
|
||||||
}
|
|
||||||
for index := range lines {
|
for index := range lines {
|
||||||
line := f.baseLineNumber + index
|
line := f.baseLineNumber + index
|
||||||
highlight, next := f.shouldHighlight(highlightIndex, line)
|
highlight, next := f.shouldHighlight(highlightIndex, line)
|
||||||
@ -147,22 +207,19 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
|
|||||||
fmt.Fprintf(w, "<span%s>", f.styleAttr(css, chroma.LineHighlight))
|
fmt.Fprintf(w, "<span%s>", f.styleAttr(css, chroma.LineHighlight))
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Fprintf(w, "<span%s>%*d\n</span>", f.styleAttr(css, chroma.LineNumbersTable), lineDigits, line)
|
fmt.Fprintf(w, "<span%s%s>%*d\n</span>", f.styleAttr(css, chroma.LineNumbersTable), f.lineIDAttribute(line), lineDigits, line)
|
||||||
|
|
||||||
if highlight {
|
if highlight {
|
||||||
fmt.Fprintf(w, "</span>")
|
fmt.Fprintf(w, "</span>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !f.preventSurroundingPre {
|
fmt.Fprint(w, f.preWrapper.End(false))
|
||||||
fmt.Fprint(w, "</pre>")
|
|
||||||
}
|
|
||||||
fmt.Fprint(w, "</td>\n")
|
fmt.Fprint(w, "</td>\n")
|
||||||
fmt.Fprintf(w, "<td%s>\n", f.styleAttr(css, chroma.LineTableTD, "width:100%"))
|
fmt.Fprintf(w, "<td%s>\n", f.styleAttr(css, chroma.LineTableTD, "width:100%"))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !f.preventSurroundingPre {
|
fmt.Fprintf(w, f.preWrapper.Start(true, f.styleAttr(css, chroma.Background)))
|
||||||
fmt.Fprintf(w, "<pre%s>", f.styleAttr(css, chroma.Background))
|
|
||||||
}
|
|
||||||
highlightIndex = 0
|
highlightIndex = 0
|
||||||
for index, tokens := range lines {
|
for index, tokens := range lines {
|
||||||
// 1-based line number.
|
// 1-based line number.
|
||||||
@ -176,7 +233,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
|
|||||||
}
|
}
|
||||||
|
|
||||||
if f.lineNumbers && !wrapInTable {
|
if f.lineNumbers && !wrapInTable {
|
||||||
fmt.Fprintf(w, "<span%s>%*d</span>", f.styleAttr(css, chroma.LineNumbers), lineDigits, line)
|
fmt.Fprintf(w, "<span%s%s>%*d</span>", f.styleAttr(css, chroma.LineNumbers), f.lineIDAttribute(line), lineDigits, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, token := range tokens {
|
for _, token := range tokens {
|
||||||
@ -192,9 +249,7 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !f.preventSurroundingPre {
|
fmt.Fprintf(w, f.preWrapper.End(true))
|
||||||
fmt.Fprint(w, "</pre>")
|
|
||||||
}
|
|
||||||
|
|
||||||
if wrapInTable {
|
if wrapInTable {
|
||||||
fmt.Fprint(w, "</td></tr></table>\n")
|
fmt.Fprint(w, "</td></tr></table>\n")
|
||||||
@ -209,6 +264,13 @@ func (f *Formatter) writeHTML(w io.Writer, style *chroma.Style, tokens []chroma.
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (f *Formatter) lineIDAttribute(line int) string {
|
||||||
|
if !f.linkableLineNumbers {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return fmt.Sprintf(" id=\"%s%d\"", f.lineNumbersIDPrefix, line)
|
||||||
|
}
|
||||||
|
|
||||||
func (f *Formatter) shouldHighlight(highlightIndex, line int) (bool, bool) {
|
func (f *Formatter) shouldHighlight(highlightIndex, line int) (bool, bool) {
|
||||||
next := false
|
next := false
|
||||||
for highlightIndex < len(f.highlightRanges) && line > f.highlightRanges[highlightIndex][1] {
|
for highlightIndex < len(f.highlightRanges) && line > f.highlightRanges[highlightIndex][1] {
|
||||||
@ -283,6 +345,13 @@ func (f *Formatter) WriteCSS(w io.Writer, style *chroma.Style) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Special-case line number highlighting when targeted.
|
||||||
|
if f.lineNumbers || f.lineNumbersInTable {
|
||||||
|
targetedLineCSS := StyleEntryToCSS(style.Get(chroma.LineHighlight))
|
||||||
|
for _, tt := range []chroma.TokenType{chroma.LineNumbers, chroma.LineNumbersTable} {
|
||||||
|
fmt.Fprintf(w, "/* %s targeted by URL anchor */ .%schroma .%s:target { %s }\n", tt, f.prefix, f.class(tt), targetedLineCSS)
|
||||||
|
}
|
||||||
|
}
|
||||||
tts := []int{}
|
tts := []int{}
|
||||||
for tt := range css {
|
for tt := range css {
|
||||||
tts = append(tts, int(tt))
|
tts = append(tts, int(tt))
|
||||||
|
51
vendor/github.com/alecthomas/chroma/formatters/svg/font_liberation_mono.go
generated
vendored
Normal file
51
vendor/github.com/alecthomas/chroma/formatters/svg/font_liberation_mono.go
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
222
vendor/github.com/alecthomas/chroma/formatters/svg/svg.go
generated
vendored
Normal file
222
vendor/github.com/alecthomas/chroma/formatters/svg/svg.go
generated
vendored
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
// Package svg contains an SVG formatter.
|
||||||
|
package svg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/alecthomas/chroma"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Option sets an option of the SVG formatter.
|
||||||
|
type Option func(f *Formatter)
|
||||||
|
|
||||||
|
// FontFamily sets the font-family.
|
||||||
|
func FontFamily(fontFamily string) Option { return func(f *Formatter) { f.fontFamily = fontFamily } }
|
||||||
|
|
||||||
|
// EmbedFontFile embeds given font file
|
||||||
|
func EmbedFontFile(fontFamily string, fileName string) (option Option, err error) {
|
||||||
|
var format FontFormat
|
||||||
|
switch path.Ext(fileName) {
|
||||||
|
case ".woff":
|
||||||
|
format = WOFF
|
||||||
|
case ".woff2":
|
||||||
|
format = WOFF2
|
||||||
|
case ".ttf":
|
||||||
|
format = TRUETYPE
|
||||||
|
default:
|
||||||
|
return nil, errors.New("unexpected font file suffix")
|
||||||
|
}
|
||||||
|
|
||||||
|
var content []byte
|
||||||
|
if content, err = ioutil.ReadFile(fileName); err == nil {
|
||||||
|
option = EmbedFont(fontFamily, base64.StdEncoding.EncodeToString(content), format)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// EmbedFont embeds given base64 encoded font
|
||||||
|
func EmbedFont(fontFamily string, font string, format FontFormat) Option {
|
||||||
|
return func(f *Formatter) { f.fontFamily = fontFamily; f.embeddedFont = font; f.fontFormat = format }
|
||||||
|
}
|
||||||
|
|
||||||
|
// New SVG formatter.
|
||||||
|
func New(options ...Option) *Formatter {
|
||||||
|
f := &Formatter{fontFamily: "Consolas, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace"}
|
||||||
|
for _, option := range options {
|
||||||
|
option(f)
|
||||||
|
}
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formatter that generates SVG.
|
||||||
|
type Formatter struct {
|
||||||
|
fontFamily string
|
||||||
|
embeddedFont string
|
||||||
|
fontFormat FontFormat
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Formatter) Format(w io.Writer, style *chroma.Style, iterator chroma.Iterator) (err error) {
|
||||||
|
f.writeSVG(w, style, iterator.Tokens())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var svgEscaper = strings.NewReplacer(
|
||||||
|
`&`, "&",
|
||||||
|
`<`, "<",
|
||||||
|
`>`, ">",
|
||||||
|
`"`, """,
|
||||||
|
` `, " ",
|
||||||
|
` `, "    ",
|
||||||
|
)
|
||||||
|
|
||||||
|
// EscapeString escapes special characters.
|
||||||
|
func escapeString(s string) string {
|
||||||
|
return svgEscaper.Replace(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Formatter) writeSVG(w io.Writer, style *chroma.Style, tokens []chroma.Token) { // nolint: gocyclo
|
||||||
|
svgStyles := f.styleToSVG(style)
|
||||||
|
lines := chroma.SplitTokensIntoLines(tokens)
|
||||||
|
|
||||||
|
fmt.Fprint(w, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n")
|
||||||
|
fmt.Fprint(w, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n")
|
||||||
|
fmt.Fprintf(w, "<svg width=\"%dpx\" height=\"%dpx\" xmlns=\"http://www.w3.org/2000/svg\">\n", 8*maxLineWidth(lines), 10+int(16.8*float64(len(lines)+1)))
|
||||||
|
|
||||||
|
if f.embeddedFont != "" {
|
||||||
|
f.writeFontStyle(w)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(w, "<rect width=\"100%%\" height=\"100%%\" fill=\"%s\"/>\n", style.Get(chroma.Background).Background.String())
|
||||||
|
fmt.Fprintf(w, "<g font-family=\"%s\" font-size=\"14px\" fill=\"%s\">\n", f.fontFamily, style.Get(chroma.Text).Colour.String())
|
||||||
|
|
||||||
|
f.writeTokenBackgrounds(w, lines, style)
|
||||||
|
|
||||||
|
for index, tokens := range lines {
|
||||||
|
fmt.Fprintf(w, "<text x=\"0\" y=\"%fem\" xml:space=\"preserve\">", 1.2*float64(index+1))
|
||||||
|
|
||||||
|
for _, token := range tokens {
|
||||||
|
text := escapeString(token.String())
|
||||||
|
attr := f.styleAttr(svgStyles, token.Type)
|
||||||
|
if attr != "" {
|
||||||
|
text = fmt.Sprintf("<tspan %s>%s</tspan>", attr, text)
|
||||||
|
}
|
||||||
|
fmt.Fprint(w, text)
|
||||||
|
}
|
||||||
|
fmt.Fprint(w, "</text>")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprint(w, "\n</g>\n")
|
||||||
|
fmt.Fprint(w, "</svg>\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func maxLineWidth(lines [][]chroma.Token) int {
|
||||||
|
maxWidth := 0
|
||||||
|
for _, tokens := range lines {
|
||||||
|
length := 0
|
||||||
|
for _, token := range tokens {
|
||||||
|
length += len(strings.Replace(token.String(), ` `, " ", -1))
|
||||||
|
}
|
||||||
|
if length > maxWidth {
|
||||||
|
maxWidth = length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxWidth
|
||||||
|
}
|
||||||
|
|
||||||
|
// There is no background attribute for text in SVG so simply calculate the position and text
|
||||||
|
// of tokens with a background color that differs from the default and add a rectangle for each before
|
||||||
|
// adding the token.
|
||||||
|
func (f *Formatter) writeTokenBackgrounds(w io.Writer, lines [][]chroma.Token, style *chroma.Style) {
|
||||||
|
for index, tokens := range lines {
|
||||||
|
lineLength := 0
|
||||||
|
for _, token := range tokens {
|
||||||
|
length := len(strings.Replace(token.String(), ` `, " ", -1))
|
||||||
|
tokenBackground := style.Get(token.Type).Background
|
||||||
|
if tokenBackground.IsSet() && tokenBackground != style.Get(chroma.Background).Background {
|
||||||
|
fmt.Fprintf(w, "<rect id=\"%s\" x=\"%dch\" y=\"%fem\" width=\"%dch\" height=\"1.2em\" fill=\"%s\" />\n", escapeString(token.String()), lineLength, 1.2*float64(index)+0.25, length, style.Get(token.Type).Background.String())
|
||||||
|
}
|
||||||
|
lineLength += length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type FontFormat int
|
||||||
|
|
||||||
|
// https://transfonter.org/formats
|
||||||
|
const (
|
||||||
|
WOFF FontFormat = iota
|
||||||
|
WOFF2
|
||||||
|
TRUETYPE
|
||||||
|
)
|
||||||
|
|
||||||
|
var fontFormats = [...]string{
|
||||||
|
"woff",
|
||||||
|
"woff2",
|
||||||
|
"truetype",
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Formatter) writeFontStyle(w io.Writer) {
|
||||||
|
fmt.Fprintf(w, `<style>
|
||||||
|
@font-face {
|
||||||
|
font-family: '%s';
|
||||||
|
src: url(data:application/x-font-%s;charset=utf-8;base64,%s) format('%s');'
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
</style>`, f.fontFamily, fontFormats[f.fontFormat], f.embeddedFont, fontFormats[f.fontFormat])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Formatter) styleAttr(styles map[chroma.TokenType]string, tt chroma.TokenType) string {
|
||||||
|
if _, ok := styles[tt]; !ok {
|
||||||
|
tt = tt.SubCategory()
|
||||||
|
if _, ok := styles[tt]; !ok {
|
||||||
|
tt = tt.Category()
|
||||||
|
if _, ok := styles[tt]; !ok {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return styles[tt]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Formatter) styleToSVG(style *chroma.Style) map[chroma.TokenType]string {
|
||||||
|
converted := map[chroma.TokenType]string{}
|
||||||
|
bg := style.Get(chroma.Background)
|
||||||
|
// Convert the style.
|
||||||
|
for t := range chroma.StandardTypes {
|
||||||
|
entry := style.Get(t)
|
||||||
|
if t != chroma.Background {
|
||||||
|
entry = entry.Sub(bg)
|
||||||
|
}
|
||||||
|
if entry.IsZero() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
converted[t] = StyleEntryToSVG(entry)
|
||||||
|
}
|
||||||
|
return converted
|
||||||
|
}
|
||||||
|
|
||||||
|
// StyleEntryToSVG converts a chroma.StyleEntry to SVG attributes.
|
||||||
|
func StyleEntryToSVG(e chroma.StyleEntry) string {
|
||||||
|
var styles []string
|
||||||
|
|
||||||
|
if e.Colour.IsSet() {
|
||||||
|
styles = append(styles, "fill=\""+e.Colour.String()+"\"")
|
||||||
|
}
|
||||||
|
if e.Bold == chroma.Yes {
|
||||||
|
styles = append(styles, "font-weight=\"bold\"")
|
||||||
|
}
|
||||||
|
if e.Italic == chroma.Yes {
|
||||||
|
styles = append(styles, "font-style=\"italic\"")
|
||||||
|
}
|
||||||
|
if e.Underline == chroma.Yes {
|
||||||
|
styles = append(styles, "text-decoration=\"underline\"")
|
||||||
|
}
|
||||||
|
return strings.Join(styles, " ")
|
||||||
|
}
|
17
vendor/github.com/alecthomas/chroma/formatters/tty_indexed.go
generated
vendored
17
vendor/github.com/alecthomas/chroma/formatters/tty_indexed.go
generated
vendored
@ -200,6 +200,7 @@ func findClosest(table *ttyTable, seeking chroma.Colour) chroma.Colour {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func styleToEscapeSequence(table *ttyTable, style *chroma.Style) map[chroma.TokenType]string {
|
func styleToEscapeSequence(table *ttyTable, style *chroma.Style) map[chroma.TokenType]string {
|
||||||
|
style = clearBackground(style)
|
||||||
out := map[chroma.TokenType]string{}
|
out := map[chroma.TokenType]string{}
|
||||||
for _, ttype := range style.Types() {
|
for _, ttype := range style.Types() {
|
||||||
entry := style.Get(ttype)
|
entry := style.Get(ttype)
|
||||||
@ -208,16 +209,22 @@ func styleToEscapeSequence(table *ttyTable, style *chroma.Style) map[chroma.Toke
|
|||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear the background colour.
|
||||||
|
func clearBackground(style *chroma.Style) *chroma.Style {
|
||||||
|
builder := style.Builder()
|
||||||
|
bg := builder.Get(chroma.Background)
|
||||||
|
bg.Background = 0
|
||||||
|
bg.NoInherit = true
|
||||||
|
builder.AddEntry(chroma.Background, bg)
|
||||||
|
style, _ = builder.Build()
|
||||||
|
return style
|
||||||
|
}
|
||||||
|
|
||||||
type indexedTTYFormatter struct {
|
type indexedTTYFormatter struct {
|
||||||
table *ttyTable
|
table *ttyTable
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *indexedTTYFormatter) Format(w io.Writer, style *chroma.Style, it chroma.Iterator) (err error) {
|
func (c *indexedTTYFormatter) Format(w io.Writer, style *chroma.Style, it chroma.Iterator) (err error) {
|
||||||
defer func() {
|
|
||||||
if perr := recover(); perr != nil {
|
|
||||||
err = perr.(error)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
theme := styleToEscapeSequence(c.table, style)
|
theme := styleToEscapeSequence(c.table, style)
|
||||||
for token := it(); token != chroma.EOF; token = it() {
|
for token := it(); token != chroma.EOF; token = it() {
|
||||||
// TODO: Cache token lookups?
|
// TODO: Cache token lookups?
|
||||||
|
1
vendor/github.com/alecthomas/chroma/formatters/tty_truecolour.go
generated
vendored
1
vendor/github.com/alecthomas/chroma/formatters/tty_truecolour.go
generated
vendored
@ -11,6 +11,7 @@ import (
|
|||||||
var TTY16m = Register("terminal16m", chroma.FormatterFunc(trueColourFormatter))
|
var TTY16m = Register("terminal16m", chroma.FormatterFunc(trueColourFormatter))
|
||||||
|
|
||||||
func trueColourFormatter(w io.Writer, style *chroma.Style, it chroma.Iterator) error {
|
func trueColourFormatter(w io.Writer, style *chroma.Style, it chroma.Iterator) error {
|
||||||
|
style = clearBackground(style)
|
||||||
for token := it(); token != chroma.EOF; token = it() {
|
for token := it(); token != chroma.EOF; token = it() {
|
||||||
entry := style.Get(token.Type)
|
entry := style.Get(token.Type)
|
||||||
if !entry.IsZero() {
|
if !entry.IsZero() {
|
||||||
|
9
vendor/github.com/alecthomas/chroma/go.mod
generated
vendored
9
vendor/github.com/alecthomas/chroma/go.mod
generated
vendored
@ -1,22 +1,19 @@
|
|||||||
module github.com/alecthomas/chroma
|
module github.com/alecthomas/chroma
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/GeertJohan/go.rice v1.0.0
|
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 // indirect
|
||||||
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae
|
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae
|
||||||
github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8
|
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 // indirect
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 // indirect
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964
|
||||||
github.com/dlclark/regexp2 v1.1.6
|
github.com/dlclark/regexp2 v1.1.6
|
||||||
github.com/gorilla/csrf v1.6.0
|
|
||||||
github.com/gorilla/handlers v1.4.1
|
|
||||||
github.com/gorilla/mux v1.7.3
|
|
||||||
github.com/mattn/go-colorable v0.0.9
|
github.com/mattn/go-colorable v0.0.9
|
||||||
github.com/mattn/go-isatty v0.0.4
|
github.com/mattn/go-isatty v0.0.4
|
||||||
github.com/sergi/go-diff v1.0.0 // indirect
|
github.com/sergi/go-diff v1.0.0 // indirect
|
||||||
github.com/stretchr/testify v1.3.0
|
github.com/stretchr/testify v1.3.0 // indirect
|
||||||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 // indirect
|
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace github.com/GeertJohan/go.rice => github.com/alecthomas/go.rice v1.0.1-0.20190719113735-961b99d742e7
|
replace github.com/GeertJohan/go.rice => github.com/alecthomas/go.rice v1.0.1-0.20190719113735-961b99d742e7
|
||||||
|
|
||||||
|
go 1.13
|
||||||
|
25
vendor/github.com/alecthomas/chroma/go.sum
generated
vendored
25
vendor/github.com/alecthomas/chroma/go.sum
generated
vendored
@ -1,20 +1,11 @@
|
|||||||
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
|
|
||||||
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
|
||||||
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
|
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
|
||||||
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
|
||||||
github.com/alecthomas/go.rice v1.0.1-0.20190719113735-961b99d742e7 h1:0cMlP9evwgTzs5JUe2C/3rLttYjmRm0kbz9fdGBIV1E=
|
|
||||||
github.com/alecthomas/go.rice v1.0.1-0.20190719113735-961b99d742e7/go.mod h1:af5vUNlDNkCjOZeSGFgIJxDje9qdjsO6hshx0gTmZt4=
|
|
||||||
github.com/alecthomas/kong v0.1.17-0.20190424132513-439c674f7ae0/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
|
||||||
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae h1:C4Q9m+oXOxcSWwYk9XzzafY2xAVAaeubZbUHJkw3PlY=
|
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae h1:C4Q9m+oXOxcSWwYk9XzzafY2xAVAaeubZbUHJkw3PlY=
|
||||||
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
github.com/alecthomas/kong v0.2.1-0.20190708041108-0548c6b1afae/go.mod h1:+inYUSluD+p4L8KdviBSgzcqEjUQOfC5fQDRFuc36lI=
|
||||||
github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8 h1:atLL+K8Hg0e8863K2X+k7qu+xz3M2a/mWFIACAPf55M=
|
|
||||||
github.com/alecthomas/kong-hcl v0.1.8-0.20190615233001-b21fea9723c8/go.mod h1:MRgZdU3vrFd05IQ89AxUZ0aYdF39BYoNFa324SodPCA=
|
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
|
||||||
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
|
||||||
github.com/daaku/go.zipexe v1.0.0 h1:VSOgZtH418pH9L16hC/JrgSNJbbAL26pj7lmD1+CGdY=
|
|
||||||
github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E=
|
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
||||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
@ -22,25 +13,11 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
|
|||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg=
|
github.com/dlclark/regexp2 v1.1.6 h1:CqB4MjHw0MFCDj+PHHjiESmHX+N7t0tJzKvC6M97BRg=
|
||||||
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
github.com/dlclark/regexp2 v1.1.6/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||||
github.com/gorilla/csrf v1.6.0 h1:60oN1cFdncCE8tjwQ3QEkFND5k37lQPcRjnlvm7CIJ0=
|
|
||||||
github.com/gorilla/csrf v1.6.0/go.mod h1:7tSf8kmjNYr7IWDCYhd3U8Ck34iQ/Yw5CJu7bAkHEGI=
|
|
||||||
github.com/gorilla/handlers v1.4.1 h1:BHvcRGJe/TrL+OqFxoKQGddTgeibiOjaBssV5a/N9sw=
|
|
||||||
github.com/gorilla/handlers v1.4.1/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
|
||||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
|
||||||
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
|
|
||||||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
|
||||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
|
||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
|
||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
|
||||||
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
|
||||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||||
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
|
||||||
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||||
github.com/nkovacs/streamquote v1.0.0/go.mod h1:BN+NaZ2CmdKqUuTUXUEm9j95B2TRbpOWpxbJYzzgUsc=
|
|
||||||
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
|
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
|
||||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@ -52,7 +29,5 @@ github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1
|
|||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
|
||||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
|
||||||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
|
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35 h1:YAFjXN64LMvktoUZH9zgY4lGc/msGN7HQfoSuKCgaDU=
|
||||||
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20181128092732-4ed8d59d0b35/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
22
vendor/github.com/alecthomas/chroma/lexers/README.md
generated
vendored
22
vendor/github.com/alecthomas/chroma/lexers/README.md
generated
vendored
@ -10,10 +10,28 @@ Run the tests as normal:
|
|||||||
go test ./lexers
|
go test ./lexers
|
||||||
```
|
```
|
||||||
|
|
||||||
## Updating the existing tests
|
## Update existing tests
|
||||||
|
When you add a new test data file (`*.actual`), you need to regenerate all tests. That's how Chroma creates the `*.expected` test file based on the corresponding lexer.
|
||||||
|
|
||||||
You can regenerate all the test outputs
|
To regenerate all tests, type in your terminal:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
RECORD=true go test ./lexers
|
RECORD=true go test ./lexers
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This first sets the `RECORD` environment variable to `true`. Then it runs `go test` on the `./lexers` directory of the Chroma project.
|
||||||
|
|
||||||
|
(That environment variable tells Chroma it needs to output test data. After running `go test ./lexers` you can remove or reset that variable.)
|
||||||
|
|
||||||
|
### Windows users
|
||||||
|
Windows users will find that the `RECORD=true go test ./lexers` command fails in both the standard command prompt terminal and in PowerShell.
|
||||||
|
|
||||||
|
Instead we have to perform both steps separately:
|
||||||
|
|
||||||
|
- Set the `RECORD` environment variable to `true`.
|
||||||
|
+ In the regular command prompt window, the `set` command sets an environment variable for the current session: `set RECORD=true`. See [this page](https://superuser.com/questions/212150/how-to-set-env-variable-in-windows-cmd-line) for more.
|
||||||
|
+ In PowerShell, you can use the `$env:RECORD = 'true'` command for that. See [this article](https://mcpmag.com/articles/2019/03/28/environment-variables-in-powershell.aspx) for more.
|
||||||
|
+ You can also make a persistent environment variable by hand in the Windows computer settings. See [this article](https://www.computerhope.com/issues/ch000549.htm) for how.
|
||||||
|
- When the environment variable is set, run `go tests ./lexers`.
|
||||||
|
|
||||||
|
Chroma will now regenerate the test files and print its results to the console window.
|
||||||
|
2
vendor/github.com/alecthomas/chroma/lexers/a/applescript.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/a/applescript.go
generated
vendored
@ -31,7 +31,7 @@ var Applescript = internal.Register(MustNewLexer(
|
|||||||
{`\b(as )(alias |application |boolean |class |constant |date |file |integer |list |number |POSIX file |real |record |reference |RGB color |script |text |unit types|(?:Unicode )?text|string)\b`, ByGroups(Keyword, NameClass), nil},
|
{`\b(as )(alias |application |boolean |class |constant |date |file |integer |list |number |POSIX file |real |record |reference |RGB color |script |text |unit types|(?:Unicode )?text|string)\b`, ByGroups(Keyword, NameClass), nil},
|
||||||
{`\b(AppleScript|current application|false|linefeed|missing value|pi|quote|result|return|space|tab|text item delimiters|true|version)\b`, NameConstant, nil},
|
{`\b(AppleScript|current application|false|linefeed|missing value|pi|quote|result|return|space|tab|text item delimiters|true|version)\b`, NameConstant, nil},
|
||||||
{`\b(ASCII (character|number)|activate|beep|choose URL|choose application|choose color|choose file( name)?|choose folder|choose from list|choose remote application|clipboard info|close( access)?|copy|count|current date|delay|delete|display (alert|dialog)|do shell script|duplicate|exists|get eof|get volume settings|info for|launch|list (disks|folder)|load script|log|make|mount volume|new|offset|open( (for access|location))?|path to|print|quit|random number|read|round|run( script)?|say|scripting components|set (eof|the clipboard to|volume)|store script|summarize|system attribute|system info|the clipboard|time to GMT|write|quoted form)\b`, NameBuiltin, nil},
|
{`\b(ASCII (character|number)|activate|beep|choose URL|choose application|choose color|choose file( name)?|choose folder|choose from list|choose remote application|clipboard info|close( access)?|copy|count|current date|delay|delete|display (alert|dialog)|do shell script|duplicate|exists|get eof|get volume settings|info for|launch|list (disks|folder)|load script|log|make|mount volume|new|offset|open( (for access|location))?|path to|print|quit|random number|read|round|run( script)?|say|scripting components|set (eof|the clipboard to|volume)|store script|summarize|system attribute|system info|the clipboard|time to GMT|write|quoted form)\b`, NameBuiltin, nil},
|
||||||
{`\b(considering|else|error|exit|from|if|ignoring|in|repeat|tell|then|times|to|try|until|using terms from|while|whith|with timeout( of)?|with transaction|by|continue|end|its?|me|my|return|of|as)\b`, Keyword, nil},
|
{`\b(considering|else|error|exit|from|if|ignoring|in|repeat|tell|then|times|to|try|until|using terms from|while|with|with timeout( of)?|with transaction|by|continue|end|its?|me|my|return|of|as)\b`, Keyword, nil},
|
||||||
{`\b(global|local|prop(erty)?|set|get)\b`, Keyword, nil},
|
{`\b(global|local|prop(erty)?|set|get)\b`, Keyword, nil},
|
||||||
{`\b(but|put|returning|the)\b`, NameBuiltin, nil},
|
{`\b(but|put|returning|the)\b`, NameBuiltin, nil},
|
||||||
{`\b(attachment|attribute run|character|day|month|paragraph|word|year)s?\b`, NameBuiltin, nil},
|
{`\b(attachment|attribute run|character|day|month|paragraph|word|year)s?\b`, NameBuiltin, nil},
|
||||||
|
2
vendor/github.com/alecthomas/chroma/lexers/b/ballerina.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/b/ballerina.go
generated
vendored
@ -25,7 +25,7 @@ var Ballerina = internal.Register(MustNewLexer(
|
|||||||
{`(annotation|bind|but|endpoint|error|function|object|private|public|returns|service|type|var|with|worker)\b`, KeywordDeclaration, nil},
|
{`(annotation|bind|but|endpoint|error|function|object|private|public|returns|service|type|var|with|worker)\b`, KeywordDeclaration, nil},
|
||||||
{`(boolean|byte|decimal|float|int|json|map|nil|record|string|table|xml)\b`, KeywordType, nil},
|
{`(boolean|byte|decimal|float|int|json|map|nil|record|string|table|xml)\b`, KeywordType, nil},
|
||||||
{`(true|false|null)\b`, KeywordConstant, nil},
|
{`(true|false|null)\b`, KeywordConstant, nil},
|
||||||
{`import(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
{`(import)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||||
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
|
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
|
||||||
{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil},
|
{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil},
|
||||||
|
2
vendor/github.com/alecthomas/chroma/lexers/b/bash.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/b/bash.go
generated
vendored
@ -53,7 +53,7 @@ var Bash = internal.Register(MustNewLexer(
|
|||||||
{`&`, Punctuation, nil},
|
{`&`, Punctuation, nil},
|
||||||
{`\|`, Punctuation, nil},
|
{`\|`, Punctuation, nil},
|
||||||
{`\s+`, Text, nil},
|
{`\s+`, Text, nil},
|
||||||
{`\d+\b`, LiteralNumber, nil},
|
{`\d+(?= |$)`, LiteralNumber, nil},
|
||||||
{"[^=\\s\\[\\]{}()$\"\\'`\\\\<&|;]+", Text, nil},
|
{"[^=\\s\\[\\]{}()$\"\\'`\\\\<&|;]+", Text, nil},
|
||||||
{`<`, Text, nil},
|
{`<`, Text, nil},
|
||||||
},
|
},
|
||||||
|
76
vendor/github.com/alecthomas/chroma/lexers/b/bibtex.go
generated
vendored
Normal file
76
vendor/github.com/alecthomas/chroma/lexers/b/bibtex.go
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package b
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
"github.com/alecthomas/chroma/lexers/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Bibtex lexer.
|
||||||
|
var Bibtex = internal.Register(MustNewLexer(
|
||||||
|
&Config{
|
||||||
|
Name: "BibTeX",
|
||||||
|
Aliases: []string{"bib", "bibtex"},
|
||||||
|
Filenames: []string{"*.bib"},
|
||||||
|
MimeTypes: []string{"text/x-bibtex"},
|
||||||
|
NotMultiline: true,
|
||||||
|
CaseInsensitive: true,
|
||||||
|
},
|
||||||
|
Rules{
|
||||||
|
"root": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`@comment`, Comment, nil},
|
||||||
|
{`@preamble`, NameClass, Push("closing-brace", "value", "opening-brace")},
|
||||||
|
{`@string`, NameClass, Push("closing-brace", "field", "opening-brace")},
|
||||||
|
{"@[a-z_@!$&*+\\-./:;<>?\\[\\\\\\]^`|~][\\w@!$&*+\\-./:;<>?\\[\\\\\\]^`|~]*", NameClass, Push("closing-brace", "command-body", "opening-brace")},
|
||||||
|
{`.+`, Comment, nil},
|
||||||
|
},
|
||||||
|
"opening-brace": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`[{(]`, Punctuation, Pop(1)},
|
||||||
|
},
|
||||||
|
"closing-brace": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`[})]`, Punctuation, Pop(1)},
|
||||||
|
},
|
||||||
|
"command-body": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`[^\s\,\}]+`, NameLabel, Push("#pop", "fields")},
|
||||||
|
},
|
||||||
|
"fields": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`,`, Punctuation, Push("field")},
|
||||||
|
Default(Pop(1)),
|
||||||
|
},
|
||||||
|
"field": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{"[a-z_@!$&*+\\-./:;<>?\\[\\\\\\]^`|~][\\w@!$&*+\\-./:;<>?\\[\\\\\\]^`|~]*", NameAttribute, Push("value", "=")},
|
||||||
|
Default(Pop(1)),
|
||||||
|
},
|
||||||
|
"=": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`=`, Punctuation, Pop(1)},
|
||||||
|
},
|
||||||
|
"value": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{"[a-z_@!$&*+\\-./:;<>?\\[\\\\\\]^`|~][\\w@!$&*+\\-./:;<>?\\[\\\\\\]^`|~]*", NameVariable, nil},
|
||||||
|
{`"`, LiteralString, Push("quoted-string")},
|
||||||
|
{`\{`, LiteralString, Push("braced-string")},
|
||||||
|
{`[\d]+`, LiteralNumber, nil},
|
||||||
|
{`#`, Punctuation, nil},
|
||||||
|
Default(Pop(1)),
|
||||||
|
},
|
||||||
|
"quoted-string": {
|
||||||
|
{`\{`, LiteralString, Push("braced-string")},
|
||||||
|
{`"`, LiteralString, Pop(1)},
|
||||||
|
{`[^\{\"]+`, LiteralString, nil},
|
||||||
|
},
|
||||||
|
"braced-string": {
|
||||||
|
{`\{`, LiteralString, Push()},
|
||||||
|
{`\}`, LiteralString, Pop(1)},
|
||||||
|
{`[^\{\}]+`, LiteralString, nil},
|
||||||
|
},
|
||||||
|
"whitespace": {
|
||||||
|
{`\s+`, Text, nil},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
3
vendor/github.com/alecthomas/chroma/lexers/c/cpp.go
generated
vendored
3
vendor/github.com/alecthomas/chroma/lexers/c/cpp.go
generated
vendored
@ -24,7 +24,8 @@ var CPP = internal.Register(MustNewLexer(
|
|||||||
{`(u8|u|U)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
|
{`(u8|u|U)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
|
||||||
{`(L?)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
|
{`(L?)(")`, ByGroups(LiteralStringAffix, LiteralString), Push("string")},
|
||||||
{`(L?)(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')`, ByGroups(LiteralStringAffix, LiteralStringChar, LiteralStringChar, LiteralStringChar), nil},
|
{`(L?)(')(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|[^\\\'\n])(')`, ByGroups(LiteralStringAffix, LiteralStringChar, LiteralStringChar, LiteralStringChar), nil},
|
||||||
{`(\.([0-9](?:'?[0-9]+)*)([eE][+-]?([0-9]('?[0-9]+)*))?|([0-9]('?[0-9]+)*)(([eE][+-]?([0-9]('?[0-9]+)*))|\.([0-9]('?[0-9]+)*)?([eE][+-]?([0-9]('?[0-9]+)*))?)|0[xX](\.([0-9A-Fa-f]('?[0-9A-Fa-f]+)*)([pP][-+]?([0-9]('?[0-9]+)*))?|([0-9A-Fa-f]('?[0-9A-Fa-f]+)*)(([pP][-+]?([0-9]('?[0-9]+)*))|\.([0-9A-Fa-f]('?[0-9A-Fa-f]+)*)?([pP][-+]?([0-9]('?[0-9]+)*))?)))[fFLlUu]*`, LiteralNumberFloat, nil},
|
{`(\d+\.\d*|\.\d+|\d+)[eE][+-]?\d+[LlUu]*`, LiteralNumberFloat, nil},
|
||||||
|
{`(\d+\.\d*|\.\d+|\d+[fF])[fF]?`, LiteralNumberFloat, nil},
|
||||||
{`0[xX]([0-9A-Fa-f]('?[0-9A-Fa-f]+)*)[LlUu]*`, LiteralNumberHex, nil},
|
{`0[xX]([0-9A-Fa-f]('?[0-9A-Fa-f]+)*)[LlUu]*`, LiteralNumberHex, nil},
|
||||||
{`0('?[0-7]+)+[LlUu]*`, LiteralNumberOct, nil},
|
{`0('?[0-7]+)+[LlUu]*`, LiteralNumberOct, nil},
|
||||||
{`0[Bb][01]('?[01]+)*[LlUu]*`, LiteralNumberBin, nil},
|
{`0[Bb][01]('?[01]+)*[LlUu]*`, LiteralNumberBin, nil},
|
||||||
|
2
vendor/github.com/alecthomas/chroma/lexers/d/docker.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/d/docker.go
generated
vendored
@ -22,7 +22,7 @@ var Docker = internal.Register(MustNewLexer(
|
|||||||
{`(ONBUILD)((?:\s*\\?\s*))`, ByGroups(Keyword, Using(b.Bash)), nil},
|
{`(ONBUILD)((?:\s*\\?\s*))`, ByGroups(Keyword, Using(b.Bash)), nil},
|
||||||
{`(HEALTHCHECK)(((?:\s*\\?\s*)--\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
{`(HEALTHCHECK)(((?:\s*\\?\s*)--\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
||||||
{`(VOLUME|ENTRYPOINT|CMD|SHELL)((?:\s*\\?\s*))(\[.*?\])`, ByGroups(Keyword, Using(b.Bash), Using(j.JSON)), nil},
|
{`(VOLUME|ENTRYPOINT|CMD|SHELL)((?:\s*\\?\s*))(\[.*?\])`, ByGroups(Keyword, Using(b.Bash), Using(j.JSON)), nil},
|
||||||
{`(LABEL|ENV|ARG)(((?:\s*\\?\s*)\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
{`(LABEL|ENV|ARG)((?:(?:\s*\\?\s*)\w+=\w+(?:\s*\\?\s*))*)`, ByGroups(Keyword, Using(b.Bash)), nil},
|
||||||
{`((?:FROM|MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)|VOLUME)\b(.*)`, ByGroups(Keyword, LiteralString), nil},
|
{`((?:FROM|MAINTAINER|EXPOSE|WORKDIR|USER|STOPSIGNAL)|VOLUME)\b(.*)`, ByGroups(Keyword, LiteralString), nil},
|
||||||
{`((?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY))`, Keyword, nil},
|
{`((?:RUN|CMD|ENTRYPOINT|ENV|ARG|LABEL|ADD|COPY))`, Keyword, nil},
|
||||||
{`(.*\\\n)*.+`, Using(b.Bash), nil},
|
{`(.*\\\n)*.+`, Using(b.Bash), nil},
|
||||||
|
5
vendor/github.com/alecthomas/chroma/lexers/h/http.go
generated
vendored
5
vendor/github.com/alecthomas/chroma/lexers/h/http.go
generated
vendored
@ -38,7 +38,6 @@ func httpContentBlock(groups []string, lexer Lexer) Iterator {
|
|||||||
{Generic, groups[0]},
|
{Generic, groups[0]},
|
||||||
}
|
}
|
||||||
return Literator(tokens...)
|
return Literator(tokens...)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func httpHeaderBlock(groups []string, lexer Lexer) Iterator {
|
func httpHeaderBlock(groups []string, lexer Lexer) Iterator {
|
||||||
@ -66,7 +65,7 @@ func httpBodyContentTypeLexer(lexer Lexer) Lexer { return &httpBodyContentTyper{
|
|||||||
|
|
||||||
type httpBodyContentTyper struct{ Lexer }
|
type httpBodyContentTyper struct{ Lexer }
|
||||||
|
|
||||||
func (d *httpBodyContentTyper) Tokenise(options *TokeniseOptions, text string) (Iterator, error) {
|
func (d *httpBodyContentTyper) Tokenise(options *TokeniseOptions, text string) (Iterator, error) { // nolint: gocognit
|
||||||
var contentType string
|
var contentType string
|
||||||
var isContentType bool
|
var isContentType bool
|
||||||
var subIterator Iterator
|
var subIterator Iterator
|
||||||
@ -123,9 +122,7 @@ func (d *httpBodyContentTyper) Tokenise(options *TokeniseOptions, text string) (
|
|||||||
return EOF
|
return EOF
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return token
|
return token
|
||||||
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
1
vendor/github.com/alecthomas/chroma/lexers/internal/api.go
generated
vendored
1
vendor/github.com/alecthomas/chroma/lexers/internal/api.go
generated
vendored
@ -1,3 +1,4 @@
|
|||||||
|
// Package internal contains common API functions and structures shared between lexer packages.
|
||||||
package internal
|
package internal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
73
vendor/github.com/alecthomas/chroma/lexers/j/j.go
generated
vendored
Normal file
73
vendor/github.com/alecthomas/chroma/lexers/j/j.go
generated
vendored
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package j
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
"github.com/alecthomas/chroma/lexers/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// J lexer.
|
||||||
|
var J = internal.Register(MustNewLexer(
|
||||||
|
&Config{
|
||||||
|
Name: "J",
|
||||||
|
Aliases: []string{"j"},
|
||||||
|
Filenames: []string{"*.ijs"},
|
||||||
|
MimeTypes: []string{"text/x-j"},
|
||||||
|
},
|
||||||
|
Rules{
|
||||||
|
"root": {
|
||||||
|
{`#!.*$`, CommentPreproc, nil},
|
||||||
|
{`NB\..*`, CommentSingle, nil},
|
||||||
|
{`\n+\s*Note`, CommentMultiline, Push("comment")},
|
||||||
|
{`\s*Note.*`, CommentSingle, nil},
|
||||||
|
{`\s+`, Text, nil},
|
||||||
|
{`'`, LiteralString, Push("singlequote")},
|
||||||
|
{`0\s+:\s*0|noun\s+define\s*$`, NameEntity, Push("nounDefinition")},
|
||||||
|
{`(([1-4]|13)\s+:\s*0|(adverb|conjunction|dyad|monad|verb)\s+define)\b`, NameFunction, Push("explicitDefinition")},
|
||||||
|
{Words(``, `\b[a-zA-Z]\w*\.`, `for_`, `goto_`, `label_`), NameLabel, nil},
|
||||||
|
{Words(``, `\.`, `assert`, `break`, `case`, `catch`, `catchd`, `catcht`, `continue`, `do`, `else`, `elseif`, `end`, `fcase`, `for`, `if`, `return`, `select`, `throw`, `try`, `while`, `whilst`), NameLabel, nil},
|
||||||
|
{`\b[a-zA-Z]\w*`, NameVariable, nil},
|
||||||
|
{Words(``, ``, `ARGV`, `CR`, `CRLF`, `DEL`, `Debug`, `EAV`, `EMPTY`, `FF`, `JVERSION`, `LF`, `LF2`, `Note`, `TAB`, `alpha17`, `alpha27`, `apply`, `bind`, `boxopen`, `boxxopen`, `bx`, `clear`, `cutLF`, `cutopen`, `datatype`, `def`, `dfh`, `drop`, `each`, `echo`, `empty`, `erase`, `every`, `evtloop`, `exit`, `expand`, `fetch`, `file2url`, `fixdotdot`, `fliprgb`, `getargs`, `getenv`, `hfd`, `inv`, `inverse`, `iospath`, `isatty`, `isutf8`, `items`, `leaf`, `list`, `nameclass`, `namelist`, `names`, `nc`, `nl`, `on`, `pick`, `rows`, `script`, `scriptd`, `sign`, `sminfo`, `smoutput`, `sort`, `split`, `stderr`, `stdin`, `stdout`, `table`, `take`, `timespacex`, `timex`, `tmoutput`, `toCRLF`, `toHOST`, `toJ`, `tolower`, `toupper`, `type`, `ucp`, `ucpcount`, `usleep`, `utf8`, `uucp`), NameFunction, nil},
|
||||||
|
{`=[.:]`, Operator, nil},
|
||||||
|
{"[-=+*#$%@!~`^&\";:.,<>{}\\[\\]\\\\|/]", Operator, nil},
|
||||||
|
{`[abCdDeEfHiIjLMoprtT]\.`, KeywordReserved, nil},
|
||||||
|
{`[aDiLpqsStux]\:`, KeywordReserved, nil},
|
||||||
|
{`(_[0-9])\:`, KeywordConstant, nil},
|
||||||
|
{`\(`, Punctuation, Push("parentheses")},
|
||||||
|
Include("numbers"),
|
||||||
|
},
|
||||||
|
"comment": {
|
||||||
|
{`[^)]`, CommentMultiline, nil},
|
||||||
|
{`^\)`, CommentMultiline, Pop(1)},
|
||||||
|
{`[)]`, CommentMultiline, nil},
|
||||||
|
},
|
||||||
|
"explicitDefinition": {
|
||||||
|
{`\b[nmuvxy]\b`, NameDecorator, nil},
|
||||||
|
Include("root"),
|
||||||
|
{`[^)]`, Name, nil},
|
||||||
|
{`^\)`, NameLabel, Pop(1)},
|
||||||
|
{`[)]`, Name, nil},
|
||||||
|
},
|
||||||
|
"numbers": {
|
||||||
|
{`\b_{1,2}\b`, LiteralNumber, nil},
|
||||||
|
{`_?\d+(\.\d+)?(\s*[ejr]\s*)_?\d+(\.?=\d+)?`, LiteralNumber, nil},
|
||||||
|
{`_?\d+\.(?=\d+)`, LiteralNumberFloat, nil},
|
||||||
|
{`_?\d+x`, LiteralNumberIntegerLong, nil},
|
||||||
|
{`_?\d+`, LiteralNumberInteger, nil},
|
||||||
|
},
|
||||||
|
"nounDefinition": {
|
||||||
|
{`[^)]`, LiteralString, nil},
|
||||||
|
{`^\)`, NameLabel, Pop(1)},
|
||||||
|
{`[)]`, LiteralString, nil},
|
||||||
|
},
|
||||||
|
"parentheses": {
|
||||||
|
{`\)`, Punctuation, Pop(1)},
|
||||||
|
Include("explicitDefinition"),
|
||||||
|
Include("root"),
|
||||||
|
},
|
||||||
|
"singlequote": {
|
||||||
|
{`[^']`, LiteralString, nil},
|
||||||
|
{`''`, LiteralString, nil},
|
||||||
|
{`'`, LiteralString, Pop(1)},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
7
vendor/github.com/alecthomas/chroma/lexers/j/java.go
generated
vendored
7
vendor/github.com/alecthomas/chroma/lexers/j/java.go
generated
vendored
@ -20,7 +20,7 @@ var Java = internal.Register(MustNewLexer(
|
|||||||
{`//.*?\n`, CommentSingle, nil},
|
{`//.*?\n`, CommentSingle, nil},
|
||||||
{`/\*.*?\*/`, CommentMultiline, nil},
|
{`/\*.*?\*/`, CommentMultiline, nil},
|
||||||
{`(assert|break|case|catch|continue|default|do|else|finally|for|if|goto|instanceof|new|return|switch|this|throw|try|while)\b`, Keyword, nil},
|
{`(assert|break|case|catch|continue|default|do|else|finally|for|if|goto|instanceof|new|return|switch|this|throw|try|while)\b`, Keyword, nil},
|
||||||
{`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
|
{`((?:(?:[^\W\d]|\$)[\w.\[\]$<>]*\s+)+?)((?:[^\W\d]|\$)[\w$]*)(\s*)(\()`, ByGroups(UsingSelf("root"), NameFunction, Text, Operator), nil},
|
||||||
{`@[^\W\d][\w.]*`, NameDecorator, nil},
|
{`@[^\W\d][\w.]*`, NameDecorator, nil},
|
||||||
{`(abstract|const|enum|extends|final|implements|native|private|protected|public|static|strictfp|super|synchronized|throws|transient|volatile)\b`, KeywordDeclaration, nil},
|
{`(abstract|const|enum|extends|final|implements|native|private|protected|public|static|strictfp|super|synchronized|throws|transient|volatile)\b`, KeywordDeclaration, nil},
|
||||||
{`(boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil},
|
{`(boolean|byte|char|double|float|int|long|short|void)\b`, KeywordType, nil},
|
||||||
@ -30,7 +30,7 @@ var Java = internal.Register(MustNewLexer(
|
|||||||
{`(import(?:\s+static)?)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
{`(import(?:\s+static)?)(\s+)`, ByGroups(KeywordNamespace, Text), Push("import")},
|
||||||
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
|
||||||
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
|
{`'\\.'|'[^\\]'|'\\u[0-9a-fA-F]{4}'`, LiteralStringChar, nil},
|
||||||
{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Punctuation, NameAttribute), nil},
|
{`(\.)((?:[^\W\d]|\$)[\w$]*)`, ByGroups(Operator, NameAttribute), nil},
|
||||||
{`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil},
|
{`^\s*([^\W\d]|\$)[\w$]*:`, NameLabel, nil},
|
||||||
{`([^\W\d]|\$)[\w$]*`, Name, nil},
|
{`([^\W\d]|\$)[\w$]*`, Name, nil},
|
||||||
{`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFdD]?|[0-9][eE][+\-]?[0-9][0-9_]*[fFdD]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFdD]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFdD]?`, LiteralNumberFloat, nil},
|
{`([0-9][0-9_]*\.([0-9][0-9_]*)?|\.[0-9][0-9_]*)([eE][+\-]?[0-9][0-9_]*)?[fFdD]?|[0-9][eE][+\-]?[0-9][0-9_]*[fFdD]?|[0-9]([eE][+\-]?[0-9][0-9_]*)?[fFdD]|0[xX]([0-9a-fA-F][0-9a-fA-F_]*\.?|([0-9a-fA-F][0-9a-fA-F_]*)?\.[0-9a-fA-F][0-9a-fA-F_]*)[pP][+\-]?[0-9][0-9_]*[fFdD]?`, LiteralNumberFloat, nil},
|
||||||
@ -38,8 +38,7 @@ var Java = internal.Register(MustNewLexer(
|
|||||||
{`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil},
|
{`0[bB][01][01_]*[lL]?`, LiteralNumberBin, nil},
|
||||||
{`0[0-7_]+[lL]?`, LiteralNumberOct, nil},
|
{`0[0-7_]+[lL]?`, LiteralNumberOct, nil},
|
||||||
{`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil},
|
{`0|[1-9][0-9_]*[lL]?`, LiteralNumberInteger, nil},
|
||||||
{`[~^*!%&<>|+=:/?-]`, Operator, nil},
|
{`[~^*!%&\[\](){}<>|+=:;,./?-]`, Operator, nil},
|
||||||
{`[\[\](){};,.]`, Punctuation, nil},
|
|
||||||
{`\n`, Text, nil},
|
{`\n`, Text, nil},
|
||||||
},
|
},
|
||||||
"class": {
|
"class": {
|
||||||
|
43
vendor/github.com/alecthomas/chroma/lexers/m/mlir.go
generated
vendored
Normal file
43
vendor/github.com/alecthomas/chroma/lexers/m/mlir.go
generated
vendored
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package m
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
"github.com/alecthomas/chroma/lexers/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MLIR lexer.
|
||||||
|
var Mlir = internal.Register(MustNewLexer(
|
||||||
|
&Config{
|
||||||
|
Name: "MLIR",
|
||||||
|
Aliases: []string{"mlir"},
|
||||||
|
Filenames: []string{"*.mlir"},
|
||||||
|
MimeTypes: []string{"text/x-mlir"},
|
||||||
|
},
|
||||||
|
Rules{
|
||||||
|
"root": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`c?"[^"]*?"`, LiteralString, nil},
|
||||||
|
{`\^([-a-zA-Z$._][\w\-$.0-9]*)\s*`, NameLabel, nil},
|
||||||
|
{`([\w\d_$.]+)\s*=`, NameLabel, nil},
|
||||||
|
Include("keyword"),
|
||||||
|
{`->`, Punctuation, nil},
|
||||||
|
{`@([\w_][\w\d_$.]*)`, NameFunction, nil},
|
||||||
|
{`[%#][\w\d_$.]+`, NameVariable, nil},
|
||||||
|
{`([1-9?][\d?]*\s*x)+`, LiteralNumber, nil},
|
||||||
|
{`0[xX][a-fA-F0-9]+`, LiteralNumber, nil},
|
||||||
|
{`-?\d+(?:[.]\d+)?(?:[eE][-+]?\d+(?:[.]\d+)?)?`, LiteralNumber, nil},
|
||||||
|
{`[=<>{}\[\]()*.,!:]|x\b`, Punctuation, nil},
|
||||||
|
{`[\w\d]+`, Text, nil},
|
||||||
|
},
|
||||||
|
"whitespace": {
|
||||||
|
{`(\n|\s)+`, Text, nil},
|
||||||
|
{`//.*?\n`, Comment, nil},
|
||||||
|
},
|
||||||
|
"keyword": {
|
||||||
|
{Words(``, ``, `constant`, `return`), KeywordType, nil},
|
||||||
|
{Words(``, ``, `func`, `loc`, `memref`, `tensor`, `vector`), KeywordType, nil},
|
||||||
|
{`bf16|f16|f32|f64|index`, Keyword, nil},
|
||||||
|
{`i[1-9]\d*`, Keyword, nil},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
2
vendor/github.com/alecthomas/chroma/lexers/m/mysql.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/m/mysql.go
generated
vendored
@ -26,7 +26,7 @@ var MySQL = internal.Register(MustNewLexer(
|
|||||||
{`((?:_[a-z0-9]+)?)(")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Push("double-string")},
|
{`((?:_[a-z0-9]+)?)(")`, ByGroups(LiteralStringAffix, LiteralStringDouble), Push("double-string")},
|
||||||
{"[+*/<>=~!@#%^&|`?-]", Operator, nil},
|
{"[+*/<>=~!@#%^&|`?-]", Operator, nil},
|
||||||
{`\b(tinyint|smallint|mediumint|int|integer|bigint|date|datetime|time|bit|bool|tinytext|mediumtext|longtext|text|tinyblob|mediumblob|longblob|blob|float|double|double\s+precision|real|numeric|dec|decimal|timestamp|year|char|varchar|varbinary|varcharacter|enum|set)(\b\s*)(\()?`, ByGroups(KeywordType, Text, Punctuation), nil},
|
{`\b(tinyint|smallint|mediumint|int|integer|bigint|date|datetime|time|bit|bool|tinytext|mediumtext|longtext|text|tinyblob|mediumblob|longblob|blob|float|double|double\s+precision|real|numeric|dec|decimal|timestamp|year|char|varchar|varbinary|varcharacter|enum|set)(\b\s*)(\()?`, ByGroups(KeywordType, Text, Punctuation), nil},
|
||||||
{`\b(add|all|alter|analyze|and|as|asc|asensitive|before|between|bigint|binary|blob|both|by|call|cascade|case|change|char|character|check|collate|column|condition|constraint|continue|convert|create|cross|current_date|current_time|current_timestamp|current_user|cursor|database|databases|day_hour|day_microsecond|day_minute|day_second|dec|decimal|declare|default|delayed|delete|desc|describe|deterministic|distinct|distinctrow|div|double|drop|dual|each|else|elseif|enclosed|escaped|exists|exit|explain|fetch|flush|float|float4|float8|for|force|foreign|from|fulltext|grant|group|having|high_priority|hour_microsecond|hour_minute|hour_second|if|ignore|in|index|infile|inner|inout|insensitive|insert|int|int1|int2|int3|int4|int8|integer|interval|into|is|iterate|join|key|keys|kill|leading|leave|left|like|limit|lines|load|localtime|localtimestamp|lock|long|loop|low_priority|match|minute_microsecond|minute_second|mod|modifies|natural|no_write_to_binlog|not|numeric|on|optimize|option|optionally|or|order|out|outer|outfile|precision|primary|procedure|purge|raid0|read|reads|real|references|regexp|release|rename|repeat|replace|require|restrict|return|revoke|right|rlike|schema|schemas|second_microsecond|select|sensitive|separator|set|show|smallint|soname|spatial|specific|sql|sql_big_result|sql_calc_found_rows|sql_small_result|sqlexception|sqlstate|sqlwarning|ssl|starting|straight_join|table|terminated|then|to|trailing|trigger|undo|union|unique|unlock|unsigned|update|usage|use|using|utc_date|utc_time|utc_timestamp|values|varying|when|where|while|with|write|x509|xor|year_month|zerofill)\b`, Keyword, nil},
|
{`\b(add|all|alter|analyze|and|as|asc|asensitive|before|between|bigint|binary|blob|both|by|call|cascade|case|change|char|character|check|collate|column|condition|constraint|continue|convert|create|cross|current_date|current_time|current_timestamp|current_user|cursor|database|databases|day_hour|day_microsecond|day_minute|day_second|dec|decimal|declare|default|delayed|delete|desc|describe|deterministic|distinct|distinctrow|div|double|drop|dual|each|else|elseif|enclosed|escaped|exists|exit|explain|fetch|flush|float|float4|float8|for|force|foreign|from|fulltext|grant|group|having|high_priority|hour_microsecond|hour_minute|hour_second|identified|if|ignore|in|index|infile|inner|inout|insensitive|insert|int|int1|int2|int3|int4|int8|integer|interval|into|is|iterate|join|key|keys|kill|leading|leave|left|like|limit|lines|load|localtime|localtimestamp|lock|long|loop|low_priority|match|minute_microsecond|minute_second|mod|modifies|natural|no_write_to_binlog|not|numeric|on|optimize|option|optionally|or|order|out|outer|outfile|precision|primary|privileges|procedure|purge|raid0|read|reads|real|references|regexp|release|rename|repeat|replace|require|restrict|return|revoke|right|rlike|schema|schemas|second_microsecond|select|sensitive|separator|set|show|smallint|soname|spatial|specific|sql|sql_big_result|sql_calc_found_rows|sql_small_result|sqlexception|sqlstate|sqlwarning|ssl|starting|straight_join|table|terminated|then|to|trailing|trigger|undo|union|unique|unlock|unsigned|update|usage|use|user|using|utc_date|utc_time|utc_timestamp|values|varying|when|where|while|with|write|x509|xor|year_month|zerofill)\b`, Keyword, nil},
|
||||||
{`\b(auto_increment|engine|charset|tables)\b`, KeywordPseudo, nil},
|
{`\b(auto_increment|engine|charset|tables)\b`, KeywordPseudo, nil},
|
||||||
{`(true|false|null)`, NameConstant, nil},
|
{`(true|false|null)`, NameConstant, nil},
|
||||||
{`([a-z_]\w*)(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil},
|
{`([a-z_]\w*)(\s*)(\()`, ByGroups(NameFunction, Text, Punctuation), nil},
|
||||||
|
1
vendor/github.com/alecthomas/chroma/lexers/n/nim.go
generated
vendored
1
vendor/github.com/alecthomas/chroma/lexers/n/nim.go
generated
vendored
@ -16,6 +16,7 @@ var Nim = internal.Register(MustNewLexer(
|
|||||||
},
|
},
|
||||||
Rules{
|
Rules{
|
||||||
"root": {
|
"root": {
|
||||||
|
{`#\[[\s\S]*?\]#`, CommentMultiline, nil},
|
||||||
{`##.*$`, LiteralStringDoc, nil},
|
{`##.*$`, LiteralStringDoc, nil},
|
||||||
{`#.*$`, Comment, nil},
|
{`#.*$`, Comment, nil},
|
||||||
{`[*=><+\-/@$~&%!?|\\\[\]]`, Operator, nil},
|
{`[*=><+\-/@$~&%!?|\\\[\]]`, Operator, nil},
|
||||||
|
4
vendor/github.com/alecthomas/chroma/lexers/p/powershell.go
generated
vendored
4
vendor/github.com/alecthomas/chroma/lexers/p/powershell.go
generated
vendored
@ -22,6 +22,7 @@ var Powershell = internal.Register(MustNewLexer(
|
|||||||
{`^(\s*#[#\s]*)(\.(?:component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis))([^\n]*$)`, ByGroups(Comment, LiteralStringDoc, Comment), nil},
|
{`^(\s*#[#\s]*)(\.(?:component|description|example|externalhelp|forwardhelpcategory|forwardhelptargetname|functionality|inputs|link|notes|outputs|parameter|remotehelprunspace|role|synopsis))([^\n]*$)`, ByGroups(Comment, LiteralStringDoc, Comment), nil},
|
||||||
{`#[^\n]*?$`, Comment, nil},
|
{`#[^\n]*?$`, Comment, nil},
|
||||||
{`(<|<)#`, CommentMultiline, Push("multline")},
|
{`(<|<)#`, CommentMultiline, Push("multline")},
|
||||||
|
{`(?i)([A-Z]:)`, Name, nil},
|
||||||
{`@"\n`, LiteralStringHeredoc, Push("heredoc-double")},
|
{`@"\n`, LiteralStringHeredoc, Push("heredoc-double")},
|
||||||
{`@'\n.*?\n'@`, LiteralStringHeredoc, nil},
|
{`@'\n.*?\n'@`, LiteralStringHeredoc, nil},
|
||||||
{"`[\\'\"$@-]", Punctuation, nil},
|
{"`[\\'\"$@-]", Punctuation, nil},
|
||||||
@ -30,7 +31,8 @@ var Powershell = internal.Register(MustNewLexer(
|
|||||||
{`(\$|@@|@)((global|script|private|env):)?\w+`, NameVariable, nil},
|
{`(\$|@@|@)((global|script|private|env):)?\w+`, NameVariable, nil},
|
||||||
{`(while|validateset|validaterange|validatepattern|validatelength|validatecount|until|trap|switch|return|ref|process|param|parameter|in|if|global:|function|foreach|for|finally|filter|end|elseif|else|dynamicparam|do|default|continue|cmdletbinding|break|begin|alias|\?|%|#script|#private|#local|#global|mandatory|parametersetname|position|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|helpmessage|try|catch|throw)\b`, Keyword, nil},
|
{`(while|validateset|validaterange|validatepattern|validatelength|validatecount|until|trap|switch|return|ref|process|param|parameter|in|if|global:|function|foreach|for|finally|filter|end|elseif|else|dynamicparam|do|default|continue|cmdletbinding|break|begin|alias|\?|%|#script|#private|#local|#global|mandatory|parametersetname|position|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|helpmessage|try|catch|throw)\b`, Keyword, nil},
|
||||||
{`-(and|as|band|bnot|bor|bxor|casesensitive|ccontains|ceq|cge|cgt|cle|clike|clt|cmatch|cne|cnotcontains|cnotlike|cnotmatch|contains|creplace|eq|exact|f|file|ge|gt|icontains|ieq|ige|igt|ile|ilike|ilt|imatch|ine|inotcontains|inotlike|inotmatch|ireplace|is|isnot|le|like|lt|match|ne|not|notcontains|notlike|notmatch|or|regex|replace|wildcard)\b`, Operator, nil},
|
{`-(and|as|band|bnot|bor|bxor|casesensitive|ccontains|ceq|cge|cgt|cle|clike|clt|cmatch|cne|cnotcontains|cnotlike|cnotmatch|contains|creplace|eq|exact|f|file|ge|gt|icontains|ieq|ige|igt|ile|ilike|ilt|imatch|ine|inotcontains|inotlike|inotmatch|ireplace|is|isnot|le|like|lt|match|ne|not|notcontains|notlike|notmatch|or|regex|replace|wildcard)\b`, Operator, nil},
|
||||||
{`(write|where|wait|use|update|unregister|undo|trace|test|tee|take|suspend|stop|start|split|sort|skip|show|set|send|select|scroll|resume|restore|restart|resolve|resize|reset|rename|remove|register|receive|read|push|pop|ping|out|new|move|measure|limit|join|invoke|import|group|get|format|foreach|export|expand|exit|enter|enable|disconnect|disable|debug|cxnew|copy|convertto|convertfrom|convert|connect|complete|compare|clear|checkpoint|aggregate|add)-[a-z_]\w*\b`, NameBuiltin, nil},
|
{`(write|where|watch|wait|use|update|unregister|unpublish|unprotect|unlock|uninstall|undo|unblock|trace|test|tee|take|sync|switch|suspend|submit|stop|step|start|split|sort|skip|show|set|send|select|search|scroll|save|revoke|resume|restore|restart|resolve|resize|reset|request|repair|rename|remove|register|redo|receive|read|push|publish|protect|pop|ping|out|optimize|open|new|move|mount|merge|measure|lock|limit|join|invoke|install|initialize|import|hide|group|grant|get|format|foreach|find|export|expand|exit|enter|enable|edit|dismount|disconnect|disable|deny|debug|cxnew|copy|convertto|convertfrom|convert|connect|confirm|compress|complete|compare|close|clear|checkpoint|block|backup|assert|approve|aggregate|add)-[a-z_]\w*\b`, NameBuiltin, nil},
|
||||||
|
{`(ac|asnp|cat|cd|cfs|chdir|clc|clear|clhy|cli|clp|cls|clv|cnsn|compare|copy|cp|cpi|cpp|curl|cvpa|dbp|del|diff|dir|dnsn|ebp|echo|epal|epcsv|epsn|erase|etsn|exsn|fc|fhx|fl|foreach|ft|fw|gal|gbp|gc|gci|gcm|gcs|gdr|ghy|gi|gjb|gl|gm|gmo|gp|gps|gpv|group|gsn|gsnp|gsv|gu|gv|gwmi|h|history|icm|iex|ihy|ii|ipal|ipcsv|ipmo|ipsn|irm|ise|iwmi|iwr|kill|lp|ls|man|md|measure|mi|mount|move|mp|mv|nal|ndr|ni|nmo|npssc|nsn|nv|ogv|oh|popd|ps|pushd|pwd|r|rbp|rcjb|rcsn|rd|rdr|ren|ri|rjb|rm|rmdir|rmo|rni|rnp|rp|rsn|rsnp|rujb|rv|rvpa|rwmi|sajb|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spjb|spps|spsv|start|sujb|sv|swmi|tee|trcm|type|wget|where|wjb|write)\s`, NameBuiltin, nil},
|
||||||
{"\\[[a-z_\\[][\\w. `,\\[\\]]*\\]", NameConstant, nil},
|
{"\\[[a-z_\\[][\\w. `,\\[\\]]*\\]", NameConstant, nil},
|
||||||
{`-[a-z_]\w*`, Name, nil},
|
{`-[a-z_]\w*`, Name, nil},
|
||||||
{`\w+`, Name, nil},
|
{`\w+`, Name, nil},
|
||||||
|
200
vendor/github.com/alecthomas/chroma/lexers/s/sml.go
generated
vendored
Normal file
200
vendor/github.com/alecthomas/chroma/lexers/s/sml.go
generated
vendored
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
package s
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
"github.com/alecthomas/chroma/lexers/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Standard ML lexer.
|
||||||
|
var StandardML = internal.Register(MustNewLexer(
|
||||||
|
&Config{
|
||||||
|
Name: "Standard ML",
|
||||||
|
Aliases: []string{"sml"},
|
||||||
|
Filenames: []string{"*.sml", "*.sig", "*.fun"},
|
||||||
|
MimeTypes: []string{"text/x-standardml", "application/x-standardml"},
|
||||||
|
},
|
||||||
|
Rules{
|
||||||
|
"whitespace": {
|
||||||
|
{`\s+`, Text, nil},
|
||||||
|
{`\(\*`, CommentMultiline, Push("comment")},
|
||||||
|
},
|
||||||
|
"delimiters": {
|
||||||
|
{`\(|\[|\{`, Punctuation, Push("main")},
|
||||||
|
{`\)|\]|\}`, Punctuation, Pop(1)},
|
||||||
|
{`\b(let|if|local)\b(?!\')`, KeywordReserved, Push("main", "main")},
|
||||||
|
{`\b(struct|sig|while)\b(?!\')`, KeywordReserved, Push("main")},
|
||||||
|
{`\b(do|else|end|in|then)\b(?!\')`, KeywordReserved, Pop(1)},
|
||||||
|
},
|
||||||
|
"core": {
|
||||||
|
{`(_|\}|\{|\)|;|,|\[|\(|\]|\.\.\.)`, Punctuation, nil},
|
||||||
|
{`#"`, LiteralStringChar, Push("char")},
|
||||||
|
{`"`, LiteralStringDouble, Push("string")},
|
||||||
|
{`~?0x[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||||
|
{`0wx[0-9a-fA-F]+`, LiteralNumberHex, nil},
|
||||||
|
{`0w\d+`, LiteralNumberInteger, nil},
|
||||||
|
{`~?\d+\.\d+[eE]~?\d+`, LiteralNumberFloat, nil},
|
||||||
|
{`~?\d+\.\d+`, LiteralNumberFloat, nil},
|
||||||
|
{`~?\d+[eE]~?\d+`, LiteralNumberFloat, nil},
|
||||||
|
{`~?\d+`, LiteralNumberInteger, nil},
|
||||||
|
{`#\s*[1-9][0-9]*`, NameLabel, nil},
|
||||||
|
{`#\s*([a-zA-Z][\w']*)`, NameLabel, nil},
|
||||||
|
{"#\\s+([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameLabel, nil},
|
||||||
|
{`\b(datatype|abstype)\b(?!\')`, KeywordReserved, Push("dname")},
|
||||||
|
{`(?=\b(exception)\b(?!\'))`, Text, Push("ename")},
|
||||||
|
{`\b(functor|include|open|signature|structure)\b(?!\')`, KeywordReserved, Push("sname")},
|
||||||
|
{`\b(type|eqtype)\b(?!\')`, KeywordReserved, Push("tname")},
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`([a-zA-Z][\w']*)(\.)`, NameNamespace, Push("dotted")},
|
||||||
|
{`\b(abstype|and|andalso|as|case|datatype|do|else|end|exception|fn|fun|handle|if|in|infix|infixr|let|local|nonfix|of|op|open|orelse|raise|rec|then|type|val|with|withtype|while|eqtype|functor|include|sharing|sig|signature|struct|structure|where)\b`, KeywordReserved, nil},
|
||||||
|
{`([a-zA-Z][\w']*)`, Name, nil},
|
||||||
|
{`\b(:|\|,=|=>|->|#|:>)\b`, KeywordReserved, nil},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Name, nil},
|
||||||
|
},
|
||||||
|
"dotted": {
|
||||||
|
{`([a-zA-Z][\w']*)(\.)`, NameNamespace, nil},
|
||||||
|
// ignoring reserved words
|
||||||
|
{`([a-zA-Z][\w']*)`, Name, Pop(1)},
|
||||||
|
// ignoring reserved words
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Name, Pop(1)},
|
||||||
|
{`\s+`, Error, nil},
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
Default(Push("main")),
|
||||||
|
},
|
||||||
|
"main": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\b(val|and)\b(?!\')`, KeywordReserved, Push("vname")},
|
||||||
|
{`\b(fun)\b(?!\')`, KeywordReserved, Push("#pop", "main-fun", "fname")},
|
||||||
|
Include("delimiters"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"main-fun": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\s`, Text, nil},
|
||||||
|
{`\(\*`, CommentMultiline, Push("comment")},
|
||||||
|
{`\b(fun|and)\b(?!\')`, KeywordReserved, Push("fname")},
|
||||||
|
{`\b(val)\b(?!\')`, KeywordReserved, Push("#pop", "main", "vname")},
|
||||||
|
{`\|`, Punctuation, Push("fname")},
|
||||||
|
{`\b(case|handle)\b(?!\')`, KeywordReserved, Push("#pop", "main")},
|
||||||
|
Include("delimiters"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"char": {
|
||||||
|
{`[^"\\]`, LiteralStringChar, nil},
|
||||||
|
{`\\[\\"abtnvfr]`, LiteralStringEscape, nil},
|
||||||
|
{`\\\^[\x40-\x5e]`, LiteralStringEscape, nil},
|
||||||
|
{`\\[0-9]{3}`, LiteralStringEscape, nil},
|
||||||
|
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
|
||||||
|
{`\\\s+\\`, LiteralStringInterpol, nil},
|
||||||
|
{`"`, LiteralStringChar, Pop(1)},
|
||||||
|
},
|
||||||
|
"string": {
|
||||||
|
{`[^"\\]`, LiteralStringDouble, nil},
|
||||||
|
{`\\[\\"abtnvfr]`, LiteralStringEscape, nil},
|
||||||
|
{`\\\^[\x40-\x5e]`, LiteralStringEscape, nil},
|
||||||
|
{`\\[0-9]{3}`, LiteralStringEscape, nil},
|
||||||
|
{`\\u[0-9a-fA-F]{4}`, LiteralStringEscape, nil},
|
||||||
|
{`\\\s+\\`, LiteralStringInterpol, nil},
|
||||||
|
{`"`, LiteralStringDouble, Pop(1)},
|
||||||
|
},
|
||||||
|
"breakout": {
|
||||||
|
{`(?=\b(where|do|handle|if|sig|op|while|case|as|else|signature|andalso|struct|infixr|functor|in|structure|then|local|rec|end|fun|of|orelse|val|include|fn|with|exception|let|and|infix|sharing|datatype|type|abstype|withtype|eqtype|nonfix|raise|open)\b(?!\'))`, Text, Pop(1)},
|
||||||
|
},
|
||||||
|
"sname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
Include("breakout"),
|
||||||
|
{`([a-zA-Z][\w']*)`, NameNamespace, nil},
|
||||||
|
Default(Pop(1)),
|
||||||
|
},
|
||||||
|
"fname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`\(`, Punctuation, Push("tyvarseq")},
|
||||||
|
{`([a-zA-Z][\w']*)`, NameFunction, Pop(1)},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameFunction, Pop(1)},
|
||||||
|
Default(Pop(1)),
|
||||||
|
},
|
||||||
|
"vname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`\(`, Punctuation, Push("tyvarseq")},
|
||||||
|
{"([a-zA-Z][\\w']*)(\\s*)(=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+))", ByGroups(NameVariable, Text, Punctuation), Pop(1)},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)(\\s*)(=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+))", ByGroups(NameVariable, Text, Punctuation), Pop(1)},
|
||||||
|
{`([a-zA-Z][\w']*)`, NameVariable, Pop(1)},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameVariable, Pop(1)},
|
||||||
|
Default(Pop(1)),
|
||||||
|
},
|
||||||
|
"tname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
Include("breakout"),
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`\(`, Punctuation, Push("tyvarseq")},
|
||||||
|
{"=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Punctuation, Push("#pop", "typbind")},
|
||||||
|
{`([a-zA-Z][\w']*)`, KeywordType, nil},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", KeywordType, nil},
|
||||||
|
{`\S+`, Error, Pop(1)},
|
||||||
|
},
|
||||||
|
"typbind": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\b(and)\b(?!\')`, KeywordReserved, Push("#pop", "tname")},
|
||||||
|
Include("breakout"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, Pop(1)},
|
||||||
|
},
|
||||||
|
"dname": {
|
||||||
|
Include("whitespace"),
|
||||||
|
Include("breakout"),
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`\(`, Punctuation, Push("tyvarseq")},
|
||||||
|
{`(=)(\s*)(datatype)`, ByGroups(Punctuation, Text, KeywordReserved), Pop(1)},
|
||||||
|
{"=(?![!%&$#+\\-/:<=>?@\\\\~`^|*]+)", Punctuation, Push("#pop", "datbind", "datcon")},
|
||||||
|
{`([a-zA-Z][\w']*)`, KeywordType, nil},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", KeywordType, nil},
|
||||||
|
{`\S+`, Error, Pop(1)},
|
||||||
|
},
|
||||||
|
"datbind": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`\b(and)\b(?!\')`, KeywordReserved, Push("#pop", "dname")},
|
||||||
|
{`\b(withtype)\b(?!\')`, KeywordReserved, Push("#pop", "tname")},
|
||||||
|
{`\b(of)\b(?!\')`, KeywordReserved, nil},
|
||||||
|
{`(\|)(\s*)([a-zA-Z][\w']*)`, ByGroups(Punctuation, Text, NameClass), nil},
|
||||||
|
{"(\\|)(\\s+)([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", ByGroups(Punctuation, Text, NameClass), nil},
|
||||||
|
Include("breakout"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"ename": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`(exception|and)\b(\s+)([a-zA-Z][\w']*)`, ByGroups(KeywordReserved, Text, NameClass), nil},
|
||||||
|
{"(exception|and)\\b(\\s*)([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", ByGroups(KeywordReserved, Text, NameClass), nil},
|
||||||
|
{`\b(of)\b(?!\')`, KeywordReserved, nil},
|
||||||
|
Include("breakout"),
|
||||||
|
Include("core"),
|
||||||
|
{`\S+`, Error, nil},
|
||||||
|
},
|
||||||
|
"datcon": {
|
||||||
|
Include("whitespace"),
|
||||||
|
{`([a-zA-Z][\w']*)`, NameClass, Pop(1)},
|
||||||
|
{"([!%&$#+\\-/:<=>?@\\\\~`^|*]+)", NameClass, Pop(1)},
|
||||||
|
{`\S+`, Error, Pop(1)},
|
||||||
|
},
|
||||||
|
"tyvarseq": {
|
||||||
|
{`\s`, Text, nil},
|
||||||
|
{`\(\*`, CommentMultiline, Push("comment")},
|
||||||
|
{`\'[\w\']*`, NameDecorator, nil},
|
||||||
|
{`[a-zA-Z][\w']*`, Name, nil},
|
||||||
|
{`,`, Punctuation, nil},
|
||||||
|
{`\)`, Punctuation, Pop(1)},
|
||||||
|
{"[!%&$#+\\-/:<=>?@\\\\~`^|*]+", Name, nil},
|
||||||
|
},
|
||||||
|
"comment": {
|
||||||
|
{`[^(*)]`, CommentMultiline, nil},
|
||||||
|
{`\(\*`, CommentMultiline, Push()},
|
||||||
|
{`\*\)`, CommentMultiline, Pop(1)},
|
||||||
|
{`[(*)]`, CommentMultiline, nil},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
2
vendor/github.com/alecthomas/chroma/lexers/s/sql.go
generated
vendored
2
vendor/github.com/alecthomas/chroma/lexers/s/sql.go
generated
vendored
File diff suppressed because one or more lines are too long
42
vendor/github.com/alecthomas/chroma/lexers/t/tablegen.go
generated
vendored
Normal file
42
vendor/github.com/alecthomas/chroma/lexers/t/tablegen.go
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package t
|
||||||
|
|
||||||
|
import (
|
||||||
|
. "github.com/alecthomas/chroma" // nolint
|
||||||
|
"github.com/alecthomas/chroma/lexers/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TableGen lexer.
|
||||||
|
var Tablegen = internal.Register(MustNewLexer(
|
||||||
|
&Config{
|
||||||
|
Name: "TableGen",
|
||||||
|
Aliases: []string{"tablegen"},
|
||||||
|
Filenames: []string{"*.td"},
|
||||||
|
MimeTypes: []string{"text/x-tablegen"},
|
||||||
|
},
|
||||||
|
Rules{
|
||||||
|
"root": {
|
||||||
|
Include("macro"),
|
||||||
|
Include("whitespace"),
|
||||||
|
{`c?"[^"]*?"`, LiteralString, nil},
|
||||||
|
Include("keyword"),
|
||||||
|
{`\$[_a-zA-Z][_\w]*`, NameVariable, nil},
|
||||||
|
{`\d*[_a-zA-Z][_\w]*`, NameVariable, nil},
|
||||||
|
{`\[\{[\w\W]*?\}\]`, LiteralString, nil},
|
||||||
|
{`[+-]?\d+|0x[\da-fA-F]+|0b[01]+`, LiteralNumber, nil},
|
||||||
|
{`[=<>{}\[\]()*.,!:;]`, Punctuation, nil},
|
||||||
|
},
|
||||||
|
"macro": {
|
||||||
|
{`(#include\s+)("[^"]*")`, ByGroups(CommentPreproc, LiteralString), nil},
|
||||||
|
{`^\s*#(ifdef|ifndef)\s+[_\w][_\w\d]*`, CommentPreproc, nil},
|
||||||
|
{`^\s*#define\s+[_\w][_\w\d]*`, CommentPreproc, nil},
|
||||||
|
{`^\s*#endif`, CommentPreproc, nil},
|
||||||
|
},
|
||||||
|
"whitespace": {
|
||||||
|
{`(\n|\s)+`, Text, nil},
|
||||||
|
{`//.*?\n`, Comment, nil},
|
||||||
|
},
|
||||||
|
"keyword": {
|
||||||
|
{Words(``, `\b`, `bit`, `bits`, `class`, `code`, `dag`, `def`, `defm`, `field`, `foreach`, `in`, `int`, `let`, `list`, `multiclass`, `string`), Keyword, nil},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
))
|
12
vendor/github.com/alecthomas/chroma/lexers/y/yaml.go
generated
vendored
12
vendor/github.com/alecthomas/chroma/lexers/y/yaml.go
generated
vendored
@ -15,12 +15,15 @@ var YAML = internal.Register(MustNewLexer(
|
|||||||
Rules{
|
Rules{
|
||||||
"root": {
|
"root": {
|
||||||
Include("whitespace"),
|
Include("whitespace"),
|
||||||
{`#.*`, Comment, nil},
|
{`^---`, Text, nil},
|
||||||
|
{`[\n?]?\s*- `, Text, nil},
|
||||||
|
{`#.*$`, Comment, nil},
|
||||||
{`!![^\s]+`, CommentPreproc, nil},
|
{`!![^\s]+`, CommentPreproc, nil},
|
||||||
{`&[^\s]+`, CommentPreproc, nil},
|
{`&[^\s]+`, CommentPreproc, nil},
|
||||||
{`\*[^\s]+`, CommentPreproc, nil},
|
{`\*[^\s]+`, CommentPreproc, nil},
|
||||||
{`^%include\s+[^\n\r]+`, CommentPreproc, nil},
|
{`^%include\s+[^\n\r]+`, CommentPreproc, nil},
|
||||||
{`([>|+-]\s+)(\s+)((?:(?:.*?$)(?:[\n\r]*?)?)*)`, ByGroups(StringDoc, StringDoc, StringDoc), nil},
|
{`([>|+-]\s+)(\s+)((?:(?:.*?$)(?:[\n\r]*?)?)*)`, ByGroups(StringDoc, StringDoc, StringDoc), nil},
|
||||||
|
Include("key"),
|
||||||
Include("value"),
|
Include("value"),
|
||||||
{`[?:,\[\]]`, Punctuation, nil},
|
{`[?:,\[\]]`, Punctuation, nil},
|
||||||
{`.`, Text, nil},
|
{`.`, Text, nil},
|
||||||
@ -33,8 +36,15 @@ var YAML = internal.Register(MustNewLexer(
|
|||||||
{`\b[+\-]?(0x[\da-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)\b`, Number, nil},
|
{`\b[+\-]?(0x[\da-f]+|0o[0-7]+|(\d+\.?\d*|\.?\d+)(e[\+\-]?\d+)?|\.inf|\.nan)\b`, Number, nil},
|
||||||
{`\b[\w]+\b`, Text, nil},
|
{`\b[\w]+\b`, Text, nil},
|
||||||
},
|
},
|
||||||
|
"key": {
|
||||||
|
{`"[^"\n].*": `, Keyword, nil},
|
||||||
|
{`(-)( )([^"\n{]*)(:)( )`, ByGroups(Punctuation, Whitespace, Keyword, Punctuation, Whitespace), nil},
|
||||||
|
{`([^"\n{]*)(:)( )`, ByGroups(Keyword, Punctuation, Whitespace), nil},
|
||||||
|
{`([^"\n{]*)(:)(\n)`, ByGroups(Keyword, Punctuation, Whitespace), nil},
|
||||||
|
},
|
||||||
"whitespace": {
|
"whitespace": {
|
||||||
{`\s+`, Whitespace, nil},
|
{`\s+`, Whitespace, nil},
|
||||||
|
{`\n+`, Whitespace, nil},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
12
vendor/github.com/alecthomas/chroma/regexp.go
generated
vendored
12
vendor/github.com/alecthomas/chroma/regexp.go
generated
vendored
@ -34,9 +34,13 @@ func (e EmitterFunc) Emit(groups []string, lexer Lexer) Iterator { return e(grou
|
|||||||
func ByGroups(emitters ...Emitter) Emitter {
|
func ByGroups(emitters ...Emitter) Emitter {
|
||||||
return EmitterFunc(func(groups []string, lexer Lexer) Iterator {
|
return EmitterFunc(func(groups []string, lexer Lexer) Iterator {
|
||||||
iterators := make([]Iterator, 0, len(groups)-1)
|
iterators := make([]Iterator, 0, len(groups)-1)
|
||||||
// NOTE: If this panics, there is a mismatch with groups
|
if len(emitters) != len(groups)-1 {
|
||||||
for i, group := range groups[1:] {
|
iterators = append(iterators, Error.Emit(groups, lexer))
|
||||||
iterators = append(iterators, emitters[i].Emit([]string{group}, lexer))
|
// panic(errors.Errorf("number of groups %q does not match number of emitters %v", groups, emitters))
|
||||||
|
} else {
|
||||||
|
for i, group := range groups[1:] {
|
||||||
|
iterators = append(iterators, emitters[i].Emit([]string{group}, lexer))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Concaterator(iterators...)
|
return Concaterator(iterators...)
|
||||||
})
|
})
|
||||||
@ -255,7 +259,7 @@ func (l *LexerState) Get(key interface{}) interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Iterator returns the next Token from the lexer.
|
// Iterator returns the next Token from the lexer.
|
||||||
func (l *LexerState) Iterator() Token {
|
func (l *LexerState) Iterator() Token { // nolint: gocognit
|
||||||
for l.Pos < len(l.Text) && len(l.Stack) > 0 {
|
for l.Pos < len(l.Text) && len(l.Stack) > 0 {
|
||||||
// Exhaust the iterator stack, if any.
|
// Exhaust the iterator stack, if any.
|
||||||
for len(l.iteratorStack) > 0 {
|
for len(l.iteratorStack) > 0 {
|
||||||
|
1
vendor/github.com/alecthomas/chroma/remap.go
generated
vendored
1
vendor/github.com/alecthomas/chroma/remap.go
generated
vendored
@ -66,7 +66,6 @@ func TypeRemappingLexer(lexer Lexer, mapping TypeMapping) Lexer {
|
|||||||
km[k] = rt.To
|
km[k] = rt.To
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return RemappingLexer(lexer, func(t Token) []Token {
|
return RemappingLexer(lexer, func(t Token) []Token {
|
||||||
if k, ok := lut[t.Type]; ok {
|
if k, ok := lut[t.Type]; ok {
|
||||||
|
BIN
vendor/github.com/dlclark/regexp2/.DS_Store
generated
vendored
Normal file
BIN
vendor/github.com/dlclark/regexp2/.DS_Store
generated
vendored
Normal file
Binary file not shown.
15
vendor/github.com/mattn/go-isatty/.travis.yml
generated
vendored
15
vendor/github.com/mattn/go-isatty/.travis.yml
generated
vendored
@ -1,13 +1,14 @@
|
|||||||
language: go
|
language: go
|
||||||
|
sudo: false
|
||||||
go:
|
go:
|
||||||
|
- 1.13.x
|
||||||
- tip
|
- tip
|
||||||
|
|
||||||
os:
|
|
||||||
- linux
|
|
||||||
- osx
|
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- go get github.com/mattn/goveralls
|
- go get -t -v ./...
|
||||||
- go get golang.org/x/tools/cmd/cover
|
|
||||||
script:
|
script:
|
||||||
- $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5
|
- ./go.test.sh
|
||||||
|
|
||||||
|
after_success:
|
||||||
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
|
2
vendor/github.com/mattn/go-isatty/README.md
generated
vendored
2
vendor/github.com/mattn/go-isatty/README.md
generated
vendored
@ -1,7 +1,7 @@
|
|||||||
# go-isatty
|
# go-isatty
|
||||||
|
|
||||||
[](http://godoc.org/github.com/mattn/go-isatty)
|
[](http://godoc.org/github.com/mattn/go-isatty)
|
||||||
[](https://travis-ci.org/mattn/go-isatty)
|
[](https://codecov.io/gh/mattn/go-isatty)
|
||||||
[](https://coveralls.io/github/mattn/go-isatty?branch=master)
|
[](https://coveralls.io/github/mattn/go-isatty?branch=master)
|
||||||
[](https://goreportcard.com/report/mattn/go-isatty)
|
[](https://goreportcard.com/report/mattn/go-isatty)
|
||||||
|
|
||||||
|
5
vendor/github.com/mattn/go-isatty/go.mod
generated
vendored
Normal file
5
vendor/github.com/mattn/go-isatty/go.mod
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module github.com/mattn/go-isatty
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
|
||||||
|
require golang.org/x/sys v0.0.0-20200116001909-b77594299b42
|
2
vendor/github.com/mattn/go-isatty/go.sum
generated
vendored
Normal file
2
vendor/github.com/mattn/go-isatty/go.sum
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
||||||
|
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
12
vendor/github.com/mattn/go-isatty/go.test.sh
generated
vendored
Normal file
12
vendor/github.com/mattn/go-isatty/go.test.sh
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
echo "" > coverage.txt
|
||||||
|
|
||||||
|
for d in $(go list ./... | grep -v vendor); do
|
||||||
|
go test -race -coverprofile=profile.out -covermode=atomic "$d"
|
||||||
|
if [ -f profile.out ]; then
|
||||||
|
cat profile.out >> coverage.txt
|
||||||
|
rm profile.out
|
||||||
|
fi
|
||||||
|
done
|
15
vendor/github.com/mattn/go-isatty/isatty_appengine.go
generated
vendored
15
vendor/github.com/mattn/go-isatty/isatty_appengine.go
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
// +build appengine
|
|
||||||
|
|
||||||
package isatty
|
|
||||||
|
|
||||||
// IsTerminal returns true if the file descriptor is terminal which
|
|
||||||
// is always false on on appengine classic which is a sandboxed PaaS.
|
|
||||||
func IsTerminal(fd uintptr) bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
|
|
||||||
// terminal. This is also always false on this environment.
|
|
||||||
func IsCygwinTerminal(fd uintptr) bool {
|
|
||||||
return false
|
|
||||||
}
|
|
18
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
18
vendor/github.com/mattn/go-isatty/isatty_bsd.go
generated
vendored
@ -3,16 +3,16 @@
|
|||||||
|
|
||||||
package isatty
|
package isatty
|
||||||
|
|
||||||
import (
|
import "golang.org/x/sys/unix"
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const ioctlReadTermios = syscall.TIOCGETA
|
|
||||||
|
|
||||||
// IsTerminal return true if the file descriptor is terminal.
|
// IsTerminal return true if the file descriptor is terminal.
|
||||||
func IsTerminal(fd uintptr) bool {
|
func IsTerminal(fd uintptr) bool {
|
||||||
var termios syscall.Termios
|
_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
|
||||||
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
return err == nil
|
||||||
return err == 0
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
||||||
|
// terminal. This is also always false on this environment.
|
||||||
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
18
vendor/github.com/mattn/go-isatty/isatty_linux.go
generated
vendored
18
vendor/github.com/mattn/go-isatty/isatty_linux.go
generated
vendored
@ -1,18 +0,0 @@
|
|||||||
// +build linux
|
|
||||||
// +build !appengine,!ppc64,!ppc64le
|
|
||||||
|
|
||||||
package isatty
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
const ioctlReadTermios = syscall.TCGETS
|
|
||||||
|
|
||||||
// IsTerminal return true if the file descriptor is terminal.
|
|
||||||
func IsTerminal(fd uintptr) bool {
|
|
||||||
var termios syscall.Termios
|
|
||||||
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
|
||||||
return err == 0
|
|
||||||
}
|
|
19
vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go
generated
vendored
19
vendor/github.com/mattn/go-isatty/isatty_linux_ppc64x.go
generated
vendored
@ -1,19 +0,0 @@
|
|||||||
// +build linux
|
|
||||||
// +build ppc64 ppc64le
|
|
||||||
|
|
||||||
package isatty
|
|
||||||
|
|
||||||
import (
|
|
||||||
"unsafe"
|
|
||||||
|
|
||||||
syscall "golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
const ioctlReadTermios = syscall.TCGETS
|
|
||||||
|
|
||||||
// IsTerminal return true if the file descriptor is terminal.
|
|
||||||
func IsTerminal(fd uintptr) bool {
|
|
||||||
var termios syscall.Termios
|
|
||||||
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
|
|
||||||
return err == 0
|
|
||||||
}
|
|
11
vendor/github.com/mattn/go-isatty/isatty_others.go
generated
vendored
11
vendor/github.com/mattn/go-isatty/isatty_others.go
generated
vendored
@ -1,9 +1,14 @@
|
|||||||
// +build !windows
|
// +build appengine js nacl
|
||||||
// +build !appengine
|
|
||||||
|
|
||||||
package isatty
|
package isatty
|
||||||
|
|
||||||
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
// IsTerminal returns true if the file descriptor is terminal which
|
||||||
|
// is always false on js and appengine classic which is a sandboxed PaaS.
|
||||||
|
func IsTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
|
||||||
// terminal. This is also always false on this environment.
|
// terminal. This is also always false on this environment.
|
||||||
func IsCygwinTerminal(fd uintptr) bool {
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
return false
|
return false
|
||||||
|
22
vendor/github.com/mattn/go-isatty/isatty_plan9.go
generated
vendored
Normal file
22
vendor/github.com/mattn/go-isatty/isatty_plan9.go
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// +build plan9
|
||||||
|
|
||||||
|
package isatty
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IsTerminal returns true if the given file descriptor is a terminal.
|
||||||
|
func IsTerminal(fd uintptr) bool {
|
||||||
|
path, err := syscall.Fd2path(int(fd))
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return path == "/dev/cons" || path == "/mnt/term/dev/cons"
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
||||||
|
// terminal. This is also always false on this environment.
|
||||||
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
|
}
|
6
vendor/github.com/mattn/go-isatty/isatty_solaris.go
generated
vendored
6
vendor/github.com/mattn/go-isatty/isatty_solaris.go
generated
vendored
@ -14,3 +14,9 @@ func IsTerminal(fd uintptr) bool {
|
|||||||
err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
|
err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio)
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
||||||
|
// terminal. This is also always false on this environment.
|
||||||
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
18
vendor/github.com/mattn/go-isatty/isatty_tcgets.go
generated
vendored
Normal file
18
vendor/github.com/mattn/go-isatty/isatty_tcgets.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// +build linux aix
|
||||||
|
// +build !appengine
|
||||||
|
|
||||||
|
package isatty
|
||||||
|
|
||||||
|
import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
// IsTerminal return true if the file descriptor is terminal.
|
||||||
|
func IsTerminal(fd uintptr) bool {
|
||||||
|
_, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
|
||||||
|
// terminal. This is also always false on this environment.
|
||||||
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
|
return false
|
||||||
|
}
|
39
vendor/github.com/mattn/go-isatty/isatty_windows.go
generated
vendored
39
vendor/github.com/mattn/go-isatty/isatty_windows.go
generated
vendored
@ -4,6 +4,7 @@
|
|||||||
package isatty
|
package isatty
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unicode/utf16"
|
"unicode/utf16"
|
||||||
@ -11,15 +12,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
fileNameInfo uintptr = 2
|
objectNameInfo uintptr = 1
|
||||||
fileTypePipe = 3
|
fileNameInfo = 2
|
||||||
|
fileTypePipe = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
||||||
|
ntdll = syscall.NewLazyDLL("ntdll.dll")
|
||||||
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
||||||
procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
|
procGetFileInformationByHandleEx = kernel32.NewProc("GetFileInformationByHandleEx")
|
||||||
procGetFileType = kernel32.NewProc("GetFileType")
|
procGetFileType = kernel32.NewProc("GetFileType")
|
||||||
|
procNtQueryObject = ntdll.NewProc("NtQueryObject")
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -45,7 +49,10 @@ func isCygwinPipeName(name string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if token[0] != `\msys` && token[0] != `\cygwin` {
|
if token[0] != `\msys` &&
|
||||||
|
token[0] != `\cygwin` &&
|
||||||
|
token[0] != `\Device\NamedPipe\msys` &&
|
||||||
|
token[0] != `\Device\NamedPipe\cygwin` {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,11 +75,35 @@ func isCygwinPipeName(name string) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getFileNameByHandle use the undocomented ntdll NtQueryObject to get file full name from file handler
|
||||||
|
// since GetFileInformationByHandleEx is not avilable under windows Vista and still some old fashion
|
||||||
|
// guys are using Windows XP, this is a workaround for those guys, it will also work on system from
|
||||||
|
// Windows vista to 10
|
||||||
|
// see https://stackoverflow.com/a/18792477 for details
|
||||||
|
func getFileNameByHandle(fd uintptr) (string, error) {
|
||||||
|
if procNtQueryObject == nil {
|
||||||
|
return "", errors.New("ntdll.dll: NtQueryObject not supported")
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf [4 + syscall.MAX_PATH]uint16
|
||||||
|
var result int
|
||||||
|
r, _, e := syscall.Syscall6(procNtQueryObject.Addr(), 5,
|
||||||
|
fd, objectNameInfo, uintptr(unsafe.Pointer(&buf)), uintptr(2*len(buf)), uintptr(unsafe.Pointer(&result)), 0)
|
||||||
|
if r != 0 {
|
||||||
|
return "", e
|
||||||
|
}
|
||||||
|
return string(utf16.Decode(buf[4 : 4+buf[0]/2])), nil
|
||||||
|
}
|
||||||
|
|
||||||
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
|
// IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2
|
||||||
// terminal.
|
// terminal.
|
||||||
func IsCygwinTerminal(fd uintptr) bool {
|
func IsCygwinTerminal(fd uintptr) bool {
|
||||||
if procGetFileInformationByHandleEx == nil {
|
if procGetFileInformationByHandleEx == nil {
|
||||||
return false
|
name, err := getFileNameByHandle(fd)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return isCygwinPipeName(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cygwin/msys's pty is a pipe.
|
// Cygwin/msys's pty is a pipe.
|
||||||
|
8
vendor/github.com/mattn/go-isatty/renovate.json
generated
vendored
Normal file
8
vendor/github.com/mattn/go-isatty/renovate.json
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"config:base"
|
||||||
|
],
|
||||||
|
"postUpdateOptions": [
|
||||||
|
"gomodTidy"
|
||||||
|
]
|
||||||
|
}
|
16
vendor/github.com/tj/front/Readme.md
generated
vendored
16
vendor/github.com/tj/front/Readme.md
generated
vendored
@ -1,16 +0,0 @@
|
|||||||
# Front
|
|
||||||
|
|
||||||
Frontmatter unmarshaller, couldn't find one without a weird API.
|
|
||||||
|
|
||||||
## Badges
|
|
||||||
|
|
||||||
[](https://godoc.org/github.com/tj/front)
|
|
||||||

|
|
||||||

|
|
||||||
[](https://apex.sh/ping/)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
> [tjholowaychuk.com](http://tjholowaychuk.com) ·
|
|
||||||
> GitHub [@tj](https://github.com/tj) ·
|
|
||||||
> Twitter [@tjholowaychuk](https://twitter.com/tjholowaychuk)
|
|
24
vendor/github.com/tj/front/front.go
generated
vendored
24
vendor/github.com/tj/front/front.go
generated
vendored
@ -1,24 +0,0 @@
|
|||||||
// Package front provides YAML frontmatter unmarshalling.
|
|
||||||
package front
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
|
|
||||||
"gopkg.in/yaml.v1"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Delimiter.
|
|
||||||
var delim = []byte("---")
|
|
||||||
|
|
||||||
// Unmarshal parses YAML frontmatter and returns the content. When no
|
|
||||||
// frontmatter delimiters are present the original content is returned.
|
|
||||||
func Unmarshal(b []byte, v interface{}) (content []byte, err error) {
|
|
||||||
if !bytes.HasPrefix(b, delim) {
|
|
||||||
return b, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
parts := bytes.SplitN(b, delim, 3)
|
|
||||||
content = parts[2]
|
|
||||||
err = yaml.Unmarshal(parts[1], v)
|
|
||||||
return
|
|
||||||
}
|
|
20
vendor/golang.org/x/sys/unix/README.md
generated
vendored
20
vendor/golang.org/x/sys/unix/README.md
generated
vendored
@ -14,7 +14,7 @@ migrating the build system to use containers so the builds are reproducible.
|
|||||||
This is being done on an OS-by-OS basis. Please update this documentation as
|
This is being done on an OS-by-OS basis. Please update this documentation as
|
||||||
components of the build system change.
|
components of the build system change.
|
||||||
|
|
||||||
### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`)
|
### Old Build System (currently for `GOOS != "linux"`)
|
||||||
|
|
||||||
The old build system generates the Go files based on the C header files
|
The old build system generates the Go files based on the C header files
|
||||||
present on your system. This means that files
|
present on your system. This means that files
|
||||||
@ -32,9 +32,9 @@ To build the files for your current OS and architecture, make sure GOOS and
|
|||||||
GOARCH are set correctly and run `mkall.sh`. This will generate the files for
|
GOARCH are set correctly and run `mkall.sh`. This will generate the files for
|
||||||
your specific system. Running `mkall.sh -n` shows the commands that will be run.
|
your specific system. Running `mkall.sh -n` shows the commands that will be run.
|
||||||
|
|
||||||
Requirements: bash, perl, go
|
Requirements: bash, go
|
||||||
|
|
||||||
### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`)
|
### New Build System (currently for `GOOS == "linux"`)
|
||||||
|
|
||||||
The new build system uses a Docker container to generate the go files directly
|
The new build system uses a Docker container to generate the go files directly
|
||||||
from source checkouts of the kernel and various system libraries. This means
|
from source checkouts of the kernel and various system libraries. This means
|
||||||
@ -52,14 +52,14 @@ system and have your GOOS and GOARCH set accordingly. Running `mkall.sh` will
|
|||||||
then generate all of the files for all of the GOOS/GOARCH pairs in the new build
|
then generate all of the files for all of the GOOS/GOARCH pairs in the new build
|
||||||
system. Running `mkall.sh -n` shows the commands that will be run.
|
system. Running `mkall.sh -n` shows the commands that will be run.
|
||||||
|
|
||||||
Requirements: bash, perl, go, docker
|
Requirements: bash, go, docker
|
||||||
|
|
||||||
## Component files
|
## Component files
|
||||||
|
|
||||||
This section describes the various files used in the code generation process.
|
This section describes the various files used in the code generation process.
|
||||||
It also contains instructions on how to modify these files to add a new
|
It also contains instructions on how to modify these files to add a new
|
||||||
architecture/OS or to add additional syscalls, types, or constants. Note that
|
architecture/OS or to add additional syscalls, types, or constants. Note that
|
||||||
if you are using the new build system, the scripts cannot be called normally.
|
if you are using the new build system, the scripts/programs cannot be called normally.
|
||||||
They must be called from within the docker container.
|
They must be called from within the docker container.
|
||||||
|
|
||||||
### asm files
|
### asm files
|
||||||
@ -81,8 +81,8 @@ each GOOS/GOARCH pair.
|
|||||||
|
|
||||||
### mksysnum
|
### mksysnum
|
||||||
|
|
||||||
Mksysnum is a script located at `${GOOS}/mksysnum.pl` (or `mksysnum_${GOOS}.pl`
|
Mksysnum is a Go program located at `${GOOS}/mksysnum.go` (or `mksysnum_${GOOS}.go`
|
||||||
for the old system). This script takes in a list of header files containing the
|
for the old system). This program takes in a list of header files containing the
|
||||||
syscall number declarations and parses them to produce the corresponding list of
|
syscall number declarations and parses them to produce the corresponding list of
|
||||||
Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
|
Go numeric constants. See `zsysnum_${GOOS}_${GOARCH}.go` for the generated
|
||||||
constants.
|
constants.
|
||||||
@ -92,14 +92,14 @@ new installation of the target OS (or updating the source checkouts for the
|
|||||||
new build system). However, depending on the OS, you make need to update the
|
new build system). However, depending on the OS, you make need to update the
|
||||||
parsing in mksysnum.
|
parsing in mksysnum.
|
||||||
|
|
||||||
### mksyscall.pl
|
### mksyscall.go
|
||||||
|
|
||||||
The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
|
The `syscall.go`, `syscall_${GOOS}.go`, `syscall_${GOOS}_${GOARCH}.go` are
|
||||||
hand-written Go files which implement system calls (for unix, the specific OS,
|
hand-written Go files which implement system calls (for unix, the specific OS,
|
||||||
or the specific OS/Architecture pair respectively) that need special handling
|
or the specific OS/Architecture pair respectively) that need special handling
|
||||||
and list `//sys` comments giving prototypes for ones that can be generated.
|
and list `//sys` comments giving prototypes for ones that can be generated.
|
||||||
|
|
||||||
The mksyscall.pl script takes the `//sys` and `//sysnb` comments and converts
|
The mksyscall.go program takes the `//sys` and `//sysnb` comments and converts
|
||||||
them into syscalls. This requires the name of the prototype in the comment to
|
them into syscalls. This requires the name of the prototype in the comment to
|
||||||
match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
|
match a syscall number in the `zsysnum_${GOOS}_${GOARCH}.go` file. The function
|
||||||
prototype can be exported (capitalized) or not.
|
prototype can be exported (capitalized) or not.
|
||||||
@ -160,7 +160,7 @@ signal numbers, and constants. Generated by `mkerrors.sh` (see above).
|
|||||||
### `zsyscall_${GOOS}_${GOARCH}.go`
|
### `zsyscall_${GOOS}_${GOARCH}.go`
|
||||||
|
|
||||||
A file containing all the generated syscalls for a specific GOOS and GOARCH.
|
A file containing all the generated syscalls for a specific GOOS and GOARCH.
|
||||||
Generated by `mksyscall.pl` (see above).
|
Generated by `mksyscall.go` (see above).
|
||||||
|
|
||||||
### `zsysnum_${GOOS}_${GOARCH}.go`
|
### `zsysnum_${GOOS}_${GOARCH}.go`
|
||||||
|
|
||||||
|
42
vendor/golang.org/x/sys/unix/affinity_linux.go
generated
vendored
42
vendor/golang.org/x/sys/unix/affinity_linux.go
generated
vendored
@ -7,6 +7,7 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math/bits"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -79,46 +80,7 @@ func (s *CPUSet) IsSet(cpu int) bool {
|
|||||||
func (s *CPUSet) Count() int {
|
func (s *CPUSet) Count() int {
|
||||||
c := 0
|
c := 0
|
||||||
for _, b := range s {
|
for _, b := range s {
|
||||||
c += onesCount64(uint64(b))
|
c += bits.OnesCount64(uint64(b))
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
// onesCount64 is a copy of Go 1.9's math/bits.OnesCount64.
|
|
||||||
// Once this package can require Go 1.9, we can delete this
|
|
||||||
// and update the caller to use bits.OnesCount64.
|
|
||||||
func onesCount64(x uint64) int {
|
|
||||||
const m0 = 0x5555555555555555 // 01010101 ...
|
|
||||||
const m1 = 0x3333333333333333 // 00110011 ...
|
|
||||||
const m2 = 0x0f0f0f0f0f0f0f0f // 00001111 ...
|
|
||||||
const m3 = 0x00ff00ff00ff00ff // etc.
|
|
||||||
const m4 = 0x0000ffff0000ffff
|
|
||||||
|
|
||||||
// Implementation: Parallel summing of adjacent bits.
|
|
||||||
// See "Hacker's Delight", Chap. 5: Counting Bits.
|
|
||||||
// The following pattern shows the general approach:
|
|
||||||
//
|
|
||||||
// x = x>>1&(m0&m) + x&(m0&m)
|
|
||||||
// x = x>>2&(m1&m) + x&(m1&m)
|
|
||||||
// x = x>>4&(m2&m) + x&(m2&m)
|
|
||||||
// x = x>>8&(m3&m) + x&(m3&m)
|
|
||||||
// x = x>>16&(m4&m) + x&(m4&m)
|
|
||||||
// x = x>>32&(m5&m) + x&(m5&m)
|
|
||||||
// return int(x)
|
|
||||||
//
|
|
||||||
// Masking (& operations) can be left away when there's no
|
|
||||||
// danger that a field's sum will carry over into the next
|
|
||||||
// field: Since the result cannot be > 64, 8 bits is enough
|
|
||||||
// and we can ignore the masks for the shifts by 8 and up.
|
|
||||||
// Per "Hacker's Delight", the first line can be simplified
|
|
||||||
// more, but it saves at best one instruction, so we leave
|
|
||||||
// it alone for clarity.
|
|
||||||
const m = 1<<64 - 1
|
|
||||||
x = x>>1&(m0&m) + x&(m0&m)
|
|
||||||
x = x>>2&(m1&m) + x&(m1&m)
|
|
||||||
x = (x>>4 + x) & (m2 & m)
|
|
||||||
x += x >> 8
|
|
||||||
x += x >> 16
|
|
||||||
x += x >> 32
|
|
||||||
return int(x) & (1<<7 - 1)
|
|
||||||
}
|
|
||||||
|
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2018 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM64, FreeBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
47
vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
generated
vendored
Normal file
47
vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build riscv64,!gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System calls for linux/riscv64.
|
||||||
|
//
|
||||||
|
// Where available, just jump to package syscall's implementation of
|
||||||
|
// these functions.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
CALL runtime·entersyscall(SB)
|
||||||
|
MOV a1+8(FP), A0
|
||||||
|
MOV a2+16(FP), A1
|
||||||
|
MOV a3+24(FP), A2
|
||||||
|
MOV trap+0(FP), A7 // syscall entry
|
||||||
|
ECALL
|
||||||
|
MOV A0, r1+32(FP) // r1
|
||||||
|
MOV A1, r2+40(FP) // r2
|
||||||
|
CALL runtime·exitsyscall(SB)
|
||||||
|
RET
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48
|
||||||
|
MOV a1+8(FP), A0
|
||||||
|
MOV a2+16(FP), A1
|
||||||
|
MOV a3+24(FP), A2
|
||||||
|
MOV trap+0(FP), A7 // syscall entry
|
||||||
|
ECALL
|
||||||
|
MOV A0, r1+32(FP)
|
||||||
|
MOV A1, r2+40(FP)
|
||||||
|
RET
|
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for ARM64, NetBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
B syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
B syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
B syscall·RawSyscall6(SB)
|
29
vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build !gccgo
|
||||||
|
|
||||||
|
#include "textflag.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// System call support for arm64, OpenBSD
|
||||||
|
//
|
||||||
|
|
||||||
|
// Just jump to package syscall's implementation for all these functions.
|
||||||
|
// The runtime may know about them.
|
||||||
|
|
||||||
|
TEXT ·Syscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·Syscall(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·Syscall6(SB)
|
||||||
|
|
||||||
|
TEXT ·Syscall9(SB),NOSPLIT,$0-104
|
||||||
|
JMP syscall·Syscall9(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall(SB),NOSPLIT,$0-56
|
||||||
|
JMP syscall·RawSyscall(SB)
|
||||||
|
|
||||||
|
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
|
||||||
|
JMP syscall·RawSyscall6(SB)
|
1
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
1
vendor/golang.org/x/sys/unix/bluetooth_linux.go
generated
vendored
@ -23,6 +23,7 @@ const (
|
|||||||
HCI_CHANNEL_USER = 1
|
HCI_CHANNEL_USER = 1
|
||||||
HCI_CHANNEL_MONITOR = 2
|
HCI_CHANNEL_MONITOR = 2
|
||||||
HCI_CHANNEL_CONTROL = 3
|
HCI_CHANNEL_CONTROL = 3
|
||||||
|
HCI_CHANNEL_LOGGING = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
// Socketoption Level
|
// Socketoption Level
|
||||||
|
91
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
91
vendor/golang.org/x/sys/unix/dirent.go
generated
vendored
@ -2,16 +2,101 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import "syscall"
|
import "unsafe"
|
||||||
|
|
||||||
|
// readInt returns the size-bytes unsigned integer in native byte order at offset off.
|
||||||
|
func readInt(b []byte, off, size uintptr) (u uint64, ok bool) {
|
||||||
|
if len(b) < int(off+size) {
|
||||||
|
return 0, false
|
||||||
|
}
|
||||||
|
if isBigEndian {
|
||||||
|
return readIntBE(b[off:], size), true
|
||||||
|
}
|
||||||
|
return readIntLE(b[off:], size), true
|
||||||
|
}
|
||||||
|
|
||||||
|
func readIntBE(b []byte, size uintptr) uint64 {
|
||||||
|
switch size {
|
||||||
|
case 1:
|
||||||
|
return uint64(b[0])
|
||||||
|
case 2:
|
||||||
|
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[1]) | uint64(b[0])<<8
|
||||||
|
case 4:
|
||||||
|
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[3]) | uint64(b[2])<<8 | uint64(b[1])<<16 | uint64(b[0])<<24
|
||||||
|
case 8:
|
||||||
|
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 |
|
||||||
|
uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56
|
||||||
|
default:
|
||||||
|
panic("syscall: readInt with unsupported size")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func readIntLE(b []byte, size uintptr) uint64 {
|
||||||
|
switch size {
|
||||||
|
case 1:
|
||||||
|
return uint64(b[0])
|
||||||
|
case 2:
|
||||||
|
_ = b[1] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[0]) | uint64(b[1])<<8
|
||||||
|
case 4:
|
||||||
|
_ = b[3] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24
|
||||||
|
case 8:
|
||||||
|
_ = b[7] // bounds check hint to compiler; see golang.org/issue/14808
|
||||||
|
return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 |
|
||||||
|
uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56
|
||||||
|
default:
|
||||||
|
panic("syscall: readInt with unsupported size")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ParseDirent parses up to max directory entries in buf,
|
// ParseDirent parses up to max directory entries in buf,
|
||||||
// appending the names to names. It returns the number of
|
// appending the names to names. It returns the number of
|
||||||
// bytes consumed from buf, the number of entries added
|
// bytes consumed from buf, the number of entries added
|
||||||
// to names, and the new names slice.
|
// to names, and the new names slice.
|
||||||
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
func ParseDirent(buf []byte, max int, names []string) (consumed int, count int, newnames []string) {
|
||||||
return syscall.ParseDirent(buf, max, names)
|
origlen := len(buf)
|
||||||
|
count = 0
|
||||||
|
for max != 0 && len(buf) > 0 {
|
||||||
|
reclen, ok := direntReclen(buf)
|
||||||
|
if !ok || reclen > uint64(len(buf)) {
|
||||||
|
return origlen, count, names
|
||||||
|
}
|
||||||
|
rec := buf[:reclen]
|
||||||
|
buf = buf[reclen:]
|
||||||
|
ino, ok := direntIno(rec)
|
||||||
|
if !ok {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if ino == 0 { // File absent in directory.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const namoff = uint64(unsafe.Offsetof(Dirent{}.Name))
|
||||||
|
namlen, ok := direntNamlen(rec)
|
||||||
|
if !ok || namoff+namlen > uint64(len(rec)) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
name := rec[namoff : namoff+namlen]
|
||||||
|
for i, c := range name {
|
||||||
|
if c == 0 {
|
||||||
|
name = name[:i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Check for useless names before allocating a string.
|
||||||
|
if string(name) == "." || string(name) == ".." {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
max--
|
||||||
|
count++
|
||||||
|
names = append(names, string(name))
|
||||||
|
}
|
||||||
|
return origlen - len(buf), count, names
|
||||||
}
|
}
|
||||||
|
2
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
2
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le
|
// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le riscv64
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
14
vendor/golang.org/x/sys/unix/fcntl.go
generated
vendored
14
vendor/golang.org/x/sys/unix/fcntl.go
generated
vendored
@ -2,19 +2,18 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd
|
// +build dragonfly freebsd linux netbsd openbsd
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
// fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
|
||||||
// systems by flock_linux_32bit.go to be SYS_FCNTL64.
|
// systems by fcntl_linux_32bit.go to be SYS_FCNTL64.
|
||||||
var fcntl64Syscall uintptr = SYS_FCNTL
|
var fcntl64Syscall uintptr = SYS_FCNTL
|
||||||
|
|
||||||
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
func fcntl(fd int, cmd, arg int) (int, error) {
|
||||||
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
valptr, _, errno := Syscall(fcntl64Syscall, uintptr(fd), uintptr(cmd), uintptr(arg))
|
||||||
valptr, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(arg))
|
|
||||||
var err error
|
var err error
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
err = errno
|
err = errno
|
||||||
@ -22,6 +21,11 @@ func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
|||||||
return int(valptr), err
|
return int(valptr), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||||
|
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
||||||
|
return fcntl(int(fd), cmd, arg)
|
||||||
|
}
|
||||||
|
|
||||||
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
||||||
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
_, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
|
||||||
|
18
vendor/golang.org/x/sys/unix/fcntl_darwin.go
generated
vendored
Normal file
18
vendor/golang.org/x/sys/unix/fcntl_darwin.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
import "unsafe"
|
||||||
|
|
||||||
|
// FcntlInt performs a fcntl syscall on fd with the provided command and argument.
|
||||||
|
func FcntlInt(fd uintptr, cmd, arg int) (int, error) {
|
||||||
|
return fcntl(int(fd), cmd, arg)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
|
||||||
|
func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
||||||
|
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
|
||||||
|
return err
|
||||||
|
}
|
29
vendor/golang.org/x/sys/unix/fdset.go
generated
vendored
Normal file
29
vendor/golang.org/x/sys/unix/fdset.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
|
|
||||||
|
package unix
|
||||||
|
|
||||||
|
// Set adds fd to the set fds.
|
||||||
|
func (fds *FdSet) Set(fd int) {
|
||||||
|
fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear removes fd from the set fds.
|
||||||
|
func (fds *FdSet) Clear(fd int) {
|
||||||
|
fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsSet returns whether fd is in the set fds.
|
||||||
|
func (fds *FdSet) IsSet(fd int) bool {
|
||||||
|
return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zero clears the set fds.
|
||||||
|
func (fds *FdSet) Zero() {
|
||||||
|
for i := range fds.Bits {
|
||||||
|
fds.Bits[i] = 0
|
||||||
|
}
|
||||||
|
}
|
41
vendor/golang.org/x/sys/unix/ioctl.go
generated
vendored
41
vendor/golang.org/x/sys/unix/ioctl.go
generated
vendored
@ -6,7 +6,19 @@
|
|||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import "runtime"
|
import (
|
||||||
|
"runtime"
|
||||||
|
"unsafe"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ioctl itself should not be exposed directly, but additional get/set
|
||||||
|
// functions for specific types are permissible.
|
||||||
|
|
||||||
|
// IoctlSetInt performs an ioctl operation which sets an integer value
|
||||||
|
// on fd, using the specified request number.
|
||||||
|
func IoctlSetInt(fd int, req uint, value int) error {
|
||||||
|
return ioctl(fd, req, uintptr(value))
|
||||||
|
}
|
||||||
|
|
||||||
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
|
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
|
||||||
//
|
//
|
||||||
@ -14,7 +26,7 @@ import "runtime"
|
|||||||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
||||||
// TODO: if we get the chance, remove the req parameter and
|
// TODO: if we get the chance, remove the req parameter and
|
||||||
// hardcode TIOCSWINSZ.
|
// hardcode TIOCSWINSZ.
|
||||||
err := ioctlSetWinsize(fd, req, value)
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
runtime.KeepAlive(value)
|
runtime.KeepAlive(value)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -24,7 +36,30 @@ func IoctlSetWinsize(fd int, req uint, value *Winsize) error {
|
|||||||
// The req value will usually be TCSETA or TIOCSETA.
|
// The req value will usually be TCSETA or TIOCSETA.
|
||||||
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
func IoctlSetTermios(fd int, req uint, value *Termios) error {
|
||||||
// TODO: if we get the chance, remove the req parameter.
|
// TODO: if we get the chance, remove the req parameter.
|
||||||
err := ioctlSetTermios(fd, req, value)
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
runtime.KeepAlive(value)
|
runtime.KeepAlive(value)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IoctlGetInt performs an ioctl operation which gets an integer value
|
||||||
|
// from fd, using the specified request number.
|
||||||
|
//
|
||||||
|
// A few ioctl requests use the return value as an output parameter;
|
||||||
|
// for those, IoctlRetInt should be used instead of this function.
|
||||||
|
func IoctlGetInt(fd int, req uint) (int, error) {
|
||||||
|
var value int
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
|
||||||
|
var value Winsize
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func IoctlGetTermios(fd int, req uint) (*Termios, error) {
|
||||||
|
var value Termios
|
||||||
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
85
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
85
vendor/golang.org/x/sys/unix/mkall.sh
generated
vendored
@ -17,6 +17,7 @@ mksysctl=""
|
|||||||
zsysctl="zsysctl_$GOOSARCH.go"
|
zsysctl="zsysctl_$GOOSARCH.go"
|
||||||
mksysnum=
|
mksysnum=
|
||||||
mktypes=
|
mktypes=
|
||||||
|
mkasm=
|
||||||
run="sh"
|
run="sh"
|
||||||
cmd=""
|
cmd=""
|
||||||
|
|
||||||
@ -45,11 +46,11 @@ case "$#" in
|
|||||||
exit 2
|
exit 2
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
|
if [[ "$GOOS" = "linux" ]]; then
|
||||||
# Use then new build system
|
# Use the Docker-based build system
|
||||||
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
|
||||||
$cmd docker build --tag generate:$GOOS $GOOS
|
$cmd docker build --tag generate:$GOOS $GOOS
|
||||||
$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
|
$cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")" && /bin/pwd):/build generate:$GOOS
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -61,112 +62,130 @@ _* | *_ | _)
|
|||||||
;;
|
;;
|
||||||
aix_ppc)
|
aix_ppc)
|
||||||
mkerrors="$mkerrors -maix32"
|
mkerrors="$mkerrors -maix32"
|
||||||
mksyscall="./mksyscall_aix_ppc.pl -aix"
|
mksyscall="go run mksyscall_aix_ppc.go -aix"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
aix_ppc64)
|
aix_ppc64)
|
||||||
mkerrors="$mkerrors -maix64"
|
mkerrors="$mkerrors -maix64"
|
||||||
mksyscall="./mksyscall_aix_ppc64.pl -aix"
|
mksyscall="go run mksyscall_aix_ppc64.go -aix"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
darwin_386)
|
darwin_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
mksyscall="go run mksyscall.go -l32"
|
mksyscall="go run mksyscall.go -l32"
|
||||||
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
mkasm="go run mkasm_darwin.go"
|
||||||
;;
|
;;
|
||||||
darwin_amd64)
|
darwin_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk macosx)/usr/include/sys/syscall.h"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
mkasm="go run mkasm_darwin.go"
|
||||||
;;
|
;;
|
||||||
darwin_arm)
|
darwin_arm)
|
||||||
mkerrors="$mkerrors"
|
mkerrors="$mkerrors"
|
||||||
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
|
mksyscall="go run mksyscall.go -l32"
|
||||||
|
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
mkasm="go run mkasm_darwin.go"
|
||||||
;;
|
;;
|
||||||
darwin_arm64)
|
darwin_arm64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksysnum="./mksysnum_darwin.pl $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
|
mksysnum="go run mksysnum.go $(xcrun --show-sdk-path --sdk iphoneos)/usr/include/sys/syscall.h"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
mkasm="go run mkasm_darwin.go"
|
||||||
;;
|
;;
|
||||||
dragonfly_amd64)
|
dragonfly_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksyscall="go run mksyscall.go -dragonfly"
|
mksyscall="go run mksyscall.go -dragonfly"
|
||||||
mksysnum="curl -s 'http://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master' | ./mksysnum_dragonfly.pl"
|
mksysnum="go run mksysnum.go 'https://gitweb.dragonflybsd.org/dragonfly.git/blob_plain/HEAD:/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
freebsd_386)
|
freebsd_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
mksyscall="go run mksyscall.go -l32"
|
mksyscall="go run mksyscall.go -l32"
|
||||||
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
freebsd_amd64)
|
freebsd_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
freebsd_arm)
|
freebsd_arm)
|
||||||
mkerrors="$mkerrors"
|
mkerrors="$mkerrors"
|
||||||
mksyscall="go run mksyscall.go -l32 -arm"
|
mksyscall="go run mksyscall.go -l32 -arm"
|
||||||
mksysnum="curl -s 'http://svn.freebsd.org/base/stable/10/sys/kern/syscalls.master' | ./mksysnum_freebsd.pl"
|
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
||||||
# Let the type of C char be signed for making the bare syscall
|
# Let the type of C char be signed for making the bare syscall
|
||||||
# API consistent across platforms.
|
# API consistent across platforms.
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
;;
|
;;
|
||||||
linux_sparc64)
|
freebsd_arm64)
|
||||||
GOOSARCH_in=syscall_linux_sparc64.go
|
|
||||||
unistd_h=/usr/include/sparc64-linux-gnu/asm/unistd.h
|
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksysnum="./mksysnum_linux.pl $unistd_h"
|
mksysnum="go run mksysnum.go 'https://svn.freebsd.org/base/stable/11/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
netbsd_386)
|
netbsd_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
mksyscall="go run mksyscall.go -l32 -netbsd"
|
mksyscall="go run mksyscall.go -l32 -netbsd"
|
||||||
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
netbsd_amd64)
|
netbsd_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksyscall="go run mksyscall.go -netbsd"
|
mksyscall="go run mksyscall.go -netbsd"
|
||||||
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
netbsd_arm)
|
netbsd_arm)
|
||||||
mkerrors="$mkerrors"
|
mkerrors="$mkerrors"
|
||||||
mksyscall="go run mksyscall.go -l32 -netbsd -arm"
|
mksyscall="go run mksyscall.go -l32 -netbsd -arm"
|
||||||
mksysnum="curl -s 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_netbsd.pl"
|
mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
# Let the type of C char be signed for making the bare syscall
|
# Let the type of C char be signed for making the bare syscall
|
||||||
# API consistent across platforms.
|
# API consistent across platforms.
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
;;
|
;;
|
||||||
|
netbsd_arm64)
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksyscall="go run mksyscall.go -netbsd"
|
||||||
|
mksysnum="go run mksysnum.go 'http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
|
;;
|
||||||
openbsd_386)
|
openbsd_386)
|
||||||
mkerrors="$mkerrors -m32"
|
mkerrors="$mkerrors -m32"
|
||||||
mksyscall="go run mksyscall.go -l32 -openbsd"
|
mksyscall="go run mksyscall.go -l32 -openbsd"
|
||||||
mksysctl="./mksysctl_openbsd.pl"
|
mksysctl="go run mksysctl_openbsd.go"
|
||||||
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
openbsd_amd64)
|
openbsd_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksyscall="go run mksyscall.go -openbsd"
|
mksyscall="go run mksyscall.go -openbsd"
|
||||||
mksysctl="./mksysctl_openbsd.pl"
|
mksysctl="go run mksysctl_openbsd.go"
|
||||||
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
;;
|
;;
|
||||||
openbsd_arm)
|
openbsd_arm)
|
||||||
mkerrors="$mkerrors"
|
mkerrors="$mkerrors"
|
||||||
mksyscall="go run mksyscall.go -l32 -openbsd -arm"
|
mksyscall="go run mksyscall.go -l32 -openbsd -arm"
|
||||||
mksysctl="./mksysctl_openbsd.pl"
|
mksysctl="go run mksysctl_openbsd.go"
|
||||||
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
|
# Let the type of C char be signed for making the bare syscall
|
||||||
|
# API consistent across platforms.
|
||||||
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
|
;;
|
||||||
|
openbsd_arm64)
|
||||||
|
mkerrors="$mkerrors -m64"
|
||||||
|
mksyscall="go run mksyscall.go -openbsd"
|
||||||
|
mksysctl="go run mksysctl_openbsd.go"
|
||||||
|
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
|
||||||
# Let the type of C char be signed for making the bare syscall
|
# Let the type of C char be signed for making the bare syscall
|
||||||
# API consistent across platforms.
|
# API consistent across platforms.
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
|
||||||
;;
|
;;
|
||||||
solaris_amd64)
|
solaris_amd64)
|
||||||
mksyscall="./mksyscall_solaris.pl"
|
mksyscall="go run mksyscall_solaris.go"
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksysnum=
|
mksysnum=
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
@ -191,6 +210,13 @@ esac
|
|||||||
if [ "$GOOSARCH" == "aix_ppc64" ]; then
|
if [ "$GOOSARCH" == "aix_ppc64" ]; then
|
||||||
# aix/ppc64 script generates files instead of writing to stdin.
|
# aix/ppc64 script generates files instead of writing to stdin.
|
||||||
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
|
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in && gofmt -w zsyscall_$GOOSARCH.go && gofmt -w zsyscall_"$GOOSARCH"_gccgo.go && gofmt -w zsyscall_"$GOOSARCH"_gc.go " ;
|
||||||
|
elif [ "$GOOS" == "darwin" ]; then
|
||||||
|
# pre-1.12, direct syscalls
|
||||||
|
echo "$mksyscall -tags $GOOS,$GOARCH,!go1.12 $syscall_goos syscall_darwin_${GOARCH}.1_11.go $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.1_11.go";
|
||||||
|
# 1.12 and later, syscalls via libSystem
|
||||||
|
echo "$mksyscall -tags $GOOS,$GOARCH,go1.12 $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
||||||
|
# 1.13 and later, syscalls via libSystem (including syscallPtr)
|
||||||
|
echo "$mksyscall -tags $GOOS,$GOARCH,go1.13 syscall_darwin.1_13.go |gofmt >zsyscall_$GOOSARCH.1_13.go";
|
||||||
else
|
else
|
||||||
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
echo "$mksyscall -tags $GOOS,$GOARCH $syscall_goos $GOOSARCH_in |gofmt >zsyscall_$GOOSARCH.go";
|
||||||
fi
|
fi
|
||||||
@ -198,7 +224,6 @@ esac
|
|||||||
esac
|
esac
|
||||||
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
|
if [ -n "$mksysctl" ]; then echo "$mksysctl |gofmt >$zsysctl"; fi
|
||||||
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
|
if [ -n "$mksysnum" ]; then echo "$mksysnum |gofmt >zsysnum_$GOOSARCH.go"; fi
|
||||||
if [ -n "$mktypes" ]; then
|
if [ -n "$mktypes" ]; then echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go"; fi
|
||||||
echo "$mktypes types_$GOOS.go | go run mkpost.go > ztypes_$GOOSARCH.go";
|
if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi
|
||||||
fi
|
|
||||||
) | $run
|
) | $run
|
||||||
|
102
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
102
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
@ -17,12 +17,10 @@ if test -z "$GOARCH" -o -z "$GOOS"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check that we are using the new build system if we should
|
# Check that we are using the new build system if we should
|
||||||
if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
|
if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
|
||||||
if [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
|
echo 1>&2 "In the Docker based build system, mkerrors should not be called directly."
|
||||||
echo 1>&2 "In the new build system, mkerrors should not be called directly."
|
echo 1>&2 "See README.md"
|
||||||
echo 1>&2 "See README.md"
|
exit 1
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$GOOS" = "aix" ]]; then
|
if [[ "$GOOS" = "aix" ]]; then
|
||||||
@ -46,6 +44,7 @@ includes_AIX='
|
|||||||
#include <sys/stropts.h>
|
#include <sys/stropts.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/poll.h>
|
#include <sys/poll.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/termio.h>
|
#include <sys/termio.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
@ -62,6 +61,7 @@ includes_Darwin='
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
@ -82,6 +82,7 @@ includes_Darwin='
|
|||||||
includes_DragonFly='
|
includes_DragonFly='
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -105,6 +106,7 @@ includes_FreeBSD='
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -181,49 +183,71 @@ struct ltchars {
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <sys/select.h>
|
||||||
|
#include <sys/signalfd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
#include <sys/xattr.h>
|
#include <sys/xattr.h>
|
||||||
|
#include <linux/bpf.h>
|
||||||
|
#include <linux/can.h>
|
||||||
|
#include <linux/capability.h>
|
||||||
|
#include <linux/cryptouser.h>
|
||||||
|
#include <linux/devlink.h>
|
||||||
|
#include <linux/errqueue.h>
|
||||||
|
#include <linux/falloc.h>
|
||||||
|
#include <linux/fanotify.h>
|
||||||
|
#include <linux/filter.h>
|
||||||
|
#include <linux/fs.h>
|
||||||
|
#include <linux/fscrypt.h>
|
||||||
|
#include <linux/genetlink.h>
|
||||||
|
#include <linux/hdreg.h>
|
||||||
|
#include <linux/icmpv6.h>
|
||||||
#include <linux/if.h>
|
#include <linux/if.h>
|
||||||
|
#include <linux/if_addr.h>
|
||||||
#include <linux/if_alg.h>
|
#include <linux/if_alg.h>
|
||||||
#include <linux/if_arp.h>
|
#include <linux/if_arp.h>
|
||||||
#include <linux/if_ether.h>
|
#include <linux/if_ether.h>
|
||||||
#include <linux/if_ppp.h>
|
#include <linux/if_ppp.h>
|
||||||
#include <linux/if_tun.h>
|
#include <linux/if_tun.h>
|
||||||
#include <linux/if_packet.h>
|
#include <linux/if_packet.h>
|
||||||
#include <linux/if_addr.h>
|
#include <linux/if_xdp.h>
|
||||||
#include <linux/falloc.h>
|
|
||||||
#include <linux/filter.h>
|
|
||||||
#include <linux/fs.h>
|
|
||||||
#include <linux/kexec.h>
|
#include <linux/kexec.h>
|
||||||
#include <linux/keyctl.h>
|
#include <linux/keyctl.h>
|
||||||
|
#include <linux/loop.h>
|
||||||
#include <linux/magic.h>
|
#include <linux/magic.h>
|
||||||
#include <linux/memfd.h>
|
#include <linux/memfd.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/netfilter/nfnetlink.h>
|
#include <linux/netfilter/nfnetlink.h>
|
||||||
#include <linux/netlink.h>
|
#include <linux/netlink.h>
|
||||||
#include <linux/net_namespace.h>
|
#include <linux/net_namespace.h>
|
||||||
|
#include <linux/nsfs.h>
|
||||||
#include <linux/perf_event.h>
|
#include <linux/perf_event.h>
|
||||||
|
#include <linux/ptrace.h>
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
|
#include <linux/rtc.h>
|
||||||
#include <linux/rtnetlink.h>
|
#include <linux/rtnetlink.h>
|
||||||
#include <linux/ptrace.h>
|
|
||||||
#include <linux/sched.h>
|
#include <linux/sched.h>
|
||||||
#include <linux/seccomp.h>
|
#include <linux/seccomp.h>
|
||||||
#include <linux/sockios.h>
|
|
||||||
#include <linux/wait.h>
|
|
||||||
#include <linux/icmpv6.h>
|
|
||||||
#include <linux/serial.h>
|
#include <linux/serial.h>
|
||||||
#include <linux/can.h>
|
#include <linux/sockios.h>
|
||||||
#include <linux/vm_sockets.h>
|
|
||||||
#include <linux/taskstats.h>
|
#include <linux/taskstats.h>
|
||||||
#include <linux/genetlink.h>
|
#include <linux/tipc.h>
|
||||||
|
#include <linux/vm_sockets.h>
|
||||||
|
#include <linux/wait.h>
|
||||||
#include <linux/watchdog.h>
|
#include <linux/watchdog.h>
|
||||||
#include <linux/hdreg.h>
|
|
||||||
#include <linux/rtc.h>
|
|
||||||
#include <linux/if_xdp.h>
|
|
||||||
#include <mtd/ubi-user.h>
|
#include <mtd/ubi-user.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
|
|
||||||
|
#if defined(__sparc__)
|
||||||
|
// On sparc{,64}, the kernel defines struct termios2 itself which clashes with the
|
||||||
|
// definition in glibc. As only the error constants are needed here, include the
|
||||||
|
// generic termibits.h (which is included by termbits.h on sparc).
|
||||||
|
#include <asm-generic/termbits.h>
|
||||||
|
#else
|
||||||
#include <asm/termbits.h>
|
#include <asm/termbits.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MSG_FASTOPEN
|
#ifndef MSG_FASTOPEN
|
||||||
#define MSG_FASTOPEN 0x20000000
|
#define MSG_FASTOPEN 0x20000000
|
||||||
@ -252,15 +276,10 @@ struct ltchars {
|
|||||||
#define FS_KEY_DESC_PREFIX_SIZE 8
|
#define FS_KEY_DESC_PREFIX_SIZE 8
|
||||||
#define FS_MAX_KEY_SIZE 64
|
#define FS_MAX_KEY_SIZE 64
|
||||||
|
|
||||||
// XDP socket constants do not appear to be picked up otherwise.
|
// The code generator produces -0x1 for (~0), but an unsigned value is necessary
|
||||||
// Copied from samples/bpf/xdpsock_user.c.
|
// for the tipc_subscr timeout __u32 field.
|
||||||
#ifndef SOL_XDP
|
#undef TIPC_WAIT_FOREVER
|
||||||
#define SOL_XDP 283
|
#define TIPC_WAIT_FOREVER 0xffffffff
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef AF_XDP
|
|
||||||
#define AF_XDP 44
|
|
||||||
#endif
|
|
||||||
'
|
'
|
||||||
|
|
||||||
includes_NetBSD='
|
includes_NetBSD='
|
||||||
@ -270,6 +289,7 @@ includes_NetBSD='
|
|||||||
#include <sys/extattr.h>
|
#include <sys/extattr.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
@ -296,6 +316,7 @@ includes_OpenBSD='
|
|||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -332,6 +353,7 @@ includes_OpenBSD='
|
|||||||
includes_SunOS='
|
includes_SunOS='
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -424,6 +446,7 @@ ccflags="$@"
|
|||||||
$2 == "XCASE" ||
|
$2 == "XCASE" ||
|
||||||
$2 == "ALTWERASE" ||
|
$2 == "ALTWERASE" ||
|
||||||
$2 == "NOKERNINFO" ||
|
$2 == "NOKERNINFO" ||
|
||||||
|
$2 == "NFDBITS" ||
|
||||||
$2 ~ /^PAR/ ||
|
$2 ~ /^PAR/ ||
|
||||||
$2 ~ /^SIG[^_]/ ||
|
$2 ~ /^SIG[^_]/ ||
|
||||||
$2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
|
$2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
|
||||||
@ -433,7 +456,9 @@ ccflags="$@"
|
|||||||
$2 ~ /^TC[IO](ON|OFF)$/ ||
|
$2 ~ /^TC[IO](ON|OFF)$/ ||
|
||||||
$2 ~ /^IN_/ ||
|
$2 ~ /^IN_/ ||
|
||||||
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
$2 ~ /^LOCK_(SH|EX|NB|UN)$/ ||
|
||||||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|EVFILT|NOTE|EV|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
|
$2 ~ /^LO_(KEY|NAME)_SIZE$/ ||
|
||||||
|
$2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ ||
|
||||||
|
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|ICMP6|TCP|MCAST|EVFILT|NOTE|EV|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR)_/ ||
|
||||||
$2 ~ /^TP_STATUS_/ ||
|
$2 ~ /^TP_STATUS_/ ||
|
||||||
$2 ~ /^FALLOC_/ ||
|
$2 ~ /^FALLOC_/ ||
|
||||||
$2 == "ICMPV6_FILTER" ||
|
$2 == "ICMPV6_FILTER" ||
|
||||||
@ -446,8 +471,9 @@ ccflags="$@"
|
|||||||
$2 ~ /^SYSCTL_VERS/ ||
|
$2 ~ /^SYSCTL_VERS/ ||
|
||||||
$2 !~ "MNT_BITS" &&
|
$2 !~ "MNT_BITS" &&
|
||||||
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
$2 ~ /^(MS|MNT|UMOUNT)_/ ||
|
||||||
|
$2 ~ /^NS_GET_/ ||
|
||||||
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
$2 ~ /^TUN(SET|GET|ATTACH|DETACH)/ ||
|
||||||
$2 ~ /^(O|F|E?FD|NAME|S|PTRACE|PT)_/ ||
|
$2 ~ /^(O|F|[ES]?FD|NAME|S|PTRACE|PT)_/ ||
|
||||||
$2 ~ /^KEXEC_/ ||
|
$2 ~ /^KEXEC_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
$2 ~ /^LINUX_REBOOT_CMD_/ ||
|
||||||
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
|
||||||
@ -466,14 +492,17 @@ ccflags="$@"
|
|||||||
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
|
$2 ~ /^RLIMIT_(AS|CORE|CPU|DATA|FSIZE|LOCKS|MEMLOCK|MSGQUEUE|NICE|NOFILE|NPROC|RSS|RTPRIO|RTTIME|SIGPENDING|STACK)|RLIM_INFINITY/ ||
|
||||||
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
$2 ~ /^PRIO_(PROCESS|PGRP|USER)/ ||
|
||||||
$2 ~ /^CLONE_[A-Z_]+/ ||
|
$2 ~ /^CLONE_[A-Z_]+/ ||
|
||||||
$2 !~ /^(BPF_TIMEVAL)$/ &&
|
$2 !~ /^(BPF_TIMEVAL|BPF_FIB_LOOKUP_[A-Z]+)$/ &&
|
||||||
$2 ~ /^(BPF|DLT)_/ ||
|
$2 ~ /^(BPF|DLT)_/ ||
|
||||||
$2 ~ /^CLOCK_/ ||
|
$2 ~ /^(CLOCK|TIMER)_/ ||
|
||||||
$2 ~ /^CAN_/ ||
|
$2 ~ /^CAN_/ ||
|
||||||
$2 ~ /^CAP_/ ||
|
$2 ~ /^CAP_/ ||
|
||||||
$2 ~ /^ALG_/ ||
|
$2 ~ /^ALG_/ ||
|
||||||
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE|IOC_(GET|SET)_ENCRYPTION)/ ||
|
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ ||
|
||||||
|
$2 ~ /^FS_IOC_.*ENCRYPTION/ ||
|
||||||
|
$2 ~ /^FSCRYPT_/ ||
|
||||||
$2 ~ /^GRND_/ ||
|
$2 ~ /^GRND_/ ||
|
||||||
|
$2 ~ /^RND/ ||
|
||||||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
||||||
$2 ~ /^KEYCTL_/ ||
|
$2 ~ /^KEYCTL_/ ||
|
||||||
$2 ~ /^PERF_EVENT_IOC_/ ||
|
$2 ~ /^PERF_EVENT_IOC_/ ||
|
||||||
@ -498,10 +527,15 @@ ccflags="$@"
|
|||||||
$2 ~ /^WDIOC_/ ||
|
$2 ~ /^WDIOC_/ ||
|
||||||
$2 ~ /^NFN/ ||
|
$2 ~ /^NFN/ ||
|
||||||
$2 ~ /^XDP_/ ||
|
$2 ~ /^XDP_/ ||
|
||||||
|
$2 ~ /^RWF_/ ||
|
||||||
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
$2 ~ /^(HDIO|WIN|SMART)_/ ||
|
||||||
|
$2 ~ /^CRYPTO_/ ||
|
||||||
|
$2 ~ /^TIPC_/ ||
|
||||||
|
$2 ~ /^DEVLINK_/ ||
|
||||||
$2 !~ "WMESGLEN" &&
|
$2 !~ "WMESGLEN" &&
|
||||||
$2 ~ /^W[A-Z0-9]+$/ ||
|
$2 ~ /^W[A-Z0-9]+$/ ||
|
||||||
$2 ~/^PPPIOC/ ||
|
$2 ~/^PPPIOC/ ||
|
||||||
|
$2 ~ /^FAN_|FANOTIFY_/ ||
|
||||||
$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
|
$2 ~ /^BLK[A-Z]*(GET$|SET$|BUF$|PART$|SIZE)/ {printf("\t%s = C.%s\n", $2, $2)}
|
||||||
$2 ~ /^__WCOREFLAG$/ {next}
|
$2 ~ /^__WCOREFLAG$/ {next}
|
||||||
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
|
$2 ~ /^__W[A-Z0-9]+$/ {printf("\t%s = C.%s\n", substr($2,3), $2)}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user