Comparing version 0.0.4 to 0.1.0
@@ -40,4 +40,14 @@ import { CString } from 'bun:ffi'; | ||
Render(text: string): CString; | ||
Copy(): this; | ||
Copy(): Style; | ||
FreeHandle(): void; | ||
private UnsetRule; | ||
UnsetAlign(): this; | ||
UnsetBackground(): this; | ||
UnsetBlink(): this; | ||
UnsetBold(): this; | ||
UnsetBorderBackground(): this; | ||
UnsetBorderBottom(): this; | ||
UnsetBorderBottomBackground(): this; | ||
UnsetBorderBottomForeground(): this; | ||
UnsetBorderForeground(): this; | ||
} | ||
@@ -44,0 +54,0 @@ declare function NewStyle(): Style; |
@@ -71,3 +71,3 @@ "use strict"; | ||
Copy: { | ||
args: [], | ||
args: [import_bun_ffi.FFIType.ptr], | ||
returns: import_bun_ffi.FFIType.ptr | ||
@@ -103,2 +103,6 @@ }, | ||
}, | ||
UnsetRule: { | ||
args: [import_bun_ffi.FFIType.ptr, import_bun_ffi.FFIType.ptr], | ||
returns: import_bun_ffi.FFIType.void | ||
}, | ||
FreeString: { | ||
@@ -230,4 +234,3 @@ args: [import_bun_ffi.FFIType.ptr], | ||
Copy() { | ||
__privateSet(this, _handle, symbols.Copy()); | ||
return this; | ||
return new _Style(symbols.Copy(__privateGet(this, _handle))); | ||
} | ||
@@ -237,2 +240,33 @@ FreeHandle() { | ||
} | ||
UnsetRule(key) { | ||
symbols.UnsetRule(__privateGet(this, _handle), (0, import_bun_ffi3.ptr)(encode(key))); | ||
return this; | ||
} | ||
UnsetAlign() { | ||
return this.UnsetRule("UnsetAlign"); | ||
} | ||
UnsetBackground() { | ||
return this.UnsetRule("UnsetBackground"); | ||
} | ||
UnsetBlink() { | ||
return this.UnsetRule("UnsetBlink"); | ||
} | ||
UnsetBold() { | ||
return this.UnsetRule("UnsetBold"); | ||
} | ||
UnsetBorderBackground() { | ||
return this.UnsetRule("UnsetBorderBackground"); | ||
} | ||
UnsetBorderBottom() { | ||
return this.UnsetRule("UnsetBorderBottom"); | ||
} | ||
UnsetBorderBottomBackground() { | ||
return this.UnsetRule("UnsetBorderBottomBackground"); | ||
} | ||
UnsetBorderBottomForeground() { | ||
return this.UnsetRule("UnsetBorderBottomForeground"); | ||
} | ||
UnsetBorderForeground() { | ||
return this.UnsetRule("UnsetBorderForeground"); | ||
} | ||
}; | ||
@@ -239,0 +273,0 @@ var Style = _Style; |
{ | ||
"name": "blipgloss", | ||
"version": "0.0.4", | ||
"version": "0.1.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "module": "dist/index.mjs", |
@@ -124,4 +124,24 @@ # blipgloss | ||
`TODO` | ||
Just use `Copy()`: | ||
```js | ||
const style = lipgloss.NewStyle().Foreground("219") | ||
const wildStyle = style.Copy().Blink(true) | ||
``` | ||
`Copy()` performs a copy on the underlying data structure ensuring that you get a true, dereferenced copy of a style. Without copying it's possible to mutate styles. | ||
## Unsetting Rules | ||
All rules can be unset: | ||
```js | ||
const style = lipgloss.NewStyle(). | ||
Bold(true). // make it bold | ||
UnsetBold(). // jk don't make it bold | ||
Background("227"). // yellow background | ||
UnsetBackground() // never mind | ||
``` | ||
## Rendering | ||
@@ -128,0 +148,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
10548286
583
157