blessed-contrib icon indicating copy to clipboard operation
blessed-contrib copied to clipboard

Add option to remove borders on grid

Open piranna opened this issue 9 years ago • 17 comments

The grid add a border on all the widgets. Add an option to remove them and only show the lines that separate the cells, it would get a little bit ugly but will allow to get some extra space on too crowd grids used on small screens. Ideally, it should detect complex configurations like the dashboard demo and use the three and four ends like graphics.

piranna avatar Feb 15 '15 20:02 piranna

This could be similar to the separator lines between widgets like the panels in Eclipse or Atom, that also allow to use the mouse to resize them.

piranna avatar Mar 26 '15 15:03 piranna

currently the border comes from blessed and is all-or-nothing: there is no concept of a separator between components - there is only the full border.

yaronn avatar Mar 26 '15 20:03 yaronn

What would be better, a separator as a new widget of only one column/row, or add the option to the windows to only show a line between them?

piranna avatar Mar 26 '15 20:03 piranna

or add the option to the windows to only show a line between them

Sorry, I wanted to say the grid :-P

piranna avatar Mar 26 '15 21:03 piranna

in terms of api this seems a grid concern so users should probably not be aware of new widgets. internally not sure how it is best for the grid to implement it - this would require more delicate calculation of positions and line drawing capabilities from blessed (e.g. infer available characters).

yaronn avatar Mar 26 '15 21:03 yaronn

I suspected something like this...

piranna avatar Mar 26 '15 21:03 piranna

Border docking is now implemented in master and I'm currently working on selective border drawing (border.left = true; border.top = false; etc.).

chjj avatar Apr 06 '15 16:04 chjj

:thumbsup:

yaronn avatar Apr 06 '15 16:04 yaronn

Both border docking and selective borders have been implemented. Border docking/merging works automatically at all angles of every box as long as the borders are the same color. I somehow found a really efficient way to implement it to my surprise. See: https://github.com/chjj/blessed/issues/118#issuecomment-90323945 and https://github.com/chjj/blessed/blob/master/test/widget-dock.js

chjj avatar Apr 07 '15 02:04 chjj

@yaronn, @piranna, it's been a while. What do you think? I think the dockBorders option is pretty nice in combination with something like left: '50%-1'. I think the need for a Separator widget is no longer necessary.

Edited for spelling.

chjj avatar May 14 '15 07:05 chjj

You are right a Separator widget is no longer necessary, only for the use case of click on them and move to resize the grid cells, but maybe now it should be a functionality of the Grid widget itself, isn't it?

piranna avatar May 14 '15 07:05 piranna

I'm not completely familiar with how the grid layout works in blessed-contrib, but blessed now has the Table/ListTable and more importantly the grid Layout option. Both Table and the grid Layout option provide a very dynamic grid-like border. I'm sure the blessed-contrib Grid operates differently most likely though. In any case, it will automatically work with dockBorders.

chjj avatar May 14 '15 08:05 chjj

Yeah, I know blessed-contrib Grid can work automatically with dockBorders option :-) What I'm asking for instead is about allow to click on the separator row/column between two cells (their border) and when moving the mouse, resize the cells on the Grid.

piranna avatar May 14 '15 08:05 piranna

Ah, I see what you're saying. Yeah, that might be tricky because it depends on which Element you were actually mousing down on, however, it could probably be implemented by cleverly looking at mouse movements and direction for each element in the grid.

chjj avatar May 14 '15 18:05 chjj

Could be the dockBorders functionality abstracted, so the Grid manage directly the mouse events on the cells borders/separators and the cells being border-less windows instead of being the Grid a container for several border-overlapping windows? Maybe this way it's easier to implement... Or maybe also fully split the border from the widget themselves and make them border-less while the borders works as a decorator, similarly (but not equal, obviously) to how window managers work...

piranna avatar May 14 '15 20:05 piranna

I think this should be closed since you can now provide the hideBorder boolean to remove them.

balthazar avatar Apr 05 '16 16:04 balthazar

I know this is old - but I'm not sure the hideBorder option is working right, and this issue is still open.

if (!this.options.hideBorder) options.border = {type: "line", fg: this.options.color || "cyan"}

If I remove 'this' from !this.options.hideBorder, it works like I expect it to (I can pass in hideBorder:true per grid widget).

kristerj avatar Oct 12 '18 05:10 kristerj