Skip to content

Conversation

niten94
Copy link

@niten94 niten94 commented Oct 2, 2025

This pull request switches all Unix platforms to only one implementation, that uses some functions in x/term like upstream to set the terminal to raw mode and restore it. This is done to avoid related bugs on new platform releases by relying on a module instead, and also deduplicate code.

This was mainly done to fix a bug on OpenBSD 7.5 or newer where the screen doesn't start, which also requires builds to be done using Go 1.23 or newer.

Previous implementations also specifically had at least one of these issues:

  • incorrect usage of Syscall*() (BSD systems)
  • VMIN and VTIME not set (BSD systems)
  • termios not copied as a whole prior to modification (Linux, Solaris)

There had been no issues when I tested on Linux, OpenBSD, FreeBSD and OpenIndiana (illumos distribution, like Solaris).

This pull request replaces #2 which is similar, but it is slightly modified to present changes better.

Related: zyedidia/micro#3557

On Linux, set the terminal to raw mode and restore it using MakeRaw()
and Restore() in x/term respectively, which is used upstream in place of
x/sys/unix.IoctlSetTermios() or syscall.Syscall6() in other platforms.

MakeRaw() performs the same changes with certain termios fields, but
copies the whole struct prior instead of those fields only.
Switch to Linux screen implementation on all Unix platforms excluding
MacOS, and add Unix platforms that are supported upstream only to the
build constraint.

The modifications on certain termios fields only differ on BSD systems
where VMIN and VTIME were not modified.
@niten94
Copy link
Author

niten94 commented Oct 2, 2025

@JoeKar @dmaluka

Only new OpenBSD releases will benefit currently if this PR is merged, but may this at least be reviewed sometime, since it has been more than 1 year since such releases where Micro stopped running?

I think I've read on OpenBSD mailing lists that Tcell cannot be patched in their package of Micro due to being a Go dependency, but I don't remember which thread I have read this.

@dmaluka
Copy link

dmaluka commented Oct 2, 2025

Quick questions (without looking into this in any depth):

  1. Is this a v2.0.14 regression?
  2. Are these fixes applicable to upstream tcell?

I guess we cannot guarantee a fast review, but we can add zyedidia/micro#3557 to the list of blockers for v2.0.15 (https://github.com/zyedidia/micro/milestone/3) if needed.

@niten94
Copy link
Author

niten94 commented Oct 3, 2025

Quick questions (without looking into this in any depth):

  1. Is this a v2.0.14 regression?
  2. Are these fixes applicable to upstream tcell?
  1. No, but this fixes a bug that doesn't occur upstream. OpenBSD 7.5 and newer is currently the only platform where the screen cannot start, due to a lot of factors including the removal of syscall(2) which are addressed in Go 1.23 and x/term.

  2. No, since upstream Tcell already switched to one generic implementation that uses x/term:
    https://github.com/gdamore/tcell/blob/d86b440bcb24a485e77211ed87edb91c6f600fe5/tty_unix.go#L83

I guess we cannot guarantee a fast review

I could understand that this PR may not be reviewed early or fast, due to probably having less priority than other issues that are more important to Micro itself.

Still, I believe that this PR shouldn't take too long to review since it switches to functions in x/term like upstream as a somewhat quick fix, which are similar to the code replaced in this PR.

but we can add zyedidia/micro#3557 to the list of blockers for v2.0.15 (https://github.com/zyedidia/micro/milestone/3) if needed.

It may not seem pleasant for users on a specific platform that Micro remains broken 1 year after the previous version, so I would suggest to do this.

@JoeKar
Copy link
Member

JoeKar commented Oct 3, 2025 via email

@dmaluka
Copy link

dmaluka commented Oct 5, 2025

I've looked through the changes, looks quite sane. But I haven't tested it on anything other than Linux.

The differences with the original implementation are the same with BSD
systems.
@niten94 niten94 force-pushed the legacy/term-makeraw branch from 10d8c90 to 46e2256 Compare October 13, 2025 15:15
@JoeKar JoeKar merged commit 278d925 into micro-editor:legacy Oct 13, 2025
@JoeKar
Copy link
Member

JoeKar commented Oct 13, 2025

In micro's go.mod#L11 we can now refer to tcell's v2.0.12 tag.

@niten94
Copy link
Author

niten94 commented Oct 13, 2025

I'll make a PR on Micro this week and try to post a notice to the OpenBSD mailing list.

I have also noticed that a workflow failed on this repository, but I was able to run go build -v . on Tcell using Go 1.19. It seems to be caused by the workflow building using Go 1.13, and old build constraint comments being removed in the updated x/sys version.

The workflow didn't run on my fork due to the reason displayed as below in the Actions tab:
image

It probably doesn't need to be addressed, since the legacy branch will unlikely be updated much. I also plan to discuss and start the sync with upstream after current tasks like the release of 2.0.15 are done.

@JoeKar
Copy link
Member

JoeKar commented Oct 13, 2025

I was also noticed by mail and fixed the legacy workflow with the min. required go version 1.18. 😉
So we can use v2.0.13 now.

BTW:

The workflow didn't run on my fork due to the reason displayed as below in the Actions tab:

This can be changed in you fork with the repository settings...
grafik

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 this pull request may close these issues.

3 participants