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

[WIP] Reconstruct TAB character when copying from grid #999

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Utkarsh-khambra
Copy link
Collaborator

@Utkarsh-khambra Utkarsh-khambra commented Jan 22, 2023

handles Tabstops.
Previously tried to track tab character by storing starting tab positions in Line but soon abandoned that since in a lot of places we directly handle cells then those places needed to be changed as well. So right now tracking tabs by setting a flag(bool) for each cell.

@github-actions github-actions bot added the VT: Backend Virtual Terminal Backend (libterminal API) label Jan 22, 2023
@christianparpart
Copy link
Member

I think it's actually harder than it looks. How's VTE lib doing that? I mean, writing A\tB will write A to (say) column 1 and B to column 9 as the \t will move the cursor forward to the next tab stop (default modulo 8). So far so good.
Which cell does not remember the tabstop? Cell at column 2, or all cells in between? 🤔 I think that's hard to say, but maybe all spacing cells in between should get that flag (or only that at which you've been writing the TAB, column 2).
Now however, what if the cursor is placed in between A and B. say, column 4, to write a C?
The only think I can make sense here is to destroy the remembered TAB information and make it look like simple spaces (or empty cells), dropping the TAB flag, then writing the C at column 4. So now we'd have A C B which used to be A\tB if reconstructed from the line.

Another note, a bool takes 8 bits, probably with padding. maybe we can make it part of CellFlags that is stored in CellExtra for the CompactCell case.

Also, the CellConcept must reflect the API change in the Cell (if we stick with this). You could probably simplify here if moving that information to CellFlags.

@christianparpart christianparpart changed the title WIP [WIP] Reconstruct TAB character when copying from grid Jan 22, 2023
@Utkarsh-khambra
Copy link
Collaborator Author

Utkarsh-khambra commented Jan 22, 2023

Which cell does not remember the tabstop? Cell at column 2, or all cells in between? thinking I think that's hard to say, but maybe all spacing cells in between should get that flag (or only that at which you've been writing the TAB, column 2).

Currently I am doing all cells in between get the flag, we can also do that only first one gets the flag but then to check which others are also covered by tab we need to do calculations every time.

Now however, what if the cursor is placed in between A and B. say, column 4, to write a C?
The only think I can make sense here is to destroy the remembered TAB information and make it look like simple spaces (or empty cells), dropping the TAB flag, then writing the C at column 4. So now we'd have A C B which used to be A\tB if reconstructed from the line.

In gnome terminal if I do printf 'A\tB\e[4DC\n' it converts it into A C\tB, maybe we can also do the same, I don't know what the actual hardware used to do for this case.

Another note, a bool takes 8 bits, probably with padding. maybe we can make it part of CellFlags that is stored in CellExtra for the CompactCell case.Also, the CellConcept must reflect the API change in the Cell (if we stick with this). You could probably simplify here if moving that information to CellFlags

Yep I'll do that.

@Utkarsh-khambra Utkarsh-khambra force-pushed the feature/handle_tabs branch 2 times, most recently from fc34a63 to 9a4c378 Compare January 28, 2023 17:26
@github-actions github-actions bot added the frontend Contour Terminal Emulator (GUI frontend) label Jan 28, 2023
@Utkarsh-khambra Utkarsh-khambra force-pushed the feature/handle_tabs branch 2 times, most recently from 9aec7ad to a3be29e Compare February 12, 2023 06:03
@Utkarsh-khambra
Copy link
Collaborator Author

Utkarsh-khambra commented Feb 12, 2023

Todo

  • handle tabs when in vim mode.
  • handle when a character is inserted between a tab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Contour Terminal Emulator (GUI frontend) VT: Backend Virtual Terminal Backend (libterminal API)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants