Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Todo: runtime detection of console support for ANSI Control Sequence Introducers (such as colors) + Operating System Commands (such as clipboard) #17

Open
SwuduSusuwu opened this issue Oct 26, 2024 · 1 comment

Comments

@SwuduSusuwu
Copy link
Owner

SwuduSusuwu commented Oct 26, 2024

cxx/Macros.hxx has compile-time detection of console support for ANSI codes; to reduce resource use, best default is this.

cxx/ClassSys.hxx + cxx/ClassSys.cxx: has run-time console (sh) functions, which will include detection of console support for ANSI attributes.

ANSI is a vast specification; this issue is just about \033[ ("CSI", short for "Control Sequence Introducer") codes + \033] ("OSC", short for "Operating System Command") codes.

Have lots to do; respond if you want this soon

SwuduSusuwu added a commit that referenced this issue Oct 29, 2024
	, +`SUSUWU_SH_BEL`, +`SUSUWU_SH_ST`, +`SUSUWU_SH_OSC`.
	`%s/"\\033\[/SUSUWU_SH_CSI "/` /* Replace magic constants with macros which refer to conventions */
	+`SUSUWU_SH_RUNTIME_COLORS`
	+`SUSUWU_PRAGMA`
	`%s/SUSUWU_USE_STDERR/SUSUWU_SH_STDERR/` /* Use _SH_ for all macro constants which have to do with `bash`/`ash`/`sh` */

?`posts/VirusAnalysis.md`: Include all of above which is used

?`README.md`:
	+How to use `SUSUWU_SH_RUNTIME_COLORS`
	`%s/SUSUWU_USE_STDERR/SUSUWU_SH_STDERR/`

Has to do with #17
SwuduSusuwu added a commit that referenced this issue Oct 29, 2024
	`SUSUWU_SH_RUNTIME_COLORS` will use this.

Has to do with #17
@SwuduSusuwu SwuduSusuwu changed the title Todo: runtime detection of console support for ANSI attributes (such as colors) Todo: runtime detection of console support for ANSI Control Sequence Introducers (such as colors) + Operating System Commands (such as clipboard) Nov 2, 2024
SwuduSusuwu added a commit that referenced this issue Nov 2, 2024
	, +`SUSUWU_SH_BEL`, +`SUSUWU_SH_ST`, +`SUSUWU_SH_OSC`,
	+`SUSUWU_SH_TO_CLIPBOARD(base64_str)` /* work-in-progress, just has `fprintf` version, doesn't include `base64(str)` function */
	`%s/"\\033\[/SUSUWU_SH_CSI "/` /* Replace magic constants with macros which refer to conventions */
	+`SUSUWU_SH_RUNTIME_OSC`, +`SUSUWU_SH_RUNTIME_COLORS` /* define to replace `#ifdef _POSIX_VERSION\ncommand\n#endif` with `termcmp`/`GetConsoleMode()`, work-in-progress */
	+`SUSUWU_PRAGMA`
	`%s/SUSUWU_USE_STDERR/SUSUWU_SH_STDERR/` /* Use _SH_ for all macro constants which have to do with `bash`/`ash`/`sh` */
	`%s/SUSUWU_SH_STDERR/SUSUWU_SH_PREFER_STDIO/` /* Operating System Commands use `std::cout`/`stdout`, thus refer to  */
	?`UNREACHABLE`: `%s/defined static_assert/defined(SUSUWU_CXX11)/` /* Fix test for `static_analysis()` */
	?`ASSUME`: "warning: found assert() that could be replaced by static_assert() [cert-dcl03-c,hicpp-static-assert,misc-static-assert]" fix (if C++11, use `static_assert()`).

?`posts/VirusAnalysis.md`: Include all of above which is used

?`README.md`:
	+How to use `SUSUWU_SH_RUNTIME_OSC`, `SUSUWU_SH_RUNTIME_COLORS`
	`%s/SUSUWU_USE_STDERR/SUSUWU_SH_PREFER_STDIO/`

Has to do with #17
Is followup to 08ed827 (+`SUSUWU_CXX11`) ce649ab (?`cxx/Macros.hxx`: `clang-tidy` fixes)
SwuduSusuwu added a commit that referenced this issue Nov 6, 2024
	for diagnostic messages.
	?`SUSUWU_SH_USE_FILE`, ?`SUSUEU_SH_USE_LINE`, ?`SUSUWU_NOTICE`, ?`SUSUWU_DEBUG`, ?`SUSUWU_DEBUGEXECUTE`: `%s/!defined(NDEBUG)/SUSUWU_SH_VERBOSE/`
	?`SUSUWU_NOTICE_EXECUTE`, ?`SUSUWU_DEBUG_EXECUTE`: indirect update (since those call `SUSUWU_NOTICE`, `SUSUWU_DEBUG`)
	Is followup to 2bb1eb7
	(SUSUWU_NOTICE_EXECUTE), 5c9e099 (+SUSUWU_DEBUGEXECUTE), aab355b (-`SUSUWU_INFO_DEBUGEXECUTE`: INFO's in `--release`, not in `--debug`)

?`README.md` How to use `-DSUSUWU_SH_VERBOSE`.

?`cxx/ClassSys.cxx`: `execves`: Warning messages:
	-`#ifndef NDEBUG`
	`%s/SUSUWU_PRINT(WARNING, /SUSUWU_NOTICE(/` (thus conditional on `SUSUWU_SH_VERBOSE`).
	Is followup to 5e0b366 (+`classSysColoredParamStr`, `clang-tidy` fixes), 7b2eba9 (?`cxx/ClassSys.hxx`:`execvesFork` ... SUSUWU_PRINT(WARNING, ...) if `wstatus` has errors)

?`cxx/VirusAnalysis.cxx`: Diagnostic messages:
	`%s/SUSUWU_PRINT(NOTICE, /SUSUWU_NOTICE(/` (thus conditional on `SUSUWU_SH_VERBOSE`).
	Indent fix

?`cxx/Macros.hxx`, ?`cxx/VirusAnalysis.cxx`, ?`cxx/CnsAssistant.cxx`:
	`%s/_DEBUGEXECUTE/_VERBOSEEXECUTE/`: since those functions got `%s/!defined(NDEBUG)/SUSUWU_SH_VERBOSE/`
	`%s/_VERBOSEEXECUTE/_EXECUTEVERBOSE/`: so that a possible future `SUSUWU_VERBOSE(message)` (`WARN_LEVEL` == `VERBOSE`) won't confuse. ( 5c9e099 should have introduced the original as `SUSUWU_EXECUTEDEBUG`, for this reason. )

?`posts/VirusAnalysis.md` /* Include all this */

All of this is about functions/macros which will improve once #17 (`SUSUWU_SH_RUNTIME_COLORS`, `classSysConsoleHasAnsiColors()`) closes, but does not assist to close.
@SwuduSusuwu
Copy link
Owner Author

f5482a0 c9c0989 was part of a local branch -- not ready to commit (thus was removed) -- but it does reflect what to expect from this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant