-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e616ac1
commit 1920bf4
Showing
4 changed files
with
97 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package main | ||
|
||
import "strings" | ||
|
||
type textStyler uint8 | ||
|
||
const ( | ||
styledText textStyler = 1 << iota | ||
dontEndStyle | ||
) | ||
|
||
func (s textStyler) strikethrough(text string) string { | ||
return s.styleTextBlock(text, "\x1b[9m", "\x1b[29m") | ||
} | ||
|
||
func (s textStyler) dim(text string) string { | ||
return s.styleTextBlock(text, "\x1b[2m", "\x1b[22m") | ||
} | ||
|
||
func (s textStyler) bold(text string) string { | ||
return s.styleTextBlock(text, "\x1b[1m", "\x1b[22m") | ||
} | ||
|
||
func (s textStyler) underline(text string) string { | ||
return s.styleTextBlock(text, "\x1b[4m", "\x1b[24m") | ||
} | ||
|
||
func (s textStyler) with(o textStyler) textStyler { | ||
return s | o | ||
} | ||
|
||
func (s textStyler) styleTextBlock(text string, prefix, suffix string) string { | ||
if s&1 == 0 { | ||
return text | ||
} | ||
if s&dontEndStyle != 0 { | ||
suffix = "" | ||
} | ||
lines := strings.Split(text, "\n") | ||
for i, line := range lines { | ||
lines[i] = prefix + line + suffix | ||
} | ||
return strings.Join(lines, "\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
{ | ||
devShells.default = pkgs.mkShell { | ||
packages = with pkgs; [ | ||
go | ||
go_1_21 | ||
gopls | ||
gotools | ||
sqlc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module libdb.so/nix-search | ||
|
||
go 1.20 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/alecthomas/assert/v2 v2.2.2 | ||
|