Skip to content

Commit

Permalink
Don't open console if only bell is "printed"
Browse files Browse the repository at this point in the history
This had an annoying effect on Teradesk's shutdown dialog or when QED
used the bell to signalize an error.

Fixes freemint/teradesk#13.
  • Loading branch information
mikrosk committed Aug 18, 2024
1 parent 282076a commit 426a800
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ fd_input(void)
if (con_win == NULL && con_fd > 0 && (readfds & (1L << con_fd)))
{
long int read_bytes = Fread(con_fd, (long)READBUFSIZ, buf);
if (read_bytes > 0) {
if (read_bytes > 0 && !(read_bytes == 1 && buf[0] == '\007')) {
if (gl_con_output) {
open_console();
write_text(con_win, buf, read_bytes);
Expand Down

5 comments on commit 426a800

@th-otto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't that just eat any bell that is written using Bconout()? Lots of applications (including AES itself) do that when eg. clicking outside a modal dialog or alert box. In that case, the Pling() would be completely unheard.

@mikrosk
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, you are probably right. I should have added a separate Bconout, forwarding the bell, without opening the console.

@mikrosk
Copy link
Member Author

@mikrosk mikrosk commented on 426a800 Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have looked into this; it seems that even the original code in proc.c is wrong (and also done by me: ab4d145). The proper fix shouldn't have been the if (con_win == NULL && con_fd > 0 && (readfds & (1L << con_fd))) code but adding something like

if (con_win == NULL && gl_con_output)
    open_console();

into handle_console. However it doesn't seem to automatically open console anymore. I wont have time to look at this for about week so you can have a go or I'll take a look to when I get back.

@th-otto
Copy link
Contributor

@th-otto th-otto commented on 426a800 Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No hurry with this. BTW, there is already code in

if (txt[0] == 7)
that will also eat BELL characters.

But imho this is both wrong. Why should the behaviour be different, depending on whether you output only a bell, or a bell embedded in some other string?

@mikrosk
Copy link
Member Author

@mikrosk mikrosk commented on 426a800 Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed now.

Why should the behaviour be different, depending on whether you output only a bell, or a bell embedded in some other string?

I guess this idea was that if the string is <bell>Hello!<bell> you want to print that message while with <bell><bell> you don't.

Please sign in to comment.