terminal/src/host
James Holderness bb71179a24
Consolidate the color palette APIs (#11784)
This PR merges the default colors and cursor color into the main color
table, enabling us to simplify the `ConGetSet` and `ITerminalApi`
interfaces, with just two methods required for getting and setting any
form of color palette entry.

The is a follow-up to the color table standardization in #11602, and a
another small step towards de-duplicating `AdaptDispatch` and
`TerminalDispatch` for issue #3849. It should also make it easier to
support color queries (#3718) and a configurable bold color (#5682) in
the future.

On the conhost side, default colors could originally be either indexed
positions in the 16-color table, or separate standalone RGB values. With
the new system, the default colors will always be in the color table, so
we just need to track their index positions.

To make this work, those positions need to be calculated at startup
based on the loaded registry/shortcut settings, and updated when
settings are changed (this is handled in
`CalculateDefaultColorIndices`). But the plus side is that it's now much
easier to lookup the default color values for rendering.

For now the default colors in Windows Terminal use hardcoded positions,
because it doesn't need indexed default colors like conhost. But in the
future I'd like to extend the index handling to both terminals, so we
can eventually support the VT525 indexed color operations.

As for the cursor color, that was previously stored in the `Cursor`
class, which meant that it needed to be copied around in various places
where cursors were being instantiated. Now that it's managed separately
in the color table, a lot of that code is no longer required.

## Validation
Some of the unit test initialization code needed to be updated to setup
the color table and default index values as required for the new system.
There were also some adjustments needed to account for API changes, in
particular for methods that now take index values for the default colors
in place of COLORREFs. But for the most part, the essential behavior of
the tests remains unchanged.

I've also run a variety of manual tests looking at the legacy console
APIs as well as the various VT color sequences, and checking that
everything works as expected when color schemes are changed, both in
Windows Terminal and conhost, and in the latter case with both indexed
colors and RGB values.

Closes #11768
2021-11-23 18:28:55 +00:00
..
exe Introduce AtlasEngine - A new text rendering prototype (#11623) 2021-11-13 00:10:06 +00:00
ft_fuzzer Introduce AtlasEngine - A new text rendering prototype (#11623) 2021-11-13 00:10:06 +00:00
ft_host Introduce AtlasEngine - A new text rendering prototype (#11623) 2021-11-13 00:10:06 +00:00
ft_integrity Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
ft_uia Wrap these commands with quotes (#11807) 2021-11-23 17:01:59 +00:00
lib Standardize the color table order (#11602) 2021-11-04 22:13:22 +00:00
proxy Fix OpenConsoleProxy for Debug builds (#11632) 2021-10-27 19:59:28 +02:00
ut_host Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
ut_lib Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
ApiRoutines.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
CommandListPopup.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
CommandListPopup.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CommandNumberPopup.cpp WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
CommandNumberPopup.hpp Add explicit identifier to some constructors (#5652) 2020-04-29 16:50:47 -07:00
ConsoleArguments.cpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
ConsoleArguments.hpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
CopyFromCharPopup.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyFromCharPopup.hpp Add explicit identifier to some constructors (#5652) 2020-04-29 16:50:47 -07:00
CopyToCharPopup.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyToCharPopup.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CursorBlinker.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
CursorBlinker.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
IIoProvider.hpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
PtySignalInputThread.cpp Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
PtySignalInputThread.hpp Implement and action for manually clearing the Terminal (and conpty) buffer (#10906) 2021-09-02 14:59:42 +00:00
ScreenBufferRenderTarget.cpp Fix TerminalControl crash on exit (#10031) 2021-05-04 21:17:37 +00:00
ScreenBufferRenderTarget.hpp Fix TerminalControl crash on exit (#10031) 2021-05-04 21:17:37 +00:00
VtInputThread.cpp Add names to threads to make debugging a slight bit easier (#9801) 2021-04-14 10:56:52 +00:00
VtInputThread.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
VtIo.cpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
VtIo.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
_output.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
_output.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
_stream.cpp Improve WriteCharsLegacy performance by increasing local buffer size (#10921) 2021-08-12 17:54:59 +00:00
_stream.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
alias.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
alias.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
cmdline.cpp WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
cmdline.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
conapi.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
conareainfo.cpp Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
conareainfo.h Improve the legacy color conversions (#6358) 2020-06-08 19:05:06 +00:00
conddkrefs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
conhost.rcv Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
conhostv2_traceviewpp.tvpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
conimeinfo.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
conimeinfo.h Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
conserv.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
consoleInformation.cpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
conv.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
convarea.cpp Make sure we don't hide the cursor until the IME starts (#7673) 2020-09-18 19:25:39 +00:00
conwinuserrefs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
dbcs.cpp Replace gsl::at with a new til::at(span) for pre-checked bounds (#6925) 2020-07-15 10:29:36 -07:00
dbcs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
directio.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
directio.h Switch all DSR responses to appending instead of prepending (#7583) 2020-09-09 23:55:22 +00:00
dirs Merged PR 5677497: [Git2Git] Merged PR 5655213: Allow conhost to handoff to registered default app handler 2021-02-11 21:07:50 +00:00
getset.cpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
getset.h Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
globals.cpp Implement a pair of shims for `cls`, `Clear-Host` in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
globals.h Introduce AtlasEngine - A new text rendering prototype (#11623) 2021-11-13 00:10:06 +00:00
handle.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
handle.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
history.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
history.h Replace macros with constexpr part 2 (#3416) 2019-11-04 07:37:47 -06:00
host-common.vcxitems Standardize the color table order (#11602) 2021-11-04 22:13:22 +00:00
init.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
init.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
input.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
input.h Replace macros with constexpr part 2 (#3416) 2019-11-04 07:37:47 -06:00
inputBuffer.cpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
inputBuffer.hpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
inputKeyInfo.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
inputReadHandleData.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
inputReadHandleData.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
misc.cpp #10497: Do not force the font on output codepage change (#10591) 2021-07-08 21:10:35 +00:00
misc.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
ntprivapi.cpp Implement basic profile matching (#11390) 2021-10-08 00:40:10 +00:00
ntprivapi.hpp Implement basic profile matching (#11390) 2021-10-08 00:40:10 +00:00
output.cpp Add support for double-width/double-height lines in conhost (#8664) 2021-02-18 05:44:50 +00:00
output.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
outputStream.cpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
outputStream.hpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
popup.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
popup.h Improve the legacy color conversions (#6358) 2020-06-08 19:05:06 +00:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Reduce Transient Allocations during Bulk Text Output (#8617) 2021-01-05 18:06:06 +00:00
readData.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
readData.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataCooked.cpp Merged PR 6285331: [Git2Git] Merged PR 6278637: Expose attached client process context to cooked read trace 2021-07-22 13:39:34 +00:00
readDataCooked.hpp Merged PR 6285331: [Git2Git] Merged PR 6278637: Expose attached client process context to cooked read trace 2021-07-22 13:39:34 +00:00
readDataDirect.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataDirect.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataRaw.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataRaw.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
registry.cpp Standardize the color table order (#11602) 2021-11-04 22:13:22 +00:00
registry.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
renderData.cpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
renderData.hpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
renderFontDefaults.cpp Allow FontInfo{,Base,Desired} to store a font name > 32 wch (#3107) 2019-10-14 21:23:45 -07:00
renderFontDefaults.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
res.rc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
resource.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
runft.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
runtests.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
runut.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
screenInfo.cpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
screenInfo.hpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
scrolling.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
scrolling.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
selection.cpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
selection.hpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
selectionInput.cpp Standardize the color table order (#11602) 2021-11-04 22:13:22 +00:00
selectionState.cpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
server.h Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
settings.cpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
settings.hpp Consolidate the color palette APIs (#11784) 2021-11-23 18:28:55 +00:00
sources.inc Migrate OSS up to f9b97c488 2021-11-09 13:39:28 -06:00
sources.test.inc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
srvinit.cpp Add even MORE logging for defterm (#11537) 2021-10-19 13:29:18 -07:00
srvinit.h Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
stream.cpp Migrate OSS up to f9a844dbd 2021-09-21 16:22:57 -05:00
stream.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
telemetry.cpp Migrate OSS up to f9a844dbd 2021-09-21 16:22:57 -05:00
telemetry.hpp Merged PR 6277720: [Git2Git] Merged PR 6275065: Trace console attach/detatch 2021-07-21 18:41:37 +00:00
tracing.cpp Migrate OSS up to f9a844dbd 2021-09-21 16:22:57 -05:00
tracing.hpp Merged PR 6285331: [Git2Git] Merged PR 6278637: Expose attached client process context to cooked read trace 2021-07-22 13:39:34 +00:00
utf8ToWideCharParser.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
utf8ToWideCharParser.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
utils.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
utils.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
writeData.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
writeData.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00