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 not input in IDEA console #80

Closed
slankka opened this issue Jul 18, 2018 · 4 comments
Closed

Can not input in IDEA console #80

slankka opened this issue Jul 18, 2018 · 4 comments

Comments

@slankka
Copy link
Contributor

slankka commented Jul 18, 2018

Hello, I am using IntelliJ IDEA CE, I launch sqlline using Run/Debug.

sqlline version 1.2.0
0: jdbc:phoenix:thin:url=http://localhost:876> !tables

When I type Enter. It just begin a new line, and the command doesn't response.
It is expected to show the tables in database.

When run it in Terminal, by:

java -cp xxxx.jar phoenixtest.ManuallyPhoenixClient

The terminal works normal, it displays the tables list.

I know this is not a bug. I just want to make sure what the problem is.

Thanks a lot.

@julianhyde
Copy link
Owner

I've seen similar problems. I don't know the solution. I suspect that the environment is different inside Intellij versus in a terminal, but I don't know enough about terminals to know what that would be. SQLLine is powered by jline2, so it might be worth searching for jline2 problems and solutions; they would probably work for SQLLine too.

@slankka
Copy link
Contributor Author

slankka commented Jul 18, 2018

I finally found that, the Debug Console in IntelliJ, is most likely not supported by Jline.
For example: the method below will return 0, and which is expected to be a positive number.

org.fusesource.jansi.internal. 
public static int getWindowsTerminalWidth()

This function call is base on JNI call.
It may cause the problem:

//sqlline version 1.2.0
sqlline.TableOutputFormat.java
//...
final int width = sqlLine.getOpts().getMaxWidth() - 4;
//...
ColorBuffer cbuf = getOutputString(rows, row);
      cbuf = cbuf.truncate(width);

the width may be negetive number, so the cbuf may be an empty string.

I can fix it by adding these command args:

--maxWidth=120
--maxHeight=2000
--color=true

It will make Sqlline output normal colorful texts in IDEA.

I found the solution:
jline/jline2#185

jline.TerminalFactory.registerFlavor(jline.TerminalFactory.Flavor.WINDOWS, UnsupportedTerminal.class);

When you try to interact with Run/Debug Console, it works!.

Thanks.

@slankka slankka closed this as completed Jul 18, 2018
@julianhyde
Copy link
Owner

Thanks for all of your research. Can you please add a section to https://github.com/julianhyde/sqlline/blob/master/HOWTO.md about how to run sqlline in Intellij? I think a lot of people would find it useful.

I'm going to re-open this case until we have some documentation.

@julianhyde
Copy link
Owner

julianhyde commented Jul 23, 2018

Merged change to HOWTO in 5a8f8bf. Thanks for the pull request, @slankka! It doesn't fix the issue, but gives a clear workaround, therefore I am marking this issue resolved.

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

No branches or pull requests

2 participants