-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
newlib: add a scroll callback #682
Comments
At the moment there are two ways to customize the terminal behaviour.
So, for example, you can stop pausing when the page fills by turning off pause which I think is what you mean by "no scroll limit": You can also reset the scroll limit so that the pause will not occur until another full page is printed: It's also possible to get a pointer to the driver's state (called the FDSTRUCT). This is done with
Callbacks I don't think fit in very well because there's potentially a lot of them and adding them would just increase code size and slow things down since the library would have to supply do-nothing weak definitions. The subclassing, however, can let the user do exactly how much he wants. Or he can write his own driver, using library code where appropriate. |
WOW so many information hidden from the user :), or there are docs but I didn't saw them ? Ok, maybe calling that callback too many times is an overhead. |
There are no docs really. This is the part of the stdio model in the newlib which is "new" (well maybe closing in on two years old now) and this is not the final state of the driver model. The next version hopefully will be the last where non-blocking io will be added as well as better handling of tty emulation and conditioning the input stream which were found to be lacking recently. Then the disk model will go in and we can put in fatfs, etc, as available to all targets. The list of io controls and pragmas are in the source code and I usually have to look at the source code to remember how the io controls are used. ioctl() takes a variable number of arguments and types depending on what the command is.
ok it sounds like you want to be able to signal the program when the scroll limit is met so it can choose to stop generating output or continue by scrolling another screenfull. The way to do it now would be to subclass the driver and intercept the scroll message like the zxnext example in the previous message. You can add state to the driver as well, so you can add another two bytes to hold a callback address, so this new scroll message handler could read the callback address and if not zero call the function to notify it that the screen is full. The return value can indicate if the scrolling should terminate. This has to do two things :- it has to set a flag so that further characters are not printed (the driver is probably in the middle of printing a string since most things are delivered as whole strings rather than individual chars) and on exit from the driver (ie after a complete string is printed) it should clear this flag so that the next thing printed by the program actually is printed. So I think there has to be two bytes for the callback function, another flag byte to disable printing, and insertion of some code that executes when the driver is about to exit so that the flag byte is cleared. The only way to do all these things would be to subclass the driver as a simple callback alone will not do it. |
There may be a better way to do it by replacing the lowest level of the driver, in particular these two functions which are the first to receive a "write buffer" or "put many of the same char" message from stdio. So these could test for the flag being set and terminate early so that there is a quick exit there, clearing that flag at the same time. Still thinking about the best way to do that but I think this is it. |
It is quite out of topic, but you might be interested in the fact that f_ansi in the classic lib expects a buffer too (usually shortened to a single char buffer for simplicity). |
I think this is complicated enough that it should be made easier but it will probably be something that must be done in the next version of the driver model. |
m4_zx_01_output_fzx
is very powerful, it will be nice if the user can register a scroll callback.This callback is useful when you want to stop the scrolling at some point or when you want to dynamically set the scroll lines count until pause.
e.g.
int (*scrollCallback)()
:The text was updated successfully, but these errors were encountered: