Autore Topic: Turbinio di caratteri nella Console con le funzioni esterne del API di ncurses  (Letto 339 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.270
  • Ne mors quidem nos iunget
    • Mostra profilo
Un turbinio di casuali caratteri nella Console con le funzioni esterne del API di ncurses:

Codice: [Seleziona]
Library "libncurses:5.9"

Private Const ERR As Integer = -1

' WINDOW * initscr (void)
' Determines the terminal type and initialises all implementation data structures.
Private Extern initscr() As Pointer

' int noecho (void)
' Disables Echo mode for the current screen.
Private Extern noecho() As Integer

' void timeout (int)
' Set blocking read for a given window.
Private Extern timeout(ms As Integer)

' int getch (void)
' Get characters from curses terminal keyboard.
Private Extern getch() As Integer

' int mvaddch (int, int, const chtype)
' Add a character to a curses window, then advance the cursor.
Private Extern mvaddch(y As Integer, x As Integer, chtype As Long) As Integer

' int refresh (void)
' Refresh current window.
Private Extern refresh() As Integer

' int endwin (void)
' Restores tty modes.
Private Extern endwin() As Integer


Public Sub Main()

  Dim win_st As Pointer
  Dim x, y As Integer
  Dim maxy, maxx As Short
 
    win_st = initscr()
    If win_st = 0 Then Error.Raise("Impossibile  inizializzare le strutture di ncurses !")
   
    noecho()
    timeout(0)
   
    While True
' Arresta il programma con la pressione di un qualsiasi tasto: ''
      If getch() <> ERR Then Break
     
      maxy = Short@(win_st + 4)
      maxx = Short@(win_st + 6)
      For y = 0 To maxy - 1
        For x = 0 To maxx - 1
          mvaddch(y, x, Rand(33, 126))
        Next
      Next
      refresh()
    Wend
   
    endwin()

End





« Ultima modifica: 27 Maggio 2016, 13:43:19 da vuott »
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »