mabe02 / lanterna

Java library for creating text-based GUIs
GNU Lesser General Public License v3.0
2.25k stars 242 forks source link

Unix terminal rendering differences vs. Swing terminal #232

Closed jslater89 closed 8 years ago

jslater89 commented 8 years ago

The screenshots below are from bash in gnome-terminal (showing the problem) and the Swing terminal emulator (showing the expected appearance), but I encounter similar issues with bash in raw Unix terminals.

The source code for the application I'm running can be found here: http://manywords.press/hg/shortlog/9ca13ad6ccc9. Am I doing something wrong?

screenshot from 2016-04-25 10 06 32 screenshot from 2016-04-25 10 07 03

avl42 commented 8 years ago

Your codebase is quite large, but it seems to contain a "RawTerminal" class, which essentially contains all the drawing logic for your game.

At some point in the method that renders the table at the left, rendering each row ends in:

   694         rowString += "\n";
   695         rowString += ANSI_RESET;

So, you reset the color only after adding a newline. This looks somewhat suspicious to me, but I haven't dug into it far enough to even see how this gets combined with the righthandside "Information" Panel.

Another detail: Esc [0m seems (in my experience) be slightly less compatible with real world terminals than Esc [m , so you might try the latter for ANSI_RESET and see if it improves things.

jslater89 commented 8 years ago

RawTerminal is deprecated, kept around for printing board positions to the console—the Lanterna-based code is in the ui.lanterna package. GameScreen holds the in-game UI.

avl42 commented 8 years ago

I will have another look at it, but probably won't get to it before friday...

avl42 commented 8 years ago

GameScreen.java seems quite big and I couldn't find the part where the grid is drawn... Also, the whole project is a bit too large to just run it on my machine...

I do have some joy in spotting problems, like other people solve crossword puzzles or sudoku, but without your help such as pointing to the relevant one of the 100 class files, it's not quite the fun.

avl42 commented 8 years ago

Another thing that would be helpful: you could run your program inside "script", which will record all output to the terminal in a file named "typescript". you could then attach that file to a message here, or filter it through some hexdump utility (e.g.: hd) and then try to isolate all the escape sequences between +-k--+ and the ||.

mabe02 commented 8 years ago

Yes, this was quite a lot of code to go through... Can you make a simple reproducing case, maybe by isolating out a very basic part of the drawing code and feed it with static data so the rest of the logic doesn't need to be pulled in?

jslater89 commented 8 years ago

Sure, I'll see if I can whip up a minimal case.

jslater89 commented 8 years ago

@mabe02 It works as expected in beta3 (though entering private mode causes an immediate quit, I can work around that until I can dig into why).