Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A grid with a single column and fixed width n only hold n-1 characters #66

Closed
bkahlert opened this issue Jul 20, 2022 · 3 comments · Fixed by #74
Closed

A grid with a single column and fixed width n only hold n-1 characters #66

bkahlert opened this issue Jul 20, 2022 · 3 comments · Fixed by #74

Comments

@bkahlert
Copy link

The following code should render a grid with a single cell (fixed 80 width)
and its content of 80 1-width characters in a single line.

Terminal().render(
                    grid {
                        cellBorders = NONE
                        padding(0, 0, 0, 0)
                        column(0) {
                            width = ColumnWidth.Fixed(80)
                        }
                        row {
                            whitespace = PRE_LINE
                            verticalAlign = TOP
                            overflowWrap = BREAK_WORD
                            cell("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod.")
                        }
                    }
                )

Expected

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod.

Actual

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod.

Removing one character from the content string makes the grid widget consume only a single line.

@bkahlert
Copy link
Author

Here's the state of the grid widget; I suppose it might have something to do with the single spaces in the borderStyle property.

{
    tableBorders: NONE,
    rows: [
              [
                  Content(content=Text(Lorem ipsum dolor sit ame…), rowSpan=1, columnSpan=1, borderLeft=false, borderTop=false, borderRight=false, borderBottom=false, style=null, textAlign=LEFT, verticalAlign=TOP)
              ]
          ],
    rowBorders: [
                    false,
                    false
                ],
    headerRowCount: 0x00,
    footerRowCount: 0x00,
    expand: false,
    columnStyles: {
                      0x00: {
                                width: 0x50
                            }
                  },
    columnCount: 0x01,
    columnBorders: <List@40545>,
    borderWidth: 0x00,
    borderType: {
                    headBottom: {
                                    w: " ",
                                    sw: " ",
                                    s: " ",
                                    nw: " ",
                                    nsw: " ",
                                    ns: " ",
                                    new: " ",
                                    nesw: " ",
                                    nes: " ",
                                    ne: " ",
                                    n: " ",
                                    ew: " ",
                                    esw: " ",
                                    es: " ",
                                    e: " ",
                                    array: [
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " "
                                           ]
                                },
                    head: {
                              w: " ",
                              sw: " ",
                              s: " ",
                              nw: " ",
                              nsw: " ",
                              ns: " ",
                              new: " ",
                              nesw: " ",
                              nes: " ",
                              ne: " ",
                              n: " ",
                              ew: " ",
                              esw: " ",
                              es: " ",
                              e: " ",
                              array: [
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " "
                                     ]
                          },
                    foot: {
                              w: " ",
                              sw: " ",
                              s: " ",
                              nw: " ",
                              nsw: " ",
                              ns: " ",
                              new: " ",
                              nesw: " ",
                              nes: " ",
                              ne: " ",
                              n: " ",
                              ew: " ",
                              esw: " ",
                              es: " ",
                              e: " ",
                              array: [
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " "
                                     ]
                          },
                    bodyBottom: {
                                    w: " ",
                                    sw: " ",
                                    s: " ",
                                    nw: " ",
                                    nsw: " ",
                                    ns: " ",
                                    new: " ",
                                    nesw: " ",
                                    nes: " ",
                                    ne: " ",
                                    n: " ",
                                    ew: " ",
                                    esw: " ",
                                    es: " ",
                                    e: " ",
                                    array: [
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " ",
                                               " "
                                           ]
                                },
                    body: {
                              w: " ",
                              sw: " ",
                              s: " ",
                              nw: " ",
                              nsw: " ",
                              ns: " ",
                              new: " ",
                              nesw: " ",
                              nes: " ",
                              ne: " ",
                              n: " ",
                              ew: " ",
                              esw: " ",
                              es: " ",
                              e: " ",
                              array: [
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " ",
                                         " "
                                     ]
                          }
                },
    borderStyle: TxtStyle(color=null, bgColor=null, bold=false, italic=false, underline=false, dim=false, inverse=false, strikethrough=false, hyperlink=null, hyperlinkId=null)
}

@ajalt
Copy link
Owner

ajalt commented Jul 21, 2022

Thanks for the report! I don't think there's any problem with grid. If you're running on JVM, mordant doesn't automatically detect terminal width at startup, since it requires a subprocess call. So it's wrapping because the default terminal width it 79 characters.

You can call terminal.info.updateTerminalSize() to detect the size, or set it manually when you create the terminal: Terminal(width=120). On native and js, the detection is a sys call, so we do it automatically.

Let me know if that fixes the problem.

@bkahlert
Copy link
Author

I added the terminal.info.updateTerminalSize() call but stty size seems to exit with -1.
I would have to look it up myself but could it be that you need to inherit the environment or use the absolute path to call stty? Running the command in my IntelliJ terminal outputs 25 368.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants