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

Word/Line wrap ERROR when x,y,width or height of TextBox are non integers #226

Open
SinanAkkoyun opened this issue Jan 5, 2023 · 0 comments

Comments

@SinanAkkoyun
Copy link

SinanAkkoyun commented Jan 5, 2023

I received following crash:

TypeError: Cannot read properties of undefined (reading 'char')
    at TextBuffer.wrapLine (/mnt/c/Users/.../node_modules/terminal-kit/lib/TextBuffer.js:595:25)
    at TextBuffer.inlineInsert (/mnt/c/Users/.../node_modules/terminal-kit/lib/TextBuffer.js:1501:35)
    at TextBuffer.insert (/mnt/c/Users/.../node_modules/terminal-kit/lib/TextBuffer.js:1388:16)
    at TextBuffer.append (/mnt/c/Users/.../node_modules/terminal-kit/lib/TextBuffer.js:1412:7)
    at TextBox.addContent (/mnt/c/Users/.../node_modules/terminal-kit/lib/document/TextBox.js:495:20)
    at TextBox.appendContent (/mnt/c/Users/.../node_modules/terminal-kit/lib/document/TextBox.js:466:80)
    at ClientEventEmitter.<anonymous> (/mnt/c/Users/.../src/index.ts:216:26)
    at ClientEventEmitter.emit (node:events:525:35)

I could remove the crash by replacing:

const speechBox = new terminalkit.TextBox( {
  parent: document ,
  // content: text ,
  // contentHasMarkup: true ,
  scrollable: true ,
  vScrollBar: false ,
  // lineWrap: true ,
  wordWrap: true ,
  x: document.outputWidth * 0.4,
  y: 0 ,
  width: document.outputWidth * 0.6, // TODO: need to find responsive solution
  height: document.outputHeight - 2,
  resizable: true
})

with:

const speechBox = new terminalkit.TextBox( {
  parent: document ,
  // content: text ,
  // contentHasMarkup: true ,
  scrollable: true ,
  vScrollBar: false ,
  // lineWrap: true ,
  wordWrap: true ,
  x: Math.round(document.outputWidth * 0.4) , // padding etc
  y: 0 ,
  width: Math.round(document.outputWidth * 0.6), // TODO: need to find responsive solution
  height: document.outputHeight - 2,
  resizable: true
})

Please incorporate that into the package itself! Thank you so much for the document feature, it's the most amazing thing I've ever seen with CLIs

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

No branches or pull requests

1 participant