forked from toolshed/abra
chore: vendor
This commit is contained in:
.gitignoremodules.txt
vendor
coopcloud.tech
dario.cat
mergo
git.coopcloud.tech
coop-cloud
github.com
AlecAivazis
survey
v2
CONTRIBUTING.mdLICENSEREADME.mdconfirm.go
core
editor.gofilter.goinput.gomultiline.gomultiselect.gopassword.gorenderer.goselect.gosurvey.goterminal
LICENSE.txtREADME.mdbuffered_reader.gocursor.gocursor_windows.godisplay.godisplay_posix.godisplay_windows.goerror.gooutput.gooutput_windows.gorunereader.gorunereader_bsd.gorunereader_linux.gorunereader_posix.gorunereader_ppc64le.gorunereader_windows.gosequences.gostdio.gosyscall_windows.goterminal.go
transform.govalidate.goAzure
go-ansiterm
BurntSushi
toml
Microsoft
go-winio
ProtonMail
go-crypto
AUTHORSCONTRIBUTORSLICENSEPATENTSkey_generation.gokeys.gokeys_test_data.go
bitcurves
brainpool
eax
internal
byteutil
ocb
openpgp
aes
keywrap
armor
canonical_text.goecdh
ecdsa
eddsa
elgamal
errors
hash.gointernal
algorithm
ecc
encoding
packet
aead_config.goaead_crypter.goaead_encrypted.gocompressed.goconfig.goencrypted_key.goliteral.gonotation.goocfb.goone_pass_signature.goopaque.gopacket.goprivate_key.goprivate_key_test_data.gopublic_key.gopublic_key_test_data.goreader.gosignature.gosymmetric_key_encrypted.gosymmetrically_encrypted.gosymmetrically_encrypted_aead.gosymmetrically_encrypted_mdc.gouserattribute.gouserid.go
read.goread_write_test_data.gos2k
write.goaymanbagabas
beorn7
perks
cenkalti
backoff
cespare
xxhash
charmbracelet
lipgloss
.gitignore.golangci-soft.yml.golangci.ymlLICENSEREADME.mdalign.goansi_unix.goansi_windows.goborders.gocolor.goget.gojoin.goposition.gorenderer.gorunes.goset.gosize.gostyle.go
table
unset.gowhitespace.golog
.gitignore.golangci.yml.goreleaser.ymlLICENSEREADME.mdcontext.goformatter.gojson.golevel.golevel_121.golevel_no121.gologfmt.gologger.gologger_121.gologger_no121.gooptions.gopkg.gostdlog.gostyles.gotext.go
x
cloudflare
containerd
containerd
log
containers
image
LICENSE
docker
cache.godocker_client.godocker_image.godocker_image_dest.godocker_image_src.godocker_transport.golookaside.go
policyconfiguration
reference
wwwauthenticate.goimage
manifest
pkg
blobinfocache
none
docker
keyctl
strslice
sysregistriesv2
tlsclientconfig
transports
types
cpuguy83
go-md2man
v2
cyphar
davecgh
decentral1se
distribution
reference
docker
cli
AUTHORSLICENSENOTICE
cli-plugins
hooks
manager
cli
cobra.go
command
cli.gocli_options.gocontext.godefaultcontextstore.gotelemetry.gotelemetry_docker.gotelemetry_options.gotelemetry_utils.gotrust.goutils.go
formatter
buildcache.gocontainer.gocontext.gocustom.godisk_usage.godisplayutils.goformatter.goimage.goreflect.go
registry.gotabwriter
volume.goservice
progress
stack
formatter
compose
interpolation
loader
schema
data
config_schema_v3.0.jsonconfig_schema_v3.1.jsonconfig_schema_v3.10.jsonconfig_schema_v3.11.jsonconfig_schema_v3.12.jsonconfig_schema_v3.13.jsonconfig_schema_v3.2.jsonconfig_schema_v3.3.jsonconfig_schema_v3.4.jsonconfig_schema_v3.5.jsonconfig_schema_v3.6.jsonconfig_schema_v3.7.jsonconfig_schema_v3.8.jsonconfig_schema_v3.9.json
schema.gotemplate
types
config
config.go
configfile
credentials
credentials.godefault_store.godefault_store_darwin.godefault_store_linux.godefault_store_unsupported.godefault_store_windows.gofile_store.gonative_store.go
types
connhelper
context
debug
error.goflags
hints
manifest
registry
required.gostreams
trust
version
opts
capabilities.goconfig.goduration.goenv.goenvfile.gofile.gogpus.gohosts.gohosts_unix.gohosts_windows.gomount.gonetwork.goopts.goparse.goport.goquotedstring.gosecret.gothrottledevice.goulimit.goweightdevice.go
templates
distribution
.dockerignore.gitignore.golangci.yml.mailmapBUILDING.mdCONTRIBUTING.mdDockerfileLICENSEMAINTAINERSMakefileREADME.mdROADMAP.mdblobs.godoc.godocker-bake.hclerrors.go
manifest
manifests.gometrics
registry.goregistry
tags.gouuid
vendor.confdocker-credential-helpers
docker
AUTHORSLICENSENOTICE
api
README.mdcommon.goswagger-gen.yamlswagger.yaml
types
blkiodev
checkpoint
client.gocontainer
change_type.gochange_types.goconfig.gocontainer.gocontainer_top.gocontainer_update.gocreate_request.gocreate_response.goerrors.goexec.gofilesystem_change.gohostconfig.gohostconfig_unix.gohostconfig_windows.gooptions.gostats.gowait_exit_error.gowait_response.gowaitcondition.go
error_response.goerror_response_ext.goevents
filters
graph_driver_data.goid_response.goimage
mount
network
plugin.goplugin_device.goplugin_env.goplugin_interface_type.goplugin_mount.goplugin_responses.goport.goregistry
strslice
swarm
common.goconfig.gocontainer.gonetwork.gonode.goruntime.go
runtime
secret.goservice.goservice_create_response.goservice_update_response.goswarm.gotask.gosystem
time
types.gotypes_deprecated.goversions
volume
client
README.mdbuild_cancel.gobuild_prune.gocheckpoint_create.gocheckpoint_delete.gocheckpoint_list.goclient.goclient_deprecated.goclient_unix.goclient_windows.goconfig_create.goconfig_inspect.goconfig_list.goconfig_remove.goconfig_update.gocontainer_attach.gocontainer_commit.gocontainer_copy.gocontainer_create.gocontainer_diff.gocontainer_exec.gocontainer_export.gocontainer_inspect.gocontainer_kill.gocontainer_list.gocontainer_logs.gocontainer_pause.gocontainer_prune.gocontainer_remove.gocontainer_rename.gocontainer_resize.gocontainer_restart.gocontainer_start.gocontainer_stats.gocontainer_stop.gocontainer_top.gocontainer_unpause.gocontainer_update.gocontainer_wait.godisk_usage.godistribution_inspect.goenvvars.goerrors.goevents.gohijack.goimage_build.goimage_create.goimage_history.goimage_import.goimage_inspect.goimage_list.goimage_load.goimage_prune.goimage_pull.goimage_push.goimage_remove.goimage_save.goimage_search.goimage_tag.goinfo.gointerface.gointerface_experimental.gointerface_stable.gologin.gonetwork_connect.gonetwork_create.gonetwork_disconnect.gonetwork_inspect.gonetwork_list.gonetwork_prune.gonetwork_remove.gonode_inspect.gonode_list.gonode_remove.gonode_update.gooptions.goping.goplugin_create.goplugin_disable.goplugin_enable.goplugin_inspect.goplugin_install.goplugin_list.goplugin_push.goplugin_remove.goplugin_set.goplugin_upgrade.gorequest.gosecret_create.gosecret_inspect.gosecret_list.gosecret_remove.gosecret_update.goservice_create.goservice_inspect.goservice_list.goservice_logs.goservice_remove.goservice_update.goswarm_get_unlock_key.goswarm_init.goswarm_inspect.goswarm_join.goswarm_leave.goswarm_unlock.goswarm_update.gotask_inspect.gotask_list.gotask_logs.goutils.goversion.govolume_create.govolume_inspect.govolume_list.govolume_prune.govolume_remove.govolume_update.go
errdefs
internal
multierror
pkg
archive
archive.goarchive_linux.goarchive_other.goarchive_unix.goarchive_windows.gochanges.gochanges_linux.gochanges_other.gochanges_unix.gochanges_windows.gocopy.gocopy_unix.gocopy_windows.godiff.godiff_unix.godiff_windows.gopath.gopath_unix.gopath_windows.gotime_linux.gotime_unsupported.gowhiteouts.gowrap.go
homedir
idtools
idtools.goidtools_unix.goidtools_windows.gousergroupadd_linux.gousergroupadd_unsupported.goutils_unix.go
ioutils
jsonmessage
pools
progress
stdcopy
streamformatter
stringid
system
args_windows.gochtimes.gochtimes_nowindows.gochtimes_windows.goerrors.gofilesys.gofilesys_unix.gofilesys_windows.goinit_windows.golstat_unix.golstat_windows.gomknod.gomknod_freebsd.gomknod_unix.gostat_bsd.gostat_darwin.gostat_illumos.gostat_linux.gostat_openbsd.gostat_unix.gostat_windows.goutimes_unix.goutimes_unsupported.goxattrs.goxattrs_linux.goxattrs_unsupported.go
registry
go-connections
LICENSE
nat
sockets
README.mdinmem_socket.goproxy.gosockets.gosockets_unix.gosockets_windows.gotcp_socket.gounix_socket.go
tlsconfig
go-metrics
CONTRIBUTING.mdLICENSELICENSE.docsNOTICEREADME.mdcounter.godocs.gogauge.gohandler.gohelpers.gonamespace.goregister.gotimer.gounit.go
go-units
go
libtrust
emirpasic
gods
felixge
httpsnoop
fvbommel
ghodss
go-git
gcfg
go-billy
v5
go-git
v5
.gitignoreCODE_OF_CONDUCT.mdCOMPATIBILITY.mdCONTRIBUTING.mdEXTENDING.mdLICENSEMakefileREADME.mdSECURITY.mdblame.gocommon.gohash.goreference.gorevision.goprune.goremote.gorepository.gosigner.gostatus.gosubmodule.goworktree.goworktree_bsd.goworktree_commit.goworktree_js.goworktree_linux.goworktree_plan9.goworktree_status.goworktree_unix_other.goworktree_windows.go
config
doc.gointernal
object_walker.gooptions.gooss-fuzz.shplumbing
cache
color
error.gofilemode
format
config
diff
gitignore
idxfile
index
objfile
packfile
common.godelta_index.godelta_selector.godiff_delta.godoc.goencoder.goerror.gofsobject.goobject_pack.gopackfile.goparser.gopatch_delta.goscanner.go
pktline
hash
memory.goobject.goobject
blob.gochange.gochange_adaptor.gocommit.gocommit_walker.gocommit_walker_bfs.gocommit_walker_bfs_filtered.gocommit_walker_ctime.gocommit_walker_limit.gocommit_walker_path.godifftree.gofile.gomerge_base.goobject.gopatch.gorename.gosignature.gotag.gotree.gotreenoder.go
protocol
packp
revlist
storer
transport
storage
filesystem
memory
storer.goutils
binary
diff
ioutil
merkletrie
sync
trace
go-logfmt
go-logr
logr
.golangci.yamlCHANGELOG.mdCONTRIBUTING.mdLICENSEREADME.mdSECURITY.mdcontext.gocontext_noslog.gocontext_slog.godiscard.go
funcr
logr.gosloghandler.goslogr.goslogsink.gostdr
go-viper
mapstructure
gogo
protobuf
AUTHORSCONTRIBUTORSLICENSE
proto
Makefileclone.gocustom_gogo.godecode.godeprecated.godiscard.goduration.goduration_gogo.goencode.goencode_gogo.goequal.goextensions.goextensions_gogo.golib.golib_gogo.gomessage_set.gopointer_reflect.gopointer_reflect_gogo.gopointer_unsafe.gopointer_unsafe_gogo.goproperties.goproperties_gogo.goskip_gogo.gotable_marshal.gotable_marshal_gogo.gotable_merge.gotable_unmarshal.gotable_unmarshal_gogo.gotext.gotext_gogo.gotext_parser.gotimestamp.gotimestamp_gogo.gowrappers.gowrappers_gogo.go
golang
google
gorilla
mux
grpc-ecosystem
grpc-gateway
hashicorp
go-cleanhttp
go-retryablehttp
inconshreveable
jbenet
kballard
go-shellquote
kevinburke
ssh_config
klauspost
compress
.gitattributes.gitignore.goreleaser.ymlLICENSEREADME.mdSECURITY.mdcompressible.gos2sx.mods2sx.sum
fse
gen.shhuff0
.gitignoreREADME.mdbitreader.gobitwriter.gocompress.godecompress.godecompress_amd64.godecompress_amd64.sdecompress_generic.gohuff0.go
internal
cpuinfo
snapref
zstd
README.mdbitreader.gobitwriter.goblockdec.goblockenc.goblocktype_string.gobytebuf.gobytereader.godecodeheader.godecoder.godecoder_options.godict.goenc_base.goenc_best.goenc_better.goenc_dfast.goenc_fast.goencoder.goencoder_options.goframedec.goframeenc.gofse_decoder.gofse_decoder_amd64.gofse_decoder_amd64.sfse_decoder_generic.gofse_encoder.gofse_predefined.gohash.gohistory.gomatchlen_amd64.gomatchlen_amd64.smatchlen_generic.goseqdec.goseqdec_amd64.goseqdec_amd64.sseqdec_generic.goseqenc.gosnappy.gozip.gozstd.go
internal
xxhash
lucasb-eyer
go-colorful
mattn
go-colorable
LICENSEREADME.mdcolorable_appengine.gocolorable_others.gocolorable_windows.gogo.test.shnoncolorable.go
go-isatty
LICENSEREADME.mddoc.gogo.test.shisatty_bsd.goisatty_others.goisatty_plan9.goisatty_solaris.goisatty_tcgets.goisatty_windows.go
go-runewidth
mgutz
miekg
pkcs11
mitchellh
colorstring
moby
docker-image-spec
patternmatcher
sys
sequential
signal
LICENSEsignal.gosignal_darwin.gosignal_freebsd.gosignal_linux.gosignal_linux_mipsx.gosignal_unix.gosignal_unsupported.gosignal_windows.go
user
term
morikuni
muesli
termenv
.gitignore.golangci-soft.yml.golangci.ymlLICENSEREADME.mdansi_compat.mdansicolors.gocolor.goconstants_linux.goconstants_solaris.goconstants_unix.gocopy.gohyperlink.gonotification.gooutput.goprofile.goscreen.gostyle.gotemplatehelper.gotermenv.gotermenv_other.gotermenv_posix.gotermenv_solaris.gotermenv_unix.gotermenv_windows.go
munnerz
goautoneg
opencontainers
go-digest
.mailmap.pullapprove.yml.travis.ymlCONTRIBUTING.mdLICENSELICENSE.docsMAINTAINERSREADME.mdalgorithm.godigest.godigester.godoc.goverifiers.go
image-spec
pjbgf
sha1cd
pkg
pmezard
go-difflib
prometheus
client_golang
LICENSENOTICE
prometheus
.gitignoreREADME.mdbuild_info_collector.gocollector.gocounter.godesc.godoc.goexpvar_collector.gofnv.gogauge.goget_pid.goget_pid_gopherjs.gogo_collector.gogo_collector_go116.gogo_collector_latest.gohistogram.go
internal
labels.gometric.gonum_threads.gonum_threads_gopherjs.goobserver.goprocess_collector.goprocess_collector_js.goprocess_collector_other.goprocess_collector_wasip1.goprocess_collector_windows.gopromhttp
registry.gosummary.gotimer.gountyped.govalue.govec.govnext.gowrap.goclient_model
common
procfs
.gitignore.golangci.ymlCODE_OF_CONDUCT.mdCONTRIBUTING.mdLICENSEMAINTAINERS.mdMakefileMakefile.commonNOTICEREADME.mdSECURITY.mdarp.gobuddyinfo.gocmdline.gocpuinfo.gocpuinfo_armx.gocpuinfo_loong64.gocpuinfo_mipsx.gocpuinfo_others.gocpuinfo_ppcx.gocpuinfo_riscvx.gocpuinfo_s390x.gocpuinfo_x86.gocrypto.godoc.gofs.gofs_statfs_notype.gofs_statfs_type.gofscache.go
internal
ipvs.gokernel_random.goloadavg.gomdstat.gomeminfo.gomountinfo.gomountstats.gonet_conntrackstat.gonet_dev.gonet_ip_socket.gonet_protocols.gonet_route.gonet_sockstat.gonet_softnet.gonet_tcp.gonet_tls_stat.gonet_udp.gonet_unix.gonet_wireless.gonet_xfrm.gonetstat.goproc.goproc_cgroup.goproc_cgroups.goproc_environ.goproc_fdinfo.goproc_interrupts.goproc_io.goproc_limits.goproc_maps.goproc_netstat.goproc_ns.goproc_psi.goproc_smaps.goproc_snmp.goproc_snmp6.goproc_stat.goproc_status.goproc_sys.goschedstat.goslab.gosoftirqs.gostat.goswaps.gothread.gottarvm.gozoneinfo.gorivo
uniseg
russross
blackfriday
schollz
sergi
go-diff
sirupsen
logrus
.gitignore.golangci.yml.travis.ymlCHANGELOG.mdLICENSEREADME.mdalt_exit.goappveyor.ymlbuffer_pool.godoc.goentry.goexported.goformatter.gohooks.gojson_formatter.gologger.gologrus.goterminal_check_appengine.goterminal_check_bsd.goterminal_check_js.goterminal_check_no_terminal.goterminal_check_notappengine.goterminal_check_solaris.goterminal_check_unix.goterminal_check_windows.gotext_formatter.gowriter.go
skeema
knownhosts
spf13
cobra
.gitignore.golangci.yml.mailmapCONDUCT.mdCONTRIBUTING.mdLICENSE.txtMAINTAINERSMakefileREADME.mdactive_help.goargs.gobash_completions.gobash_completionsV2.gocobra.gocommand.gocommand_notwin.gocommand_win.gocompletions.gofish_completions.goflag_groups.gopowershell_completions.goshell_completions.gozsh_completions.go
pflag
.gitignore.travis.ymlLICENSEREADME.mdbool.gobool_slice.gobytes.gocount.goduration.goduration_slice.goflag.gofloat32.gofloat32_slice.gofloat64.gofloat64_slice.gogolangflag.goint.goint16.goint32.goint32_slice.goint64.goint64_slice.goint8.goint_slice.goip.goip_slice.goipmask.goipnet.gostring.gostring_array.gostring_slice.gostring_to_int.gostring_to_int64.gostring_to_string.gouint.gouint16.gouint32.gouint64.gouint8.gouint_slice.go
stretchr
testify
theupdateframework
notary
.gitignoreCHANGELOG.mdCODE_OF_CONDUCT.mdCONTRIBUTING.mdCONTRIBUTORSDockerfileJenkinsfileLICENSEMAINTAINERSMAINTAINERS.ALUMNIMAINTAINERS_RULES.mdMakefileNOTARY_VERSIONREADME.mdcodecov.ymlconst.goconst_nowindows.goconst_windows.gocross.Dockerfile
client
changelist
client.godelegations.goerrors.gohelpers.gointerface.goreader.gorepo.gorepo_pkcs11.gotufclient.gowitness.gocryptoservice
development.mysql.ymldevelopment.postgresql.ymldevelopment.rethink.ymldocker-compose.postgresql.ymldocker-compose.rethink.ymldocker-compose.ymlescrow.Dockerfilefips.gonotary.gopassphrase
server.Dockerfileserver.minimal.Dockerfilesigner.Dockerfilesigner.minimal.Dockerfilestorage
trustmanager
trustpinning
tuf
urfave
cli
.flake8.gitignoreCODE_OF_CONDUCT.mdLICENSEREADME.mdapp.gocategory.gocli.gocommand.gocontext.godocs.goerrors.gofish.goflag.goflag_bool.goflag_bool_t.goflag_duration.goflag_float64.goflag_generic.goflag_int.goflag_int64.goflag_int64_slice.goflag_int_slice.goflag_string.goflag_string_slice.goflag_uint.goflag_uint64.gofuncs.gohelp.goparse.gosort.gotemplate.go
xanzy
xeipuuv
gojsonpointer
gojsonreference
gojsonschema
go.opentelemetry.io
contrib
instrumentation
net
http
otel
.codespellignore.codespellrc.gitattributes.gitignore.golangci.yml.lycheeignore.markdownlint.yamlCHANGELOG.mdCODEOWNERSCONTRIBUTING.mdLICENSEMakefileREADME.mdRELEASING.mdVERSIONING.mdget_main_pkgs.shhandler.gotrace.go
attribute
baggage
codes
doc.goerror_handler.goexporters
otlp
otlpmetric
otlpmetricgrpc
otlptrace
LICENSEREADME.mdclients.godoc.goexporter.go
internal
tracetransform
otlptracegrpc
LICENSEREADME.mdclient.godoc.goexporter.go
version.gointernal
options.gointernal
internal_logging.gometric.gometric
LICENSEREADME.mdasyncfloat64.goasyncint64.goconfig.godoc.go
propagation.goembedded
instrument.gometer.gonoop
syncfloat64.gosyncint64.gopropagation
renovate.jsonrequirements.txtsdk
LICENSEREADME.md
instrumentation
internal
metric
LICENSEREADME.mdaggregation.gocache.goconfig.godoc.goenv.goexemplar.goexporter.goinstrument.goinstrumentkind_string.go
internal
manual_reader.gometer.gometricdata
periodic_reader.gopipeline.goprovider.goreader.goversion.goview.goresource
README.mdauto.gobuiltin.goconfig.gocontainer.godoc.goenv.gohost_id.gohost_id_bsd.gohost_id_darwin.gohost_id_exec.gohost_id_linux.gohost_id_readfile.gohost_id_unsupported.gohost_id_windows.goos.goos_release_darwin.goos_release_unix.goos_unix.goos_unsupported.goos_windows.goprocess.goresource.go
trace
README.mdbatch_span_processor.godoc.goevent.goevictedqueue.goid_generator.golink.goprovider.gosampler_env.gosampling.gosimple_span_processor.gosnapshot.gospan.gospan_exporter.gospan_limits.gospan_processor.gotracer.goversion.go
version.gosemconv
v1.20.0
v1.21.0
v1.24.0
v1.26.0
trace
verify_examples.shverify_readmes.shversion.goversions.yamlproto
otlp
golang.org
x
crypto
LICENSEPATENTS
argon2
blake2b
blake2b.goblake2bAVX2_amd64.goblake2bAVX2_amd64.sblake2b_amd64.sblake2b_generic.goblake2b_ref.goblake2x.goregister.go
blowfish
cast5
chacha20
chacha_arm64.gochacha_arm64.schacha_generic.gochacha_noasm.gochacha_ppc64le.gochacha_ppc64le.schacha_s390x.gochacha_s390x.sxor.go
curve25519
ed25519
hkdf
internal
alias
poly1305
pbkdf2
sha3
doc.gohashes.gohashes_noasm.gokeccakf.gokeccakf_amd64.gokeccakf_amd64.ssha3.gosha3_s390x.gosha3_s390x.sshake.goshake_noasm.goxor.go
ssh
exp
net
LICENSEPATENTS
context
http
httpguts
http2
.gitignoreascii.gociphers.goclient_conn_pool.godatabuffer.goerrors.goflow.goframe.gogotrack.goheadermap.go
hpack
http2.gopipe.goserver.gotimer.gotransport.gowrite.gowritesched.gowritesched_priority.gowritesched_random.gowritesched_roundrobin.goidna
go118.goidna10.0.0.goidna9.0.0.gopre_go118.gopunycode.gotables10.0.0.gotables11.0.0.gotables12.0.0.gotables13.0.0.gotables15.0.0.gotables9.0.0.gotrie.gotrie12.0.0.gotrie13.0.0.gotrieval.go
internal
proxy
trace
sync
sys
LICENSEPATENTS
cpu
asm_aix_ppc64.sbyteorder.gocpu.gocpu_aix.gocpu_arm.gocpu_arm64.gocpu_arm64.scpu_gc_arm64.gocpu_gc_s390x.gocpu_gc_x86.gocpu_gccgo_arm64.gocpu_gccgo_s390x.gocpu_gccgo_x86.ccpu_gccgo_x86.gocpu_linux.gocpu_linux_arm.gocpu_linux_arm64.gocpu_linux_mips64x.gocpu_linux_noinit.gocpu_linux_ppc64x.gocpu_linux_s390x.gocpu_loong64.gocpu_mips64x.gocpu_mipsx.gocpu_netbsd_arm64.gocpu_openbsd_arm64.gocpu_openbsd_arm64.scpu_other_arm.gocpu_other_arm64.gocpu_other_mips64x.gocpu_other_ppc64x.gocpu_other_riscv64.gocpu_ppc64x.gocpu_riscv64.gocpu_s390x.gocpu_s390x.scpu_wasm.gocpu_x86.gocpu_x86.scpu_zos.gocpu_zos_s390x.goendian_big.goendian_little.gohwcap_linux.goparse.goproc_cpuinfo_linux.goruntime_auxv.goruntime_auxv_go121.gosyscall_aix_gccgo.gosyscall_aix_ppc64_gc.go
execabs
plan9
asm.sasm_plan9_386.sasm_plan9_amd64.sasm_plan9_arm.sconst_plan9.godir_plan9.goenv_plan9.goerrors_plan9.gomkall.shmkerrors.shmksysnum_plan9.shpwd_go15_plan9.gopwd_plan9.gorace.gorace0.gostr.gosyscall.gosyscall_plan9.gozsyscall_plan9_386.gozsyscall_plan9_amd64.gozsyscall_plan9_arm.gozsysnum_plan9.go
unix
.gitignoreREADME.mdaffinity_linux.goaliases.goasm_aix_ppc64.sasm_bsd_386.sasm_bsd_amd64.sasm_bsd_arm.sasm_bsd_arm64.sasm_bsd_ppc64.sasm_bsd_riscv64.sasm_linux_386.sasm_linux_amd64.sasm_linux_arm.sasm_linux_arm64.sasm_linux_loong64.sasm_linux_mips64x.sasm_linux_mipsx.sasm_linux_ppc64x.sasm_linux_riscv64.sasm_linux_s390x.sasm_openbsd_mips64.sasm_solaris_amd64.sasm_zos_s390x.sbluetooth_linux.gobpxsvc_zos.gobpxsvc_zos.scap_freebsd.goconstants.godev_aix_ppc.godev_aix_ppc64.godev_darwin.godev_dragonfly.godev_freebsd.godev_linux.godev_netbsd.godev_openbsd.godev_zos.godirent.goendian_big.goendian_little.goenv_unix.gofcntl.gofcntl_darwin.gofcntl_linux_32bit.gofdset.gogccgo.gogccgo_c.cgccgo_linux_amd64.goifreq_linux.goioctl_linux.goioctl_signed.goioctl_unsigned.goioctl_zos.gomkall.shmkerrors.shmmap_nomremap.gomremap.gopagesize_unix.gopledge_openbsd.goptrace_darwin.goptrace_ios.gorace.gorace0.goreaddirent_getdents.goreaddirent_getdirentries.gosockcmsg_dragonfly.gosockcmsg_linux.gosockcmsg_unix.gosockcmsg_unix_other.gosockcmsg_zos.gosymaddr_zos_s390x.ssyscall.gosyscall_aix.gosyscall_aix_ppc.gosyscall_aix_ppc64.gosyscall_bsd.gosyscall_darwin.gosyscall_darwin_amd64.gosyscall_darwin_arm64.gosyscall_darwin_libSystem.gosyscall_dragonfly.gosyscall_dragonfly_amd64.gosyscall_freebsd.gosyscall_freebsd_386.gosyscall_freebsd_amd64.gosyscall_freebsd_arm.gosyscall_freebsd_arm64.gosyscall_freebsd_riscv64.gosyscall_hurd.gosyscall_hurd_386.gosyscall_illumos.gosyscall_linux.gosyscall_linux_386.gosyscall_linux_alarm.gosyscall_linux_amd64.gosyscall_linux_amd64_gc.gosyscall_linux_arm.gosyscall_linux_arm64.gosyscall_linux_gc.gosyscall_linux_gc_386.gosyscall_linux_gc_arm.gosyscall_linux_gccgo_386.gosyscall_linux_gccgo_arm.gosyscall_linux_loong64.gosyscall_linux_mips64x.gosyscall_linux_mipsx.gosyscall_linux_ppc.gosyscall_linux_ppc64x.gosyscall_linux_riscv64.gosyscall_linux_s390x.gosyscall_linux_sparc64.gosyscall_netbsd.gosyscall_netbsd_386.gosyscall_netbsd_amd64.gosyscall_netbsd_arm.gosyscall_netbsd_arm64.gosyscall_openbsd.gosyscall_openbsd_386.gosyscall_openbsd_amd64.gosyscall_openbsd_arm.gosyscall_openbsd_arm64.gosyscall_openbsd_libc.gosyscall_openbsd_mips64.gosyscall_openbsd_ppc64.gosyscall_openbsd_riscv64.gosyscall_solaris.gosyscall_solaris_amd64.gosyscall_unix.gosyscall_unix_gc.gosyscall_unix_gc_ppc64x.gosyscall_zos_s390x.gosysvshm_linux.gosysvshm_unix.gosysvshm_unix_other.gotimestruct.gounveil_openbsd.goxattr_bsd.gozerrors_aix_ppc.gozerrors_aix_ppc64.gozerrors_darwin_amd64.gozerrors_darwin_arm64.gozerrors_dragonfly_amd64.gozerrors_freebsd_386.gozerrors_freebsd_amd64.gozerrors_freebsd_arm.gozerrors_freebsd_arm64.gozerrors_freebsd_riscv64.gozerrors_linux.gozerrors_linux_386.gozerrors_linux_amd64.gozerrors_linux_arm.gozerrors_linux_arm64.gozerrors_linux_loong64.gozerrors_linux_mips.gozerrors_linux_mips64.gozerrors_linux_mips64le.gozerrors_linux_mipsle.gozerrors_linux_ppc.gozerrors_linux_ppc64.gozerrors_linux_ppc64le.gozerrors_linux_riscv64.gozerrors_linux_s390x.gozerrors_linux_sparc64.gozerrors_netbsd_386.gozerrors_netbsd_amd64.gozerrors_netbsd_arm.gozerrors_netbsd_arm64.gozerrors_openbsd_386.gozerrors_openbsd_amd64.gozerrors_openbsd_arm.gozerrors_openbsd_arm64.gozerrors_openbsd_mips64.gozerrors_openbsd_ppc64.gozerrors_openbsd_riscv64.gozerrors_solaris_amd64.gozerrors_zos_s390x.gozptrace_armnn_linux.gozptrace_linux_arm64.gozptrace_mipsnn_linux.gozptrace_mipsnnle_linux.gozptrace_x86_linux.gozsymaddr_zos_s390x.szsyscall_aix_ppc.gozsyscall_aix_ppc64.gozsyscall_aix_ppc64_gc.gozsyscall_aix_ppc64_gccgo.gozsyscall_darwin_amd64.gozsyscall_darwin_amd64.szsyscall_darwin_arm64.gozsyscall_darwin_arm64.szsyscall_dragonfly_amd64.gozsyscall_freebsd_386.gozsyscall_freebsd_amd64.gozsyscall_freebsd_arm.gozsyscall_freebsd_arm64.gozsyscall_freebsd_riscv64.gozsyscall_illumos_amd64.gozsyscall_linux.gozsyscall_linux_386.gozsyscall_linux_amd64.gozsyscall_linux_arm.gozsyscall_linux_arm64.gozsyscall_linux_loong64.gozsyscall_linux_mips.gozsyscall_linux_mips64.gozsyscall_linux_mips64le.gozsyscall_linux_mipsle.gozsyscall_linux_ppc.gozsyscall_linux_ppc64.gozsyscall_linux_ppc64le.gozsyscall_linux_riscv64.gozsyscall_linux_s390x.gozsyscall_linux_sparc64.gozsyscall_netbsd_386.gozsyscall_netbsd_amd64.gozsyscall_netbsd_arm.gozsyscall_netbsd_arm64.gozsyscall_openbsd_386.gozsyscall_openbsd_386.szsyscall_openbsd_amd64.gozsyscall_openbsd_amd64.szsyscall_openbsd_arm.gozsyscall_openbsd_arm.szsyscall_openbsd_arm64.gozsyscall_openbsd_arm64.szsyscall_openbsd_mips64.gozsyscall_openbsd_mips64.szsyscall_openbsd_ppc64.gozsyscall_openbsd_ppc64.szsyscall_openbsd_riscv64.gozsyscall_openbsd_riscv64.szsyscall_solaris_amd64.gozsyscall_zos_s390x.gozsysctl_openbsd_386.gozsysctl_openbsd_amd64.gozsysctl_openbsd_arm.gozsysctl_openbsd_arm64.gozsysctl_openbsd_mips64.gozsysctl_openbsd_ppc64.gozsysctl_openbsd_riscv64.gozsysnum_darwin_amd64.gozsysnum_darwin_arm64.gozsysnum_dragonfly_amd64.gozsysnum_freebsd_386.gozsysnum_freebsd_amd64.gozsysnum_freebsd_arm.gozsysnum_freebsd_arm64.gozsysnum_freebsd_riscv64.gozsysnum_linux_386.gozsysnum_linux_amd64.gozsysnum_linux_arm.gozsysnum_linux_arm64.gozsysnum_linux_loong64.gozsysnum_linux_mips.gozsysnum_linux_mips64.gozsysnum_linux_mips64le.gozsysnum_linux_mipsle.gozsysnum_linux_ppc.gozsysnum_linux_ppc64.gozsysnum_linux_ppc64le.gozsysnum_linux_riscv64.gozsysnum_linux_s390x.gozsysnum_linux_sparc64.gozsysnum_netbsd_386.gozsysnum_netbsd_amd64.gozsysnum_netbsd_arm.gozsysnum_netbsd_arm64.gozsysnum_openbsd_386.gozsysnum_openbsd_amd64.gozsysnum_openbsd_arm.gozsysnum_openbsd_arm64.gozsysnum_openbsd_mips64.gozsysnum_openbsd_ppc64.gozsysnum_openbsd_riscv64.gozsysnum_zos_s390x.goztypes_aix_ppc.goztypes_aix_ppc64.goztypes_darwin_amd64.goztypes_darwin_arm64.goztypes_dragonfly_amd64.goztypes_freebsd_386.goztypes_freebsd_amd64.goztypes_freebsd_arm.goztypes_freebsd_arm64.goztypes_freebsd_riscv64.goztypes_linux.goztypes_linux_386.goztypes_linux_amd64.goztypes_linux_arm.goztypes_linux_arm64.goztypes_linux_loong64.goztypes_linux_mips.goztypes_linux_mips64.goztypes_linux_mips64le.goztypes_linux_mipsle.goztypes_linux_ppc.goztypes_linux_ppc64.goztypes_linux_ppc64le.goztypes_linux_riscv64.goztypes_linux_s390x.goztypes_linux_sparc64.goztypes_netbsd_386.goztypes_netbsd_amd64.goztypes_netbsd_arm.goztypes_netbsd_arm64.goztypes_openbsd_386.goztypes_openbsd_amd64.goztypes_openbsd_arm.goztypes_openbsd_arm64.goztypes_openbsd_mips64.goztypes_openbsd_ppc64.goztypes_openbsd_riscv64.goztypes_solaris_amd64.goztypes_zos_s390x.go
windows
aliases.godll_windows.goenv_windows.goeventlog.goexec_windows.gomemory_windows.gomkerrors.bashmkknownfolderids.bashmksyscall.gorace.gorace0.go
registry
security_windows.goservice.gosetupapi_windows.gostr.gosyscall.gosyscall_windows.gotypes_windows.gotypes_windows_386.gotypes_windows_amd64.gotypes_windows_arm.gotypes_windows_arm64.gozerrors_windows.gozknownfolderids_windows.gozsyscall_windows.goterm
CONTRIBUTING.mdLICENSEPATENTSREADME.mdcodereview.cfgterm.goterm_plan9.goterm_unix.goterm_unix_bsd.goterm_unix_other.goterm_unsupported.goterm_windows.goterminal.go
text
LICENSEPATENTS
cases
cases.gocontext.gofold.goicu.goinfo.gomap.gotables10.0.0.gotables11.0.0.gotables12.0.0.gotables13.0.0.gotables15.0.0.gotables9.0.0.gotrieval.go
internal
internal.go
language
match.gotag
language
secure
transform
unicode
bidi
bidi.gobracket.gocore.goprop.gotables10.0.0.gotables11.0.0.gotables12.0.0.gotables13.0.0.gotables15.0.0.gotables9.0.0.gotrieval.go
norm
width
time
google.golang.org
genproto
googleapis
grpc
AUTHORSCODE-OF-CONDUCT.mdCONTRIBUTING.mdGOVERNANCE.mdLICENSEMAINTAINERS.mdMakefileNOTICE.txtREADME.mdSECURITY.mdcall.gointerceptor.go
attributes
backoff.gobackoff
balancer
balancer_wrapper.gobinarylog
grpc_binarylog_v1
channelz
clientconn.gocodec.gocodes
connectivity
credentials
dialoptions.godoc.goencoding
grpclog
health
grpc_health_v1
internal
backoff
balancer
gracefulswitch
balancerload
binarylog
buffer
channelz
channel.gochannelmap.gofuncs.gologging.goserver.gosocket.gosubchannel.gosyscall_linux.gosyscall_nonlinux.gotrace.go
credentials
envconfig
experimental.gogrpclog
grpcsync
grpcutil
idle
internal.gometadata
pretty
resolver
serviceconfig
status
syscall
tcp_keepalive_others.gotcp_keepalive_unix.gotcp_keepalive_windows.gotransport
keepalive
metadata
peer
picker_wrapper.gopreloader.goregenerate.shresolver
resolver_wrapper.gorpc_util.goserver.goservice_config.goserviceconfig
shared_buffer_pool.gostats
status
stream.gostream_interfaces.gotap
trace.gotrace_notrace.gotrace_withtrace.goversion.goprotobuf
LICENSEPATENTS
encoding
protodelim
protojson
prototext
protowire
internal
descfmt
descopts
detrand
editiondefaults
encoding
defval
json
messageset
tag
text
errors
filedesc
filetype
flags
genid
any_gen.goapi_gen.godescriptor_gen.godoc.goduration_gen.goempty_gen.gofield_mask_gen.gogo_features_gen.gogoname.gomap_entry.gosource_context_gen.gostruct_gen.gotimestamp_gen.gotype_gen.gowrappers.gowrappers_gen.go
impl
api_export.gocheckinit.gocodec_extension.gocodec_field.gocodec_gen.gocodec_map.gocodec_map_go111.gocodec_map_go112.gocodec_message.gocodec_messageset.gocodec_reflect.gocodec_tables.gocodec_unsafe.goconvert.goconvert_list.goconvert_map.godecode.goencode.goenum.goextension.golegacy_enum.golegacy_export.golegacy_extension.golegacy_file.golegacy_message.gomerge.gomerge_gen.gomessage.gomessage_reflect.gomessage_reflect_field.gomessage_reflect_gen.gopointer_reflect.gopointer_unsafe.govalidate.goweak.go
order
pragma
set
strs
version
proto
checkinit.godecode.godecode_gen.godoc.goencode.goencode_gen.goequal.goextension.gomerge.gomessageset.goproto.goproto_methods.goproto_reflect.goreset.gosize.gosize_gen.gowrappers.go
protoadapt
reflect
protoreflect
methods.goproto.gosource.gosource_gen.gotype.govalue.govalue_equal.govalue_pure.govalue_union.govalue_unsafe_go120.govalue_unsafe_go121.go
protoregistry
runtime
types
known
anypb
durationpb
fieldmaskpb
structpb
timestamppb
wrapperspb
gopkg.in
warnings.v0
yaml.v2
.travis.ymlLICENSELICENSE.libyamlNOTICEREADME.mdapic.godecode.goemitterc.goencode.goparserc.goreaderc.goresolve.goscannerc.gosorter.gowriterc.goyaml.goyamlh.goyamlprivateh.go
yaml.v3
gotest.tools
v3
15
vendor/github.com/muesli/termenv/.gitignore
generated
vendored
Normal file
15
vendor/github.com/muesli/termenv/.gitignore
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
47
vendor/github.com/muesli/termenv/.golangci-soft.yml
generated
vendored
Normal file
47
vendor/github.com/muesli/termenv/.golangci-soft.yml
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
run:
|
||||
tests: false
|
||||
|
||||
issues:
|
||||
include:
|
||||
- EXC0001
|
||||
- EXC0005
|
||||
- EXC0011
|
||||
- EXC0012
|
||||
- EXC0013
|
||||
|
||||
max-issues-per-linter: 0
|
||||
max-same-issues: 0
|
||||
|
||||
linters:
|
||||
enable:
|
||||
# - dupl
|
||||
- exhaustive
|
||||
# - exhaustivestruct
|
||||
- goconst
|
||||
- godot
|
||||
- godox
|
||||
- gomnd
|
||||
- gomoddirectives
|
||||
- goprintffuncname
|
||||
- ifshort
|
||||
# - lll
|
||||
- misspell
|
||||
- nakedret
|
||||
- nestif
|
||||
- noctx
|
||||
- nolintlint
|
||||
- prealloc
|
||||
- wrapcheck
|
||||
|
||||
# disable default linters, they are already enabled in .golangci.yml
|
||||
disable:
|
||||
- deadcode
|
||||
- errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- typecheck
|
||||
- unused
|
||||
- varcheck
|
29
vendor/github.com/muesli/termenv/.golangci.yml
generated
vendored
Normal file
29
vendor/github.com/muesli/termenv/.golangci.yml
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
run:
|
||||
tests: false
|
||||
|
||||
issues:
|
||||
include:
|
||||
- EXC0001
|
||||
- EXC0005
|
||||
- EXC0011
|
||||
- EXC0012
|
||||
- EXC0013
|
||||
|
||||
max-issues-per-linter: 0
|
||||
max-same-issues: 0
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- bodyclose
|
||||
- exportloopref
|
||||
- goimports
|
||||
- gosec
|
||||
- nilerr
|
||||
- predeclared
|
||||
- revive
|
||||
- rowserrcheck
|
||||
- sqlclosecheck
|
||||
- tparallel
|
||||
- unconvert
|
||||
- unparam
|
||||
- whitespace
|
21
vendor/github.com/muesli/termenv/LICENSE
generated
vendored
Normal file
21
vendor/github.com/muesli/termenv/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Christian Muehlhaeuser
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
431
vendor/github.com/muesli/termenv/README.md
generated
vendored
Normal file
431
vendor/github.com/muesli/termenv/README.md
generated
vendored
Normal file
@ -0,0 +1,431 @@
|
||||
<p align="center">
|
||||
<img src="https://stuff.charm.sh/termenv.png" width="480" alt="termenv Logo">
|
||||
<br />
|
||||
<a href="https://github.com/muesli/termenv/releases"><img src="https://img.shields.io/github/release/muesli/termenv.svg" alt="Latest Release"></a>
|
||||
<a href="https://godoc.org/github.com/muesli/termenv"><img src="https://godoc.org/github.com/golang/gddo?status.svg" alt="GoDoc"></a>
|
||||
<a href="https://github.com/muesli/termenv/actions"><img src="https://github.com/muesli/termenv/workflows/build/badge.svg" alt="Build Status"></a>
|
||||
<a href="https://coveralls.io/github/muesli/termenv?branch=master"><img src="https://coveralls.io/repos/github/muesli/termenv/badge.svg?branch=master" alt="Coverage Status"></a>
|
||||
<a href="https://goreportcard.com/report/muesli/termenv"><img src="https://goreportcard.com/badge/muesli/termenv" alt="Go ReportCard"></a>
|
||||
<br />
|
||||
<img src="https://github.com/muesli/termenv/raw/master/examples/hello-world/hello-world.png" alt="Example terminal output">
|
||||
</p>
|
||||
|
||||
`termenv` lets you safely use advanced styling options on the terminal. It
|
||||
gathers information about the terminal environment in terms of its ANSI & color
|
||||
support and offers you convenient methods to colorize and style your output,
|
||||
without you having to deal with all kinds of weird ANSI escape sequences and
|
||||
color conversions.
|
||||
|
||||
## Features
|
||||
|
||||
- RGB/TrueColor support
|
||||
- Detects the supported color range of your terminal
|
||||
- Automatically converts colors to the best matching, available colors
|
||||
- Terminal theme (light/dark) detection
|
||||
- Chainable syntax
|
||||
- Nested styles
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
go get github.com/muesli/termenv
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
output := termenv.NewOutput(os.Stdout)
|
||||
```
|
||||
|
||||
`termenv` queries the terminal's capabilities it is running in, so you can
|
||||
safely use advanced features, like RGB colors or ANSI styles. `output.Profile`
|
||||
returns the supported profile:
|
||||
|
||||
- `termenv.Ascii` - no ANSI support detected, ASCII only
|
||||
- `termenv.ANSI` - 16 color ANSI support
|
||||
- `termenv.ANSI256` - Extended 256 color ANSI support
|
||||
- `termenv.TrueColor` - RGB/TrueColor support
|
||||
|
||||
Alternatively, you can use `termenv.EnvColorProfile` which evaluates the
|
||||
terminal like `ColorProfile`, but also respects the `NO_COLOR` and
|
||||
`CLICOLOR_FORCE` environment variables.
|
||||
|
||||
You can also query the terminal for its color scheme, so you know whether your
|
||||
app is running in a light- or dark-themed environment:
|
||||
|
||||
```go
|
||||
// Returns terminal's foreground color
|
||||
color := output.ForegroundColor()
|
||||
|
||||
// Returns terminal's background color
|
||||
color := output.BackgroundColor()
|
||||
|
||||
// Returns whether terminal uses a dark-ish background
|
||||
darkTheme := output.HasDarkBackground()
|
||||
```
|
||||
|
||||
### Manual Profile Selection
|
||||
|
||||
If you don't want to rely on the automatic detection, you can manually select
|
||||
the profile you want to use:
|
||||
|
||||
```go
|
||||
output := termenv.NewOutput(os.Stdout, termenv.WithProfile(termenv.TrueColor))
|
||||
```
|
||||
|
||||
## Colors
|
||||
|
||||
`termenv` supports multiple color profiles: Ascii (black & white only),
|
||||
ANSI (16 colors), ANSI Extended (256 colors), and TrueColor (24-bit RGB). Colors
|
||||
will automatically be degraded to the best matching available color in the
|
||||
desired profile:
|
||||
|
||||
`TrueColor` => `ANSI 256 Colors` => `ANSI 16 Colors` => `Ascii`
|
||||
|
||||
```go
|
||||
s := output.String("Hello World")
|
||||
|
||||
// Supports hex values
|
||||
// Will automatically degrade colors on terminals not supporting RGB
|
||||
s.Foreground(output.Color("#abcdef"))
|
||||
// but also supports ANSI colors (0-255)
|
||||
s.Background(output.Color("69"))
|
||||
// ...or the color.Color interface
|
||||
s.Foreground(output.FromColor(color.RGBA{255, 128, 0, 255}))
|
||||
|
||||
// Combine fore- & background colors
|
||||
s.Foreground(output.Color("#ffffff")).Background(output.Color("#0000ff"))
|
||||
|
||||
// Supports the fmt.Stringer interface
|
||||
fmt.Println(s)
|
||||
```
|
||||
|
||||
## Styles
|
||||
|
||||
You can use a chainable syntax to compose your own styles:
|
||||
|
||||
```go
|
||||
s := output.String("foobar")
|
||||
|
||||
// Text styles
|
||||
s.Bold()
|
||||
s.Faint()
|
||||
s.Italic()
|
||||
s.CrossOut()
|
||||
s.Underline()
|
||||
s.Overline()
|
||||
|
||||
// Reverse swaps current fore- & background colors
|
||||
s.Reverse()
|
||||
|
||||
// Blinking text
|
||||
s.Blink()
|
||||
|
||||
// Combine multiple options
|
||||
s.Bold().Underline()
|
||||
```
|
||||
|
||||
## Template Helpers
|
||||
|
||||
`termenv` provides a set of helper functions to style your Go templates:
|
||||
|
||||
```go
|
||||
// load template helpers
|
||||
f := output.TemplateFuncs()
|
||||
tpl := template.New("tpl").Funcs(f)
|
||||
|
||||
// apply bold style in a template
|
||||
bold := `{{ Bold "Hello World" }}`
|
||||
|
||||
// examples for colorized templates
|
||||
col := `{{ Color "#ff0000" "#0000ff" "Red on Blue" }}`
|
||||
fg := `{{ Foreground "#ff0000" "Red Foreground" }}`
|
||||
bg := `{{ Background "#0000ff" "Blue Background" }}`
|
||||
|
||||
// wrap styles
|
||||
wrap := `{{ Bold (Underline "Hello World") }}`
|
||||
|
||||
// parse and render
|
||||
tpl, err = tpl.Parse(bold)
|
||||
|
||||
var buf bytes.Buffer
|
||||
tpl.Execute(&buf, nil)
|
||||
fmt.Println(&buf)
|
||||
```
|
||||
|
||||
Other available helper functions are: `Faint`, `Italic`, `CrossOut`,
|
||||
`Underline`, `Overline`, `Reverse`, and `Blink`.
|
||||
|
||||
## Positioning
|
||||
|
||||
```go
|
||||
// Move the cursor to a given position
|
||||
output.MoveCursor(row, column)
|
||||
|
||||
// Save the cursor position
|
||||
output.SaveCursorPosition()
|
||||
|
||||
// Restore a saved cursor position
|
||||
output.RestoreCursorPosition()
|
||||
|
||||
// Move the cursor up a given number of lines
|
||||
output.CursorUp(n)
|
||||
|
||||
// Move the cursor down a given number of lines
|
||||
output.CursorDown(n)
|
||||
|
||||
// Move the cursor up a given number of lines
|
||||
output.CursorForward(n)
|
||||
|
||||
// Move the cursor backwards a given number of cells
|
||||
output.CursorBack(n)
|
||||
|
||||
// Move the cursor down a given number of lines and place it at the beginning
|
||||
// of the line
|
||||
output.CursorNextLine(n)
|
||||
|
||||
// Move the cursor up a given number of lines and place it at the beginning of
|
||||
// the line
|
||||
output.CursorPrevLine(n)
|
||||
```
|
||||
|
||||
## Screen
|
||||
|
||||
```go
|
||||
// Reset the terminal to its default style, removing any active styles
|
||||
output.Reset()
|
||||
|
||||
// RestoreScreen restores a previously saved screen state
|
||||
output.RestoreScreen()
|
||||
|
||||
// SaveScreen saves the screen state
|
||||
output.SaveScreen()
|
||||
|
||||
// Switch to the altscreen. The former view can be restored with ExitAltScreen()
|
||||
output.AltScreen()
|
||||
|
||||
// Exit the altscreen and return to the former terminal view
|
||||
output.ExitAltScreen()
|
||||
|
||||
// Clear the visible portion of the terminal
|
||||
output.ClearScreen()
|
||||
|
||||
// Clear the current line
|
||||
output.ClearLine()
|
||||
|
||||
// Clear a given number of lines
|
||||
output.ClearLines(n)
|
||||
|
||||
// Set the scrolling region of the terminal
|
||||
output.ChangeScrollingRegion(top, bottom)
|
||||
|
||||
// Insert the given number of lines at the top of the scrollable region, pushing
|
||||
// lines below down
|
||||
output.InsertLines(n)
|
||||
|
||||
// Delete the given number of lines, pulling any lines in the scrollable region
|
||||
// below up
|
||||
output.DeleteLines(n)
|
||||
```
|
||||
|
||||
## Session
|
||||
|
||||
```go
|
||||
// SetWindowTitle sets the terminal window title
|
||||
output.SetWindowTitle(title)
|
||||
|
||||
// SetForegroundColor sets the default foreground color
|
||||
output.SetForegroundColor(color)
|
||||
|
||||
// SetBackgroundColor sets the default background color
|
||||
output.SetBackgroundColor(color)
|
||||
|
||||
// SetCursorColor sets the cursor color
|
||||
output.SetCursorColor(color)
|
||||
|
||||
// Hide the cursor
|
||||
output.HideCursor()
|
||||
|
||||
// Show the cursor
|
||||
output.ShowCursor()
|
||||
|
||||
// Copy to clipboard
|
||||
output.Copy(message)
|
||||
|
||||
// Copy to primary clipboard (X11)
|
||||
output.CopyPrimary(message)
|
||||
|
||||
// Trigger notification
|
||||
output.Notify(title, body)
|
||||
```
|
||||
|
||||
## Mouse
|
||||
|
||||
```go
|
||||
// Enable X10 mouse mode, only button press events are sent
|
||||
output.EnableMousePress()
|
||||
|
||||
// Disable X10 mouse mode
|
||||
output.DisableMousePress()
|
||||
|
||||
// Enable Mouse Tracking mode
|
||||
output.EnableMouse()
|
||||
|
||||
// Disable Mouse Tracking mode
|
||||
output.DisableMouse()
|
||||
|
||||
// Enable Hilite Mouse Tracking mode
|
||||
output.EnableMouseHilite()
|
||||
|
||||
// Disable Hilite Mouse Tracking mode
|
||||
output.DisableMouseHilite()
|
||||
|
||||
// Enable Cell Motion Mouse Tracking mode
|
||||
output.EnableMouseCellMotion()
|
||||
|
||||
// Disable Cell Motion Mouse Tracking mode
|
||||
output.DisableMouseCellMotion()
|
||||
|
||||
// Enable All Motion Mouse mode
|
||||
output.EnableMouseAllMotion()
|
||||
|
||||
// Disable All Motion Mouse mode
|
||||
output.DisableMouseAllMotion()
|
||||
```
|
||||
|
||||
## Bracketed Paste
|
||||
|
||||
```go
|
||||
// Enables bracketed paste mode
|
||||
termenv.EnableBracketedPaste()
|
||||
|
||||
// Disables bracketed paste mode
|
||||
termenv.DisableBracketedPaste()
|
||||
```
|
||||
|
||||
## Terminal Feature Support
|
||||
|
||||
### Color Support
|
||||
|
||||
- 24-bit (RGB): alacritty, foot, iTerm, kitty, Konsole, st, tmux, vte-based, wezterm, Windows Terminal
|
||||
- 8-bit (256): rxvt, screen, xterm, Apple Terminal
|
||||
- 4-bit (16): Linux Console
|
||||
|
||||
### Control Sequences
|
||||
|
||||
<details>
|
||||
<summary>Click to show feature matrix</summary>
|
||||
|
||||
| Terminal | Query Color Scheme | Query Cursor Position | Set Window Title | Change Cursor Color | Change Default Foreground Setting | Change Default Background Setting | Bracketed Paste | Extended Mouse (SGR) | Pixels Mouse (SGR-Pixels) |
|
||||
| ---------------- | :----------------: | :-------------------: | :--------------: | :-----------------: | :-------------------------------: | :-------------------------------: | :-------------: | :------------------: | :-----------------------: |
|
||||
| alacritty | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||
| foot | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| kitty | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| Konsole | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||
| rxvt | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
||||
| urxvt | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||
| screen | ⛔[^mux] | ✅ | ✅ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
||||
| st | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||
| tmux | ⛔[^mux] | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||
| vte-based[^vte] | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ |
|
||||
| wezterm | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||
| xterm | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
|
||||
| Linux Console | ❌ | ✅ | ⛔ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||
| Apple Terminal | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||
| iTerm | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ |
|
||||
| Windows cmd | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
|
||||
| Windows Terminal | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
||||
|
||||
[^vte]: This covers all vte-based terminals, including Gnome Terminal, guake, Pantheon Terminal, Terminator, Tilix, XFCE Terminal.
|
||||
[^mux]: Unavailable as multiplexers (like tmux or screen) can be connected to multiple terminals (with different color settings) at the same time.
|
||||
|
||||
You can help improve this list! Check out [how to](ansi_compat.md) and open an issue or pull request.
|
||||
|
||||
</details>
|
||||
|
||||
### System Commands
|
||||
|
||||
<details>
|
||||
<summary>Click to show feature matrix</summary>
|
||||
|
||||
| Terminal | Copy to Clipboard (OSC52) | Hyperlinks (OSC8) | Notifications (OSC777) |
|
||||
| ---------------- | :-----------------------: | :---------------: | :--------------------: |
|
||||
| alacritty | ✅ | ❌[^alacritty] | ❌ |
|
||||
| foot | ✅ | ✅ | ✅ |
|
||||
| kitty | ✅ | ✅ | ✅ |
|
||||
| Konsole | ❌[^konsole] | ✅ | ❌ |
|
||||
| rxvt | ❌ | ❌ | ❌ |
|
||||
| urxvt | ✅[^urxvt] | ❌ | ✅ |
|
||||
| screen | ✅ | ❌[^screen] | ❌ |
|
||||
| st | ✅ | ❌ | ❌ |
|
||||
| tmux | ✅ | ❌[^tmux] | ❌ |
|
||||
| vte-based[^vte] | ❌[^vte] | ✅ | ❌ |
|
||||
| wezterm | ✅ | ✅ | ❌ |
|
||||
| xterm | ✅ | ❌ | ❌ |
|
||||
| Linux Console | ⛔ | ⛔ | ❌ |
|
||||
| Apple Terminal | ✅[^apple] | ❌ | ❌ |
|
||||
| iTerm | ✅ | ✅ | ❌ |
|
||||
| Windows cmd | ❌ | ❌ | ❌ |
|
||||
| Windows Terminal | ✅ | ✅ | ❌ |
|
||||
|
||||
[^vte]: This covers all vte-based terminals, including Gnome Terminal, guake, Pantheon Terminal, Terminator, Tilix, XFCE Terminal. OSC52 is not supported, see [issue#2495](https://gitlab.gnome.org/GNOME/vte/-/issues/2495).
|
||||
[^urxvt]: Workaround for urxvt not supporting OSC52. See [this](https://unix.stackexchange.com/a/629485) for more information.
|
||||
[^konsole]: OSC52 is not supported, for more info see [bug#372116](https://bugs.kde.org/show_bug.cgi?id=372116).
|
||||
[^apple]: OSC52 works with a [workaround](https://github.com/roy2220/osc52pty).
|
||||
[^tmux]: OSC8 is not supported, for more info see [issue#911](https://github.com/tmux/tmux/issues/911).
|
||||
[^screen]: OSC8 is not supported, for more info see [bug#50952](https://savannah.gnu.org/bugs/index.php?50952).
|
||||
[^alacritty]: OSC8 is not supported, for more info see [issue#922](https://github.com/alacritty/alacritty/issues/922).
|
||||
|
||||
</details>
|
||||
|
||||
## Platform Support
|
||||
|
||||
`termenv` works on Unix systems (like Linux, macOS, or BSD) and Windows. While
|
||||
terminal applications on Unix support ANSI styling out-of-the-box, on Windows
|
||||
you need to enable ANSI processing in your application first:
|
||||
|
||||
```go
|
||||
restoreConsole, err := termenv.EnableVirtualTerminalProcessing(termenv.DefaultOutput())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer restoreConsole()
|
||||
```
|
||||
|
||||
The above code is safe to include on non-Windows systems or when os.Stdout does
|
||||
not refer to a terminal (e.g. in tests).
|
||||
|
||||
## Color Chart
|
||||
|
||||

|
||||
|
||||
You can find the source code used to create this chart in `termenv`'s examples.
|
||||
|
||||
## Related Projects
|
||||
|
||||
- [reflow](https://github.com/muesli/reflow) - ANSI-aware text operations
|
||||
- [Lip Gloss](https://github.com/charmbracelet/lipgloss) - style definitions for nice terminal layouts 👄
|
||||
- [ansi](https://github.com/muesli/ansi) - ANSI sequence helpers
|
||||
|
||||
## termenv in the Wild
|
||||
|
||||
Need some inspiration or just want to see how others are using `termenv`? Check
|
||||
out these projects:
|
||||
|
||||
- [Bubble Tea](https://github.com/charmbracelet/bubbletea) - a powerful little TUI framework 🏗
|
||||
- [Glamour](https://github.com/charmbracelet/glamour) - stylesheet-based markdown rendering for your CLI apps 💇🏻♀️
|
||||
- [Glow](https://github.com/charmbracelet/glow) - a markdown renderer for the command-line 💅🏻
|
||||
- [duf](https://github.com/muesli/duf) - Disk Usage/Free Utility - a better 'df' alternative
|
||||
- [gitty](https://github.com/muesli/gitty) - contextual information about your git projects
|
||||
- [slides](https://github.com/maaslalani/slides) - terminal-based presentation tool
|
||||
|
||||
## Feedback
|
||||
|
||||
Got some feedback or suggestions? Please open an issue or drop me a note!
|
||||
|
||||
- [Twitter](https://twitter.com/mueslix)
|
||||
- [The Fediverse](https://mastodon.social/@fribbledom)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/muesli/termenv/raw/master/LICENSE)
|
65
vendor/github.com/muesli/termenv/ansi_compat.md
generated
vendored
Normal file
65
vendor/github.com/muesli/termenv/ansi_compat.md
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
## Change Foreground Color
|
||||
|
||||
This command should enable a blue foreground color:
|
||||
|
||||
```bash
|
||||
echo -ne "\033]10;#0000ff\007"
|
||||
```
|
||||
|
||||
## Change Background Color
|
||||
|
||||
This command should enable a green background color:
|
||||
|
||||
```bash
|
||||
echo -ne "\033]11;#00ff00\007"
|
||||
```
|
||||
|
||||
## Change Cursor Color
|
||||
|
||||
This command should enable a red cursor color:
|
||||
|
||||
```bash
|
||||
echo -ne "\033]12;#ff0000\007"
|
||||
```
|
||||
|
||||
## Query Color Scheme
|
||||
|
||||
These two commands should print out the currently active color scheme:
|
||||
|
||||
```bash
|
||||
echo -ne "\033]10;?\033\\"
|
||||
echo -ne "\033]11;?\033\\"
|
||||
```
|
||||
|
||||
## Query Cursor Position
|
||||
|
||||
This command should print out the current cursor position:
|
||||
|
||||
```bash
|
||||
echo -ne "\033[6n"
|
||||
```
|
||||
|
||||
## Set Window Title
|
||||
|
||||
This command should set the window title to "Test":
|
||||
|
||||
```bash
|
||||
echo -ne "\033]2;Test\007" && sleep 10
|
||||
```
|
||||
|
||||
## Bracketed paste
|
||||
|
||||
Enter this command, then paste a word from the clipboard. The text
|
||||
displayed on the terminal should contain the codes `200~` and `201~`:
|
||||
|
||||
```bash
|
||||
echo -ne "\033[?2004h" && sleep 10
|
||||
```
|
||||
|
||||
## Trigger Notification
|
||||
|
||||
This command should trigger a notification:
|
||||
|
||||
```bash
|
||||
echo -ne "\033]777;notify;Title;Body\033\\"
|
||||
```
|
281
vendor/github.com/muesli/termenv/ansicolors.go
generated
vendored
Normal file
281
vendor/github.com/muesli/termenv/ansicolors.go
generated
vendored
Normal file
@ -0,0 +1,281 @@
|
||||
package termenv
|
||||
|
||||
// ANSI color codes
|
||||
const (
|
||||
ANSIBlack ANSIColor = iota
|
||||
ANSIRed
|
||||
ANSIGreen
|
||||
ANSIYellow
|
||||
ANSIBlue
|
||||
ANSIMagenta
|
||||
ANSICyan
|
||||
ANSIWhite
|
||||
ANSIBrightBlack
|
||||
ANSIBrightRed
|
||||
ANSIBrightGreen
|
||||
ANSIBrightYellow
|
||||
ANSIBrightBlue
|
||||
ANSIBrightMagenta
|
||||
ANSIBrightCyan
|
||||
ANSIBrightWhite
|
||||
)
|
||||
|
||||
// RGB values of ANSI colors (0-255).
|
||||
var ansiHex = []string{
|
||||
"#000000",
|
||||
"#800000",
|
||||
"#008000",
|
||||
"#808000",
|
||||
"#000080",
|
||||
"#800080",
|
||||
"#008080",
|
||||
"#c0c0c0",
|
||||
"#808080",
|
||||
"#ff0000",
|
||||
"#00ff00",
|
||||
"#ffff00",
|
||||
"#0000ff",
|
||||
"#ff00ff",
|
||||
"#00ffff",
|
||||
"#ffffff",
|
||||
"#000000",
|
||||
"#00005f",
|
||||
"#000087",
|
||||
"#0000af",
|
||||
"#0000d7",
|
||||
"#0000ff",
|
||||
"#005f00",
|
||||
"#005f5f",
|
||||
"#005f87",
|
||||
"#005faf",
|
||||
"#005fd7",
|
||||
"#005fff",
|
||||
"#008700",
|
||||
"#00875f",
|
||||
"#008787",
|
||||
"#0087af",
|
||||
"#0087d7",
|
||||
"#0087ff",
|
||||
"#00af00",
|
||||
"#00af5f",
|
||||
"#00af87",
|
||||
"#00afaf",
|
||||
"#00afd7",
|
||||
"#00afff",
|
||||
"#00d700",
|
||||
"#00d75f",
|
||||
"#00d787",
|
||||
"#00d7af",
|
||||
"#00d7d7",
|
||||
"#00d7ff",
|
||||
"#00ff00",
|
||||
"#00ff5f",
|
||||
"#00ff87",
|
||||
"#00ffaf",
|
||||
"#00ffd7",
|
||||
"#00ffff",
|
||||
"#5f0000",
|
||||
"#5f005f",
|
||||
"#5f0087",
|
||||
"#5f00af",
|
||||
"#5f00d7",
|
||||
"#5f00ff",
|
||||
"#5f5f00",
|
||||
"#5f5f5f",
|
||||
"#5f5f87",
|
||||
"#5f5faf",
|
||||
"#5f5fd7",
|
||||
"#5f5fff",
|
||||
"#5f8700",
|
||||
"#5f875f",
|
||||
"#5f8787",
|
||||
"#5f87af",
|
||||
"#5f87d7",
|
||||
"#5f87ff",
|
||||
"#5faf00",
|
||||
"#5faf5f",
|
||||
"#5faf87",
|
||||
"#5fafaf",
|
||||
"#5fafd7",
|
||||
"#5fafff",
|
||||
"#5fd700",
|
||||
"#5fd75f",
|
||||
"#5fd787",
|
||||
"#5fd7af",
|
||||
"#5fd7d7",
|
||||
"#5fd7ff",
|
||||
"#5fff00",
|
||||
"#5fff5f",
|
||||
"#5fff87",
|
||||
"#5fffaf",
|
||||
"#5fffd7",
|
||||
"#5fffff",
|
||||
"#870000",
|
||||
"#87005f",
|
||||
"#870087",
|
||||
"#8700af",
|
||||
"#8700d7",
|
||||
"#8700ff",
|
||||
"#875f00",
|
||||
"#875f5f",
|
||||
"#875f87",
|
||||
"#875faf",
|
||||
"#875fd7",
|
||||
"#875fff",
|
||||
"#878700",
|
||||
"#87875f",
|
||||
"#878787",
|
||||
"#8787af",
|
||||
"#8787d7",
|
||||
"#8787ff",
|
||||
"#87af00",
|
||||
"#87af5f",
|
||||
"#87af87",
|
||||
"#87afaf",
|
||||
"#87afd7",
|
||||
"#87afff",
|
||||
"#87d700",
|
||||
"#87d75f",
|
||||
"#87d787",
|
||||
"#87d7af",
|
||||
"#87d7d7",
|
||||
"#87d7ff",
|
||||
"#87ff00",
|
||||
"#87ff5f",
|
||||
"#87ff87",
|
||||
"#87ffaf",
|
||||
"#87ffd7",
|
||||
"#87ffff",
|
||||
"#af0000",
|
||||
"#af005f",
|
||||
"#af0087",
|
||||
"#af00af",
|
||||
"#af00d7",
|
||||
"#af00ff",
|
||||
"#af5f00",
|
||||
"#af5f5f",
|
||||
"#af5f87",
|
||||
"#af5faf",
|
||||
"#af5fd7",
|
||||
"#af5fff",
|
||||
"#af8700",
|
||||
"#af875f",
|
||||
"#af8787",
|
||||
"#af87af",
|
||||
"#af87d7",
|
||||
"#af87ff",
|
||||
"#afaf00",
|
||||
"#afaf5f",
|
||||
"#afaf87",
|
||||
"#afafaf",
|
||||
"#afafd7",
|
||||
"#afafff",
|
||||
"#afd700",
|
||||
"#afd75f",
|
||||
"#afd787",
|
||||
"#afd7af",
|
||||
"#afd7d7",
|
||||
"#afd7ff",
|
||||
"#afff00",
|
||||
"#afff5f",
|
||||
"#afff87",
|
||||
"#afffaf",
|
||||
"#afffd7",
|
||||
"#afffff",
|
||||
"#d70000",
|
||||
"#d7005f",
|
||||
"#d70087",
|
||||
"#d700af",
|
||||
"#d700d7",
|
||||
"#d700ff",
|
||||
"#d75f00",
|
||||
"#d75f5f",
|
||||
"#d75f87",
|
||||
"#d75faf",
|
||||
"#d75fd7",
|
||||
"#d75fff",
|
||||
"#d78700",
|
||||
"#d7875f",
|
||||
"#d78787",
|
||||
"#d787af",
|
||||
"#d787d7",
|
||||
"#d787ff",
|
||||
"#d7af00",
|
||||
"#d7af5f",
|
||||
"#d7af87",
|
||||
"#d7afaf",
|
||||
"#d7afd7",
|
||||
"#d7afff",
|
||||
"#d7d700",
|
||||
"#d7d75f",
|
||||
"#d7d787",
|
||||
"#d7d7af",
|
||||
"#d7d7d7",
|
||||
"#d7d7ff",
|
||||
"#d7ff00",
|
||||
"#d7ff5f",
|
||||
"#d7ff87",
|
||||
"#d7ffaf",
|
||||
"#d7ffd7",
|
||||
"#d7ffff",
|
||||
"#ff0000",
|
||||
"#ff005f",
|
||||
"#ff0087",
|
||||
"#ff00af",
|
||||
"#ff00d7",
|
||||
"#ff00ff",
|
||||
"#ff5f00",
|
||||
"#ff5f5f",
|
||||
"#ff5f87",
|
||||
"#ff5faf",
|
||||
"#ff5fd7",
|
||||
"#ff5fff",
|
||||
"#ff8700",
|
||||
"#ff875f",
|
||||
"#ff8787",
|
||||
"#ff87af",
|
||||
"#ff87d7",
|
||||
"#ff87ff",
|
||||
"#ffaf00",
|
||||
"#ffaf5f",
|
||||
"#ffaf87",
|
||||
"#ffafaf",
|
||||
"#ffafd7",
|
||||
"#ffafff",
|
||||
"#ffd700",
|
||||
"#ffd75f",
|
||||
"#ffd787",
|
||||
"#ffd7af",
|
||||
"#ffd7d7",
|
||||
"#ffd7ff",
|
||||
"#ffff00",
|
||||
"#ffff5f",
|
||||
"#ffff87",
|
||||
"#ffffaf",
|
||||
"#ffffd7",
|
||||
"#ffffff",
|
||||
"#080808",
|
||||
"#121212",
|
||||
"#1c1c1c",
|
||||
"#262626",
|
||||
"#303030",
|
||||
"#3a3a3a",
|
||||
"#444444",
|
||||
"#4e4e4e",
|
||||
"#585858",
|
||||
"#626262",
|
||||
"#6c6c6c",
|
||||
"#767676",
|
||||
"#808080",
|
||||
"#8a8a8a",
|
||||
"#949494",
|
||||
"#9e9e9e",
|
||||
"#a8a8a8",
|
||||
"#b2b2b2",
|
||||
"#bcbcbc",
|
||||
"#c6c6c6",
|
||||
"#d0d0d0",
|
||||
"#dadada",
|
||||
"#e4e4e4",
|
||||
"#eeeeee",
|
||||
}
|
204
vendor/github.com/muesli/termenv/color.go
generated
vendored
Normal file
204
vendor/github.com/muesli/termenv/color.go
generated
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
"github.com/lucasb-eyer/go-colorful"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrInvalidColor gets returned when a color is invalid.
|
||||
ErrInvalidColor = errors.New("invalid color")
|
||||
)
|
||||
|
||||
// Foreground and Background sequence codes
|
||||
const (
|
||||
Foreground = "38"
|
||||
Background = "48"
|
||||
)
|
||||
|
||||
// Color is an interface implemented by all colors that can be converted to an
|
||||
// ANSI sequence.
|
||||
type Color interface {
|
||||
// Sequence returns the ANSI Sequence for the color.
|
||||
Sequence(bg bool) string
|
||||
}
|
||||
|
||||
// NoColor is a nop for terminals that don't support colors.
|
||||
type NoColor struct{}
|
||||
|
||||
func (c NoColor) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// ANSIColor is a color (0-15) as defined by the ANSI Standard.
|
||||
type ANSIColor int
|
||||
|
||||
func (c ANSIColor) String() string {
|
||||
return ansiHex[c]
|
||||
}
|
||||
|
||||
// ANSI256Color is a color (16-255) as defined by the ANSI Standard.
|
||||
type ANSI256Color int
|
||||
|
||||
func (c ANSI256Color) String() string {
|
||||
return ansiHex[c]
|
||||
}
|
||||
|
||||
// RGBColor is a hex-encoded color, e.g. "#abcdef".
|
||||
type RGBColor string
|
||||
|
||||
// ConvertToRGB converts a Color to a colorful.Color.
|
||||
func ConvertToRGB(c Color) colorful.Color {
|
||||
var hex string
|
||||
switch v := c.(type) {
|
||||
case RGBColor:
|
||||
hex = string(v)
|
||||
case ANSIColor:
|
||||
hex = ansiHex[v]
|
||||
case ANSI256Color:
|
||||
hex = ansiHex[v]
|
||||
}
|
||||
|
||||
ch, _ := colorful.Hex(hex)
|
||||
return ch
|
||||
}
|
||||
|
||||
// Sequence returns the ANSI Sequence for the color.
|
||||
func (c NoColor) Sequence(_ bool) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Sequence returns the ANSI Sequence for the color.
|
||||
func (c ANSIColor) Sequence(bg bool) string {
|
||||
col := int(c)
|
||||
bgMod := func(c int) int {
|
||||
if bg {
|
||||
return c + 10
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
if col < 8 {
|
||||
return fmt.Sprintf("%d", bgMod(col)+30)
|
||||
}
|
||||
return fmt.Sprintf("%d", bgMod(col-8)+90)
|
||||
}
|
||||
|
||||
// Sequence returns the ANSI Sequence for the color.
|
||||
func (c ANSI256Color) Sequence(bg bool) string {
|
||||
prefix := Foreground
|
||||
if bg {
|
||||
prefix = Background
|
||||
}
|
||||
return fmt.Sprintf("%s;5;%d", prefix, c)
|
||||
}
|
||||
|
||||
// Sequence returns the ANSI Sequence for the color.
|
||||
func (c RGBColor) Sequence(bg bool) string {
|
||||
f, err := colorful.Hex(string(c))
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
prefix := Foreground
|
||||
if bg {
|
||||
prefix = Background
|
||||
}
|
||||
return fmt.Sprintf("%s;2;%d;%d;%d", prefix, uint8(f.R*255), uint8(f.G*255), uint8(f.B*255))
|
||||
}
|
||||
|
||||
func xTermColor(s string) (RGBColor, error) {
|
||||
if len(s) < 24 || len(s) > 25 {
|
||||
return RGBColor(""), ErrInvalidColor
|
||||
}
|
||||
|
||||
switch {
|
||||
case strings.HasSuffix(s, string(BEL)):
|
||||
s = strings.TrimSuffix(s, string(BEL))
|
||||
case strings.HasSuffix(s, string(ESC)):
|
||||
s = strings.TrimSuffix(s, string(ESC))
|
||||
case strings.HasSuffix(s, ST):
|
||||
s = strings.TrimSuffix(s, ST)
|
||||
default:
|
||||
return RGBColor(""), ErrInvalidColor
|
||||
}
|
||||
|
||||
s = s[4:]
|
||||
|
||||
prefix := ";rgb:"
|
||||
if !strings.HasPrefix(s, prefix) {
|
||||
return RGBColor(""), ErrInvalidColor
|
||||
}
|
||||
s = strings.TrimPrefix(s, prefix)
|
||||
|
||||
h := strings.Split(s, "/")
|
||||
hex := fmt.Sprintf("#%s%s%s", h[0][:2], h[1][:2], h[2][:2])
|
||||
return RGBColor(hex), nil
|
||||
}
|
||||
|
||||
func ansi256ToANSIColor(c ANSI256Color) ANSIColor {
|
||||
var r int
|
||||
md := math.MaxFloat64
|
||||
|
||||
h, _ := colorful.Hex(ansiHex[c])
|
||||
for i := 0; i <= 15; i++ {
|
||||
hb, _ := colorful.Hex(ansiHex[i])
|
||||
d := h.DistanceHSLuv(hb)
|
||||
|
||||
if d < md {
|
||||
md = d
|
||||
r = i
|
||||
}
|
||||
}
|
||||
|
||||
return ANSIColor(r)
|
||||
}
|
||||
|
||||
func hexToANSI256Color(c colorful.Color) ANSI256Color {
|
||||
v2ci := func(v float64) int {
|
||||
if v < 48 {
|
||||
return 0
|
||||
}
|
||||
if v < 115 {
|
||||
return 1
|
||||
}
|
||||
return int((v - 35) / 40)
|
||||
}
|
||||
|
||||
// Calculate the nearest 0-based color index at 16..231
|
||||
r := v2ci(c.R * 255.0) // 0..5 each
|
||||
g := v2ci(c.G * 255.0)
|
||||
b := v2ci(c.B * 255.0)
|
||||
ci := 36*r + 6*g + b /* 0..215 */
|
||||
|
||||
// Calculate the represented colors back from the index
|
||||
i2cv := [6]int{0, 0x5f, 0x87, 0xaf, 0xd7, 0xff}
|
||||
cr := i2cv[r] // r/g/b, 0..255 each
|
||||
cg := i2cv[g]
|
||||
cb := i2cv[b]
|
||||
|
||||
// Calculate the nearest 0-based gray index at 232..255
|
||||
var grayIdx int
|
||||
average := (r + g + b) / 3
|
||||
if average > 238 {
|
||||
grayIdx = 23
|
||||
} else {
|
||||
grayIdx = (average - 3) / 10 // 0..23
|
||||
}
|
||||
gv := 8 + 10*grayIdx // same value for r/g/b, 0..255
|
||||
|
||||
// Return the one which is nearer to the original input rgb value
|
||||
c2 := colorful.Color{R: float64(cr) / 255.0, G: float64(cg) / 255.0, B: float64(cb) / 255.0}
|
||||
g2 := colorful.Color{R: float64(gv) / 255.0, G: float64(gv) / 255.0, B: float64(gv) / 255.0}
|
||||
colorDist := c.DistanceHSLuv(c2)
|
||||
grayDist := c.DistanceHSLuv(g2)
|
||||
|
||||
if colorDist <= grayDist {
|
||||
return ANSI256Color(16 + ci)
|
||||
}
|
||||
return ANSI256Color(232 + grayIdx)
|
||||
}
|
8
vendor/github.com/muesli/termenv/constants_linux.go
generated
vendored
Normal file
8
vendor/github.com/muesli/termenv/constants_linux.go
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
package termenv
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
const (
|
||||
tcgetattr = unix.TCGETS
|
||||
tcsetattr = unix.TCSETS
|
||||
)
|
8
vendor/github.com/muesli/termenv/constants_solaris.go
generated
vendored
Normal file
8
vendor/github.com/muesli/termenv/constants_solaris.go
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
package termenv
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
const (
|
||||
tcgetattr = unix.TCGETS
|
||||
tcsetattr = unix.TCSETS
|
||||
)
|
13
vendor/github.com/muesli/termenv/constants_unix.go
generated
vendored
Normal file
13
vendor/github.com/muesli/termenv/constants_unix.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
//go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && !solaris && !illumos
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
// +build !solaris
|
||||
// +build !illumos
|
||||
|
||||
package termenv
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
const (
|
||||
tcgetattr = unix.TIOCGETA
|
||||
tcsetattr = unix.TIOCSETA
|
||||
)
|
37
vendor/github.com/muesli/termenv/copy.go
generated
vendored
Normal file
37
vendor/github.com/muesli/termenv/copy.go
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/aymanbagabas/go-osc52/v2"
|
||||
)
|
||||
|
||||
// Copy copies text to clipboard using OSC 52 escape sequence.
|
||||
func (o Output) Copy(str string) {
|
||||
s := osc52.New(str)
|
||||
if strings.HasPrefix(o.environ.Getenv("TERM"), "screen") {
|
||||
s = s.Screen()
|
||||
}
|
||||
_, _ = s.WriteTo(o)
|
||||
}
|
||||
|
||||
// CopyPrimary copies text to primary clipboard (X11) using OSC 52 escape
|
||||
// sequence.
|
||||
func (o Output) CopyPrimary(str string) {
|
||||
s := osc52.New(str).Primary()
|
||||
if strings.HasPrefix(o.environ.Getenv("TERM"), "screen") {
|
||||
s = s.Screen()
|
||||
}
|
||||
_, _ = s.WriteTo(o)
|
||||
}
|
||||
|
||||
// Copy copies text to clipboard using OSC 52 escape sequence.
|
||||
func Copy(str string) {
|
||||
output.Copy(str)
|
||||
}
|
||||
|
||||
// CopyPrimary copies text to primary clipboard (X11) using OSC 52 escape
|
||||
// sequence.
|
||||
func CopyPrimary(str string) {
|
||||
output.CopyPrimary(str)
|
||||
}
|
11
vendor/github.com/muesli/termenv/hyperlink.go
generated
vendored
Normal file
11
vendor/github.com/muesli/termenv/hyperlink.go
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
package termenv
|
||||
|
||||
// Hyperlink creates a hyperlink using OSC8.
|
||||
func Hyperlink(link, name string) string {
|
||||
return output.Hyperlink(link, name)
|
||||
}
|
||||
|
||||
// Hyperlink creates a hyperlink using OSC8.
|
||||
func (o *Output) Hyperlink(link, name string) string {
|
||||
return OSC + "8;;" + link + ST + name + OSC + "8;;" + ST
|
||||
}
|
11
vendor/github.com/muesli/termenv/notification.go
generated
vendored
Normal file
11
vendor/github.com/muesli/termenv/notification.go
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
package termenv
|
||||
|
||||
// Notify triggers a notification using OSC777.
|
||||
func Notify(title, body string) {
|
||||
output.Notify(title, body)
|
||||
}
|
||||
|
||||
// Notify triggers a notification using OSC777.
|
||||
func (o *Output) Notify(title, body string) {
|
||||
_, _ = o.WriteString(OSC + "777;notify;" + title + ";" + body + ST)
|
||||
}
|
197
vendor/github.com/muesli/termenv/output.go
generated
vendored
Normal file
197
vendor/github.com/muesli/termenv/output.go
generated
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
// output is the default global output.
|
||||
output = NewOutput(os.Stdout)
|
||||
)
|
||||
|
||||
// File represents a file descriptor.
|
||||
type File interface {
|
||||
io.ReadWriter
|
||||
Fd() uintptr
|
||||
}
|
||||
|
||||
// OutputOption sets an option on Output.
|
||||
type OutputOption = func(*Output)
|
||||
|
||||
// Output is a terminal output.
|
||||
type Output struct {
|
||||
Profile
|
||||
tty io.Writer
|
||||
environ Environ
|
||||
|
||||
assumeTTY bool
|
||||
unsafe bool
|
||||
cache bool
|
||||
fgSync *sync.Once
|
||||
fgColor Color
|
||||
bgSync *sync.Once
|
||||
bgColor Color
|
||||
}
|
||||
|
||||
// Environ is an interface for getting environment variables.
|
||||
type Environ interface {
|
||||
Environ() []string
|
||||
Getenv(string) string
|
||||
}
|
||||
|
||||
type osEnviron struct{}
|
||||
|
||||
func (oe *osEnviron) Environ() []string {
|
||||
return os.Environ()
|
||||
}
|
||||
|
||||
func (oe *osEnviron) Getenv(key string) string {
|
||||
return os.Getenv(key)
|
||||
}
|
||||
|
||||
// DefaultOutput returns the default global output.
|
||||
func DefaultOutput() *Output {
|
||||
return output
|
||||
}
|
||||
|
||||
// SetDefaultOutput sets the default global output.
|
||||
func SetDefaultOutput(o *Output) {
|
||||
output = o
|
||||
}
|
||||
|
||||
// NewOutput returns a new Output for the given file descriptor.
|
||||
func NewOutput(tty io.Writer, opts ...OutputOption) *Output {
|
||||
o := &Output{
|
||||
tty: tty,
|
||||
environ: &osEnviron{},
|
||||
Profile: -1,
|
||||
fgSync: &sync.Once{},
|
||||
fgColor: NoColor{},
|
||||
bgSync: &sync.Once{},
|
||||
bgColor: NoColor{},
|
||||
}
|
||||
|
||||
if o.tty == nil {
|
||||
o.tty = os.Stdout
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(o)
|
||||
}
|
||||
if o.Profile < 0 {
|
||||
o.Profile = o.EnvColorProfile()
|
||||
}
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
// WithEnvironment returns a new OutputOption for the given environment.
|
||||
func WithEnvironment(environ Environ) OutputOption {
|
||||
return func(o *Output) {
|
||||
o.environ = environ
|
||||
}
|
||||
}
|
||||
|
||||
// WithProfile returns a new OutputOption for the given profile.
|
||||
func WithProfile(profile Profile) OutputOption {
|
||||
return func(o *Output) {
|
||||
o.Profile = profile
|
||||
}
|
||||
}
|
||||
|
||||
// WithColorCache returns a new OutputOption with fore- and background color values
|
||||
// pre-fetched and cached.
|
||||
func WithColorCache(v bool) OutputOption {
|
||||
return func(o *Output) {
|
||||
o.cache = v
|
||||
|
||||
// cache the values now
|
||||
_ = o.ForegroundColor()
|
||||
_ = o.BackgroundColor()
|
||||
}
|
||||
}
|
||||
|
||||
// WithTTY returns a new OutputOption to assume whether or not the output is a TTY.
|
||||
// This is useful when mocking console output.
|
||||
func WithTTY(v bool) OutputOption {
|
||||
return func(o *Output) {
|
||||
o.assumeTTY = v
|
||||
}
|
||||
}
|
||||
|
||||
// WithUnsafe returns a new OutputOption with unsafe mode enabled. Unsafe mode doesn't
|
||||
// check whether or not the terminal is a TTY.
|
||||
//
|
||||
// This option supersedes WithTTY.
|
||||
//
|
||||
// This is useful when mocking console output and enforcing ANSI escape output
|
||||
// e.g. on SSH sessions.
|
||||
func WithUnsafe() OutputOption {
|
||||
return func(o *Output) {
|
||||
o.unsafe = true
|
||||
}
|
||||
}
|
||||
|
||||
// ForegroundColor returns the terminal's default foreground color.
|
||||
func (o *Output) ForegroundColor() Color {
|
||||
f := func() {
|
||||
if !o.isTTY() {
|
||||
return
|
||||
}
|
||||
|
||||
o.fgColor = o.foregroundColor()
|
||||
}
|
||||
|
||||
if o.cache {
|
||||
o.fgSync.Do(f)
|
||||
} else {
|
||||
f()
|
||||
}
|
||||
|
||||
return o.fgColor
|
||||
}
|
||||
|
||||
// BackgroundColor returns the terminal's default background color.
|
||||
func (o *Output) BackgroundColor() Color {
|
||||
f := func() {
|
||||
if !o.isTTY() {
|
||||
return
|
||||
}
|
||||
|
||||
o.bgColor = o.backgroundColor()
|
||||
}
|
||||
|
||||
if o.cache {
|
||||
o.bgSync.Do(f)
|
||||
} else {
|
||||
f()
|
||||
}
|
||||
|
||||
return o.bgColor
|
||||
}
|
||||
|
||||
// HasDarkBackground returns whether terminal uses a dark-ish background.
|
||||
func (o *Output) HasDarkBackground() bool {
|
||||
c := ConvertToRGB(o.BackgroundColor())
|
||||
_, _, l := c.Hsl()
|
||||
return l < 0.5
|
||||
}
|
||||
|
||||
// TTY returns the terminal's file descriptor. This may be nil if the output is
|
||||
// not a terminal.
|
||||
func (o Output) TTY() File {
|
||||
if f, ok := o.tty.(File); ok {
|
||||
return f
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o Output) Write(p []byte) (int, error) {
|
||||
return o.tty.Write(p)
|
||||
}
|
||||
|
||||
// WriteString writes the given string to the output.
|
||||
func (o Output) WriteString(s string) (int, error) {
|
||||
return o.Write([]byte(s))
|
||||
}
|
97
vendor/github.com/muesli/termenv/profile.go
generated
vendored
Normal file
97
vendor/github.com/muesli/termenv/profile.go
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/lucasb-eyer/go-colorful"
|
||||
)
|
||||
|
||||
// Profile is a color profile: Ascii, ANSI, ANSI256, or TrueColor.
|
||||
type Profile int
|
||||
|
||||
const (
|
||||
// TrueColor, 24-bit color profile
|
||||
TrueColor = Profile(iota)
|
||||
// ANSI256, 8-bit color profile
|
||||
ANSI256
|
||||
// ANSI, 4-bit color profile
|
||||
ANSI
|
||||
// Ascii, uncolored profile
|
||||
Ascii //nolint:revive
|
||||
)
|
||||
|
||||
// String returns a new Style.
|
||||
func (p Profile) String(s ...string) Style {
|
||||
return Style{
|
||||
profile: p,
|
||||
string: strings.Join(s, " "),
|
||||
}
|
||||
}
|
||||
|
||||
// Convert transforms a given Color to a Color supported within the Profile.
|
||||
func (p Profile) Convert(c Color) Color {
|
||||
if p == Ascii {
|
||||
return NoColor{}
|
||||
}
|
||||
|
||||
switch v := c.(type) {
|
||||
case ANSIColor:
|
||||
return v
|
||||
|
||||
case ANSI256Color:
|
||||
if p == ANSI {
|
||||
return ansi256ToANSIColor(v)
|
||||
}
|
||||
return v
|
||||
|
||||
case RGBColor:
|
||||
h, err := colorful.Hex(string(v))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
if p != TrueColor {
|
||||
ac := hexToANSI256Color(h)
|
||||
if p == ANSI {
|
||||
return ansi256ToANSIColor(ac)
|
||||
}
|
||||
return ac
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
// Color creates a Color from a string. Valid inputs are hex colors, as well as
|
||||
// ANSI color codes (0-15, 16-255).
|
||||
func (p Profile) Color(s string) Color {
|
||||
if len(s) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
var c Color
|
||||
if strings.HasPrefix(s, "#") {
|
||||
c = RGBColor(s)
|
||||
} else {
|
||||
i, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if i < 16 {
|
||||
c = ANSIColor(i)
|
||||
} else {
|
||||
c = ANSI256Color(i)
|
||||
}
|
||||
}
|
||||
|
||||
return p.Convert(c)
|
||||
}
|
||||
|
||||
// FromColor creates a Color from a color.Color.
|
||||
func (p Profile) FromColor(c color.Color) Color {
|
||||
col, _ := colorful.MakeColor(c)
|
||||
return p.Color(col.Hex())
|
||||
}
|
590
vendor/github.com/muesli/termenv/screen.go
generated
vendored
Normal file
590
vendor/github.com/muesli/termenv/screen.go
generated
vendored
Normal file
@ -0,0 +1,590 @@
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Sequence definitions.
|
||||
const (
|
||||
// Cursor positioning.
|
||||
CursorUpSeq = "%dA"
|
||||
CursorDownSeq = "%dB"
|
||||
CursorForwardSeq = "%dC"
|
||||
CursorBackSeq = "%dD"
|
||||
CursorNextLineSeq = "%dE"
|
||||
CursorPreviousLineSeq = "%dF"
|
||||
CursorHorizontalSeq = "%dG"
|
||||
CursorPositionSeq = "%d;%dH"
|
||||
EraseDisplaySeq = "%dJ"
|
||||
EraseLineSeq = "%dK"
|
||||
ScrollUpSeq = "%dS"
|
||||
ScrollDownSeq = "%dT"
|
||||
SaveCursorPositionSeq = "s"
|
||||
RestoreCursorPositionSeq = "u"
|
||||
ChangeScrollingRegionSeq = "%d;%dr"
|
||||
InsertLineSeq = "%dL"
|
||||
DeleteLineSeq = "%dM"
|
||||
|
||||
// Explicit values for EraseLineSeq.
|
||||
EraseLineRightSeq = "0K"
|
||||
EraseLineLeftSeq = "1K"
|
||||
EraseEntireLineSeq = "2K"
|
||||
|
||||
// Mouse.
|
||||
EnableMousePressSeq = "?9h" // press only (X10)
|
||||
DisableMousePressSeq = "?9l"
|
||||
EnableMouseSeq = "?1000h" // press, release, wheel
|
||||
DisableMouseSeq = "?1000l"
|
||||
EnableMouseHiliteSeq = "?1001h" // highlight
|
||||
DisableMouseHiliteSeq = "?1001l"
|
||||
EnableMouseCellMotionSeq = "?1002h" // press, release, move on pressed, wheel
|
||||
DisableMouseCellMotionSeq = "?1002l"
|
||||
EnableMouseAllMotionSeq = "?1003h" // press, release, move, wheel
|
||||
DisableMouseAllMotionSeq = "?1003l"
|
||||
EnableMouseExtendedModeSeq = "?1006h" // press, release, move, wheel, extended coordinates
|
||||
DisableMouseExtendedModeSeq = "?1006l"
|
||||
EnableMousePixelsModeSeq = "?1016h" // press, release, move, wheel, extended pixel coordinates
|
||||
DisableMousePixelsModeSeq = "?1016l"
|
||||
|
||||
// Screen.
|
||||
RestoreScreenSeq = "?47l"
|
||||
SaveScreenSeq = "?47h"
|
||||
AltScreenSeq = "?1049h"
|
||||
ExitAltScreenSeq = "?1049l"
|
||||
|
||||
// Bracketed paste.
|
||||
// https://en.wikipedia.org/wiki/Bracketed-paste
|
||||
EnableBracketedPasteSeq = "?2004h"
|
||||
DisableBracketedPasteSeq = "?2004l"
|
||||
StartBracketedPasteSeq = "200~"
|
||||
EndBracketedPasteSeq = "201~"
|
||||
|
||||
// Session.
|
||||
SetWindowTitleSeq = "2;%s" + string(BEL)
|
||||
SetForegroundColorSeq = "10;%s" + string(BEL)
|
||||
SetBackgroundColorSeq = "11;%s" + string(BEL)
|
||||
SetCursorColorSeq = "12;%s" + string(BEL)
|
||||
ShowCursorSeq = "?25h"
|
||||
HideCursorSeq = "?25l"
|
||||
)
|
||||
|
||||
// Reset the terminal to its default style, removing any active styles.
|
||||
func (o Output) Reset() {
|
||||
fmt.Fprint(o.tty, CSI+ResetSeq+"m")
|
||||
}
|
||||
|
||||
// SetForegroundColor sets the default foreground color.
|
||||
func (o Output) SetForegroundColor(color Color) {
|
||||
fmt.Fprintf(o.tty, OSC+SetForegroundColorSeq, color)
|
||||
}
|
||||
|
||||
// SetBackgroundColor sets the default background color.
|
||||
func (o Output) SetBackgroundColor(color Color) {
|
||||
fmt.Fprintf(o.tty, OSC+SetBackgroundColorSeq, color)
|
||||
}
|
||||
|
||||
// SetCursorColor sets the cursor color.
|
||||
func (o Output) SetCursorColor(color Color) {
|
||||
fmt.Fprintf(o.tty, OSC+SetCursorColorSeq, color)
|
||||
}
|
||||
|
||||
// RestoreScreen restores a previously saved screen state.
|
||||
func (o Output) RestoreScreen() {
|
||||
fmt.Fprint(o.tty, CSI+RestoreScreenSeq)
|
||||
}
|
||||
|
||||
// SaveScreen saves the screen state.
|
||||
func (o Output) SaveScreen() {
|
||||
fmt.Fprint(o.tty, CSI+SaveScreenSeq)
|
||||
}
|
||||
|
||||
// AltScreen switches to the alternate screen buffer. The former view can be
|
||||
// restored with ExitAltScreen().
|
||||
func (o Output) AltScreen() {
|
||||
fmt.Fprint(o.tty, CSI+AltScreenSeq)
|
||||
}
|
||||
|
||||
// ExitAltScreen exits the alternate screen buffer and returns to the former
|
||||
// terminal view.
|
||||
func (o Output) ExitAltScreen() {
|
||||
fmt.Fprint(o.tty, CSI+ExitAltScreenSeq)
|
||||
}
|
||||
|
||||
// ClearScreen clears the visible portion of the terminal.
|
||||
func (o Output) ClearScreen() {
|
||||
fmt.Fprintf(o.tty, CSI+EraseDisplaySeq, 2)
|
||||
o.MoveCursor(1, 1)
|
||||
}
|
||||
|
||||
// MoveCursor moves the cursor to a given position.
|
||||
func (o Output) MoveCursor(row int, column int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorPositionSeq, row, column)
|
||||
}
|
||||
|
||||
// HideCursor hides the cursor.
|
||||
func (o Output) HideCursor() {
|
||||
fmt.Fprint(o.tty, CSI+HideCursorSeq)
|
||||
}
|
||||
|
||||
// ShowCursor shows the cursor.
|
||||
func (o Output) ShowCursor() {
|
||||
fmt.Fprint(o.tty, CSI+ShowCursorSeq)
|
||||
}
|
||||
|
||||
// SaveCursorPosition saves the cursor position.
|
||||
func (o Output) SaveCursorPosition() {
|
||||
fmt.Fprint(o.tty, CSI+SaveCursorPositionSeq)
|
||||
}
|
||||
|
||||
// RestoreCursorPosition restores a saved cursor position.
|
||||
func (o Output) RestoreCursorPosition() {
|
||||
fmt.Fprint(o.tty, CSI+RestoreCursorPositionSeq)
|
||||
}
|
||||
|
||||
// CursorUp moves the cursor up a given number of lines.
|
||||
func (o Output) CursorUp(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorUpSeq, n)
|
||||
}
|
||||
|
||||
// CursorDown moves the cursor down a given number of lines.
|
||||
func (o Output) CursorDown(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorDownSeq, n)
|
||||
}
|
||||
|
||||
// CursorForward moves the cursor up a given number of lines.
|
||||
func (o Output) CursorForward(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorForwardSeq, n)
|
||||
}
|
||||
|
||||
// CursorBack moves the cursor backwards a given number of cells.
|
||||
func (o Output) CursorBack(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorBackSeq, n)
|
||||
}
|
||||
|
||||
// CursorNextLine moves the cursor down a given number of lines and places it at
|
||||
// the beginning of the line.
|
||||
func (o Output) CursorNextLine(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorNextLineSeq, n)
|
||||
}
|
||||
|
||||
// CursorPrevLine moves the cursor up a given number of lines and places it at
|
||||
// the beginning of the line.
|
||||
func (o Output) CursorPrevLine(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+CursorPreviousLineSeq, n)
|
||||
}
|
||||
|
||||
// ClearLine clears the current line.
|
||||
func (o Output) ClearLine() {
|
||||
fmt.Fprint(o.tty, CSI+EraseEntireLineSeq)
|
||||
}
|
||||
|
||||
// ClearLineLeft clears the line to the left of the cursor.
|
||||
func (o Output) ClearLineLeft() {
|
||||
fmt.Fprint(o.tty, CSI+EraseLineLeftSeq)
|
||||
}
|
||||
|
||||
// ClearLineRight clears the line to the right of the cursor.
|
||||
func (o Output) ClearLineRight() {
|
||||
fmt.Fprint(o.tty, CSI+EraseLineRightSeq)
|
||||
}
|
||||
|
||||
// ClearLines clears a given number of lines.
|
||||
func (o Output) ClearLines(n int) {
|
||||
clearLine := fmt.Sprintf(CSI+EraseLineSeq, 2)
|
||||
cursorUp := fmt.Sprintf(CSI+CursorUpSeq, 1)
|
||||
fmt.Fprint(o.tty, clearLine+strings.Repeat(cursorUp+clearLine, n))
|
||||
}
|
||||
|
||||
// ChangeScrollingRegion sets the scrolling region of the terminal.
|
||||
func (o Output) ChangeScrollingRegion(top, bottom int) {
|
||||
fmt.Fprintf(o.tty, CSI+ChangeScrollingRegionSeq, top, bottom)
|
||||
}
|
||||
|
||||
// InsertLines inserts the given number of lines at the top of the scrollable
|
||||
// region, pushing lines below down.
|
||||
func (o Output) InsertLines(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+InsertLineSeq, n)
|
||||
}
|
||||
|
||||
// DeleteLines deletes the given number of lines, pulling any lines in
|
||||
// the scrollable region below up.
|
||||
func (o Output) DeleteLines(n int) {
|
||||
fmt.Fprintf(o.tty, CSI+DeleteLineSeq, n)
|
||||
}
|
||||
|
||||
// EnableMousePress enables X10 mouse mode. Button press events are sent only.
|
||||
func (o Output) EnableMousePress() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMousePressSeq)
|
||||
}
|
||||
|
||||
// DisableMousePress disables X10 mouse mode.
|
||||
func (o Output) DisableMousePress() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMousePressSeq)
|
||||
}
|
||||
|
||||
// EnableMouse enables Mouse Tracking mode.
|
||||
func (o Output) EnableMouse() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseSeq)
|
||||
}
|
||||
|
||||
// DisableMouse disables Mouse Tracking mode.
|
||||
func (o Output) DisableMouse() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseSeq)
|
||||
}
|
||||
|
||||
// EnableMouseHilite enables Hilite Mouse Tracking mode.
|
||||
func (o Output) EnableMouseHilite() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseHiliteSeq)
|
||||
}
|
||||
|
||||
// DisableMouseHilite disables Hilite Mouse Tracking mode.
|
||||
func (o Output) DisableMouseHilite() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseHiliteSeq)
|
||||
}
|
||||
|
||||
// EnableMouseCellMotion enables Cell Motion Mouse Tracking mode.
|
||||
func (o Output) EnableMouseCellMotion() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseCellMotionSeq)
|
||||
}
|
||||
|
||||
// DisableMouseCellMotion disables Cell Motion Mouse Tracking mode.
|
||||
func (o Output) DisableMouseCellMotion() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseCellMotionSeq)
|
||||
}
|
||||
|
||||
// EnableMouseAllMotion enables All Motion Mouse mode.
|
||||
func (o Output) EnableMouseAllMotion() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseAllMotionSeq)
|
||||
}
|
||||
|
||||
// DisableMouseAllMotion disables All Motion Mouse mode.
|
||||
func (o Output) DisableMouseAllMotion() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseAllMotionSeq)
|
||||
}
|
||||
|
||||
// EnableMouseExtendedMotion enables Extended Mouse mode (SGR). This should be
|
||||
// enabled in conjunction with EnableMouseCellMotion, and EnableMouseAllMotion.
|
||||
func (o Output) EnableMouseExtendedMode() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMouseExtendedModeSeq)
|
||||
}
|
||||
|
||||
// DisableMouseExtendedMotion disables Extended Mouse mode (SGR).
|
||||
func (o Output) DisableMouseExtendedMode() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMouseExtendedModeSeq)
|
||||
}
|
||||
|
||||
// EnableMousePixelsMotion enables Pixel Motion Mouse mode (SGR-Pixels). This
|
||||
// should be enabled in conjunction with EnableMouseCellMotion, and
|
||||
// EnableMouseAllMotion.
|
||||
func (o Output) EnableMousePixelsMode() {
|
||||
fmt.Fprint(o.tty, CSI+EnableMousePixelsModeSeq)
|
||||
}
|
||||
|
||||
// DisableMousePixelsMotion disables Pixel Motion Mouse mode (SGR-Pixels).
|
||||
func (o Output) DisableMousePixelsMode() {
|
||||
fmt.Fprint(o.tty, CSI+DisableMousePixelsModeSeq)
|
||||
}
|
||||
|
||||
// SetWindowTitle sets the terminal window title.
|
||||
func (o Output) SetWindowTitle(title string) {
|
||||
fmt.Fprintf(o.tty, OSC+SetWindowTitleSeq, title)
|
||||
}
|
||||
|
||||
// EnableBracketedPaste enables bracketed paste.
|
||||
func (o Output) EnableBracketedPaste() {
|
||||
fmt.Fprintf(o.tty, CSI+EnableBracketedPasteSeq)
|
||||
}
|
||||
|
||||
// DisableBracketedPaste disables bracketed paste.
|
||||
func (o Output) DisableBracketedPaste() {
|
||||
fmt.Fprintf(o.tty, CSI+DisableBracketedPasteSeq)
|
||||
}
|
||||
|
||||
// Legacy functions.
|
||||
|
||||
// Reset the terminal to its default style, removing any active styles.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func Reset() {
|
||||
output.Reset()
|
||||
}
|
||||
|
||||
// SetForegroundColor sets the default foreground color.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func SetForegroundColor(color Color) {
|
||||
output.SetForegroundColor(color)
|
||||
}
|
||||
|
||||
// SetBackgroundColor sets the default background color.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func SetBackgroundColor(color Color) {
|
||||
output.SetBackgroundColor(color)
|
||||
}
|
||||
|
||||
// SetCursorColor sets the cursor color.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func SetCursorColor(color Color) {
|
||||
output.SetCursorColor(color)
|
||||
}
|
||||
|
||||
// RestoreScreen restores a previously saved screen state.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func RestoreScreen() {
|
||||
output.RestoreScreen()
|
||||
}
|
||||
|
||||
// SaveScreen saves the screen state.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func SaveScreen() {
|
||||
output.SaveScreen()
|
||||
}
|
||||
|
||||
// AltScreen switches to the alternate screen buffer. The former view can be
|
||||
// restored with ExitAltScreen().
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func AltScreen() {
|
||||
output.AltScreen()
|
||||
}
|
||||
|
||||
// ExitAltScreen exits the alternate screen buffer and returns to the former
|
||||
// terminal view.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func ExitAltScreen() {
|
||||
output.ExitAltScreen()
|
||||
}
|
||||
|
||||
// ClearScreen clears the visible portion of the terminal.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func ClearScreen() {
|
||||
output.ClearScreen()
|
||||
}
|
||||
|
||||
// MoveCursor moves the cursor to a given position.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func MoveCursor(row int, column int) {
|
||||
output.MoveCursor(row, column)
|
||||
}
|
||||
|
||||
// HideCursor hides the cursor.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func HideCursor() {
|
||||
output.HideCursor()
|
||||
}
|
||||
|
||||
// ShowCursor shows the cursor.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func ShowCursor() {
|
||||
output.ShowCursor()
|
||||
}
|
||||
|
||||
// SaveCursorPosition saves the cursor position.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func SaveCursorPosition() {
|
||||
output.SaveCursorPosition()
|
||||
}
|
||||
|
||||
// RestoreCursorPosition restores a saved cursor position.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func RestoreCursorPosition() {
|
||||
output.RestoreCursorPosition()
|
||||
}
|
||||
|
||||
// CursorUp moves the cursor up a given number of lines.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func CursorUp(n int) {
|
||||
output.CursorUp(n)
|
||||
}
|
||||
|
||||
// CursorDown moves the cursor down a given number of lines.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func CursorDown(n int) {
|
||||
output.CursorDown(n)
|
||||
}
|
||||
|
||||
// CursorForward moves the cursor up a given number of lines.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func CursorForward(n int) {
|
||||
output.CursorForward(n)
|
||||
}
|
||||
|
||||
// CursorBack moves the cursor backwards a given number of cells.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func CursorBack(n int) {
|
||||
output.CursorBack(n)
|
||||
}
|
||||
|
||||
// CursorNextLine moves the cursor down a given number of lines and places it at
|
||||
// the beginning of the line.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func CursorNextLine(n int) {
|
||||
output.CursorNextLine(n)
|
||||
}
|
||||
|
||||
// CursorPrevLine moves the cursor up a given number of lines and places it at
|
||||
// the beginning of the line.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func CursorPrevLine(n int) {
|
||||
output.CursorPrevLine(n)
|
||||
}
|
||||
|
||||
// ClearLine clears the current line.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func ClearLine() {
|
||||
output.ClearLine()
|
||||
}
|
||||
|
||||
// ClearLineLeft clears the line to the left of the cursor.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func ClearLineLeft() {
|
||||
output.ClearLineLeft()
|
||||
}
|
||||
|
||||
// ClearLineRight clears the line to the right of the cursor.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func ClearLineRight() {
|
||||
output.ClearLineRight()
|
||||
}
|
||||
|
||||
// ClearLines clears a given number of lines.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func ClearLines(n int) {
|
||||
output.ClearLines(n)
|
||||
}
|
||||
|
||||
// ChangeScrollingRegion sets the scrolling region of the terminal.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func ChangeScrollingRegion(top, bottom int) {
|
||||
output.ChangeScrollingRegion(top, bottom)
|
||||
}
|
||||
|
||||
// InsertLines inserts the given number of lines at the top of the scrollable
|
||||
// region, pushing lines below down.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func InsertLines(n int) {
|
||||
output.InsertLines(n)
|
||||
}
|
||||
|
||||
// DeleteLines deletes the given number of lines, pulling any lines in
|
||||
// the scrollable region below up.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func DeleteLines(n int) {
|
||||
output.DeleteLines(n)
|
||||
}
|
||||
|
||||
// EnableMousePress enables X10 mouse mode. Button press events are sent only.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func EnableMousePress() {
|
||||
output.EnableMousePress()
|
||||
}
|
||||
|
||||
// DisableMousePress disables X10 mouse mode.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func DisableMousePress() {
|
||||
output.DisableMousePress()
|
||||
}
|
||||
|
||||
// EnableMouse enables Mouse Tracking mode.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func EnableMouse() {
|
||||
output.EnableMouse()
|
||||
}
|
||||
|
||||
// DisableMouse disables Mouse Tracking mode.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func DisableMouse() {
|
||||
output.DisableMouse()
|
||||
}
|
||||
|
||||
// EnableMouseHilite enables Hilite Mouse Tracking mode.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func EnableMouseHilite() {
|
||||
output.EnableMouseHilite()
|
||||
}
|
||||
|
||||
// DisableMouseHilite disables Hilite Mouse Tracking mode.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func DisableMouseHilite() {
|
||||
output.DisableMouseHilite()
|
||||
}
|
||||
|
||||
// EnableMouseCellMotion enables Cell Motion Mouse Tracking mode.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func EnableMouseCellMotion() {
|
||||
output.EnableMouseCellMotion()
|
||||
}
|
||||
|
||||
// DisableMouseCellMotion disables Cell Motion Mouse Tracking mode.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func DisableMouseCellMotion() {
|
||||
output.DisableMouseCellMotion()
|
||||
}
|
||||
|
||||
// EnableMouseAllMotion enables All Motion Mouse mode.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func EnableMouseAllMotion() {
|
||||
output.EnableMouseAllMotion()
|
||||
}
|
||||
|
||||
// DisableMouseAllMotion disables All Motion Mouse mode.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func DisableMouseAllMotion() {
|
||||
output.DisableMouseAllMotion()
|
||||
}
|
||||
|
||||
// SetWindowTitle sets the terminal window title.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func SetWindowTitle(title string) {
|
||||
output.SetWindowTitle(title)
|
||||
}
|
||||
|
||||
// EnableBracketedPaste enables bracketed paste.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func EnableBracketedPaste() {
|
||||
output.EnableBracketedPaste()
|
||||
}
|
||||
|
||||
// DisableBracketedPaste disables bracketed paste.
|
||||
//
|
||||
// Deprecated: please use termenv.Output instead.
|
||||
func DisableBracketedPaste() {
|
||||
output.DisableBracketedPaste()
|
||||
}
|
126
vendor/github.com/muesli/termenv/style.go
generated
vendored
Normal file
126
vendor/github.com/muesli/termenv/style.go
generated
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/mattn/go-runewidth"
|
||||
)
|
||||
|
||||
// Sequence definitions.
|
||||
const (
|
||||
ResetSeq = "0"
|
||||
BoldSeq = "1"
|
||||
FaintSeq = "2"
|
||||
ItalicSeq = "3"
|
||||
UnderlineSeq = "4"
|
||||
BlinkSeq = "5"
|
||||
ReverseSeq = "7"
|
||||
CrossOutSeq = "9"
|
||||
OverlineSeq = "53"
|
||||
)
|
||||
|
||||
// Style is a string that various rendering styles can be applied to.
|
||||
type Style struct {
|
||||
profile Profile
|
||||
string
|
||||
styles []string
|
||||
}
|
||||
|
||||
// String returns a new Style.
|
||||
func String(s ...string) Style {
|
||||
return Style{
|
||||
profile: ANSI,
|
||||
string: strings.Join(s, " "),
|
||||
}
|
||||
}
|
||||
|
||||
func (t Style) String() string {
|
||||
return t.Styled(t.string)
|
||||
}
|
||||
|
||||
// Styled renders s with all applied styles.
|
||||
func (t Style) Styled(s string) string {
|
||||
if t.profile == Ascii {
|
||||
return s
|
||||
}
|
||||
if len(t.styles) == 0 {
|
||||
return s
|
||||
}
|
||||
|
||||
seq := strings.Join(t.styles, ";")
|
||||
if seq == "" {
|
||||
return s
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s%sm%s%sm", CSI, seq, s, CSI+ResetSeq)
|
||||
}
|
||||
|
||||
// Foreground sets a foreground color.
|
||||
func (t Style) Foreground(c Color) Style {
|
||||
if c != nil {
|
||||
t.styles = append(t.styles, c.Sequence(false))
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// Background sets a background color.
|
||||
func (t Style) Background(c Color) Style {
|
||||
if c != nil {
|
||||
t.styles = append(t.styles, c.Sequence(true))
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
// Bold enables bold rendering.
|
||||
func (t Style) Bold() Style {
|
||||
t.styles = append(t.styles, BoldSeq)
|
||||
return t
|
||||
}
|
||||
|
||||
// Faint enables faint rendering.
|
||||
func (t Style) Faint() Style {
|
||||
t.styles = append(t.styles, FaintSeq)
|
||||
return t
|
||||
}
|
||||
|
||||
// Italic enables italic rendering.
|
||||
func (t Style) Italic() Style {
|
||||
t.styles = append(t.styles, ItalicSeq)
|
||||
return t
|
||||
}
|
||||
|
||||
// Underline enables underline rendering.
|
||||
func (t Style) Underline() Style {
|
||||
t.styles = append(t.styles, UnderlineSeq)
|
||||
return t
|
||||
}
|
||||
|
||||
// Overline enables overline rendering.
|
||||
func (t Style) Overline() Style {
|
||||
t.styles = append(t.styles, OverlineSeq)
|
||||
return t
|
||||
}
|
||||
|
||||
// Blink enables blink mode.
|
||||
func (t Style) Blink() Style {
|
||||
t.styles = append(t.styles, BlinkSeq)
|
||||
return t
|
||||
}
|
||||
|
||||
// Reverse enables reverse color mode.
|
||||
func (t Style) Reverse() Style {
|
||||
t.styles = append(t.styles, ReverseSeq)
|
||||
return t
|
||||
}
|
||||
|
||||
// CrossOut enables crossed-out rendering.
|
||||
func (t Style) CrossOut() Style {
|
||||
t.styles = append(t.styles, CrossOutSeq)
|
||||
return t
|
||||
}
|
||||
|
||||
// Width returns the width required to print all runes in Style.
|
||||
func (t Style) Width() int {
|
||||
return runewidth.StringWidth(t.string)
|
||||
}
|
86
vendor/github.com/muesli/termenv/templatehelper.go
generated
vendored
Normal file
86
vendor/github.com/muesli/termenv/templatehelper.go
generated
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"text/template"
|
||||
)
|
||||
|
||||
// TemplateFuncs returns template helpers for the given output.
|
||||
func (o Output) TemplateFuncs() template.FuncMap {
|
||||
return TemplateFuncs(o.Profile)
|
||||
}
|
||||
|
||||
// TemplateFuncs contains a few useful template helpers.
|
||||
func TemplateFuncs(p Profile) template.FuncMap {
|
||||
if p == Ascii {
|
||||
return noopTemplateFuncs
|
||||
}
|
||||
|
||||
return template.FuncMap{
|
||||
"Color": func(values ...interface{}) string {
|
||||
s := p.String(values[len(values)-1].(string))
|
||||
switch len(values) {
|
||||
case 2:
|
||||
s = s.Foreground(p.Color(values[0].(string)))
|
||||
case 3:
|
||||
s = s.
|
||||
Foreground(p.Color(values[0].(string))).
|
||||
Background(p.Color(values[1].(string)))
|
||||
}
|
||||
|
||||
return s.String()
|
||||
},
|
||||
"Foreground": func(values ...interface{}) string {
|
||||
s := p.String(values[len(values)-1].(string))
|
||||
if len(values) == 2 {
|
||||
s = s.Foreground(p.Color(values[0].(string)))
|
||||
}
|
||||
|
||||
return s.String()
|
||||
},
|
||||
"Background": func(values ...interface{}) string {
|
||||
s := p.String(values[len(values)-1].(string))
|
||||
if len(values) == 2 {
|
||||
s = s.Background(p.Color(values[0].(string)))
|
||||
}
|
||||
|
||||
return s.String()
|
||||
},
|
||||
"Bold": styleFunc(p, Style.Bold),
|
||||
"Faint": styleFunc(p, Style.Faint),
|
||||
"Italic": styleFunc(p, Style.Italic),
|
||||
"Underline": styleFunc(p, Style.Underline),
|
||||
"Overline": styleFunc(p, Style.Overline),
|
||||
"Blink": styleFunc(p, Style.Blink),
|
||||
"Reverse": styleFunc(p, Style.Reverse),
|
||||
"CrossOut": styleFunc(p, Style.CrossOut),
|
||||
}
|
||||
}
|
||||
|
||||
func styleFunc(p Profile, f func(Style) Style) func(...interface{}) string {
|
||||
return func(values ...interface{}) string {
|
||||
s := p.String(values[0].(string))
|
||||
return f(s).String()
|
||||
}
|
||||
}
|
||||
|
||||
var noopTemplateFuncs = template.FuncMap{
|
||||
"Color": noColorFunc,
|
||||
"Foreground": noColorFunc,
|
||||
"Background": noColorFunc,
|
||||
"Bold": noStyleFunc,
|
||||
"Faint": noStyleFunc,
|
||||
"Italic": noStyleFunc,
|
||||
"Underline": noStyleFunc,
|
||||
"Overline": noStyleFunc,
|
||||
"Blink": noStyleFunc,
|
||||
"Reverse": noStyleFunc,
|
||||
"CrossOut": noStyleFunc,
|
||||
}
|
||||
|
||||
func noColorFunc(values ...interface{}) string {
|
||||
return values[len(values)-1].(string)
|
||||
}
|
||||
|
||||
func noStyleFunc(values ...interface{}) string {
|
||||
return values[0].(string)
|
||||
}
|
114
vendor/github.com/muesli/termenv/termenv.go
generated
vendored
Normal file
114
vendor/github.com/muesli/termenv/termenv.go
generated
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrStatusReport gets returned when the terminal can't be queried.
|
||||
ErrStatusReport = errors.New("unable to retrieve status report")
|
||||
)
|
||||
|
||||
const (
|
||||
// Escape character
|
||||
ESC = '\x1b'
|
||||
// Bell
|
||||
BEL = '\a'
|
||||
// Control Sequence Introducer
|
||||
CSI = string(ESC) + "["
|
||||
// Operating System Command
|
||||
OSC = string(ESC) + "]"
|
||||
// String Terminator
|
||||
ST = string(ESC) + `\`
|
||||
)
|
||||
|
||||
func (o *Output) isTTY() bool {
|
||||
if o.assumeTTY || o.unsafe {
|
||||
return true
|
||||
}
|
||||
if len(o.environ.Getenv("CI")) > 0 {
|
||||
return false
|
||||
}
|
||||
if o.TTY() == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return isatty.IsTerminal(o.TTY().Fd())
|
||||
}
|
||||
|
||||
// ColorProfile returns the supported color profile:
|
||||
// Ascii, ANSI, ANSI256, or TrueColor.
|
||||
func ColorProfile() Profile {
|
||||
return output.ColorProfile()
|
||||
}
|
||||
|
||||
// ForegroundColor returns the terminal's default foreground color.
|
||||
func ForegroundColor() Color {
|
||||
return output.ForegroundColor()
|
||||
}
|
||||
|
||||
// BackgroundColor returns the terminal's default background color.
|
||||
func BackgroundColor() Color {
|
||||
return output.BackgroundColor()
|
||||
}
|
||||
|
||||
// HasDarkBackground returns whether terminal uses a dark-ish background.
|
||||
func HasDarkBackground() bool {
|
||||
return output.HasDarkBackground()
|
||||
}
|
||||
|
||||
// EnvNoColor returns true if the environment variables explicitly disable color output
|
||||
// by setting NO_COLOR (https://no-color.org/)
|
||||
// or CLICOLOR/CLICOLOR_FORCE (https://bixense.com/clicolors/)
|
||||
// If NO_COLOR is set, this will return true, ignoring CLICOLOR/CLICOLOR_FORCE
|
||||
// If CLICOLOR=="0", it will be true only if CLICOLOR_FORCE is also "0" or is unset.
|
||||
func (o *Output) EnvNoColor() bool {
|
||||
return o.environ.Getenv("NO_COLOR") != "" || (o.environ.Getenv("CLICOLOR") == "0" && !o.cliColorForced())
|
||||
}
|
||||
|
||||
// EnvNoColor returns true if the environment variables explicitly disable color output
|
||||
// by setting NO_COLOR (https://no-color.org/)
|
||||
// or CLICOLOR/CLICOLOR_FORCE (https://bixense.com/clicolors/)
|
||||
// If NO_COLOR is set, this will return true, ignoring CLICOLOR/CLICOLOR_FORCE
|
||||
// If CLICOLOR=="0", it will be true only if CLICOLOR_FORCE is also "0" or is unset.
|
||||
func EnvNoColor() bool {
|
||||
return output.EnvNoColor()
|
||||
}
|
||||
|
||||
// EnvColorProfile returns the color profile based on environment variables set
|
||||
// Supports NO_COLOR (https://no-color.org/)
|
||||
// and CLICOLOR/CLICOLOR_FORCE (https://bixense.com/clicolors/)
|
||||
// If none of these environment variables are set, this behaves the same as ColorProfile()
|
||||
// It will return the Ascii color profile if EnvNoColor() returns true
|
||||
// If the terminal does not support any colors, but CLICOLOR_FORCE is set and not "0"
|
||||
// then the ANSI color profile will be returned.
|
||||
func EnvColorProfile() Profile {
|
||||
return output.EnvColorProfile()
|
||||
}
|
||||
|
||||
// EnvColorProfile returns the color profile based on environment variables set
|
||||
// Supports NO_COLOR (https://no-color.org/)
|
||||
// and CLICOLOR/CLICOLOR_FORCE (https://bixense.com/clicolors/)
|
||||
// If none of these environment variables are set, this behaves the same as ColorProfile()
|
||||
// It will return the Ascii color profile if EnvNoColor() returns true
|
||||
// If the terminal does not support any colors, but CLICOLOR_FORCE is set and not "0"
|
||||
// then the ANSI color profile will be returned.
|
||||
func (o *Output) EnvColorProfile() Profile {
|
||||
if o.EnvNoColor() {
|
||||
return Ascii
|
||||
}
|
||||
p := o.ColorProfile()
|
||||
if o.cliColorForced() && p == Ascii {
|
||||
return ANSI
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (o *Output) cliColorForced() bool {
|
||||
if forced := o.environ.Getenv("CLICOLOR_FORCE"); forced != "" {
|
||||
return forced != "0"
|
||||
}
|
||||
return false
|
||||
}
|
30
vendor/github.com/muesli/termenv/termenv_other.go
generated
vendored
Normal file
30
vendor/github.com/muesli/termenv/termenv_other.go
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
//go:build js || plan9 || aix
|
||||
// +build js plan9 aix
|
||||
|
||||
package termenv
|
||||
|
||||
import "io"
|
||||
|
||||
// ColorProfile returns the supported color profile:
|
||||
// ANSI256
|
||||
func (o Output) ColorProfile() Profile {
|
||||
return ANSI256
|
||||
}
|
||||
|
||||
func (o Output) foregroundColor() Color {
|
||||
// default gray
|
||||
return ANSIColor(7)
|
||||
}
|
||||
|
||||
func (o Output) backgroundColor() Color {
|
||||
// default black
|
||||
return ANSIColor(0)
|
||||
}
|
||||
|
||||
// EnableVirtualTerminalProcessing enables virtual terminal processing on
|
||||
// Windows for w and returns a function that restores w to its previous state.
|
||||
// On non-Windows platforms, or if w does not refer to a terminal, then it
|
||||
// returns a non-nil no-op function and no error.
|
||||
func EnableVirtualTerminalProcessing(w io.Writer) (func() error, error) {
|
||||
return func() error { return nil }, nil
|
||||
}
|
17
vendor/github.com/muesli/termenv/termenv_posix.go
generated
vendored
Normal file
17
vendor/github.com/muesli/termenv/termenv_posix.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func isForeground(fd int) bool {
|
||||
pgrp, err := unix.IoctlGetInt(fd, unix.TIOCGPGRP)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return pgrp == unix.Getpgrp()
|
||||
}
|
22
vendor/github.com/muesli/termenv/termenv_solaris.go
generated
vendored
Normal file
22
vendor/github.com/muesli/termenv/termenv_solaris.go
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
//go:build solaris || illumos
|
||||
// +build solaris illumos
|
||||
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func isForeground(fd int) bool {
|
||||
pgrp, err := unix.IoctlGetInt(fd, unix.TIOCGPGRP)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
g, err := unix.Getpgrp()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return pgrp == g
|
||||
}
|
293
vendor/github.com/muesli/termenv/termenv_unix.go
generated
vendored
Normal file
293
vendor/github.com/muesli/termenv/termenv_unix.go
generated
vendored
Normal file
@ -0,0 +1,293 @@
|
||||
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
|
||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
// timeout for OSC queries
|
||||
OSCTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
// ColorProfile returns the supported color profile:
|
||||
// Ascii, ANSI, ANSI256, or TrueColor.
|
||||
func (o *Output) ColorProfile() Profile {
|
||||
if !o.isTTY() {
|
||||
return Ascii
|
||||
}
|
||||
|
||||
if o.environ.Getenv("GOOGLE_CLOUD_SHELL") == "true" {
|
||||
return TrueColor
|
||||
}
|
||||
|
||||
term := o.environ.Getenv("TERM")
|
||||
colorTerm := o.environ.Getenv("COLORTERM")
|
||||
|
||||
switch strings.ToLower(colorTerm) {
|
||||
case "24bit":
|
||||
fallthrough
|
||||
case "truecolor":
|
||||
if strings.HasPrefix(term, "screen") {
|
||||
// tmux supports TrueColor, screen only ANSI256
|
||||
if o.environ.Getenv("TERM_PROGRAM") != "tmux" {
|
||||
return ANSI256
|
||||
}
|
||||
}
|
||||
return TrueColor
|
||||
case "yes":
|
||||
fallthrough
|
||||
case "true":
|
||||
return ANSI256
|
||||
}
|
||||
|
||||
switch term {
|
||||
case "xterm-kitty", "wezterm":
|
||||
return TrueColor
|
||||
case "linux":
|
||||
return ANSI
|
||||
}
|
||||
|
||||
if strings.Contains(term, "256color") {
|
||||
return ANSI256
|
||||
}
|
||||
if strings.Contains(term, "color") {
|
||||
return ANSI
|
||||
}
|
||||
if strings.Contains(term, "ansi") {
|
||||
return ANSI
|
||||
}
|
||||
|
||||
return Ascii
|
||||
}
|
||||
|
||||
func (o Output) foregroundColor() Color {
|
||||
s, err := o.termStatusReport(10)
|
||||
if err == nil {
|
||||
c, err := xTermColor(s)
|
||||
if err == nil {
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
colorFGBG := o.environ.Getenv("COLORFGBG")
|
||||
if strings.Contains(colorFGBG, ";") {
|
||||
c := strings.Split(colorFGBG, ";")
|
||||
i, err := strconv.Atoi(c[0])
|
||||
if err == nil {
|
||||
return ANSIColor(i)
|
||||
}
|
||||
}
|
||||
|
||||
// default gray
|
||||
return ANSIColor(7)
|
||||
}
|
||||
|
||||
func (o Output) backgroundColor() Color {
|
||||
s, err := o.termStatusReport(11)
|
||||
if err == nil {
|
||||
c, err := xTermColor(s)
|
||||
if err == nil {
|
||||
return c
|
||||
}
|
||||
}
|
||||
|
||||
colorFGBG := o.environ.Getenv("COLORFGBG")
|
||||
if strings.Contains(colorFGBG, ";") {
|
||||
c := strings.Split(colorFGBG, ";")
|
||||
i, err := strconv.Atoi(c[len(c)-1])
|
||||
if err == nil {
|
||||
return ANSIColor(i)
|
||||
}
|
||||
}
|
||||
|
||||
// default black
|
||||
return ANSIColor(0)
|
||||
}
|
||||
|
||||
func (o *Output) waitForData(timeout time.Duration) error {
|
||||
fd := o.TTY().Fd()
|
||||
tv := unix.NsecToTimeval(int64(timeout))
|
||||
var readfds unix.FdSet
|
||||
readfds.Set(int(fd))
|
||||
|
||||
for {
|
||||
n, err := unix.Select(int(fd)+1, &readfds, nil, nil, &tv)
|
||||
if err == unix.EINTR {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if n == 0 {
|
||||
return fmt.Errorf("timeout")
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *Output) readNextByte() (byte, error) {
|
||||
if !o.unsafe {
|
||||
if err := o.waitForData(OSCTimeout); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
var b [1]byte
|
||||
n, err := o.TTY().Read(b[:])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
panic("read returned no data")
|
||||
}
|
||||
|
||||
return b[0], nil
|
||||
}
|
||||
|
||||
// readNextResponse reads either an OSC response or a cursor position response:
|
||||
// - OSC response: "\x1b]11;rgb:1111/1111/1111\x1b\\"
|
||||
// - cursor position response: "\x1b[42;1R"
|
||||
func (o *Output) readNextResponse() (response string, isOSC bool, err error) {
|
||||
start, err := o.readNextByte()
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
|
||||
// first byte must be ESC
|
||||
for start != ESC {
|
||||
start, err = o.readNextByte()
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
}
|
||||
|
||||
response += string(start)
|
||||
|
||||
// next byte is either '[' (cursor position response) or ']' (OSC response)
|
||||
tpe, err := o.readNextByte()
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
|
||||
response += string(tpe)
|
||||
|
||||
var oscResponse bool
|
||||
switch tpe {
|
||||
case '[':
|
||||
oscResponse = false
|
||||
case ']':
|
||||
oscResponse = true
|
||||
default:
|
||||
return "", false, ErrStatusReport
|
||||
}
|
||||
|
||||
for {
|
||||
b, err := o.readNextByte()
|
||||
if err != nil {
|
||||
return "", false, err
|
||||
}
|
||||
|
||||
response += string(b)
|
||||
|
||||
if oscResponse {
|
||||
// OSC can be terminated by BEL (\a) or ST (ESC)
|
||||
if b == BEL || strings.HasSuffix(response, string(ESC)) {
|
||||
return response, true, nil
|
||||
}
|
||||
} else {
|
||||
// cursor position response is terminated by 'R'
|
||||
if b == 'R' {
|
||||
return response, false, nil
|
||||
}
|
||||
}
|
||||
|
||||
// both responses have less than 25 bytes, so if we read more, that's an error
|
||||
if len(response) > 25 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return "", false, ErrStatusReport
|
||||
}
|
||||
|
||||
func (o Output) termStatusReport(sequence int) (string, error) {
|
||||
// screen/tmux can't support OSC, because they can be connected to multiple
|
||||
// terminals concurrently.
|
||||
term := o.environ.Getenv("TERM")
|
||||
if strings.HasPrefix(term, "screen") || strings.HasPrefix(term, "tmux") {
|
||||
return "", ErrStatusReport
|
||||
}
|
||||
|
||||
tty := o.TTY()
|
||||
if tty == nil {
|
||||
return "", ErrStatusReport
|
||||
}
|
||||
|
||||
if !o.unsafe {
|
||||
fd := int(tty.Fd())
|
||||
// if in background, we can't control the terminal
|
||||
if !isForeground(fd) {
|
||||
return "", ErrStatusReport
|
||||
}
|
||||
|
||||
t, err := unix.IoctlGetTermios(fd, tcgetattr)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("%s: %s", ErrStatusReport, err)
|
||||
}
|
||||
defer unix.IoctlSetTermios(fd, tcsetattr, t) //nolint:errcheck
|
||||
|
||||
noecho := *t
|
||||
noecho.Lflag = noecho.Lflag &^ unix.ECHO
|
||||
noecho.Lflag = noecho.Lflag &^ unix.ICANON
|
||||
if err := unix.IoctlSetTermios(fd, tcsetattr, &noecho); err != nil {
|
||||
return "", fmt.Errorf("%s: %s", ErrStatusReport, err)
|
||||
}
|
||||
}
|
||||
|
||||
// first, send OSC query, which is ignored by terminal which do not support it
|
||||
fmt.Fprintf(tty, OSC+"%d;?"+ST, sequence)
|
||||
|
||||
// then, query cursor position, should be supported by all terminals
|
||||
fmt.Fprintf(tty, CSI+"6n")
|
||||
|
||||
// read the next response
|
||||
res, isOSC, err := o.readNextResponse()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("%s: %s", ErrStatusReport, err)
|
||||
}
|
||||
|
||||
// if this is not OSC response, then the terminal does not support it
|
||||
if !isOSC {
|
||||
return "", ErrStatusReport
|
||||
}
|
||||
|
||||
// read the cursor query response next and discard the result
|
||||
_, _, err = o.readNextResponse()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// fmt.Println("Rcvd", res[1:])
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// EnableVirtualTerminalProcessing enables virtual terminal processing on
|
||||
// Windows for w and returns a function that restores w to its previous state.
|
||||
// On non-Windows platforms, or if w does not refer to a terminal, then it
|
||||
// returns a non-nil no-op function and no error.
|
||||
func EnableVirtualTerminalProcessing(_ io.Writer) (func() error, error) {
|
||||
return func() error { return nil }, nil
|
||||
}
|
139
vendor/github.com/muesli/termenv/termenv_windows.go
generated
vendored
Normal file
139
vendor/github.com/muesli/termenv/termenv_windows.go
generated
vendored
Normal file
@ -0,0 +1,139 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package termenv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
func (o *Output) ColorProfile() Profile {
|
||||
if !o.isTTY() {
|
||||
return Ascii
|
||||
}
|
||||
|
||||
if o.environ.Getenv("ConEmuANSI") == "ON" {
|
||||
return TrueColor
|
||||
}
|
||||
|
||||
winVersion, _, buildNumber := windows.RtlGetNtVersionNumbers()
|
||||
if buildNumber < 10586 || winVersion < 10 {
|
||||
// No ANSI support before Windows 10 build 10586.
|
||||
if o.environ.Getenv("ANSICON") != "" {
|
||||
conVersion := o.environ.Getenv("ANSICON_VER")
|
||||
cv, err := strconv.ParseInt(conVersion, 10, 64)
|
||||
if err != nil || cv < 181 {
|
||||
// No 8 bit color support before v1.81 release.
|
||||
return ANSI
|
||||
}
|
||||
|
||||
return ANSI256
|
||||
}
|
||||
|
||||
return Ascii
|
||||
}
|
||||
if buildNumber < 14931 {
|
||||
// No true color support before build 14931.
|
||||
return ANSI256
|
||||
}
|
||||
|
||||
return TrueColor
|
||||
}
|
||||
|
||||
func (o Output) foregroundColor() Color {
|
||||
// default gray
|
||||
return ANSIColor(7)
|
||||
}
|
||||
|
||||
func (o Output) backgroundColor() Color {
|
||||
// default black
|
||||
return ANSIColor(0)
|
||||
}
|
||||
|
||||
// EnableWindowsANSIConsole enables virtual terminal processing on Windows
|
||||
// platforms. This allows the use of ANSI escape sequences in Windows console
|
||||
// applications. Ensure this gets called before anything gets rendered with
|
||||
// termenv.
|
||||
//
|
||||
// Returns the original console mode and an error if one occurred.
|
||||
func EnableWindowsANSIConsole() (uint32, error) {
|
||||
handle, err := windows.GetStdHandle(windows.STD_OUTPUT_HANDLE)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
var mode uint32
|
||||
err = windows.GetConsoleMode(handle, &mode)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// See https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
|
||||
if mode&windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING != windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING {
|
||||
vtpmode := mode | windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||||
if err := windows.SetConsoleMode(handle, vtpmode); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
return mode, nil
|
||||
}
|
||||
|
||||
// RestoreWindowsConsole restores the console mode to a previous state.
|
||||
func RestoreWindowsConsole(mode uint32) error {
|
||||
handle, err := windows.GetStdHandle(windows.STD_OUTPUT_HANDLE)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return windows.SetConsoleMode(handle, mode)
|
||||
}
|
||||
|
||||
// EnableVirtualTerminalProcessing enables virtual terminal processing on
|
||||
// Windows for o and returns a function that restores o to its previous state.
|
||||
// On non-Windows platforms, or if o does not refer to a terminal, then it
|
||||
// returns a non-nil no-op function and no error.
|
||||
func EnableVirtualTerminalProcessing(o *Output) (restoreFunc func() error, err error) {
|
||||
// There is nothing to restore until we set the console mode.
|
||||
restoreFunc = func() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// If o is not a tty, then there is nothing to do.
|
||||
tty := o.TTY()
|
||||
if tty == nil {
|
||||
return
|
||||
}
|
||||
|
||||
// Get the current console mode. If there is an error, assume that o is not
|
||||
// a terminal, discard the error, and return.
|
||||
var mode uint32
|
||||
if err2 := windows.GetConsoleMode(windows.Handle(tty.Fd()), &mode); err2 != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// If virtual terminal processing is already set, then there is nothing to
|
||||
// do and nothing to restore.
|
||||
if mode&windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING == windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING {
|
||||
return
|
||||
}
|
||||
|
||||
// Enable virtual terminal processing. See
|
||||
// https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
|
||||
if err2 := windows.SetConsoleMode(windows.Handle(tty.Fd()), mode|windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING); err2 != nil {
|
||||
err = fmt.Errorf("windows.SetConsoleMode: %w", err2)
|
||||
return
|
||||
}
|
||||
|
||||
// Set the restore function. We maintain a reference to the tty in the
|
||||
// closure (rather than just its handle) to ensure that the tty is not
|
||||
// closed by a finalizer.
|
||||
restoreFunc = func() error {
|
||||
return windows.SetConsoleMode(windows.Handle(tty.Fd()), mode)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user