Rectangle, Point, and Size need concerted structure #5639

Open
opened 2026-01-31 00:18:03 +00:00 by claunia · 0 comments
Owner

Originally created by @miniksa on GitHub (Dec 18, 2019).

Originally assigned to: @lhecker on GitHub.

OK, as I'm refactoring, there's a few problems:

  1. There's a lot of conversion on interface boundaries between size_t, long, and SHORT based versions of representations of rectangles, points, and sizes.
  2. There's a bunch of places where we pass a line,column pair as two size_ts because there isn't a size_t version of SIZE. It should probably be passed as one sensible struct because the ordering of these parameters keeps getting reversed too.
  3. Many of our conversions use an assorted mix of either C-cast, static_cast, gsl::narrow, gsl::narrow_cast, or intsafe.h.
  4. We don't distinguish points from sizes in console code. They're both COORD. x is width and y is height for size usage.

We're also going to want to be able to expand most of our values to reach an "infinite" scrollback.

My proposal here would be:

  • In the types library, we should create:
  1. Point
  • Contains x and y like Windows SDK 'POINT' but is size_t.
  • Has conversions to Windows SDK POINT safely.
  • Has conversions to Console's COORD safely.
  1. Size
  • Contains 'cx' and 'cy' like Windows SDK 'SIZE' but is size_t.
  • Has conversions to Windows SDK SIZE safely.
  • Has conversions to Console's COORD safely.
  1. Rectangle
  • Contains a Point and a Size.
  • Has conversions to Windows SDK RECT safely.
  • Has conversions to Console's SMALL_RECT safely.
  1. Viewport
  • Update this guy to be happy with conversions in and out of the above 3.

Then walk through the code and update to use these things.

Originally created by @miniksa on GitHub (Dec 18, 2019). Originally assigned to: @lhecker on GitHub. OK, as I'm refactoring, there's a few problems: 1. There's a lot of conversion on interface boundaries between `size_t`, `long`, and `SHORT` based versions of representations of rectangles, points, and sizes. 2. There's a bunch of places where we pass a line,column pair as two size_ts because there isn't a size_t version of `SIZE`. It should probably be passed as one sensible struct because the ordering of these parameters keeps getting reversed too. 3. Many of our conversions use an assorted mix of either C-cast, static_cast, gsl::narrow, gsl::narrow_cast, or intsafe.h. 4. We don't distinguish points from sizes in console code. They're both `COORD`. x is width and y is height for size usage. We're also going to want to be able to expand most of our values to reach an "infinite" scrollback. My proposal here would be: - In the `types` library, we should create: 1. Point - Contains `x` and `y` like Windows SDK 'POINT' but is `size_t`. - Has conversions to Windows SDK `POINT` safely. - Has conversions to Console's `COORD` safely. 2. Size - Contains 'cx' and 'cy' like Windows SDK 'SIZE' but is `size_t`. - Has conversions to Windows SDK `SIZE` safely. - Has conversions to Console's `COORD` safely. 3. Rectangle - Contains a `Point` and a `Size`. - Has conversions to Windows SDK `RECT` safely. - Has conversions to Console's `SMALL_RECT` safely. 4. Viewport - Update this guy to be happy with conversions in and out of the above 3. Then walk through the code and update to use these things.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5639