@@ -39,10 +39,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
39
39
// - coordCursor - New location of cursor.
40
40
// - fKeepCursorVisible - TRUE if changing window origin desirable when hit right edge
41
41
// Return Value:
42
- [[nodiscard]] NTSTATUS AdjustCursorPosition (SCREEN_INFORMATION& screenInfo,
43
- _In_ til::point coordCursor,
44
- const BOOL fKeepCursorVisible ,
45
- _Inout_opt_ til::CoordType* psScrollY)
42
+ void AdjustCursorPosition (SCREEN_INFORMATION& screenInfo, _In_ til::point coordCursor, const BOOL fKeepCursorVisible , _Inout_opt_ til::CoordType* psScrollY)
46
43
{
47
44
const auto bufferSize = screenInfo.GetBufferSize ().Dimensions ();
48
45
if (coordCursor.x < 0 )
@@ -71,16 +68,10 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
71
68
}
72
69
}
73
70
74
- auto Status = STATUS_SUCCESS;
75
-
76
71
if (coordCursor.y >= bufferSize.height )
77
72
{
78
73
// At the end of the buffer. Scroll contents of screen buffer so new position is visible.
79
- FAIL_FAST_IF (!(coordCursor.y == bufferSize.height ));
80
- if (!StreamScrollRegion (screenInfo))
81
- {
82
- Status = STATUS_NO_MEMORY;
83
- }
74
+ StreamScrollRegion (screenInfo);
84
75
85
76
if (nullptr != psScrollY)
86
77
{
@@ -90,28 +81,21 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
90
81
}
91
82
92
83
const auto cursorMovedPastViewport = coordCursor.y > screenInfo.GetViewport ().BottomInclusive ();
93
- if (SUCCEEDED_NTSTATUS (Status))
84
+
85
+ // if at right or bottom edge of window, scroll right or down one char.
86
+ if (cursorMovedPastViewport)
94
87
{
95
- // if at right or bottom edge of window, scroll right or down one char.
96
- if (cursorMovedPastViewport)
97
- {
98
- til::point WindowOrigin;
99
- WindowOrigin.x = 0 ;
100
- WindowOrigin.y = coordCursor.y - screenInfo.GetViewport ().BottomInclusive ();
101
- Status = screenInfo.SetViewportOrigin (false , WindowOrigin, true );
102
- }
88
+ til::point WindowOrigin;
89
+ WindowOrigin.x = 0 ;
90
+ WindowOrigin.y = coordCursor.y - screenInfo.GetViewport ().BottomInclusive ();
91
+ LOG_IF_FAILED (screenInfo.SetViewportOrigin (false , WindowOrigin, true ));
103
92
}
104
93
105
- if (SUCCEEDED_NTSTATUS (Status) )
94
+ if (fKeepCursorVisible )
106
95
{
107
- if (fKeepCursorVisible )
108
- {
109
- screenInfo.MakeCursorVisible (coordCursor);
110
- }
111
- Status = screenInfo.SetCursorPosition (coordCursor, !!fKeepCursorVisible );
96
+ screenInfo.MakeCursorVisible (coordCursor);
112
97
}
113
-
114
- return Status;
98
+ LOG_IF_FAILED (screenInfo.SetCursorPosition (coordCursor, !!fKeepCursorVisible ));
115
99
}
116
100
117
101
// Routine Description:
@@ -180,7 +164,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
180
164
CursorPosition.x = 0 ;
181
165
CursorPosition.y ++;
182
166
183
- Status = AdjustCursorPosition (screenInfo, CursorPosition, WI_IsFlagSet (dwFlags, WC_KEEP_CURSOR_VISIBLE), psScrollY);
167
+ AdjustCursorPosition (screenInfo, CursorPosition, WI_IsFlagSet (dwFlags, WC_KEEP_CURSOR_VISIBLE), psScrollY);
184
168
185
169
CursorPosition = cursor.GetPosition ();
186
170
}
@@ -372,7 +356,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
372
356
// WCL-NOTE: wrong place (typically inside another character).
373
357
CursorPosition.x = XPosition;
374
358
375
- Status = AdjustCursorPosition (screenInfo, CursorPosition, WI_IsFlagSet (dwFlags, WC_KEEP_CURSOR_VISIBLE), psScrollY);
359
+ AdjustCursorPosition (screenInfo, CursorPosition, WI_IsFlagSet (dwFlags, WC_KEEP_CURSOR_VISIBLE), psScrollY);
376
360
377
361
// WCL-NOTE: If we have processed the entire input string during our "fast one-line print" handler,
378
362
// WCL-NOTE: we are done as there is nothing more to do. Neat!
@@ -501,7 +485,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
501
485
CursorPosition.x -= 1 ;
502
486
TempNumSpaces -= 1 ;
503
487
504
- Status = AdjustCursorPosition (screenInfo, CursorPosition, dwFlags & WC_KEEP_CURSOR_VISIBLE, psScrollY);
488
+ AdjustCursorPosition (screenInfo, CursorPosition, dwFlags & WC_KEEP_CURSOR_VISIBLE, psScrollY);
505
489
if (dwFlags & WC_DESTRUCTIVE_BACKSPACE)
506
490
{
507
491
try
@@ -523,7 +507,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
523
507
CursorPosition.x = 0 ;
524
508
OutputDebugStringA ((" CONSRV: Ignoring backspace to previous line\n " ));
525
509
}
526
- Status = AdjustCursorPosition (screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0 , psScrollY);
510
+ AdjustCursorPosition (screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0 , psScrollY);
527
511
if (dwFlags & WC_DESTRUCTIVE_BACKSPACE)
528
512
{
529
513
try
@@ -548,7 +532,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
548
532
// on the prev row if it was set
549
533
textBuffer.GetRowByOffset (CursorPosition.y ).SetWrapForced (false );
550
534
551
- Status = AdjustCursorPosition (screenInfo, CursorPosition, dwFlags & WC_KEEP_CURSOR_VISIBLE, psScrollY);
535
+ AdjustCursorPosition (screenInfo, CursorPosition, dwFlags & WC_KEEP_CURSOR_VISIBLE, psScrollY);
552
536
}
553
537
}
554
538
// Notify accessibility to read the backspaced character.
@@ -598,7 +582,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
598
582
}
599
583
CATCH_LOG ();
600
584
601
- Status = AdjustCursorPosition (screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0 , psScrollY);
585
+ AdjustCursorPosition (screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0 , psScrollY);
602
586
break ;
603
587
}
604
588
case UNICODE_CARRIAGERETURN:
@@ -609,7 +593,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
609
593
pwchBuffer++;
610
594
CursorPosition.x = 0 ;
611
595
CursorPosition.y = cursor.GetPosition ().y ;
612
- Status = AdjustCursorPosition (screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0 , psScrollY);
596
+ AdjustCursorPosition (screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0 , psScrollY);
613
597
break ;
614
598
}
615
599
case UNICODE_LINEFEED:
@@ -632,7 +616,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
632
616
textBuffer.GetRowByOffset (cursor.GetPosition ().y ).SetWrapForced (false );
633
617
}
634
618
635
- Status = AdjustCursorPosition (screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0 , psScrollY);
619
+ AdjustCursorPosition (screenInfo, CursorPosition, (dwFlags & WC_KEEP_CURSOR_VISIBLE) != 0 , psScrollY);
636
620
break ;
637
621
}
638
622
default :
@@ -678,7 +662,7 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
678
662
// is too wide to fit on the current line).
679
663
Row.SetDoubleBytePadded (true );
680
664
681
- Status = AdjustCursorPosition (screenInfo, CursorPosition, dwFlags & WC_KEEP_CURSOR_VISIBLE, psScrollY);
665
+ AdjustCursorPosition (screenInfo, CursorPosition, dwFlags & WC_KEEP_CURSOR_VISIBLE, psScrollY);
682
666
continue ;
683
667
}
684
668
break ;
0 commit comments