[Gambas-user] ncurses help texts missing

Tobias Boege taboege at ...626...
Mon Mar 24 16:15:00 CET 2014


On Mon, 24 Mar 2014, Rolf-Werner Eilert wrote:
> Am 05.02.2014 18:15, schrieb Tobias Boege:
> > On Tue, 04 Feb 2014, Tobias Boege wrote:
> >> On Tue, 04 Feb 2014, Tobias Boege wrote:
> >>> On Tue, 04 Feb 2014, Rolf-Werner Eilert wrote:
> >>>>
> >>>>
> >>>> Am 04.02.2014 09:46, schrieb Tobias Boege:
> >>>>> On Tue, 04 Feb 2014, Rolf-Werner Eilert wrote:
> >>>>>> Hi Tobias,
> >>>>>>
> >>>>>> your name is mentioned as the author of the ncurses component. Is that
> >>>>>> right?
> >>>>>>
> >>>>>
> >>>>> Yes, that's right.
> >>>>>
> >>>>>> Anyway, I wanted to play around a bit with ncurses and found this
> >>>>>> component. A long time ago, I tried to write a program with ncurses but
> >>>>>> gave up when I had to find the screen dimensions (the original C
> >>>>>> function uses a pointer thing I couldn't make workable for my Gambas
> >>>>>> program). So thanks you've done it for me :)
> >>>>>>
> >>>>>> But the help texts aren't ready yet, and I miss some short examples on
> >>>>>> how to start by making a window and so on.
> >>>>>>
> >>>>>> Are the undocumented functions not ready yet, or is it that the help
> >>>>>> texts aren't complete yet?
> >>>>>>
> >>>>>
> >>>>> The help just isn't written. The component itself didn't change since 3.3 or
> >>>>> so. Not that I am totally confident with it but it's working as it should at
> >>>>> this point.
> >>>>>
> >>>>> Some things missing (actually, the whole menu and forms extensions of
> >>>>> ncurses and wide character support!), etc. and I also want to add a
> >>>>> gb.ncurses.cdk component based on the CDK library which implements controls
> >>>>> in terminal but I have to design this carefully - and maybe even break
> >>>>> gb.ncurses' API (very slightly if at all!). This is why I'm stuck programming
> >>>>> and if the programming isn't done, I struggle to do the documentation :-)
> >>>>>
> >>>>> There are gb.ncurses examples: Pong and Invaders (the last one still not
> >>>>> finished in regard to game logic) in the Games section. But if you told me
> >>>>> that these don't help gb.ncurses newbies, I would agree...
> >>>>>
> >>>>> I'm actually not that fit anymore with gb.ncurses :-) but today afternoon
> >>>>> I'll put some lines together about the basics.
> >>>>>
> >>>>> Regards,
> >>>>> Tobi
> >>>>>
> >>>>> And now off to the Linear Algebra test ;-)
> >>>>>
> >>>>
> >>>> Uuuuh - good luck!
> >>>>
> >>>> Just give me some hint how to start, and we could write some help texts
> >>>> and little examples. Although I don't have too much time right now, I
> >>>> would be able to help out a bit here...
> >>>>
> >>>
> >>> Wait a minute (or one or two hours, more likely). I'm halfways through a
> >>> quite comprehensive tutorial about basic usage:
> >>>
> >>>   - printing text,
> >>>   - using attributes and colours,
> >>>   - creating dialogs.
> >>>
> >>
> >> Almost everything is in place here[0]. With the last little paragraph, I'll
> >> continue tomorrow as it's time for a break now. I've also prepared a project
> >> containing all the snippets presented which I will complete and upload
> >> tomorrow, too. Hope it helps.
> >>
> >> Note that I needed to fix some bugs I encountered while putting the code
> >> together so you better use the latest revision to test ;-)
> >>
> >> Regards,
> >> Tobi
> >>
> >> [0] http://gambasdoc.org/help/tutorial/ncursestut?v3
> >>
> >
> > OK, now it's ready and has a source code archive. Let me know if you have
> > any suggestions. (Maybe one or the other screenshot would be nice?)
> >
> > Regards,
> > Tobi
> >
> 
> 
> Hi,
> 
> it's been quite a while, but now I had the time to test your examples.
> 
> There seem to be some mistakes in the example, so I'm giving a version 
> that runs:
> 
> Dim hDialog As New Window(True, 0, 0, Window.W / 2, 6)
> 'Dim sChoice As String
> Dim iChoice As Integer
> 
>    hDialog.Border = Border.ACS
>    hDialog.Caption = ("Make a choice")
>    hDialog.Center()
>    hDialog.Show()
> 
>    hDialog.PrintCenter(Subst$(("What to do?\n\nEvalute 42^2 [&1]\nQuit 
> [&2]"), ("E"), ("q")))
>    Screen.Echo = False
>    iChoice = hDialog.Ask("Eq")
>    hDialog = Null ' Destroy the dialog window
>    'If sChoice = ("e") Then
>    If iChoice = 1 Then
>      Window.PrintCenter(Subst$(("Here it is: 42^2 = &1"), 42 ^ 2)) ', 
> Attr.Bold, Pair[Color.Green, Color.Black])
>    ' Else
>    '   Window.Print("Pressed something else")
>    Endif
>    Window.Print(("Press any key to continue"), 0, Window.H - 1)
>    Window.Read()
> 
>    Quit
> 
> 
> As you will see, .Ask returns an integer, and this should be mentioned 
> in the help text. Currently this is described to be string. (This cost 
> me quite a while to find out... :-) )
> 

Since revision #6130 (Gambas 3.5.3 in the future), it IS a string and the
project will work with any recent-enough version. There is an info box in
the tutorial that tells the revision the project needs. (This time, the
documentation was right and the code was wrong.)

> If there is no Quit at the end of the program, it will never end. Only 
> ^C helps then.
> 

This is a known side-effect. gb.ncurses uses an interpreter API to catch the
terminal's SIGWINCH signal but using this API keeps the program running
beyond the normal termination conditions (Main() finished and nothing is
watched). I am not sure how to solve that...

> Personally I find the cursor behind each .Print string irritating. Can 
> it be suppressed?
> 

Screen.Cursor = Cursor.Hidden

> 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.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list