@@ -20,7 +20,7 @@ private static void InvertLines(int start, int count)
20
20
buffer [ i ] . ForegroundColor = ( ConsoleColor ) ( ( int ) buffer [ i ] . ForegroundColor ^ 7 ) ;
21
21
buffer [ i ] . BackgroundColor = ( ConsoleColor ) ( ( int ) buffer [ i ] . BackgroundColor ^ 7 ) ;
22
22
}
23
- _singleton . _console . WriteBufferLines ( buffer , ref start ) ;
23
+ _singleton . _console . WriteBufferLines ( buffer , ref start , false ) ;
24
24
}
25
25
26
26
/// <summary>
@@ -33,6 +33,13 @@ public static void CaptureScreen(ConsoleKeyInfo? key = null, object arg = null)
33
33
int selectionTop = _singleton . _console . CursorTop ;
34
34
int selectionHeight = 1 ;
35
35
int currentY = selectionTop ;
36
+ Internal . IConsole console = _singleton . _console ;
37
+
38
+ // We'll keep the current selection line (currentY) at least 4 lines
39
+ // away from the top or bottom of the window.
40
+ const int margin = 5 ;
41
+ Func < bool > tooCloseToTop = ( ) => { return ( currentY - console . WindowTop ) < margin ; } ;
42
+ Func < bool > tooCloseToBottom = ( ) => { return ( ( console . WindowTop + console . WindowHeight ) - currentY ) < margin ; } ;
36
43
37
44
// Current lines starts out selected
38
45
InvertLines ( selectionTop , selectionHeight ) ;
@@ -42,7 +49,11 @@ public static void CaptureScreen(ConsoleKeyInfo? key = null, object arg = null)
42
49
var k = ReadKey ( ) ;
43
50
switch ( k . Key )
44
51
{
52
+ case ConsoleKey . K :
45
53
case ConsoleKey . UpArrow :
54
+ if ( tooCloseToTop ( ) )
55
+ ScrollDisplayUpLine ( ) ;
56
+
46
57
if ( currentY > 0 )
47
58
{
48
59
currentY -= 1 ;
@@ -67,8 +78,12 @@ public static void CaptureScreen(ConsoleKeyInfo? key = null, object arg = null)
67
78
}
68
79
break ;
69
80
81
+ case ConsoleKey . J :
70
82
case ConsoleKey . DownArrow :
71
- if ( currentY < ( _singleton . _console . BufferHeight - 1 ) )
83
+ if ( tooCloseToBottom ( ) )
84
+ ScrollDisplayDownLine ( ) ;
85
+
86
+ if ( currentY < ( console . BufferHeight - 1 ) )
72
87
{
73
88
currentY += 1 ;
74
89
if ( ( k . Modifiers & ConsoleModifiers . Shift ) == ConsoleModifiers . Shift )
@@ -103,6 +118,7 @@ public static void CaptureScreen(ConsoleKeyInfo? key = null, object arg = null)
103
118
case ConsoleKey . Enter :
104
119
InvertLines ( selectionTop , selectionHeight ) ;
105
120
DumpScreenToClipboard ( selectionTop , selectionHeight ) ;
121
+ ScrollDisplayToCursor ( ) ;
106
122
return ;
107
123
108
124
case ConsoleKey . Escape :
@@ -124,6 +140,7 @@ public static void CaptureScreen(ConsoleKeyInfo? key = null, object arg = null)
124
140
}
125
141
}
126
142
InvertLines ( selectionTop , selectionHeight ) ;
143
+ ScrollDisplayToCursor ( ) ;
127
144
}
128
145
129
146
private const string CmdColorTable = @"
0 commit comments