Text Window Input-Output Control

version 2 by Erik Temple

  • Home page
  • Beginning
  • Previous
  • Next



  • Chapter - Hacked screen routines

    Include (-

    [ VM_ClearScreen window;
    if (window == WIN_ALL or WIN_MAIN) {
    glk_window_clear( (+ current text output window +).ref_number );
    if (gg_quotewin) {
    glk_window_close(gg_quotewin, 0);
    gg_quotewin = 0;
    }
    }
    if (gg_statuswin && window == WIN_ALL or WIN_STATUS) glk_window_clear(gg_statuswin);
    ];

    [ VM_ScreenWidth id;
    id= (+ current text output window +).ref_number;
    if (gg_statuswin && statuswin_current) id = gg_statuswin;
    glk_window_get_size(id, gg_arguments, 0);
    return gg_arguments-->0;
    ];

    [ VM_ScreenHeight;
    glk_window_get_size( (+ current text output window +).ref_number, 0, gg_arguments);
    return gg_arguments-->0;
    ];

    -) instead of "The Screen" in "Glulx.i6t"

    [
    Chapter - Hacked window color routines

    Include (-

    [ VM_SetWindowColours f b window doclear i fwd bwd swin;
    if (clr_on && f && b) {
    if (window) swin = 5-window; ! 4 for TextGrid, 3 for TextBuffer

    fwd = MakeColourWord(f);
    bwd = MakeColourWord(b);
    for (i=0 : i<style_NUMSTYLES: i++) {
    if (f == CLR_DEFAULT || b == CLR_DEFAULT) { ! remove style hints
    glk_stylehint_clear(swin, i, stylehint_TextColor);
    glk_stylehint_clear(swin, i, stylehint_BackColor);
    } else {
    glk_stylehint_set(swin, i, stylehint_TextColor, fwd);
    glk_stylehint_set(swin, i, stylehint_BackColor, bwd);
    }
    }

    ! Now re-open the windows to apply the hints
    if (gg_statuswin) glk_window_close(gg_statuswin, 0);
    gg_statuswin = 0;

    if (doclear || ( window ~= 1 && (clr_fg ~= f || clr_bg ~= b) ) ) {
    glk_window_close( (+ current text output window +).ref_number, 0);
    gg_mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, (+ current text output window +).rock_value);
    if (gg_scriptstr ~= 0)
    glk_window_set_echo_stream((+ current text output window +).ref_number, gg_scriptstr);
    }

    gg_statuswin =
    glk_window_open(gg_mainwin, winmethod_Fixed + winmethod_Above,
    statuswin_cursize, wintype_TextGrid, GG_STATUSWIN_ROCK);
    if (statuswin_current && gg_statuswin) VM_MoveCursorInStatusLine(); else VM_MainWindow();

    if (window ~= 2) {
    clr_fgstatus = f;
    clr_bgstatus = b;
    }
    if (window ~= 1) {
    clr_fg = f;
    clr_bg = b;
    }
    }
    ];

    [ VM_RestoreWindowColours; ! used after UNDO: compare I6 patch L61007
    if (clr_on) { ! check colour has been used
    VM_SetWindowColours(clr_fg, clr_bg, 2); ! make sure both sets of variables are restored
    VM_SetWindowColours(clr_fgstatus, clr_bgstatus, 1, true);
    VM_ClearScreen();
    }
    ];

    [ MakeColourWord c;
    if (c > 9) return c;
    c = c-2;
    return $ff0000*(c&1) + $ff00*(c&2 ~= 0) + $ff*(c&4 ~= 0);
    ];

    -) instead of "Window Colours" in "Glulx.i6t"
    ]