Support PgUp/PgDn
This commit is contained in:
parent
a7207aaab1
commit
57486aac9c
@ -134,8 +134,8 @@ namespace MApplication
|
|||||||
_ when CursorRelativeLine == Height - 1 =>
|
_ when CursorRelativeLine == Height - 1 =>
|
||||||
With(
|
With(
|
||||||
out changed1,
|
out changed1,
|
||||||
startingLine: Math.Min(CursorAbsoluteLine + 1, Text.Lines.Count) - Height + 1,
|
startingLine: Math.Min(CursorAbsoluteLine + 1, Text.Lines.Count - 1) - Height + 1,
|
||||||
cursorAbsoluteLine: Math.Min(CursorAbsoluteLine + 1, Text.Lines.Count)),
|
cursorAbsoluteLine: Math.Min(CursorAbsoluteLine + 1, Text.Lines.Count - 1)),
|
||||||
_ => With(
|
_ => With(
|
||||||
out changed1,
|
out changed1,
|
||||||
cursorAbsoluteLine: CursorAbsoluteLine + 1),
|
cursorAbsoluteLine: CursorAbsoluteLine + 1),
|
||||||
@ -145,6 +145,28 @@ namespace MApplication
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal DisplayTextViewPort PageDown(out bool needsRedraw)
|
||||||
|
{
|
||||||
|
var result1 = With(
|
||||||
|
out var changed1,
|
||||||
|
startingLine: Math.Min(StartingLine + Height, Text.Lines.Count - 1),
|
||||||
|
cursorAbsoluteLine: Math.Min(CursorAbsoluteLine + Height, Text.Lines.Count - 1));
|
||||||
|
var result = result1.SnapToLine(out var changed2);
|
||||||
|
needsRedraw = changed1 || changed2;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal DisplayTextViewPort PageUp(out bool needsRedraw)
|
||||||
|
{
|
||||||
|
var result1 = With(
|
||||||
|
out var changed1,
|
||||||
|
startingLine: Math.Max(StartingLine - Height, 0),
|
||||||
|
cursorAbsoluteLine: Math.Max(CursorAbsoluteLine - Height, 0));
|
||||||
|
var result = result1.SnapToLine(out var changed2);
|
||||||
|
needsRedraw = changed1 || changed2;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public DisplayTextViewPort CursorHome(out bool needsRedraw)
|
public DisplayTextViewPort CursorHome(out bool needsRedraw)
|
||||||
{
|
{
|
||||||
return With(
|
return With(
|
||||||
|
@ -47,35 +47,24 @@ namespace MApplication
|
|||||||
_outputView.MoveCursorTo(viewPort.CursorRelativeColumn, viewPort.CursorRelativeLine);
|
_outputView.MoveCursorTo(viewPort.CursorRelativeColumn, viewPort.CursorRelativeLine);
|
||||||
|
|
||||||
var key = Console.ReadKey(intercept: true);
|
var key = Console.ReadKey(intercept: true);
|
||||||
switch (key.Key)
|
viewPort = key.Key switch
|
||||||
{
|
{
|
||||||
case ConsoleKey.LeftArrow:
|
ConsoleKey.LeftArrow => viewPort.CursorLeft(out needsRedraw),
|
||||||
viewPort = viewPort.CursorLeft(out needsRedraw);
|
ConsoleKey.RightArrow => viewPort.CursorRight(out needsRedraw),
|
||||||
break;
|
ConsoleKey.UpArrow => viewPort.CursorUp(out needsRedraw),
|
||||||
|
ConsoleKey.DownArrow => viewPort.CursorDown(out needsRedraw),
|
||||||
case ConsoleKey.RightArrow:
|
ConsoleKey.Home => viewPort.CursorHome(out needsRedraw),
|
||||||
viewPort = viewPort.CursorRight(out needsRedraw);
|
ConsoleKey.End => viewPort.CursorEnd(out needsRedraw),
|
||||||
break;
|
ConsoleKey.PageUp => viewPort.PageUp(out needsRedraw),
|
||||||
|
ConsoleKey.PageDown => viewPort.PageDown(out needsRedraw),
|
||||||
case ConsoleKey.UpArrow:
|
_ => viewPort,
|
||||||
viewPort = viewPort.CursorUp(out needsRedraw);
|
};
|
||||||
break;
|
if (key.Key == ConsoleKey.Q)
|
||||||
|
{
|
||||||
case ConsoleKey.DownArrow:
|
return;
|
||||||
viewPort = viewPort.CursorDown(out needsRedraw);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ConsoleKey.Home:
|
|
||||||
viewPort = viewPort.CursorHome(out needsRedraw);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ConsoleKey.End:
|
|
||||||
viewPort = viewPort.CursorEnd(out needsRedraw);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Program
|
class Program
|
||||||
|
Loading…
x
Reference in New Issue
Block a user