Posted 26 March 2016 - 02:14 AM
Stitch isn't a new idea, but it's certainly a useful one.
The basic idea is to create a larger monitor out of multiple smaller ones. The implementation is anything but basic.
Installation and Setup
For the lengthy, human-readable API, download from rKU6E2K4 (~9,774 bytes)
Since I was overly-verbose in variable naming, a minified version is available from CTrVdFK9 (~3,812 bytes)
You can load the API through either os.loadAPI or dofile; it will detect which one automatically. If you are in need of multiple instances, you will want to use dofile
There is one very important function that seperates this from a normal terminal object.
Before you do ANYTHING with the virtual monitor object, be sure to set the monitors. It sets up several internal variables, meaning the results of calling functions before it range from overwriting those changes to outright errors.
After the monitors have been set, you may easily use term.redirect to run practically anything on this giant monitor.
For testing, I used this clever program to run any program on the monitor:
Finally, we have the two functions which, if misused, will screw things up. For efficiency purposes, the monitor object acts as a buffer, and is updated every 0.05 seconds (20 times per second). I have included the ability to disable this functionality and manually control the buffer updates.
Known Bugs:
Any text drawn at an x value of 0 or less will not show up. Fixed!
term.scroll incorrectly determines length of background colors string Fixed!
Huge thanks to BombBloke (and everyone else in AAP), for putting up with all the things I did wrong, and helping me get this thing up to spec.
And finally, thanks to GravityScore for his sublime text pluginUpdate!
+Fixed known bugs
+Added redraw() and setVisible( boolean visible )
Update!
+Changed behavior of redraw and setVisible
+Fixed a crash bug
The basic idea is to create a larger monitor out of multiple smaller ones. The implementation is anything but basic.
Installation and Setup
For the lengthy, human-readable API, download from rKU6E2K4 (~9,774 bytes)
Since I was overly-verbose in variable naming, a minified version is available from CTrVdFK9 (~3,812 bytes)
You can load the API through either os.loadAPI or dofile; it will detect which one automatically. If you are in need of multiple instances, you will want to use dofile
Examples
os.loadAPI( "stitch" ) --#loads stitch as a global API
local stitch = dofile( "stitch" ) --#loads stitch as a local "API"
local stitch_2 = dofile( "stitch" ) --#as shown here, you can have multiple objects this way
stitch.setMonitors( table t )
The table provided is to be a table of strings, which refer to monitors (eg "monitor_0"). It is a two-dimensional table, in the order t[ y ][ x ]. This means the table is visually similar to the layout of the monitors when viewed from the front.Example Table
stitch.setMonitors( {
{"monitor_0", "monitor_1"},
{"monitor_2", "monitor_3"},
} )
After the monitors have been set, you may easily use term.redirect to run practically anything on this giant monitor.
term.redirect( stitch )
stitch.setTextScale( 5 )
print( "Hello, world!" )
A rather useful feature of my API is the overriding I do on the peripheral API functions and event system. "stitch" is a valid monitor for all intents and purposes. Please note that having multiple instances will not be individualized, and may have unintended consequences when used this way.For testing, I used this clever program to run any program on the monitor:
Spoiler
os.loadAPI( "stitch" )
stitch.setMonitors( {
{"monitor_7", "monitor_1", "monitor_6"},
{"monitor_3", "monitor_4", "monitor_5"},
} )
stitch.setTextScale( 0.5 )
stitch.clear()
shell.run( "monitor stitch", ... )
WARNING: Do you really need to do this?
stitch.disableAutoBuffer() --#disables the automatic buffer.
stitch.buffer() --#forces the API to render the buffer to the screen (note: does not 'redraw' parts that haven't been changed)
Screenshots
Credits
Thanks to Shazz, for the original API. I didn't use any of his code, but it was an inspiration.Huge thanks to BombBloke (and everyone else in AAP), for putting up with all the things I did wrong, and helping me get this thing up to spec.
And finally, thanks to GravityScore for his sublime text plugin
+Fixed known bugs
+Added redraw() and setVisible( boolean visible )
Update!
+Changed behavior of redraw and setVisible
+Fixed a crash bug
Edited on 06 November 2016 - 08:49 PM