1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-12-13 09:18:04 +00:00

Added term.getLine and window.getLine

This commit is contained in:
liquid
2019-07-12 22:54:37 -05:00
parent f9929cb27d
commit 85b740f484
4 changed files with 46 additions and 0 deletions

View File

@@ -67,6 +67,7 @@ public class TermAPI implements ILuaAPI
"nativePaletteColour",
"nativePaletteColor",
"getCursorBlink",
"getLine"
};
}
@@ -279,6 +280,21 @@ public class TermAPI implements ILuaAPI
case 25:
// getCursorBlink
return new Object[] { m_terminal.getCursorBlink() };
case 26:
// getLine
int y = getInt( args, 0 ) - 1;
if ( y < 0 || y >= m_terminal.getHeight() )
{
throw new LuaException( "Line is out of range." );
}
String line, lineTextColour, lineBackgroundColour;
synchronized (m_terminal)
{
line = m_terminal.getLine( y ).read();
lineTextColour = m_terminal.getTextColourLine( y ).read();
lineBackgroundColour = m_terminal.getBackgroundColourLine( y ).read();
}
return new Object[] { line, lineTextColour, lineBackgroundColour };
default:
return null;
}

View File

@@ -388,6 +388,16 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
return nBackgroundColor
end
function window.getLine( nY )
if type(nY) ~= "number" then expect(1, nY, "number") end
if nY < 1 or nY > nHeight then
error( "Line is out of range.", 2 )
end
return tLines[nY].text, tLines[nY].textColor, tLines[nY].backgroundColor
end
-- Other functions
function window.setVisible( bVis )
if type(bVis) ~= "boolean" then expect(1, bVis, "boolean") end