From b5b232a04dbdd0e7f9312f50ae6447d92e01c0a6 Mon Sep 17 00:00:00 2001 From: Markus Gans Date: Mon, 23 Oct 2023 00:38:59 +0200 Subject: [PATCH] Reorganize the data structure of FOptiAttr --- final/output/tty/fterm.cpp | 64 +++++++----------- test/foptiattr-test.cpp | 134 +++++++++++++++++++++++-------------- 2 files changed, 108 insertions(+), 90 deletions(-) diff --git a/final/output/tty/fterm.cpp b/final/output/tty/fterm.cpp index a64023c1..bb145665 100644 --- a/final/output/tty/fterm.cpp +++ b/final/output/tty/fterm.cpp @@ -1203,44 +1203,32 @@ void FTerm::init_optiAttr() const FOptiAttr::TermEnv optiattr_env = { - TCAP(t_enter_bold_mode), - TCAP(t_exit_bold_mode), - TCAP(t_enter_dim_mode), - TCAP(t_exit_dim_mode), - TCAP(t_enter_italics_mode), - TCAP(t_exit_italics_mode), - TCAP(t_enter_underline_mode), - TCAP(t_exit_underline_mode), - TCAP(t_enter_blink_mode), - TCAP(t_exit_blink_mode), - TCAP(t_enter_reverse_mode), - TCAP(t_exit_reverse_mode), - TCAP(t_enter_standout_mode), - TCAP(t_exit_standout_mode), - TCAP(t_enter_secure_mode), - TCAP(t_exit_secure_mode), - TCAP(t_enter_protected_mode), - TCAP(t_exit_protected_mode), - TCAP(t_enter_crossed_out_mode), - TCAP(t_exit_crossed_out_mode), - TCAP(t_enter_dbl_underline_mode), - TCAP(t_exit_dbl_underline_mode), - TCAP(t_set_attributes), - TCAP(t_exit_attribute_mode), - TCAP(t_enter_alt_charset_mode), - TCAP(t_exit_alt_charset_mode), - TCAP(t_enter_pc_charset_mode), - TCAP(t_exit_pc_charset_mode), - TCAP(t_set_a_foreground), - TCAP(t_set_a_background), - TCAP(t_set_foreground), - TCAP(t_set_background), - TCAP(t_orig_pair), - TCAP(t_orig_pair), - TCAP(t_orig_colors), - FTermcap::max_color, - FTermcap::attr_without_color, - FTermcap::ansi_default_color + { TCAP(t_enter_bold_mode) , TCAP(t_exit_bold_mode) }, + { TCAP(t_enter_dim_mode) , TCAP(t_exit_dim_mode) }, + { TCAP(t_enter_italics_mode) , TCAP(t_exit_italics_mode) }, + { TCAP(t_enter_underline_mode) , TCAP(t_exit_underline_mode) }, + { TCAP(t_enter_blink_mode) , TCAP(t_exit_blink_mode) }, + { TCAP(t_enter_reverse_mode) , TCAP(t_exit_reverse_mode) }, + { TCAP(t_enter_standout_mode) , TCAP(t_exit_standout_mode) }, + { TCAP(t_enter_secure_mode) , TCAP(t_exit_secure_mode) }, + { TCAP(t_enter_protected_mode) , TCAP(t_exit_protected_mode) }, + { TCAP(t_enter_crossed_out_mode) , TCAP(t_exit_crossed_out_mode) }, + { TCAP(t_enter_dbl_underline_mode) , TCAP(t_exit_dbl_underline_mode) }, + { TCAP(t_set_attributes) , TCAP(t_exit_attribute_mode) }, + { TCAP(t_enter_alt_charset_mode) , TCAP(t_exit_alt_charset_mode) }, + { TCAP(t_enter_pc_charset_mode) , TCAP(t_exit_pc_charset_mode) }, + { + TCAP(t_set_a_foreground), + TCAP(t_set_a_background), + TCAP(t_set_foreground), + TCAP(t_set_background), + TCAP(t_set_color_pair), + TCAP(t_orig_pair), + TCAP(t_orig_colors), + FTermcap::max_color, + FTermcap::attr_without_color, + FTermcap::ansi_default_color + } }; static auto& opti_attr = FOptiAttr::getInstance(); diff --git a/test/foptiattr-test.cpp b/test/foptiattr-test.cpp index cffa0027..8f1d9475 100644 --- a/test/foptiattr-test.cpp +++ b/test/foptiattr-test.cpp @@ -4149,58 +4149,88 @@ void FOptiAttrTest::wyse50Test() finalcut::FOptiAttr oa; finalcut::FOptiAttr::TermEnv optiattr_env = { - nullptr, // Enter bold - ESC "(" ESC "H\003" - ESC "G0" ESC "cD", // Exit bold - ESC "Gp", // Enter dim - ESC "(" ESC "H\003" - ESC "G0" ESC "cD", // Exit dim - nullptr, // Enter italics - nullptr, // Exit italics - ESC "G8", // Enter underline - ESC "G0", // Exit underline - ESC "G2", // Enter blink - ESC "(" ESC "H\003" - ESC "G0" ESC "cD", // Exit blink - ESC "G2", // Enter reverse - ESC "(" ESC "H\003" - ESC "G0" ESC "cD", // Exit reverse - ESC "Gt", // Enter standout - ESC "G0", // Exit standout - ESC "G1", // Enter secure - ESC "(" ESC "H\003" - ESC "G0" ESC "cD", // Exit secure - ESC ")", // Enter protected - ESC "(" ESC "H\003" - ESC "G0" ESC "cD", // Exit protected - nullptr, // Enter crossed out - ESC "(" ESC "H\003" - ESC "G0" ESC "cD", // Exit crossed out - nullptr, // Enter double underline - nullptr, // Exit double underline - "%?%p8%t\033)%e\033(%;" - "%?%p9%t\033cE%e\033cD%;\033G%'0'" - "%?%p2%t%{8}%|%;" - "%?%p1%p3%|%p6%|%t%{4}%|%;" - "%?%p4%t%{2}%|%;" - "%?%p1%p5%|%t%'@'%|%;" - "%?%p7%t%{1}%|%;%c", // Set attributes - ESC "(" ESC "H\003" - ESC "G0" ESC "cD", // Exit attribute - ESC "cE", // Enter alt charset - ESC "cD", // Exit alt charset - nullptr, // Enter pc charset - nullptr, // Exit pc charset - nullptr, // Ansi foreground color - nullptr, // Ansi background color - nullptr, // Foreground color - nullptr, // Background color - nullptr, // Term color pair - nullptr, // Orig pair - nullptr, // Orig orig colors - 1, // Max color - 0, // No color video - false // No ANSI default color + { + nullptr, // Enter bold + ESC "(" ESC "H\003" + ESC "G0" ESC "cD" // Exit bold + }, + { + ESC "Gp", // Enter dim + ESC "(" ESC "H\003" + ESC "G0" ESC "cD" // Exit dim + }, + { + nullptr, // Enter italics + nullptr // Exit italics + }, + { + ESC "G8", // Enter underline + ESC "G0" // Exit underline + }, + { + ESC "G2", // Enter blink + ESC "(" ESC "H\003" + ESC "G0" ESC "cD" // Exit blink + }, + { + ESC "G2", // Enter reverse + ESC "(" ESC "H\003" + ESC "G0" ESC "cD" // Exit reverse + }, + { + ESC "Gt", // Enter standout + ESC "G0" // Exit standout + }, + { + ESC "G1", // Enter secure + ESC "(" ESC "H\003" + ESC "G0" ESC "cD" // Exit secure + }, + { + ESC ")", // Enter protected + ESC "(" ESC "H\003" + ESC "G0" ESC "cD" // Exit protected + }, + { + nullptr, // Enter crossed out + ESC "(" ESC "H\003" + ESC "G0" ESC "cD" // Exit crossed out + }, + { + nullptr, // Enter double underline + nullptr // Exit double underline + }, + { + "%?%p8%t\033)%e\033(%;" + "%?%p9%t\033cE%e\033cD%;\033G%'0'" + "%?%p2%t%{8}%|%;" + "%?%p1%p3%|%p6%|%t%{4}%|%;" + "%?%p4%t%{2}%|%;" + "%?%p1%p5%|%t%'@'%|%;" + "%?%p7%t%{1}%|%;%c", // Set attributes + ESC "(" ESC "H\003" + ESC "G0" ESC "cD" // Exit attribute + }, + { + ESC "cE", // Enter alt charset + ESC "cD" // Exit alt charset + }, + { + nullptr, // Enter pc charset + nullptr // Exit pc charset + }, + { + nullptr, // Ansi foreground color + nullptr, // Ansi background color + nullptr, // Foreground color + nullptr, // Background color + nullptr, // Term color pair + nullptr, // Orig pair + nullptr, // Orig orig colors + 1, // Max color + 0, // No color video + false // No ANSI default color + } }; oa.setTermEnvironment(optiattr_env);