Terminal Buffers
#1
Posted 15 November 2013 - 12:52 AM
If terminals could provide a buffer swap then functions like double-buffering would be available too.
Ideally buffering should be handled in the terminal itself (to simulate hardware buffering), but alternatively if Lua could read the state of the screen then our programs could handle buffering that way.
#2
Posted 15 November 2013 - 01:32 AM
#3
Posted 15 November 2013 - 01:42 AM
Terminal redirects to not stack, so for example LyqydOS does not run properly through my Billboard program because you're using your own redirects to handle frame buffering.
*edit* To head off any argument that it's my program at fault, LyqydOS also does not work with the Monitor program, which uses the same technique.
And given the terminals are already keeping an internal buffer all I'm asking for is that be exposed to the Lua side.
Edited by distantcam, 15 November 2013 - 01:51 AM.
#4
Posted 15 November 2013 - 07:48 AM
The reason that this is a bad idea is that, while yes it would be good in a few circumstances, for the most part it would cause massive conflicts. Imagine two programs, running, attempting to control their rendering. You could have one application rendering over part of others etc and just create bad, unusable programs.
This is definitely implementable, and easily at that, as Lyqyd stated. And it is definitely yours and the other "Monitor" program at fault here, use a better technique and it will be fine. Just because another program uses the same technique you do, doesn't make it the best, nor does it make it the only technique.
One technique would be to override term.redirect and term.native.redirect making sure that the other program doesn't take control away from you, but so that it "thinks" it does have control. Then of course you get to know what its doing and do what you wish with it.
Another (more complicated, and kinda pointless) technique would be to make an override of the term.native table with references to your table/functions, this way when other programs attempt to make a redirect object, and use term (you've redirected) or term.native as what they invoke in their redirects, YOU will get their commands, and YOU have control over how they get passed to the real term/term.native. Just make sure of course that you create a backup of the real term/term.native for you own uses and of course restore it once your program has finished.
Using either of these method, no matter how the other programs create a redirect object, you'll have control. I'm sure that other people can probably think of other techniques too, this is just two techniques that I can think of off the top of my head in the spur of the moment.
Edited by theoriginalbit, 15 November 2013 - 07:49 AM.
#5
Posted 15 November 2013 - 10:21 AM
Edited by wojbie, 15 November 2013 - 10:42 AM.
#6
Posted 15 November 2013 - 10:27 AM
theoriginalbit's suggestion about overriding term.native above would probably also work.
Also, you guys should re-read term. There is no term.native.redirect.
#7
Posted 15 November 2013 - 11:18 AM
For example term.write will write to the monitor, and write to the printer. How would they stack together?
theoriginalbit, on 15 November 2013 - 07:48 AM, said:
Well first off how would you run 2 programs? You can't without writing some code to run each program in a coroutine. So how does the current system handle running 2 programs in a coroutine? Not very well. They both fight to move the cursor around, etc.
So ideally if you were to run 2 or more programs concurrently you'd also handle the redraw system. But oh wait you can't force a program to redraw and since there's no built in buffer swap you'd have to implement that too. But then we get back to the fact that term.redirect does not handle this scenario well.
Ok, let me describe what I'm ultimately trying to do, and see if there's another solution.
I want to create a system where the terminate event is rewired to pop up a box to enter a password, and if the password is incorrect the box goes away and whatever program that was running redraws what was under the box.
I was hoping to do this as just a program, not a full OS replacement. The best I could figure was I needed some way to either capture what the program is drawing, or have a screen buffer that I can capture right before displaying the box, and then restore when the box closes.
So, if I were to use a terminal redirect to capture the buffer then any redirects added after the buffer that ignored term and went straight to the peripheral would not be captured.
#8
Posted 15 November 2013 - 01:20 PM
#9
Posted 15 November 2013 - 07:26 PM
distantcam, on 15 November 2013 - 11:18 AM, said:
For example term.write will write to the monitor, and write to the printer. How would they stack together?
distantcam, on 15 November 2013 - 11:18 AM, said:
I want to create a system where the terminate event is rewired to pop up a box to enter a password, and if the password is incorrect the box goes away and whatever program that was running redraws what was under the box.
I was hoping to do this as just a program, not a full OS replacement. The best I could figure was I needed some way to either capture what the program is drawing, or have a screen buffer that I can capture right before displaying the box, and then restore when the box closes.
So, if I were to use a terminal redirect to capture the buffer then any redirects added after the buffer that ignored term and went straight to the peripheral would not be captured.
- Make your program startup (making sure it only runs once) and run a new shell and your listener function
- Make a backup of term and term.native
- Override term and term.native with my own functions, not redirect!
- Keep a copy of everything that is written to the terminal in a table
- When needed to your function takes control and renders the box over it
- Once the box disappears redraw only needed areas to the screen from the buffer
- The program now continues
- ????
- profit
Lyqyd, on 15 November 2013 - 10:27 AM, said:
#10
Posted 15 November 2013 - 08:49 PM
#11
Posted 15 November 2013 - 09:13 PM
#12
Posted 15 November 2013 - 10:59 PM
Lyqyd, on 15 November 2013 - 08:49 PM, said:
distantcam, on 15 November 2013 - 09:13 PM, said:
#13
Posted 16 November 2013 - 01:41 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











