Add clamped math methods to til types #7219

Open
opened 2026-01-31 00:58:12 +00:00 by claunia · 0 comments
Owner

Originally created by @zadjii-msft on GitHub (Mar 30, 2020).

Add a clamped sub method to til::point instead of doing it on the outside? I feel like this line should read

const auto offsetPoint = coord.ClampSub(controlOrigin);

Originally posted by @miniksa in https://github.com/microsoft/terminal/pull/5131

I moved this because I thought this comment was a generally good idea. We've got checked math operators defined on the til types already, but there are scenarios where one might want to use clamped math instead. Those callers should be able to use pointA.ClampedAdd(pointB), etc. to be able to do clamped math.

This seems like an easier solution than having some sort of other magic to say "I want a clamped point" that always does clamped math.

Originally created by @zadjii-msft on GitHub (Mar 30, 2020). Add a clamped sub method to til::point instead of doing it on the outside? I feel like this line should read ``` const auto offsetPoint = coord.ClampSub(controlOrigin); ``` _Originally posted by @miniksa in https://github.com/microsoft/terminal/pull/5131_ I moved this because I thought this comment was a generally good idea. We've got checked math operators defined on the `til` types already, but there are scenarios where one might want to use clamped math instead. Those callers should be able to use `pointA.ClampedAdd(pointB)`, etc. to be able to do clamped math. This seems like an easier solution than having some sort of other magic to say "I want a clamped point" that _always_ does clamped math.
claunia added the Help WantedIssue-TaskProduct-MetaArea-CodeHealth labels 2026-01-31 00:58:12 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#7219