profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/kjellkvinge/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.

kjellkvinge/gocover 21

test coverage analysis in your terminal

kjellkvinge/excalidrawserver 0

selfhosted excalidraw

kjellkvinge/fgallery 0

a modern, minimalist javascript photo gallery

kjellkvinge/gitea 0

Gitea: Git with a cup of tea

kjellkvinge/go-livereload 0

Golang implementation of Livereload.

kjellkvinge/gonagall 0

Web-gallery system written in Go Language

kjellkvinge/hacker-slides 0

A small UI for building presentation slides from markdown markup

kjellkvinge/kind 0

Kubernetes IN Docker - local clusters for testing Kubernetes

kjellkvinge/kjellkvinge.github.io 0

home on kjellkvinge.github.io

kjellkvinge/lightbox2 0

The original lightbox script, now on Github!

fork kjellkvinge/go-livereload

Golang implementation of Livereload.

fork in 2 days

create barnchkjellkvinge/gocover

branch : issue_6_better_example

created branch time in 2 months

issue commentpterm/pterm

boxed table - style is not reset between cells

Thank you. The remaining bugs are probably my own 😆 I'm actually try to make a markdownrenderer using this library. This issue came up with the table component. I didn't realize that you had this in the pipeline (#14) If you are interested I can share what I got. Maybe some of it can be useful for you?

kjellkvinge

comment created time in 2 months

issue commentpterm/pterm

boxed table - style is not reset between cells

No worries. Enjoy you vacation 😃

kjellkvinge

comment created time in 3 months

issue commentpterm/pterm

boxed table - style is not reset between cells

Could the bug be in Sprint?

I notice the reset code is replaced by the new style. Now, we keep the reset and add the new style.

--- a/color.go
+++ b/color.go
@@ -151,7 +151,7 @@ func (c Color) Sprint(a ...interface{}) string {
 	message := Sprint(a...)
 	messageLines := strings.Split(message, "\n")
 	for i, line := range messageLines {
-		messageLines[i] = color.RenderCode(c.String(), strings.ReplaceAll(line, color.ResetSet, Sprintf("\u001B[%sm", c.String())))
+		messageLines[i] = color.RenderCode(c.String(), strings.ReplaceAll(line, color.ResetSet, Sprintf("\u001B[%sm%s",color.ResetSet, c.String())))
 	}
 	message = strings.Join(messageLines, "\n")
 	return message

There is a similar line in func (s Style) Sprint(a ...interface{}) string {

kjellkvinge

comment created time in 3 months

issue commentpterm/pterm

boxed table - style is not reset between cells

A second look, this patch fixes my case, but i probably break something else?

--- a/box_printer.go
+++ b/box_printer.go
@@ -266,11 +266,11 @@ func (p BoxPrinter) Sprint(a ...interface{}) string {
 	ss := strings.Split(boxString, "\n")
 	for i, s2 := range ss {
 		if runewidth.StringWidth(RemoveColorFromString(s2)) < maxWidth {
-			ss[i] = p.BoxStyle.Sprint(p.VerticalString) + strings.Repeat(" ", p.LeftPadding) + p.TextStyle.Sprint(s2) +
+			ss[i] = p.BoxStyle.Sprint(p.VerticalString) + strings.Repeat(" ", p.LeftPadding) + s2 +
 				strings.Repeat(" ", maxWidth-runewidth.StringWidth(RemoveColorFromString(s2))+p.RightPadding) +
 				p.BoxStyle.Sprint(p.VerticalString)
 		} else {
-			ss[i] = p.BoxStyle.Sprint(p.VerticalString) + strings.Repeat(" ", p.LeftPadding) + p.TextStyle.Sprint(s2) +
+			ss[i] = p.BoxStyle.Sprint(p.VerticalString) + strings.Repeat(" ", p.LeftPadding) + s2 +
 				strings.Repeat(" ", p.RightPadding) + p.BoxStyle.Sprint(p.VerticalString)
 		}
 	}

kjellkvinge

comment created time in 3 months

issue openedpterm/pterm

boxed table - style is not reset between cells

Hi. Thank you for this great project.

I notice that when a cell contains a string formated with style (i.e bold or italic), the next cell is "infected" with the same style. This is only reproducible in boxed mode.

concider the following code:

func TestBox(t *testing.T) {
	line := pterm.Italic.Sprint("italic")


	table, _ := pterm.DefaultTable.WithBoxed().WithData(
		[][]string{
			{line, "a", "b", "c"},
		}).Srender()

	fmt.Println(table)

	table, _ = pterm.DefaultTable.WithData(
		[][]string{
			{line, "a", "b", "c"},
		}).Srender()

	fmt.Println(table)

	pterm.DefaultBox.Println(table)
}

I get the following. You can see that the normal table renders fine, but in box-mode - all the rest of the line is italic.

Screenshot from 2021-07-29 01-43-51

This is probably a problem with BoxPrinter, as you can see with:

pterm.DefaultBox.Println("normal", pterm.Bold.Sprint("bold."), "this should not be bold\nnewline fixes")

Thank you.

created time in 3 months