@@ -348,6 +348,21 @@ supplement_seqs (ChafaTermInfo *dest, ChafaTermInfo *src,
348348 supplement_seq (dest , src , seqs [i ]);
349349}
350350
351+ static gint
352+ print_multiple (ChafaTerm * term , const gint * print_seqs )
353+ {
354+ gint n_printed = 0 ;
355+ gint i ;
356+
357+ for (i = 0 ; print_seqs [i ] > -1 ; i ++ )
358+ {
359+ if (chafa_term_print_seq (term , print_seqs [i ], -1 ) > 0 )
360+ n_printed ++ ;
361+ }
362+
363+ return n_printed ;
364+ }
365+
351366/* ----------------------- *
352367 * Internal event handling *
353368 * ----------------------- */
@@ -902,7 +917,17 @@ chafa_term_sync_probe (ChafaTerm *term, gint timeout_ms)
902917 struct termios saved_termios ;
903918 gboolean termios_changed = FALSE;
904919#endif
905- gint printed_len = 0 ;
920+ const gint probe_seqs [] =
921+ {
922+ CHAFA_TERM_SEQ_QUERY_DEFAULT_FG ,
923+ CHAFA_TERM_SEQ_QUERY_DEFAULT_BG ,
924+ CHAFA_TERM_SEQ_QUERY_TEXT_AREA_SIZE_CELLS ,
925+ CHAFA_TERM_SEQ_QUERY_TEXT_AREA_SIZE_PX ,
926+ CHAFA_TERM_SEQ_QUERY_CELL_SIZE_PX ,
927+ CHAFA_TERM_SEQ_QUERY_PRIMARY_DEVICE_ATTRIBUTES ,
928+ -1
929+ };
930+ gint n_probes = 0 ;
906931
907932 if (term -> probe_success )
908933 return TRUE;
@@ -918,15 +943,10 @@ chafa_term_sync_probe (ChafaTerm *term, gint timeout_ms)
918943 ensure_raw_mode_enabled (term , & saved_termios , & termios_changed );
919944#endif
920945
921- printed_len += chafa_term_print_seq (term , CHAFA_TERM_SEQ_QUERY_DEFAULT_FG , -1 );
922- printed_len += chafa_term_print_seq (term , CHAFA_TERM_SEQ_QUERY_DEFAULT_BG , -1 );
923- printed_len += chafa_term_print_seq (term , CHAFA_TERM_SEQ_QUERY_TEXT_AREA_SIZE_CELLS , -1 );
924- printed_len += chafa_term_print_seq (term , CHAFA_TERM_SEQ_QUERY_TEXT_AREA_SIZE_PX , -1 );
925- printed_len += chafa_term_print_seq (term , CHAFA_TERM_SEQ_QUERY_CELL_SIZE_PX , -1 );
926- printed_len += chafa_term_print_seq (term , CHAFA_TERM_SEQ_QUERY_PRIMARY_DEVICE_ATTRIBUTES , -1 );
946+ n_probes = print_multiple (term , probe_seqs );
927947 term -> probe_attempt = TRUE;
928948
929- if (printed_len == 0 )
949+ if (n_probes == 0 )
930950 {
931951 /* Terminal doesn't support any of the probe sequences */
932952 term -> probe_success = FALSE;
0 commit comments