From b917db941bf08fbb89e1eb171fb0b874008ca901 Mon Sep 17 00:00:00 2001 From: "Michael Z. Kadaner" Date: Sun, 28 Jan 2024 11:52:36 -0800 Subject: [PATCH] WIP: adjust_hpos_shift works --- far/vmenu.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/far/vmenu.cpp b/far/vmenu.cpp index 5d4a733902..792a64cf3b 100644 --- a/far/vmenu.cpp +++ b/far/vmenu.cpp @@ -407,15 +407,13 @@ namespace if (Shift < 0) { - if (Right <= 0) return 0; - const auto NegativeLeftShiftLimit{ 1 - Right }; + 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) { - if (TextAreaWidth <= Left) return 0; - const auto PositiveRightShiftLimit{ TextAreaWidth - Left - 1 }; + const auto PositiveRightShiftLimit{ std::max(TextAreaWidth - Left - 1, 0) }; const auto NegativeGapLeftOfTextArea{ std::min(Right, 0) }; return std::min(Shift - NegativeGapLeftOfTextArea, PositiveRightShiftLimit); } @@ -423,19 +421,17 @@ namespace //if (Shift < 0) //{ - // if (Right <= 0) - // return 0; - // if (Left >= TextAreaWidth) - // return std::max(Shift - (Left - TextAreaWidth), 1 - Right); - // return std::max(Shift, 1 - Right); + // 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 (Right <= 0) - // return std::min(Shift - Right, TextAreaWidth - Left - 1); - // if (Left >= TextAreaWidth) - // return 0; - // return std::min(Shift, TextAreaWidth - Left - 1); + // 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; }