Flexible Windows

version 13/130803 by Jon Ingold

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter 8 - Basic keystroke input

    [Added by Erik Temple 22 May 2010]

    [These phrases simply recast the keystroke commands from Basic Screen Effects in a way that allows them to be called from any compatible window (that is, from a text-buffer or text-grid window; char input cannot be called from a graphics window).]

    To request character input in (win - a g-window):
        (- glk_request_char_event({win}.ref_number); -)

    To cancel line input in (win - a g-window):
        (- glk_cancel_line_event({win}.ref_number, GLK_NULL); -)
        
    To cancel character input in (win - a g-window):
        (- glk_cancel_char_event({win}.ref_number); -)

    To wait for any key in (win - a g-window):
        (- WinKeyPause({win}.ref_number); -)

    To wait for the/-- SPACE key in (win - a g-window):
        (- WinSPACEPause({win}.ref_number); -)

    To decide what number is the character code entered in (win - a g-window):
        (- WinGetKey({win}.ref_number) -)

    Include (-

    [ WinKeyPause win i ;
        i = VM_KeyChar(win);
        rfalse;
    ];

    [ WinSPACEPause win i;
        while (i ~= 13 or 31 or 32)
        {
            i = VM_KeyChar(win);
        }
    ];

    [ WinGetKey win i;
        i = VM_KeyChar(win);
        return i;
    ];

    -)