[Gambas-devel] ncurses component

tobi tobias at ...692...
Wed Mar 28 22:14:53 CEST 2012


hi,

i'm getting started writing an ncurses component for gambas which in turn gets me started with
programming my first gambas component in c. as being redirected from the gambas-user list by
Benoît, this message is almost the same as there:

after having to read about those nifty configure scripts, i'm to face the first obstacle.
this code works:

-----
' Gambas module file

Public Sub Main()

  NCurses.On()
  NCurses.Print("this is text", 10, 10)
  NCurses.Attributes = NCurses.Bold Or NCurses.Reverse
  Print " this is a brave test."
  NCurses.Print("next line", , 11)
  NCurses.WaitKey()
  NCurses.Off()

End
-----

but as the docs about programming components in c/c++ reasonably say, this is rather c-style and
not suitable for the gambas language. (at the moment, there is one static object NCurses - i want
to discover the api further before writing any serious classes).

the Print() _function_ takes optionally x,y coordinates from which to print the text using ncurses.
i thought, it would be better to just use the Print instruction to print text instead of this
function all over again - this is just not aesthetic (but bearable?).
while the Print _instruction_ works fine so far - tried also with multiple ncurses WINDOWs
present - it always prints after the current cursor position, no matter what's there. that's the
same with the ncurses functions, the main and actual problem is that i turned on some attributes
which are handled by the library, too. the text from the Print instruction doesn't get bold and
video reversed. consequently, one may never use Print instruction to stdout in ncurses mode and
this option has departed...
i had the weirdest ideas of redirecting stdout to a stream object inside the ncurses component,
reading from that and printing the data with the ncurses functions, but that's way too strange...

any suggestions/ideas about a suitable interface for something that fundamental? or may the above
code fit? (i appear to not often use the ncurses mvwprintw() in any bigger thing without having
built a wrapper around it or controlled it via a loop, so this may really fit as is...)

what is your opinion now?





More information about the Devel mailing list