RFR: 8209937: Enhance java.io.Console - provide methods to query console width and height
Alan Bateman
Alan.Bateman at oracle.com
Mon Aug 27 11:29:42 UTC 2018
On 24/08/2018 14:18, Langer, Christoph wrote:
> Hi Rémi, Hi Peter,
>
> thanks for your quick answers.
>
> What you've suggested, Rémi, is perfectly right. I've updated my webrev. The methods were copied from our old implementation (of a different class) where they were provided as static.
>
> I will also think of using an optional. I'm furthermore wondering if we should provide a method "dimensions()" returning an (optional) java.io.Console.Dimension object that contains both height and width...
>
> Here is a new webrev: http://cr.openjdk.java.net/~clanger/webrevs/8209937.1/
I'm in two minds as to whether this API is the right thing to do. Can
you expand a bit on how you are using them? There have been several
requests for additions to the Console API over the years, mostly to
support formatting or exposing the console encoding, but I don't recall
anyone looking for the dimensions. Roger is right that it's a bit of a
slippery slope. As I recall, java.io.Console was deliberately minimized
for Java SE 6 to focus on password input and avoid introducing an
extensive API. In the mean-time, the additional of jshell has exposed
some of the shorting comings and maybe we should look at exposing just
enough to support that type of use-case (editing and line history mostly).
As regards the proposal then I think the API docs will need fleshing out
to define what height and width as the current javadoc isn't clear if it
means bytes, characters, pixels in whatever font is used for the
console, or something else. In addition, the javadoc would need to be
clear that it's just a snaphot of the dimension as it can change at any
time.
-Alan
More information about the core-libs-dev
mailing list