mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -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)
|
term.setCursorBlink(true)
|
||||||
while term.isAvailable() do
|
while term.isAvailable() do
|
||||||
|
local ocx, ocy = getCursor()
|
||||||
local ok, name, address, charOrValue, code = pcall(event.pull)
|
local ok, name, address, charOrValue, code = pcall(event.pull)
|
||||||
if not ok then
|
if not ok then
|
||||||
cleanup()
|
cleanup()
|
||||||
error("interrupted", 0)
|
error("interrupted", 0)
|
||||||
end
|
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
|
if term.isAvailable() and -- may have changed since pull
|
||||||
type(address) == "string" and
|
type(address) == "string" and
|
||||||
component.isPrimary(address)
|
component.isPrimary(address)
|
||||||
|
@ -23,10 +23,10 @@ object MonospaceFontRenderer {
|
|||||||
val fontWidth = 5
|
val fontWidth = 5
|
||||||
val fontHeight = 9
|
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 None => OpenComputers.log.warning("Trying to render string with uninitialized MonospaceFontRenderer.")
|
||||||
case Some(renderer) => renderer.drawString(x, y, value, color, depth)
|
case Some(renderer) => renderer.drawString(x, y, value, color, depth)
|
||||||
}
|
})
|
||||||
|
|
||||||
private class Renderer(private val textureManager: TextureManager) {
|
private class Renderer(private val textureManager: TextureManager) {
|
||||||
/** Display lists, one per char (renders quad with char's uv coords). */
|
/** 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) {
|
private def compileOrDraw(list: Int) = if (screen.bufferIsDirty) {
|
||||||
screen.bufferIsDirty = false
|
|
||||||
val sx = screen.width
|
val sx = screen.width
|
||||||
val sy = screen.height
|
val sy = screen.height
|
||||||
val tw = sx * 16f
|
val tw = sx * 16f
|
||||||
val th = sy * 16f
|
val th = sy * 16f
|
||||||
|
|
||||||
|
val doCompile = !RenderState.compilingDisplayList
|
||||||
|
if (doCompile) {
|
||||||
|
screen.bufferIsDirty = false
|
||||||
GL11.glNewList(list, GL11.GL_COMPILE_AND_EXECUTE)
|
GL11.glNewList(list, GL11.GL_COMPILE_AND_EXECUTE)
|
||||||
|
}
|
||||||
|
|
||||||
transform()
|
transform()
|
||||||
|
|
||||||
@ -178,7 +181,9 @@ object ScreenRenderer extends TileEntitySpecialRenderer with Callable[Int] with
|
|||||||
MonospaceFontRenderer.drawString(0, i * MonospaceFontRenderer.fontHeight, line, color, screen.buffer.depth)
|
MonospaceFontRenderer.drawString(0, i * MonospaceFontRenderer.fontHeight, line, color, screen.buffer.depth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (doCompile) {
|
||||||
GL11.glEndList()
|
GL11.glEndList()
|
||||||
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user