tonyhffong / TermWin.jl

ncurses based data navigators
Other
26 stars 11 forks source link

display does not work quite right for me #13

Open JeffBezanson opened 9 years ago

JeffBezanson commented 9 years ago

First of all, this package is really awesome! Trying it on linux, I get some strange characters in the display:

termwin

JeffBezanson commented 9 years ago

This is with julia v0.3.5, ubuntu 14.04 and gnome-terminal.

tonyhffong commented 9 years ago

Unfortunately, I don't have a linux box to test it on. I developed this on a mac using iterm, using xterm-256 emulation.

The boundary works fine so a part of it behaves okay. The way the code works is that it tries to print utf8 strings of "L", rotated "T" and triangles in the ncurses window, using ccall on mvwprintw

Some hypotheses:

Is it possible for you to try different terminal applications in linux to see if they behave the same?

tonyhffong commented 9 years ago

Another thing to try, does the linux distro support wide char using a separate libcursesw? If so, go to the script src/ccall.jl and try replacing line 3 from libcurses to libcursesw to see if it makes a difference.

JeffBezanson commented 9 years ago

I have tried xterm and uxterm, and also the libncursesw change; no luck so far.

With libncursesw the unicode character in the message ஃ TermWin: Please wait ... displays correctly. However the rest of the display is even worse: the window border turns into l, q, x, and m instead of lines.

tonyhffong commented 9 years ago

I have to admit I'm out of my depth. Perhaps we should reach out to the user mailing list to see if others have more luck?

tonyhffong commented 9 years ago

@sjkelly had some success with debian last year. Perhaps he can shed more light on this issue.

tonyhffong commented 9 years ago

I'm completely shooting in the dark. Googling a bit gives another thing to try: calling setlocale(LC_ALL,"") in libc at the very beginning of the initialization. I guess it's just setlocale( 0, "" )

mturok commented 9 years ago

FWIW, I get the exact same result as @JeffBezanson, ubuntu 14.04, julia 0.3.6, and xfce4-terminal.

sjkelly commented 9 years ago

@tonyhffong I just noticed I was mentioned here, so I decided to try again. I am getting the same issues as Jeff on Debian Jessie now. This package was quite helpful when I was learning meta programming a few months ago.

screenshot from 2015-04-15 20 23 52

habemus-papadum commented 9 years ago

Hi -- also encountering the same issue on Centos 7, julia 0.3.8.

I tried changing src/ccall.jl to use libcursesw and saw similar behavior as @JeffBezanson -- the unicode in the splash screen is fine, but the screen that follows is much worse than before.

julia seems to be setting the locale properly:

julia> l = ccall((:setlocale,"libc"),Ptr{Uint8},(Int32,Ptr{Uint8}),0,0)
Ptr{Uint8} @0x0000000000a6db20

julia> bytestring(l)
"en_US.UTF-8"

But, without doubt, this is an awesome package!

habemus-papadum commented 9 years ago

Small progress -- it only makes sense to use libcursesw if you are also using libpanelw (this is why the splash screen works fine -- it isn't using a panel) Changing the appropriate line in ccall.jl from libpanel -> libpanelw makes things better but not perfect: Below is a screen shot of os x on the left and linux on the right (both centos and ubuntu show similar behavior) . Some unicode characters work, others do not

screen shot 2015-05-08 at 2 06 56 pm

habemus-papadum commented 9 years ago

Notes for my future self or others: good starting point for using on linux

With these changes "generic" unicode works fine. What does't work are "acs" characters (this is some sort of ncurses concept that allows for creating corners and tees and such in a portable way across terminals of varying power -- acs is some sort of poor man's unicode)

It's probably not hard to fix this but I haven't tracked it down just yet

tonyhffong commented 9 years ago

There must be a Unicode equiv of the acs codes. I can take a look this weekend.

On Friday, May 8, 2015, Nehal Patel notifications@github.com wrote:

Notes for my future self or others: good starting point for using on linux

  • in ccall.jl: use "w" versions of library
  • in TermWin.jl: update cglobal calls to use w (once this issue is fully resolved, submit PR that uses os conditionals) (scan above entries to better understand what these statements mean)

With these changes "generic" unicode works fine. What does't work are "acs" characters (this is some sort of ncurses concept that allows for creating corners and tees and such in a portable way across terminals of varying power -- acs is some sort of poor man's unicode)

It's probably not hard to fix this but I haven't tracked it down just yet

— Reply to this email directly or view it on GitHub https://github.com/tonyhffong/TermWin.jl/issues/13#issuecomment-100323730 .

Keno commented 9 years ago

Unfortunately the unicode equivalents do not display the same as the acs characters, because terminals treat those specially. I can probably also take a look at this. I've been working on some better automated testing for this package which I should finish and which might help here.

tonyhffong commented 9 years ago

Hey thanks for jumping in guys. I wonder if we should use mvwadd_wch instead of mvwaddch. Could you test it out?

habemus-papadum commented 9 years ago

Hi -- Yesterday, I tried a few variations using mvwadd_wch -- none of them worked, but I was just trying things out quickly so I could have made a mistake -- others should definitely try as well.

(basically, i changed the acs_map_ptr found in TermWin to use the wide acs map defined in the curses.wide header file (google "ncurses github" to browse the source) )

then i modified the places in julia code which uses get_acs_val to call mvwadd_wch with the correct pointer (this part was rough and dirty)

It didn't work but I could have had a typo. (the output looked different, but was still broken)

My advise would be to try to replicate and then fix the issue with the following standalone code offered here: http://melvilletheatre.com/articles/ncurses-extended-characters/index.html (working in C, not in julia)

And then based on that figure out how to best fix TermWin because there might need to be a bit of refactoring to cleanly support both the OSX and Linux variants of ncurses