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

Port bundled linenoise to windows #1612

Merged
merged 1 commit into from
Jun 3, 2023
Merged

Port bundled linenoise to windows #1612

merged 1 commit into from
Jun 3, 2023

Conversation

benjaminwinger
Copy link
Collaborator

Adapted from https://github.com/microsoftarchive/redis/blob/3.0/deps/linenoise/linenoise.c and https://github.com/LuaDist-testing/linenoise-windows/blob/master/linenoise-windows/linenoise.c.

Those also make some more changes which I'm not sure are necessary, but (linenoise-windows replaces some control characters with windows API calls; which may be necessary with older versions of windows since it sounds like the ANSI control code support is recent, but I tried to keep this as small as possible rather than blindly copying stuff, particularly since linenoise-windows is for an older version of linenoise which is missing a bunch of stuff).

Generally it seems to work. I tested the basic functionality and most of the control codes (one thing I had to fix myself; the ports linked above tried had special handling to read the control codes which seemed to be broken, but it works without the special case).

I had to disable highlighting on windows, which was badly broken. According to https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences it should be possible to use colour codes if you set the ENABLE_VIRTUAL_TERMINAL_PROCESSING console mode flag, but setting that always failed on the terminal I was testing with. Even without that the colour codes had an effect (it did seem to turn text green), but behaved badly. There are windows API calls which can be used to control the formatting instead, but I don't think that would work very well with the current way highlighting is done since I think they all write directly to the console, rather than to a buffer (since they don't use special characters I guess).

There are also some alternative libraries which are cross-platform, but this seemed like the most straightforward way of getting it working.

  • Crossline: Not very active, but small and simple. It doesn't support unicode.
  • linenoise-ng: A somewhat more modern version of linenoise which supports unicode, but is unmaintained and has been inactive for 6 years.
  • replxx: Seems like the most active and feature-rich, though nothing has been merged for 1.5 years.

@codecov
Copy link

codecov bot commented Jun 2, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.01 ⚠️

Comparison is base (ae9ac90) 92.00% compared to head (2e76aab) 91.99%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1612      +/-   ##
==========================================
- Coverage   92.00%   91.99%   -0.01%     
==========================================
  Files         715      715              
  Lines       26067    26067              
==========================================
- Hits        23982    23981       -1     
- Misses       2085     2086       +1     

see 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@acquamarin acquamarin merged commit 2e0f617 into master Jun 3, 2023
8 checks passed
@acquamarin acquamarin deleted the linenoise-windows branch June 3, 2023 21:44
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.

None yet

2 participants