curiousdannii-testing / inform7-imported-bugs

0 stars 0 forks source link

[I7-1669] [Mantis 1705] glk_cancel_line_event handled wrong #415

Open curiousdannii-testing opened 2 years ago

curiousdannii-testing commented 2 years ago

Reported by : zarf

Description :

This is a very old problem. I thought it was filed, but it's not.

CocoaGlk's handling of glk_cancel_line_event has always been a mess. It's supposed to leave the player's in-progress command visible, followed by a newline (or just a newline if the player hasn't typed anything). It doesn't. Instead, the player's in-progress command is shifted down to the next line input (ignoring the request_line_event call's ability to specify a pre-loaded input line).

Then there's the glk_set_echo_line_event call. That's a feature, so it doesn't have to be dealt with as part of this. However, note that (a) the bug existed before the glk_set_echo_line_event feature was invented, and (b) CocoaGlk's current behavior doesn't match either the glk_set_echo_line_event(true) or glk_set_echo_line_event(false) rules.

Steps to reproduce :

"Test Case" by Andrew Plotkin.

The Study is a room.

Rule for constructing the status line: quick draw status line.
To quick draw status line: (- QuickDrawStatusLine(); -).

When play begins:
    follow the display banner rule;
    say "[paragraph break]Hit the links in the status window to test hyperlink input. When either link is clicked, player input in progress should remain visible in place. The next input line should start empty (if the first link was used) or continuing the previous input (if the second link was.) The displayed message 'Interrupted input...' should always appear on a line by itself, not run on after the prompt.";
    request statuswin hyperlink input;
    quick parser loop;
To quick parser loop: (- QuickParserLoop(); -).

To request statuswin hyperlink input: (- glk_request_hyperlink_event(gg_statuswin); -).

Include (-
[ QuickDrawStatusLine;
    VM_StatusLineHeight(3);
    VM_MoveCursorInStatusLine(2, 2);
    glk_set_hyperlink(1);
    print "Message, no preserve";
    glk_set_hyperlink(0);
    VM_MoveCursorInStatusLine(3, 2);
    glk_set_hyperlink(2);
    print "Message and preserve";
    glk_set_hyperlink(0);
];

[ QuickParserLoop    ix ch;
    DrawStatusLine();
    while (1) {
        print "^>";
        QuickReadKeyboard(buffer);
        print "You typed ~";
        glk_put_buffer(buffer+WORDSIZE, buffer-->0);
        print "~^";
    }
];

[ QuickReadKeyboard a_buffer    done linkval prevlen;
     done = false;
    glk_request_line_event(gg_mainwin, a_buffer+WORDSIZE, INPUT_BUFFER_LEN-WORDSIZE, 0);
    while (~~done) {
        glk_select(gg_event);
        switch (gg_event-->0) {
            evtype_Arrange:
                DrawStatusLine();
            evtype_LineInput:
                if (gg_event-->1 == gg_mainwin) {
                    a_buffer-->0 = gg_event-->2;
                    done = true;
                }
            evtype_Hyperlink:
                linkval = gg_event-->2;
                glk_cancel_line_event(gg_mainwin, gg_event);
                prevlen = gg_event-->2;
                print "Interrupted input ~";
                glk_put_buffer(buffer+WORDSIZE, prevlen);
                print "~^";
                print "^>";
                if (linkval ~= 2)
                    prevlen = 0;
                glk_request_line_event(gg_mainwin, a_buffer+WORDSIZE, INPUT_BUFFER_LEN-WORDSIZE, prevlen);
                glk_request_hyperlink_event(gg_statuswin);
        }
    }

];

-).

Additional information :

imported from: [Mantis 1705] glk_cancel_line_event handled wrong
  • status: Reported
  • resolution: Open
  • resolved: 2022-04-07T05:00:08+10:00
  • imported: 2022/01/10
curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
Added sample source code.

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by zarf :
Compare the behavior in Gargoyle and Quixe (which are correct) to that of the Mac IDE and Mac Zoom (not correct).