Skip to content

Commit

Permalink
Reorganize the data structure of FOptiAttr
Browse files Browse the repository at this point in the history
  • Loading branch information
gansm committed Oct 22, 2023
1 parent 8732f50 commit b5b232a
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 90 deletions.
64 changes: 26 additions & 38 deletions final/output/tty/fterm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
134 changes: 82 additions & 52 deletions test/foptiattr-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b5b232a

Please sign in to comment.