8000 termui/par.go at tabpane · soone/termui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
{"payload":{"allShortcutsEnabled":false,"fileTree":{"":{"items":[{"name":"_docs","path":"_docs","contentType":"directory"},{"name":"_example","path":"_example","contentType":"directory"},{"name":"debug","path":"debug","contentType":"directory"},{"name":"extra","path":"extra","contentType":"directory"},{"name":"test","path":"test","contentType":"directory"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"LICENSE","path":"LICENSE","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"barchart.go","path":"barchart.go","contentType":"file"},{"name":"block.go","path":"block.go","contentType":"file"},{"name":"block_common.go","path":"block_common.go","contentType":"file"},{"name":"block_test.go","path":"block_test.go","contentType":"file"},{"name":"block_windows.go","path":"block_windows.go","contentType":"file"},{"name":"buffer.go","path":"buffer.go","contentType":"file"},{"name":"buffer_test.go","path":"buffer_test.go","contentType":"file"},{"name":"canvas.go","path":"canvas.go","contentType":"file"},{"name":"canvas_test.go","path":"canvas_test.go","contentType":"file"},{"name":"config","path":"config","contentType":"file"},{"name":"doc.go","path":"doc.go","contentType":"file"},{"name":"events.go","path":"events.go","contentType":"file"},{"name":"events_test.go","path":"events_test.go","contentType":"file"},{"name":"gauge.go","path":"gauge.go","contentType":"file"},{"name":"glide.lock","path":"glide.lock","contentType":"file"},{"name":"glide.yaml","path":"glide.yaml","contentType":"file"},{"name":"grid.go","path":"grid.go","contentType":"file"},{"name":"grid_test.go","path":"grid_test.go","contentType":"file"},{"name":"helper.go","path":"helper.go","contentType":"file"},{"name":"helper_test.go","path":"helper_test.go","contentType":"file"},{"name":"linechart.go","path":"linechart.go","contentType":"file"},{"name":"linechart_others.go","path":"linechart_others.go","contentType":"file"},{"name":"linechart_windows.go","path":"linechart_windows.go","contentType":"file"},{"name":"list.go","path":"list.go","contentType":"file"},{"name":"mbarchart.go","path":"mbarchart.go","contentType":"file"},{"name":"mkdocs.yml","path":"mkdocs.yml","contentType":"file"},{"name":"par.go","path":"par.go","contentType":"file"},{"name":"par_test.go","path":"par_test.go","contentType":"file"},{"name":"pos.go","path":"pos.go","contentType":"file"},{"name":"pos_test.go","path":"pos_test.go","contentType":"file"},{"name":"render.go","path":"render.go","contentType":"file"},{"name":"sparkline.go","path":"sparkline.go","contentType":"file"},{"name":"textbuilder.go","path":"textbuilder.go","contentType":"file"},{"name":"textbuilder_test.go","path":"textbuilder_test.go","contentType":"file"},{"name":"theme.go","path":"theme.go","contentType":"file"},{"name":"theme_test.go","path":"theme_test.go","contentType":"file"},{"name":"widget.go","path":"widget.go","contentType":"file"}],"totalCount":46}},"fileTreeProcessingTime":3.4246290000000004,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":83419512,"defaultBranch":"master","name":"termui","ownerLogin":"soone","currentUserCanPush":false,"isFork":true,"isEmpty":false,"createdAt":"2017-02-28T10:26:21.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/52793?v=4","public":true,"private":false,"isOrgOwned":false},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"tabpane","listCacheKey":"v0:1614908259.650898","canEdit":false,"refType":"branch","currentOid":"7cbb70e87e46006819637b2d9327254c0ffce15c"},"path":"par.go","currentUser":null,"blob":{"rawLines":["// Copyright 2016 Zack Guo \u003cgizak@icloud.com\u003e. All rights reserved.","// Use of this source code is governed by a MIT license that can","// be found in the LICENSE file.","","package termui","","// Par displays a paragraph.","/*"," par := termui.NewPar(\"Simple Text\")"," par.Height = 3"," par.Width = 17"," par.BorderLabel = \"Label\"","*/","type Par struct {","\tBlock","\tText string","\tTextFgColor Attribute","\tTextBgColor Attribute","\tWrapLength int // words wrap limit. Note it may not work properly with multi-width char","}","","// NewPar returns a new *Par with given text as its content.","func NewPar(s string) *Par {","\treturn \u0026Par{","\t\tBlock: *NewBlock(),","\t\tText: s,","\t\tTextFgColor: ThemeAttr(\"par.text.fg\"),","\t\tTextBgColor: ThemeAttr(\"par.text.bg\"),","\t\tWrapLength: 0,","\t}","}","","// Buffer implements Bufferer interface.","func (p *Par) Buffer() Buffer {","\tbuf := p.Block.Buffer()","","\tfg, bg := p.TextFgColor, p.TextBgColor","\tcs := DefaultTxBuilder.Build(p.Text, fg, bg)","","\t// wrap if WrapLength set","\tif p.WrapLength \u003c 0 {","\t\tcs = wrapTx(cs, p.Width-2)","\t} else if p.WrapLength \u003e 0 {","\t\tcs = wrapTx(cs, p.WrapLength)","\t}","","\ty, x, n := 0, 0, 0","\tfor y \u003c p.innerArea.Dy() \u0026\u0026 n \u003c len(cs) {","\t\tw := cs[n].Width()","\t\tif cs[n].Ch == '\\n' || x+w \u003e p.innerArea.Dx() {","\t\t\ty++","\t\t\tx = 0 // set x = 0","\t\t\tif cs[n].Ch == '\\n' {","\t\t\t\tn++","\t\t\t}","","\t\t\tif y \u003e= p.innerArea.Dy() {","\t\t\t\tbuf.Set(p.innerArea.Min.X+p.innerArea.Dx()-1,","\t\t\t\t\tp.innerArea.Min.Y+p.innerArea.Dy()-1,","\t\t\t\t\tCell{Ch: '…', Fg: p.TextFgColor, Bg: p.TextBgColor})","\t\t\t\tbreak","\t\t\t}","\t\t\tcontinue","\t\t}","","\t\tbuf.Set(p.innerArea.Min.X+x, p.innerArea.Min.Y+y, cs[n])","","\t\tn++","\t\tx += w","\t}","","\treturn buf","}"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/soone/termui/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"par.go","displayUrl":"https://github.com/soone/termui/blob/tabpane/par.go?raw=true","headerInfo":{"blobSize":"1.56 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"78bffd0","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fsoone%2Ftermui%2Fblob%2Ftabpane%2Fpar.go","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"73","truncatedSloc":"62"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"Go","languageID":132,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/soone/termui/blob/tabpane/par.go","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/soone/termui/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/soone/termui/raw/refs/heads/tabpane/par.go","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":null},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"isMarketplaceEnabled":true,"csrf_tokens":{"/soone/termui/branches":{"post":"mQTZY8OfgAEUWlfyEqsW6vUuLsNF6F06UVQ6dZVDJGh5nQEbpO_bmHFIapAXHH8tNGRPd7JPJR3XfpTvdztHhw"},"/repos/preferences":{"post":"SAfYMo1jmTdRpLH-kCX6UcW98luax3RBE8d0AP20IXt3gURSq9Cah_PwI6dG1id0lM3M5A9GTZsJnt3frdRgzQ"}}},"title":"termui/par.go at tabpane · soone/termui","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-263cab1760dd.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-98e6e9db3609.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true}}}
0