mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
making term.read
check for changes to the term's cursor position between events, to make it less problematic to display text via print
or term.write
when there's a read active (e.g. because we're in the shell or so but we want to print something from an event listener, such as a timer)
This commit is contained in:
parent
6b60dbdd06
commit
ad4359f2dd
@ -284,11 +284,17 @@ function term.read(history)
|
||||
|
||||
term.setCursorBlink(true)
|
||||
while term.isAvailable() do
|
||||
local ocx, ocy = getCursor()
|
||||
local ok, name, address, charOrValue, code = pcall(event.pull)
|
||||
if not ok then
|
||||
cleanup()
|
||||
error("interrupted", 0)
|
||||
end
|
||||
local ncx, ncy = getCursor()
|
||||
if ocx ~= ncx or ocy ~= ncy then
|
||||
cleanup()
|
||||
return "" -- soft fail the read if someone messes with the term
|
||||
end
|
||||
if term.isAvailable() and -- may have changed since pull
|
||||
type(address) == "string" and
|
||||
component.isPrimary(address)
|
||||
|
@ -23,10 +23,10 @@ object MonospaceFontRenderer {
|
||||
val fontWidth = 5
|
||||
val fontHeight = 9
|
||||
|
||||
def drawString(x: Int, y: Int, value: Array[Char], color: Array[Short], depth: PackedColor.Depth.Value) = instance match {
|
||||
def drawString(x: Int, y: Int, value: Array[Char], color: Array[Short], depth: PackedColor.Depth.Value) = this.synchronized(instance match {
|
||||
case None => OpenComputers.log.warning("Trying to render string with uninitialized MonospaceFontRenderer.")
|
||||
case Some(renderer) => renderer.drawString(x, y, value, color, depth)
|
||||
}
|
||||
})
|
||||
|
||||
private class Renderer(private val textureManager: TextureManager) {
|
||||
/** Display lists, one per char (renders quad with char's uv coords). */
|
||||
|
@ -132,14 +132,17 @@ object ScreenRenderer extends TileEntitySpecialRenderer with Callable[Int] with
|
||||
}
|
||||
}
|
||||
|
||||
private def compileOrDraw(list: Int) = if (screen.bufferIsDirty && !RenderState.compilingDisplayList) {
|
||||
screen.bufferIsDirty = false
|
||||
private def compileOrDraw(list: Int) = if (screen.bufferIsDirty) {
|
||||
val sx = screen.width
|
||||
val sy = screen.height
|
||||
val tw = sx * 16f
|
||||
val th = sy * 16f
|
||||
|
||||
GL11.glNewList(list, GL11.GL_COMPILE_AND_EXECUTE)
|
||||
val doCompile = !RenderState.compilingDisplayList
|
||||
if (doCompile) {
|
||||
screen.bufferIsDirty = false
|
||||
GL11.glNewList(list, GL11.GL_COMPILE_AND_EXECUTE)
|
||||
}
|
||||
|
||||
transform()
|
||||
|
||||
@ -178,7 +181,9 @@ object ScreenRenderer extends TileEntitySpecialRenderer with Callable[Int] with
|
||||
MonospaceFontRenderer.drawString(0, i * MonospaceFontRenderer.fontHeight, line, color, screen.buffer.depth)
|
||||
}
|
||||
|
||||
GL11.glEndList()
|
||||
if (doCompile) {
|
||||
GL11.glEndList()
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user