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

Review ConsolePrompt's method visibilities #1141

Closed
mattirn opened this issue Dec 23, 2024 · 2 comments · Fixed by #1148
Closed

Review ConsolePrompt's method visibilities #1141

mattirn opened this issue Dec 23, 2024 · 2 comments · Fixed by #1148
Milestone

Comments

@mattirn
Copy link
Collaborator

mattirn commented Dec 23, 2024

  1. ConsolePrompt do not implement AutoCloseable
  2. Create open() method that set terminal in raw mode (the last four statement of the constructor)
  3. enclose prompt methods
    1. public Map<String, PromptResultItemIF> prompt(List<AttributedString> header, List<PromptableElementIF> promptableElementList) and
    2. public Map<String, PromptResultItemIF> prompt(List<AttributedString> headerIn, Function<Map<String, PromptResultItemIF>, List<PromptableElementIF>> promptableElementLists)

code with "open() - close()" i.e.

    public Map<String, PromptResultItemIF> prompt(...) throws IOException {
        try {
            open();
            ....
            ....
            return resultMap;
        } finally {
            close();
        }
    }
  1. remove @Deprecated statements
  2. review ConsolePrompt's other methods visibilities
  3. fix examples
@quintesse
Copy link
Contributor

quintesse commented Dec 23, 2024

Ok, so if I understand this correctly this would roll back the change that made ConsolePrompt AutoCloseable?

If so another improvement might be introduce a subclass of ConsolePrompt that does implement AutoCloseable and that handles the open/close for you.

And perhaps (but I haven't thought it through a 100% yet) we would not even need a (public) open() necessarily, thereby maintaining full backward compatibility with older code (but we'd advise people to switch to the newer, improved, AutoCloseable version of ConsolePrompt)

WDYT?

@mattirn
Copy link
Collaborator Author

mattirn commented Jan 6, 2025

Ok, so if I understand this correctly this would roll back the change that made ConsolePrompt AutoCloseable?

Yes.

If so another improvement might be introduce a subclass of ConsolePrompt that does implement AutoCloseable and that handles the open/close for you.

There are only two methods where we need to call open(), close() methods. IMHO there is no real advantage to introduce a AutoCloseable subclass.

And perhaps (but I haven't thought it through a 100% yet) we would not even need a (public) open() necessarily, thereby maintaining full backward compatibility with older code (but we'd advise people to switch to the newer, improved, AutoCloseable version of ConsolePrompt)

I think it is better break now backward compatibility. The old dynamic prompt API is available only in JLine 3.28.0. Those who have started to use old API must migrate to the new one when they start to use JLine version > 3.28.0.

quintesse added a commit to quintesse/jline3 that referenced this issue Jan 8, 2025
quintesse added a commit to quintesse/jline3 that referenced this issue Jan 16, 2025
quintesse added a commit to quintesse/jline3 that referenced this issue Jan 16, 2025
@gnodet gnodet modified the milestones: 3.28.1, 3.28.2, 3.29.1, 3.29.0 Jan 30, 2025
@gnodet gnodet closed this as completed in a6a7786 Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants