mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-07-04 03:38:16 +08:00
Fix resizing of Live views with reduced size. (#1840)
This commit is contained in:
@ -4,7 +4,6 @@ internal sealed class LiveDisplayRenderer : IRenderHook
|
||||
{
|
||||
private readonly IAnsiConsole _console;
|
||||
private readonly LiveDisplayContext _context;
|
||||
|
||||
public LiveDisplayRenderer(IAnsiConsole console, LiveDisplayContext context)
|
||||
{
|
||||
_console = console;
|
||||
@ -45,7 +44,7 @@ internal sealed class LiveDisplayRenderer : IRenderHook
|
||||
{
|
||||
lock (_context.Lock)
|
||||
{
|
||||
yield return _context.Live.PositionCursor();
|
||||
yield return _context.Live.PositionCursor(options);
|
||||
|
||||
foreach (var renderable in renderables)
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ internal sealed class LiveRenderable : Renderable
|
||||
}
|
||||
}
|
||||
|
||||
public IRenderable PositionCursor()
|
||||
public IRenderable PositionCursor(RenderOptions options)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
@ -48,6 +48,14 @@ internal sealed class LiveRenderable : Renderable
|
||||
return new ControlCode(string.Empty);
|
||||
}
|
||||
|
||||
// Check if the size have been reduced
|
||||
if (_shape.Value.Height > options.ConsoleSize.Height || _shape.Value.Width > options.ConsoleSize.Width)
|
||||
{
|
||||
// Important reset shape, so the size can shrink
|
||||
_shape = null;
|
||||
return new ControlCode(ED(2) + ED(3) + CUP(1, 1));
|
||||
}
|
||||
|
||||
var linesToMoveUp = _shape.Value.Height - 1;
|
||||
return new ControlCode("\r" + CUU(linesToMoveUp));
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ internal sealed class DefaultProgressRenderer : ProgressRenderer
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
yield return _live.PositionCursor();
|
||||
yield return _live.PositionCursor(options);
|
||||
|
||||
foreach (var renderable in renderables)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ internal sealed class ListPromptRenderHook<T> : IRenderHook
|
||||
_dirty = false;
|
||||
}
|
||||
|
||||
yield return _live.PositionCursor();
|
||||
yield return _live.PositionCursor(options);
|
||||
|
||||
foreach (var renderable in renderables)
|
||||
{
|
||||
|
Reference in New Issue
Block a user