From 9e8508177e81f53aaeeb1a4c46046e6ae2c6fce7 Mon Sep 17 00:00:00 2001 From: "Michael Z. Kadaner" Date: Sun, 28 Jan 2024 14:52:54 -0800 Subject: [PATCH] WIP: adjust_hpos_shift and test finalized. --- far/vmenu.cpp | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) diff --git a/far/vmenu.cpp b/far/vmenu.cpp index 2098f313105..8e6356aea9c 100644 --- a/far/vmenu.cpp +++ b/far/vmenu.cpp @@ -409,42 +409,12 @@ namespace if (Shift > 0) { - const auto RightShiftLimit{ std::max(TextAreaWidth - Left - 1, 0) }; + const auto ShiftLimit{ std::max(TextAreaWidth - Left - 1, 0) }; const auto GapLeftOfTextArea{ std::max(-Right, 0) }; - return std::min(Shift + GapLeftOfTextArea, RightShiftLimit); + return std::min(Shift + GapLeftOfTextArea, ShiftLimit); } return -adjust_hpos_shift(-Shift, TextAreaWidth - Right, TextAreaWidth - Left, TextAreaWidth); - - //if (Shift < 0) - //{ - // const auto NegativeLeftShiftLimit{ std::min(1 - Right, 0) }; - // const auto PositiveGapRightOfTextArea{ std::max(Left - TextAreaWidth, 0) }; - // return std::max(Shift - PositiveGapRightOfTextArea, NegativeLeftShiftLimit); - //} - //if (Shift > 0) - //{ - // const auto PositiveRightShiftLimit{ std::max(TextAreaWidth - Left - 1, 0) }; - // const auto NegativeGapLeftOfTextArea{ std::min(Right, 0) }; - // return std::min(Shift - NegativeGapLeftOfTextArea, PositiveRightShiftLimit); - //} - //return 0; - - //if (Shift < 0) - //{ - // if (Right <= 0) return 0; - // const auto NegativeLeftShiftLimit{ 1 - Right }; - // const auto PositiveGapRightOfTextArea{ std::max(Left - TextAreaWidth, 0) }; - // return std::max(Shift - PositiveGapRightOfTextArea, NegativeLeftShiftLimit); - //} - //if (Shift > 0) - //{ - // if (TextAreaWidth <= Left) return 0; - // const auto PositiveRightShiftLimit{ TextAreaWidth - Left - 1 }; - // const auto NegativeGapLeftOfTextArea{ std::min(Right, 0) }; - // return std::min(Shift - NegativeGapLeftOfTextArea, PositiveRightShiftLimit); - //} - //return 0; } int adjust_en_bloc_shift(const int Shift, const int EnBlocHScrollDiscriminator, const int TextAreaWidth) @@ -3795,8 +3765,6 @@ TEST_CASE("adjust.hpos.shift") REQUIRE(TestDataPoint.Expected[I] == adjust_hpos_shift(Shifts[I], TestDataPoint.Left, TestDataPoint.Right, TextAreaWidth)); } } - - // adjust_hpos_shift } TEST_CASE("adjust.en.bloc.shift")