Git Product home page Git Product logo

simpletable's People

Contributors

0xflotus avatar alexeyco avatar elisaado avatar povsister avatar woosley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

simpletable's Issues

Color Support?

Does this support cell coloring? foreground? background? full or partial?

color

hi. im wondering how to add color to your tables style

Multiple header support?

This may already be possible and I have tried several different iterations to try and make it work but I am trying to have a header with the table name that spans the whole width and then under that the normal header with the column names.

+------------------------------------------------------------------+
|                            HEADER                                |
+---+-----------+-------------------------------+-------+----------+
| # |   FIELD   |            FIELD              | FIELD |  FIELD   |
+---+-----------+-------------------------------+-------+----------+

 table.Header = &simpletable.Header{
         Cells: []*simpletable.Cell{
             {Align: simpletable.AlignCenter, Span: 5, Text: "HEADER"},  
             {Align: simpletable.AlignCenter, Text: "#"},
             {Align: simpletable.AlignCenter, Text: "FIELD"},
             {Align: simpletable.AlignCenter, Text: "FIELD"},
             {Align: simpletable.AlignCenter, Text: "FIELD"},
             {Align: simpletable.AlignCenter, Text: "FIELD"},
         },
     }

Maybe something like this.

append(table.Header, Cells:[]*simpletable.Cell{ 
     Align: simpletable.AlignCenter,
     Span: 5,
     Text: "HEADER"
  })

This code is obviously not going to work but I have been unable to figure out a way to do this. Is this possible? Or do you have any suggestions and finally I am sorry to bother you with this your time is greatly appreciated I hate submitting issues for things like this but I have been unable to locate any information on forums about this.
Thank you,
Jason C.

can you support chinese?

Hello, I found this a very useful tool, but can you support Chinese, because if the table content is Chinese and the table cannot be aligned, I try to modify the realLength function in content.go and change utf8.RuneCountInString to len, but it no effect

Is Span supported in the header?

Hey Alex,

Thanks for this great library.

I am having an issue adding Span to the header. Any idea what I am doing wrong? I posted the error and code below.

Regards,
Maruf

Error:

/usr/local/Cellar/go/1.15.5/libexec/bin/go build -o /private/var/folders/wh/fnt_yh0n5mxfmttpjts9l9jc0000gp/T/___go_build_main_go__2_ /Users/m0a00v4/go/src/github.com/simpletable/_example/05-colorize/main.go #gosetup
/private/var/folders/wh/fnt_yh0n5mxfmttpjts9l9jc0000gp/T/___go_build_main_go__2_
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x10d2ca9]

goroutine 1 [running]:
github.com/alexeyco/simpletable.(*Table).prepareColumns(0xc0000de000)
        /Users/m0a00v4/go/src/github.com/alexeyco/simpletable/table.go:257 +0xb69
github.com/alexeyco/simpletable.(*Table).String(0xc0000de000, 0xc000092b60, 0xc0000ac040)
        /Users/m0a00v4/go/src/github.com/alexeyco/simpletable/table.go:34 +0xdc
github.com/alexeyco/simpletable.(*Table).Println(0xc0000de000)
        /Users/m0a00v4/go/src/github.com/alexeyco/simpletable/table.go:65 +0x2f
main.main()
        /Users/m0a00v4/go/src/github.com/simpletable/_example/05-colorize/main.go:47 +0x97f

Process finished with exit code 2

Code:

func main() {
	table := simpletable.New()

	table.Header = &simpletable.Header{
		Cells: []*simpletable.Cell{
			{Align: simpletable.AlignCenter, Text: "FOO"},
			{Align: simpletable.AlignCenter, Text: "BAZ"},
			{Align: simpletable.AlignRight, Span: 2, Text: "BAR"},
		},
	}

	table.Body = &simpletable.Body{
		Cells: [][]*simpletable.Cell{
			{
				&simpletable.Cell{Text: red("I am red")},
				&simpletable.Cell{Text: green("I am green")},
				&simpletable.Cell{Text: blue("I am blue")},
				&simpletable.Cell{Text: blue("I am blue 2")},

			},
		},
	}

	table.Footer = &simpletable.Footer{
		Cells: []*simpletable.Cell{
			{Align: simpletable.AlignCenter, Span: 4, Text: gray("And all columns is well sized")},
		},
	}

	table.Println()
} 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.