Closed akrasuski1 closed 9 years ago
I may be missing the difference, but is this a duplicate of #979 ?
It's a duplicate because of how it got misdescribed here.
What I actually wanted as an issue here (https://github.com/KSP-KOS/KSLib/pull/61#issuecomment-104047861) was more along the line of "implement the interpretation of the BEL char in the GUI terminal so it acts just like telnet when someone uses the KSlib beep char."
You can already beep the telnet terminal with a 0x0007 char, provided you use KSM file trickery to get that 0x0007 char into a string variable. This was supposed to be just an issue about eliminating an already existing difference between the GUI terminal and the telnet terminal.
Whether the 0x0007 char comes through the output stream because you did it in a PRINT command or in a separate BEEP command that prints just that one char is unrelated to this issue (or unrelated to the issue I was trying to describe anyway). The issue I was describing is that the GUI terminal should react to the BEL char just like the telnet terminal already does.
It's more about the GUI terminals's "hardware spec" than about what the language feature in kerboscript looks like to activate that hardware feature.
Darn it, I really hate it when something supposedly simple ends up being a major pain because of how the infrastructure is laid out.
I ran into this problem:
When you PRINT blarg.
, for any blarg, the path the code takes to make this work is as follows:
Get the current ScreenBuffer. Tell the ScreenBuffer to Print the string Blarg. When the ScreenBuffer prints the string Blarg, it stores the resulting chars in the buffer array.
Multiple times a second, the GUI terminal wakes up and checks its screenbuffer to display what it sees there.
Therefore the system doesn't support "printing" characters that don't take up an actual cell on the terminal grid. The Terminal has a reference to the ScreenBuffer, but the ScreenBuffer doesn't have a reference to the Terminal in it, so ScreenBuffer.Print() can't just tell the terminal to beep when it sees a 0x07 char.
I think the ScreenBuffer needs a "beep is pending" flag. When it is on, the next update will issue a beep and clear the flag. Therefore when you ScreenBuffer.Type() a beep, the next update will issue the beep from somewhere (it doesn't matter where) on the screen as it prints the characters.
Extra suggestion: add "Visual bell". It will blink terminal until you focus it. It will be possible to disable it through config.
"Audible bell" config option is not going to be useful I think - you can just mute whole KSP instead.
Visual bell is a good idea. But it should toggle per-terminal, I think, not in the config file for all of kOS. Maybe we make a config setting for all of kOS for how it defaults when you open a new terminal, but each terminal should be able to set it independently, I think.
@Dunbaratu we dont currently have a way for you to address each of the connected terminals do we?
i guess what i mean is can we answer the question "how many terminals do i have open?" from kerboscript?
hmm...... each kOS PartModule has one terminal associated. maybe if there's a way to walk all the kOS Partmodules? But otherwise, not we'd have to use ugly slow Reflection to get all instances of the class.
For within the remit of this issue, I'm going to make visual bell a per-terminal setting with a button you click on in the terminal frame. For a separate issue we can maybe talk about giving the setting some persistence and also having a default in CONFIG it draws from.
Well, what for would you need to enumerate terminals? Can't it work the same way as changing terminal size?
@evg-zhabotinsky The question wasn't "can we make a list of the terminals", but "do we" already have such a list. It was describing the current state of things - saying we don't already have such a list. It would be easy to make one - just have the constructor update a static list every time it gets invoked, and remove it self from the list every time it gets destructed.
@erendrake -what was the reason for wanting such a list?
@Dunbaratu i may have misunderstood what you meant. i thought you were saying you would want to control the 'visual bell' per terminal in script. not enabling the bell on the terminal. like "only flash on the in game terminal" or "flash terminal 3"
EDIT: Changed description.
It is already possible to do beep via telnet interface, but the in-game tutorial should also respond to ASCII 7th character (BEL).