[PR #12247] [MERGED] Refactor and simplify the ConGetSet API #28924

Open
opened 2026-01-31 09:31:40 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/12247
Author: @j4james
Created: 1/25/2022
Status: Merged
Merged: 2/4/2022
Merged by: @undefined

Base: mainHead: refactor-congetset


📝 Commits (10+)

  • e9a3992 Remove DoSrvPrivateWriteConsoleInputW.
  • ce0f0d1 Remove DoSrvPrivateSetAutoWrapMode.
  • 3eb03bd Remove DoSrvPrivateShowCursor.
  • e5b141c Remove DoSrvPrivateAllowCursorBlinking.
  • 841a357 Remove DoSrvPrivateSetScrollingRegion.
  • d5cc106 Remove DoSrvPrivateLineFeed.
  • e1992ed Remove DoSrvPrivateReverseLineFeed.
  • 6d13028 Remove DoSrvPrivateUseAlternateScreenBuffer.
  • 5568c9e Remove DoSrvPrivateUseMainScreenBuffer.
  • 7b05ba5 Remove DoSrvPrivateEraseAll.

📊 Changes

24 files changed (+1706 additions, -2482 deletions)

View changed files

📝 src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp (+1 -1)
📝 src/host/PtySignalInputThread.cpp (+1 -1)
📝 src/host/cmdline.h (+0 -2)
📝 src/host/directio.cpp (+0 -44)
📝 src/host/directio.h (+0 -8)
📝 src/host/getset.cpp (+3 -506)
📝 src/host/getset.h (+0 -52)
📝 src/host/outputStream.cpp (+374 -236)
📝 src/host/outputStream.hpp (+54 -54)
📝 src/host/ut_host/ConptyOutputTests.cpp (+1 -1)
📝 src/host/ut_host/ScreenBufferTests.cpp (+4 -3)
📝 src/terminal/adapter/DispatchCommon.cpp (+30 -41)
📝 src/terminal/adapter/DispatchCommon.hpp (+2 -2)
📝 src/terminal/adapter/InteractDispatch.cpp (+42 -83)
📝 src/terminal/adapter/adaptDispatch.cpp (+609 -749)
📝 src/terminal/adapter/adaptDispatch.hpp (+11 -11)
📝 src/terminal/adapter/adaptDispatchGraphics.cpp (+186 -206)
📝 src/terminal/adapter/conGetSet.hpp (+49 -51)
📝 src/terminal/adapter/ut_adapter/adapterTest.cpp (+221 -297)
📝 src/terminal/parser/InputStateMachineEngine.cpp (+4 -11)

...and 4 more files

📄 Description

Summary of the Pull Request

This PR refactors the ConGetSet API, eliminating some of the bloat produced by the DoSrvPrivateXXXX functions, simplifying the method naming to more closely match the ITerminalApi interface, and making better use of exceptions for error conditions in place of boolean return values.

References

This is another small step towards merging the AdaptDispatch and TerminalDispatch classes (#3849).

PR Checklist

Detailed Description of the Pull Request / Additional comments

There are two main parts to this. The first step was to get rid of all the DoSrvPrivateXXX functions, and move their implementation directly into the ConhostInternalGetSet class. For the most part this was just copying and pasting the code, but I also fixed a couple of bugs where we were using the wrong output buffer (the global buffer rather than the one associated with the output handle), and got rid of some unnecessary calls to GetActiveBuffer.

The second part was to make better use of exceptions for error conditions. Instead of catching the exceptions at the ConGetSet level, we now allow them to fall through all the way to the StateMachine. This greatly simplifies the AdaptDispatch implementation since it no longer needs to check a boolean return value on every ConGetSet call. This also enables the getter methods to return properties directly instead of having to use a reference parameter.

Validation Steps Performed

A number of the unit tests had to be updated to match the new API. Sometimes this just required changes to method names, but in other cases error conditions that were previously detected with boolean returns now needed to be caught as exceptions.

There were also a few direct calls to DoSrvPrivateXXX functions that now needed to be invoked through other means: either by generating an equivalent escape sequence, or calling a lower level API serving the same purpose.

And in the adapter tests, the mock ConGetSet implementation required significant refactoring to match the new interface, mostly to account for the changes in error handling.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/12247 **Author:** [@j4james](https://github.com/j4james) **Created:** 1/25/2022 **Status:** ✅ Merged **Merged:** 2/4/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `refactor-congetset` --- ### 📝 Commits (10+) - [`e9a3992`](https://github.com/microsoft/terminal/commit/e9a3992eec9879b164d192cd8907ef970ae33da8) Remove DoSrvPrivateWriteConsoleInputW. - [`ce0f0d1`](https://github.com/microsoft/terminal/commit/ce0f0d1d6eff6c134583bb9bbabe7a36338e1ca7) Remove DoSrvPrivateSetAutoWrapMode. - [`3eb03bd`](https://github.com/microsoft/terminal/commit/3eb03bd0961c285dc724947e158a3d176203e76a) Remove DoSrvPrivateShowCursor. - [`e5b141c`](https://github.com/microsoft/terminal/commit/e5b141c4f9c775e3a251a19ee961f4bdb41f6bde) Remove DoSrvPrivateAllowCursorBlinking. - [`841a357`](https://github.com/microsoft/terminal/commit/841a3573f672720c6b28352f8f46ad67d4ace1d1) Remove DoSrvPrivateSetScrollingRegion. - [`d5cc106`](https://github.com/microsoft/terminal/commit/d5cc1068c1c32271346c644b68825ebbb18a5197) Remove DoSrvPrivateLineFeed. - [`e1992ed`](https://github.com/microsoft/terminal/commit/e1992ed739e72b5607d06279de4974ab6852903e) Remove DoSrvPrivateReverseLineFeed. - [`6d13028`](https://github.com/microsoft/terminal/commit/6d13028b7597e8d319188faea8ffac1a6a1eb4af) Remove DoSrvPrivateUseAlternateScreenBuffer. - [`5568c9e`](https://github.com/microsoft/terminal/commit/5568c9eccae9d92ff892abd59dd7cc14d332e6ba) Remove DoSrvPrivateUseMainScreenBuffer. - [`7b05ba5`](https://github.com/microsoft/terminal/commit/7b05ba55d40353efed5f1b19ccd0c9b71201e291) Remove DoSrvPrivateEraseAll. ### 📊 Changes **24 files changed** (+1706 additions, -2482 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/UnitTests_TerminalCore/ConptyRoundtripTests.cpp` (+1 -1) 📝 `src/host/PtySignalInputThread.cpp` (+1 -1) 📝 `src/host/cmdline.h` (+0 -2) 📝 `src/host/directio.cpp` (+0 -44) 📝 `src/host/directio.h` (+0 -8) 📝 `src/host/getset.cpp` (+3 -506) 📝 `src/host/getset.h` (+0 -52) 📝 `src/host/outputStream.cpp` (+374 -236) 📝 `src/host/outputStream.hpp` (+54 -54) 📝 `src/host/ut_host/ConptyOutputTests.cpp` (+1 -1) 📝 `src/host/ut_host/ScreenBufferTests.cpp` (+4 -3) 📝 `src/terminal/adapter/DispatchCommon.cpp` (+30 -41) 📝 `src/terminal/adapter/DispatchCommon.hpp` (+2 -2) 📝 `src/terminal/adapter/InteractDispatch.cpp` (+42 -83) 📝 `src/terminal/adapter/adaptDispatch.cpp` (+609 -749) 📝 `src/terminal/adapter/adaptDispatch.hpp` (+11 -11) 📝 `src/terminal/adapter/adaptDispatchGraphics.cpp` (+186 -206) 📝 `src/terminal/adapter/conGetSet.hpp` (+49 -51) 📝 `src/terminal/adapter/ut_adapter/adapterTest.cpp` (+221 -297) 📝 `src/terminal/parser/InputStateMachineEngine.cpp` (+4 -11) _...and 4 more files_ </details> ### 📄 Description ## Summary of the Pull Request This PR refactors the `ConGetSet` API, eliminating some of the bloat produced by the `DoSrvPrivateXXXX` functions, simplifying the method naming to more closely match the `ITerminalApi` interface, and making better use of exceptions for error conditions in place of boolean return values. ## References This is another small step towards merging the `AdaptDispatch` and `TerminalDispatch` classes (#3849). ## PR Checklist * [x] Closes #12193 * [x] Closes #12194 * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [x] I've discussed this with core contributors already. Issue number where discussion took place: #3849 ## Detailed Description of the Pull Request / Additional comments There are two main parts to this. The first step was to get rid of all the `DoSrvPrivateXXX` functions, and move their implementation directly into the `ConhostInternalGetSet` class. For the most part this was just copying and pasting the code, but I also fixed a couple of bugs where we were using the wrong output buffer (the global buffer rather than the one associated with the output handle), and got rid of some unnecessary calls to `GetActiveBuffer`. The second part was to make better use of exceptions for error conditions. Instead of catching the exceptions at the `ConGetSet` level, we now allow them to fall through all the way to the `StateMachine`. This greatly simplifies the `AdaptDispatch` implementation since it no longer needs to check a boolean return value on every `ConGetSet` call. This also enables the getter methods to return properties directly instead of having to use a reference parameter. ## Validation Steps Performed A number of the unit tests had to be updated to match the new API. Sometimes this just required changes to method names, but in other cases error conditions that were previously detected with boolean returns now needed to be caught as exceptions. There were also a few direct calls to `DoSrvPrivateXXX` functions that now needed to be invoked through other means: either by generating an equivalent escape sequence, or calling a lower level API serving the same purpose. And in the adapter tests, the mock `ConGetSet` implementation required significant refactoring to match the new interface, mostly to account for the changes in error handling. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:31:40 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28924