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

Can't compose user terminal resize logic with Reline's terminal resize logic #735

Closed
fractaledmind opened this issue Aug 10, 2024 · 0 comments · Fixed by #788
Closed

Can't compose user terminal resize logic with Reline's terminal resize logic #735

fractaledmind opened this issue Aug 10, 2024 · 0 comments · Fixed by #788

Comments

@fractaledmind
Copy link

Description

I am building a CLI that uses Reline. In this CLI, I render a box at the top of the screen before the readline input:

 ┌──────────────────────────────────────────────────┐
 │                                                  │
 │                                                  │
 └──────────────────────────────────────────────────┘

   > |

I want to ensure that this box looks decent in various terminal window sizes. I am trying to avoid something like this:

 ┌───────────────────────────────────────────────
───┐
 │                                              
    │
 │                                              
    │
 └───────────────────────────────────────────────
───┘

   > |

In order to ensure the box stays decent, I need to react to the terminal window being resized; this means that I need to trap the WINCH signal.

Unfortunately, Reline traps that signal and provides no way for me run my own resize code as well. I expect to be able, in some way, to define my own resize hook that composes with Reline's resize hook.

fractaledmind added a commit to fractaledmind/reline that referenced this issue Aug 10, 2024
Resolves ruby#735

Just as the `handle_interrupted` method runs Reline's interrupt hook logic and then runs any user-defined interrupt hook logic, `handle_resized` should run Reline's resize hook logic and then run any user-defined resize logic.

This allows user CLI's with additional content in addition to the Reline prompt to ensure that additional content is rendered properly as the terminal is resized.

Note: This is my best first attempt at this solution as someone who has only read the source code here today. There may be details/considerations that are important that I missed or didn't consider. I am very open to changes as necessary.

cc: @st0012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant