Skip to content

Migrating to Tcell v3 #2284

@joelim-work

Description

@joelim-work

A new major version of the Tcell library has been recently been released, which includes breaking changes that need to be addressed in the code. I have analyzed the codebase briefly and compiled a list of potential changes that should be made:

  • The PollEvent function should be replaced with the EventQ channel where terminal events can be directly read from.
  • The Style.Decompose function has been removed, which means it might no longer be possible to implement the SGR 8 terminal sequence (concealed text) as Tcell does not support it directly. However I think it is a niche feature that isn't necessary to have, and the current implementation is a hacky workaround that sets the foreground color to the background color.
  • KeyBackspace2 will no longer be sent, and will instead be mapped to KeyBackspace. This means that support for the <backspace2> key can dropped as <backspace> alone will be sufficient.
  • EventKey now contains a string instead of a rune, and the code needs to be changed for both reading keys (EventKey to string) and pushing keys (string to EventKey).
  • The special keys KeyCtrlSpace, KeyCtrlLeftSq, KeyCtrlRightSq, KeyCtrlBackslash, KeyCtrlCarat and KeyCtrlUnderscore have been removed, and are instead represented as a rune key with the ModCtrl mask. This is problematic because special keys and rune keys have different processing logic so it will have to be adjusted to handle the new changes. Perhaps it is worth creating utility functions for converting between EventKey and string, which can then be unit tested.
  • The existing SetContent function is used to assign runes to individual cells, however there are now high-level PutStr/PutStrStyled functions for writing entire strings, and from my testing it appears to support terminal sequences inside those strings, but it may not work for every case. I am fine with leaving the existing win.print unchanged for now.

Some of these changes are straightforward, but that may not be the case for others. Fortunately I have just released a new version of lf, so there will be ample time to test the new changes before releasing them in the following version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingPull requests that introduce breaking changesdependenciesPull requests that update a dependency filegoPull requests that update Go code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions