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 the platform abstraction layer #6

Open
ForNeVeR opened this issue Dec 10, 2017 · 6 comments
Open

Review the platform abstraction layer #6

ForNeVeR opened this issue Dec 10, 2017 · 6 comments

Comments

@ForNeVeR
Copy link
Member

(Probably linked with #5)

Currently, the platform abstraction layer is nearly-nonexistent. We need to make an isolated place for all of the platform-dependent things (e.g. key codes, Display implementation etc.), so that we have a definitive answer to the question "How do I add the new platform".

@hagane
Copy link
Contributor

hagane commented Nov 15, 2018

  1. We need something to abstract color representation because #D13B0B or LightGoldenRodYellow do not mean a thing for a terminal. Rot.js has some facility to map weird HTML stuff onto ANSI colors, but it's not available in the JVM world.
  2. Input, too. Looks like input handling is ignored and every app has to roll its own.
  3. Storage should be abstracted too. JS apps should use browser local storage, native applications will have to dump their stuff somewhere into user's home directory.

@ForNeVeR
Copy link
Member Author

Regarding the color and input stuff: probably take a look at lanterna, that's a library offering some nice abstractions around terminals.

It somewhat lacked proper Windows support last time I looked, but I could hack it.

@hagane
Copy link
Contributor

hagane commented Nov 17, 2018

I've already dropped in lanterna while implementing terminal support and did some preliminary research on unborking windows terminals, so I'm way ahead on this. Guess I'll do something with colors while finishing #5.

(tldr on terminals in Windows is that they are messed up beyond belief because of historical reasons. lanterna does works ok in a cygwin terminal and has an AWT terminal emulation mode)

@ForNeVeR
Copy link
Member Author

ForNeVeR commented Nov 17, 2018

Well, starting from some stupid version of Windows 10 it should work much better. I think we should support that mode. To enable that shit, we should call SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_PROCESSING. Here're docs. I think it should be worth to enable these shits in lanterna.

@hagane
Copy link
Contributor

hagane commented Nov 17, 2018

Not exactly, no. The thing is, lanterna does not have any Windows support to speak of. If it runs in a cygwin environment, it sort of works. If one tries to start it in a cmd window, it still tries to run like that and crashes trying to run stty.exe.
I guess there's a possibility of dropping in our own implementation based on com.googlecode.lanterna.terminal.ansi.ANSITerminal. Lanterna does looks for com.googlecode.lanterna.terminal.WindowsTerminal in classpath and tries to use it before falling back to Cygwin. I'm not exactly jumping at the thought of calling WinAPI from inside JVM here though.

@ForNeVeR
Copy link
Member Author

The thing is, lanterna does not have any Windows support to speak of.

Well, yeah, mainstream lanterna doesn't. But some time ago I was working on a branch where it is. If there is a necessity, then we'll be able to dust it out.

I'm not exactly jumping at the thought of calling WinAPI from inside JVM here though.

Heh, but I am!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants