[Gambas-user] ncurses help texts missing
Tobias Boege
taboege at ...626...
Mon Mar 31 19:42:26 CEST 2014
On Mon, 31 Mar 2014, Rolf-Werner Eilert wrote:
>
>
> Am 31.03.2014 15:26, schrieb Tobias Boege:
> > On Mon, 31 Mar 2014, Rolf-Werner Eilert wrote:
> >> [I'll free that thread from some lines...]
> >>
> >>>> Moreover, umlauts aren't printed correctly (I guess it's UTF-8). Is
> >>>> there a solution?
> >>>>
> >>>
> >>> My turn. NCurses offers an ncursesw library for wide characters - I just
> >>> don't use it.
> >>>
> >>> Not out of ignorance or laziness but because I want to use the CDK (curses
> >>> development kit) to implement controls in the terminal (Button (yes, with
> >>> mouse support!), TextBox, TextArea, ListBox, Menu, etc.). And the CDK does
> >>> not support wide characters (which UTF-8 ones are). If I rewrite gb.ncurses
> >>> to use ncursesw now, I'll certainly run into compatibility problems with the
> >>> CDK later.
> >>>
> >>> MAYBE, I can dig into the CDK in summer and try to patch it to use ncursesw.
> >>> However, Thomas Dickey says that this is not as trivial as one might think
> >>> at first. If this does not work, I'm afraid gb.ncurses will not support wide
> >>> characters.
> >>>
> >>
> >> Rather ambitious :-)
> >>
> >> But couldn't I use Conv() to achieve that? I tried
> >>
> >> hDialog.Caption = (Conv$("Make a choice ???", "UTF-8", "ASCII"))
> >>
> >> but it gave a conversion error. So I tried
> >>
> >> hDialog.Caption = (Conv$("Make a choice", "UTF-8", "ISO-8859-15"))
> >>
> >> and it gave no error (but the result was wrong, of course).
> >>
> >> So, what character set does ncurses use then? Can I use conv() for it
> >> anyway? If not, there should be a way to write a simple conversion table
> >> for German umlauts, e. g. using Replace().
> >>
> >
> > NCurses is ASCII-based. You cannot encode umlauts into ASCII, so the
> > conversion attempt will fail.
>
> Ok, I see your point. I was talking 8-bit ASCII here like I was used to
> have in old DOS programming times. In the upper half of this encoding,
> there are umlauts and some accent letters.
>
> >
> > What do you mean by "conversion table"? Do you want to have a-umlaut to be
> > "ae" or "a" or "?" or ...?
>
> "ae" would be a good workaround, but it would mean two letters instead
> of one, so it might destroy the programmer's "line" order in a text screen.
>
> I found this page
>
> http://www.melvilletheatre.com/articles/ncurses-extended-characters/index.html
>
> and it says "228" for an "?", but I tried to encode by writing a little
> function
>
> Private Function charConv(srcString As String) As String
>
> Replace$(srcString, "?", Chr$(228))
>
> Return srcString
>
> End
>
> and the result was "M-CM-$" for it... What a shame :-)
>
>
>
> > My mail client, mutt, uses the question mark to
> > replace any non-ASCII character (as can be seen above) and this seems to be
> > a pretty good solution as there are also letters with diacritics in some
> > languages and those have no representation like "ae" for a German a-umlaut.
>
> Midnight-Commander (also made with ncurses) can display German umlauts
> in file names. Maybe you could ask the guys who made it how they did the
> trick... And consoles know umlauts, too. Maybe a simple Esc-code that
> produces the special characters in a console would do?
>
I will look at the sources. At first glance, it looks interesting how they
print - but their configure scripts are also aware of ncurses*w*...
> >
> > What you can do is the following: create and export your own Window class
> > and hook the Print method. Do your conversion there and then call
> > Super.Print(). This way, the conversion is specific to your application but
> > you can use gb.ncurses like you always did. [ You may even want to write a
> > gb.ncurses.umlauts component/library... ]
>
> Wow... Never done such a thing before. Sounds easy though as long as you
> know what to do... :-)
>
You create a Window.class in your project and write "Export" into the first
payload line in the class. This makes it exported into the interpreter's
global symbol table (the theory is here [0]). Because there will already be
a Window class from gb.ncurses, your Window.class will _extend_ gb.ncurses'
one by inheritance. In your Window.class, write a Print method that has the
same signature as in gb.ncurses. Do your conversion there and call
Super.Print() (the original gb.ncurses' Window.Print()) with the converted
strings. Then the interpreter will do the rest for you: any call to
Window.Print() from your application will first go to your Window class'
Print() and from there to gb.ncurses' Window's Print().
Regards,
Tobi
[0] http://gambaswiki.org/wiki/doc/object-model
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User
mailing list