tui-go
tui-go copied to clipboard
Add simple border
Widget Grid can use SetSimpleBorder() to set the simple border. look like:
+----------+--------------+------+-----+---------+----------------+
| FIELD | TYPE | NULL | KEY | DEFAULT | EXTRA |
+----------+--------------+------+-----+---------+----------------+
| user_id | smallint(5) | NO | PRI | NULL | auto_increment |
+----------+--------------+------+-----+---------+----------------+
| username | varchar(10) | NO | | NULL | |
+----------+--------------+------+-----+---------+----------------+
| password | varchar(100) | NO | | NULL | |
+----------+--------------+------+-----+---------+----------------+
default
┌────────────┬──────────────┬───────┬───────┬──────────┬──────────────────┐
│FIELD │ TYPE │ NULL │ KEY │ DEFAULT │ EXTRA │
├────────────┼──────────────┼───────┼───────┼──────────┼──────────────────┤
│ user_id │ smallint(5) │ NO │ PRI │ NULL │auto_increment │
├────────────┼──────────────┼───────┼───────┼──────────┼──────────────────┤
│ username │ varchar(10) │ NO │ │ NULL │ dog │
├────────────┼──────────────┼───────┼───────┼──────────┼──────────────────┤
│ password │ varchar(100) │ NO │ │ NULL │ dog │
└────────────┴──────────────┴───────┴───────┴──────────┴──────────────────┘
I think this is a nice addition! Although ideally I think this could be considered a global theme setting (I don't see people using both default and simple border in the same application, but I could be wrong. I'm thinking possibly adding a method to the Theme struct (maybe tui.SetBorderStyle(tui.BorderStyleSimple)
). Then, instead of checking the border style in each widget, maybe add a new tui.DrawRectangle()
to the Painter
struct. Since Painter
has access to the current theme, you could do the lookup there instead. What do you think?
Thanks for your advice.
Before submitting this pr, I thought there were many ways to implement this feature without breaking the original design. One scene that makes me want to use two borders at the same time is that I use tui-go
to create a terminal app which has a login
page and many forms. The login
in example is very pretty, you can display different forms after login. The report uses a simple border to make it look easier.
Making changes in the Painter
allows for more flexible functionality and more considerations. Now that I have some good ideas for adding functionality to Painter
.