mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #698] TextView adds extra spaces at the end of each line #509
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#509
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AmrGanz on GitHub (Feb 3, 2022).
Original GitHub issue: https://github.com/rivo/tview/issues/698
When I display some text in TextView while disabling the mouse [EnableMouse(false)]. The lines seems to have unnecessary spaces at the end:
Example code:
@rivo commented on GitHub (Apr 14, 2022):
I'm not sure I understand. If mouse handling is turned off, dragging your mouse on the screen will cause text to be highlighted/selected in most terminals. It's not a functionality of
tviewbut of the terminal you're using. Here's what it looks like when I randomly drag the mouse in iTerm2 on macOS:It has nothing to do with the
TextViewcomponent.Or am I missing something here?
@AmrGanz commented on GitHub (Apr 24, 2022):
Hello Rivo,
If I
cata file in the terminalfor example /etc/passwd, and if I highlight the first line, it will not show extra empty characters at the end of it, rather it will immediately jump to the next linesince it understands the new line character.But, in the textview case, I think it adds empty characters till it hits the new line.
I could think of this test:
1- Use the same code I shared in this issue
2- Count the text characters
without running the code3- Run the code and highlight
with mousethe text from the first character in the first line till the last character in the last line and copy it4- Add the copied characters to a file and count the number of characters there and it will show a different and bigger number compared to the first count in step 2
I ran this test and got these counts:
@rivo commented on GitHub (Dec 17, 2022):
Yes, it does that. The nature of
tview(or, rather,tcell, whichtviewuses) is that it uses the entire screen to draw content into it. That's very different from printing a few characters into a regular terminal session, like withechoor something similar. Terminals deal with that case differently.Maybe this becomes more obvious if you include a border:
The characters between the text and the right border are technically spaces.
I would say that using
TextViewor actuallytviewin general is the wrong tool if you're looking for "normal" terminal-like behaviour. Having said that, there is a discussion (#774) which might result in me adding text selection toTextViewwhen the mouse is enabled. I can't say at this point when this will be introduced, however. And even when it is, it will still work differently from directly selecting and copy+pasting content. (For example, it still won't be able to handle Cmd-C+Cmd-V on Macs as those are not sent directly to the application running inside the terminal.)@AmrGanz commented on GitHub (Dec 17, 2022):
Hello @rivo ,
Thank you for getting back to me on this, I always appreciate your help.
You made a valid point, as I didn't look at this "issue" from such a perspective, and now I see why it won't be possible to show output on TextView on such a way.
Thanks again, I will close this ticket.