learn by doing
wobsoriano / blipgloss Goto Github PK
View Code? Open in Web Editor NEWStyle definitions for nice terminal layouts ๐
License: MIT License
Style definitions for nice terminal layouts ๐
License: MIT License
learn by doing
import { NewStyle, Position } from 'blipgloss'
const style = NewStyle()
.Bold(true)
.Foreground('#FAFAFA')
.Background('#7D56F4')
.Width(22)
.Align(Position.Center)
console.log(style.Render('Hello'))
end up with:
$ bun run ./src/index.ts
unexpected fault address 0x41f4770400000000
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x2 addr=0x41f4770400000000 pc=0x137804bb4]
goroutine 17 [running, locked to thread]:
runtime.throw({0x137929969?, 0x0?})
/usr/local/go/src/runtime/panic.go:1047 +0x40 fp=0x1400014bca0 sp=0x1400014bc70 pc=0x137836560
runtime.sigpanic()
/usr/local/go/src/runtime/signal_unix.go:842 +0x1a0 fp=0x1400014bcd0 sp=0x1400014bca0 pc=0x13784b3d0
indexbytebody()
/usr/local/go/src/internal/bytealg/indexbyte_arm64.s:74 +0x64 fp=0x1400014bce0 sp=0x1400014bce0 pc=0x137804bb4
runtime.findnull(0x137971f00?)
/usr/local/go/src/runtime/string.go:542 +0x7c fp=0x1400014bd40 sp=0x1400014bce0 pc=0x137850b2c
runtime.gostring(0x137971f00?)
/usr/local/go/src/runtime/string.go:331 +0x20 fp=0x1400014bd90 sp=0x1400014bd40 pc=0x1378607b0
main._Cfunc_GoString(...)
_cgo_gotypes.go:72
main.str(...)
/source/main.go:28
main.getStyle(...)
/source/main.go:37
main.Align(0x13796dd01?, 0x4fa3b820)
/source/main.go:162 +0x28 fp=0x1400014bde0 sp=0x1400014bd90 pc=0x137926cf8
_cgoexp_13e36339c2a6_Align(0x16ef3e668?)
_cgo_gotypes.go:250 +0x28 fp=0x1400014be00 sp=0x1400014bde0 pc=0x137927e08
runtime.cgocallbackg1(0x137927de0, 0x1400014bfe0?, 0x0)
/usr/local/go/src/runtime/cgocall.go:316 +0x244 fp=0x1400014bef0 sp=0x1400014be00 pc=0x137805fa4
runtime.cgocallbackg(0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/cgocall.go:235 +0xd8 fp=0x1400014bf80 sp=0x1400014bef0 pc=0x137805cd8
runtime.cgocallbackg(0x137927de0, 0x16ef3e690, 0x0)
<autogenerated>:1 +0x1c fp=0x1400014bfb0 sp=0x1400014bf80 pc=0x13786561c
runtime.cgocallback(0x0, 0x0, 0x0)
/usr/local/go/src/runtime/asm_arm64.s:1094 +0xa0 fp=0x1400014bfe0 sp=0x1400014bfb0 pc=0x137863e90
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1172 +0x4 fp=0x1400014bfe0 sp=0x1400014bfe0 pc=0x137863f64
goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xe4 fp=0x14000052fa0 sp=0x14000052f80 pc=0x137838ea4
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:302 +0xb4 fp=0x14000052fd0 sp=0x14000052fa0 pc=0x137838d34
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000052fd0 sp=0x14000052fd0 pc=0x137863f64
created by runtime.init.6
/usr/local/go/src/runtime/proc.go:290 +0x24
goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xe4 fp=0x14000053770 sp=0x14000053750 pc=0x137838ea4
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
/usr/local/go/src/runtime/mgcsweep.go:278 +0xa4 fp=0x140000537b0 sp=0x14000053770 pc=0x137826284
runtime.gcenable.func1()
/usr/local/go/src/runtime/mgc.go:178 +0x28 fp=0x140000537d0 sp=0x140000537b0 pc=0x13781a6b8
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000537d0 sp=0x140000537d0 pc=0x137863f64
created by runtime.gcenable
/usr/local/go/src/runtime/mgc.go:178 +0x70
goroutine 4 [GC scavenge wait]:
runtime.gopark(0x1400002a0e0?, 0x137961ca0?, 0x1?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xe4 fp=0x14000053f50 sp=0x14000053f30 pc=0x137838ea4
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x137a7bc00)
/usr/local/go/src/runtime/mgcscavenge.go:389 +0x5c fp=0x14000053f80 sp=0x14000053f50 pc=0x13782424c
runtime.bgscavenge(0x0?)
/usr/local/go/src/runtime/mgcscavenge.go:617 +0x44 fp=0x14000053fb0 sp=0x14000053f80 pc=0x1378247e4
runtime.gcenable.func2()
/usr/local/go/src/runtime/mgc.go:179 +0x28 fp=0x14000053fd0 sp=0x14000053fb0 pc=0x13781a658
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000053fd0 sp=0x14000053fd0 pc=0x137863f64
created by runtime.gcenable
/usr/local/go/src/runtime/mgc.go:179 +0xb4
goroutine 18 [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:363 +0xe4 fp=0x1400004e580 sp=0x1400004e560 pc=0x137838ea4
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:369
runtime.runfinq()
/usr/local/go/src/runtime/mfinal.go:180 +0x128 fp=0x1400004e7d0 sp=0x1400004e580 pc=0x1378198d8
runtime.goexit()
/usr/local/go/src/runtime/asm_arm64.s:1172 +0x4 fp=0x1400004e7d0 sp=0x1400004e7d0 pc=0x137863f64
created by runtime.createfing
/usr/local/go/src/runtime/mfinal.go:157 +0x94
error: script "gen" exited with code 6 (SIGABRT)
Right now I'm doing this, which prints out the dialog, but doesn't make it interactive. Is there any built-in way to do interactive dialogs?
import blipgloss from "blipgloss";
// Adapted from https://github.com/wobsoriano/blipgloss/blob/main/examples/layout.ts
const docStyle = blipgloss.NewStyle().Padding(1, 2, 1, 2);
const doc: string[] = [];
const width = 72;
const dialogBoxStyle = blipgloss
.NewStyle()
.Border(blipgloss.Border.Rounded)
.BorderForeground("#56949f")
.Padding(1, 0)
.BorderTop(true)
.BorderLeft(true)
.BorderRight(true)
.BorderBottom(true);
const buttonStyle = blipgloss
.NewStyle()
.Foreground("#faf4ed")
.Background("#575279")
.Padding(0, 3)
.MarginTop(1);
const activeButtonStyle = buttonStyle
.Copy()
.Foreground("#faf4ed")
.Background("#b4637a")
.MarginRight(2)
.Underline(true);
const okButton = activeButtonStyle.Render("Yes");
const cancelButton = buttonStyle.Render("No");
const question = blipgloss
.NewStyle()
.Width(50)
.Align(blipgloss.Position.Center)
.Render(`Update ${outdated.map((model) => model.name).join(", ")}?`);
const buttons = blipgloss.JoinHorizontal(
blipgloss.Position.Top,
okButton,
cancelButton
);
const ui = blipgloss.JoinVertical(
blipgloss.Position.Center,
question,
buttons
);
const dialog = blipgloss.Place(
width,
9,
blipgloss.Position.Center,
blipgloss.Position.Center,
dialogBoxStyle.Render(ui),
blipgloss.WithWhitespaceChars("๐ฆ"),
);
doc.push(dialog);
console.log(docStyle.Render(doc.join("\n\n")));
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.