@@ -241,8 +241,6 @@ spectrogram_source::list_value_for_overlay(const listview_curses& lv,
241241 auto mark_offset = TIME_COLUMN_WIDTH + this ->ss_cursor_column .value ();
242242 auto mark_is_before = true ;
243243
244- retval.al_attrs .emplace_back (line_range{0 , -1 },
245- VC_ROLE.value (role_t ::VCR_STATUS_INFO));
246244 if (desc.length () + 8 > (ssize_t ) width) {
247245 desc.clear ();
248246 }
@@ -259,6 +257,7 @@ spectrogram_source::list_value_for_overlay(const listview_curses& lv,
259257 if (!mark_is_before) {
260258 retval.append (" \u25b2 " );
261259 }
260+ retval.with_attr_for_all (VC_ROLE.value (role_t ::VCR_CURSOR_LINE));
262261
263262 if (this ->ss_details_view != nullptr ) {
264263 if (s_row.sr_details_source_provider ) {
@@ -411,18 +410,16 @@ spectrogram_source::chart_attrs_for_line(textview_curses& tc,
411410 continue ;
412411 }
413412
414- role_t role;
415-
416- if (col_value < st.st_green_threshold ) {
417- role = role_t ::VCR_LOW_THRESHOLD;
418- } else if (col_value < st.st_yellow_threshold ) {
419- role = role_t ::VCR_MED_THRESHOLD;
420- } else {
421- role = role_t ::VCR_HIGH_THRESHOLD;
422- }
413+ auto role = lnav::enums::to_underlying (role_t ::VCR_SPECTRO_THRESHOLD0);
414+ auto t_iter = std::lower_bound (std::begin (st.st_thresholds ),
415+ std::end (st.st_thresholds ),
416+ col_value);
417+ auto dist = std::distance (std::begin (st.st_thresholds ), t_iter);
418+ role += dist;
419+ ensure (role < (int ) role_t ::VCR__MAX);
423420 auto lr
424421 = line_range{TIME_COLUMN_WIDTH + lpc, TIME_COLUMN_WIDTH + lpc + 1 };
425- value_out.emplace_back (lr, VC_ROLE.value (role));
422+ value_out.emplace_back (lr, VC_ROLE.value (role_t { role} ));
426423 }
427424}
428425
@@ -545,6 +542,8 @@ spectrogram_source::cache_bounds()
545542 return ;
546543 }
547544
545+ auto [height, width] = this ->tss_view ->get_dimensions ();
546+ width -= UNUSABLE_WIDTH;
548547 auto grain_begin_time = rounddown (sb.sb_begin_time , this ->ss_granularity );
549548 auto grain_end_time = roundup_size (sb.sb_end_time , this ->ss_granularity );
550549
@@ -555,19 +554,21 @@ spectrogram_source::cache_bounds()
555554 int64_t samples_per_row = sb.sb_count / this ->ss_cached_line_count ;
556555 auto & st = this ->ss_cached_thresholds ;
557556
558- st.st_yellow_threshold = samples_per_row / 4 ;
559- st.st_green_threshold = st.st_yellow_threshold / 2 ;
560-
561- if (st.st_green_threshold <= 1 ) {
562- st.st_green_threshold = 2 ;
563- }
564- if (st.st_yellow_threshold <= st.st_green_threshold ) {
565- st.st_yellow_threshold = st.st_green_threshold + 1 ;
557+ st.st_thresholds [0 ] = samples_per_row / width;
558+ st.st_thresholds [1 ] = samples_per_row / (width / 2 );
559+ st.st_thresholds [2 ] = samples_per_row / (width / 4 );
560+ st.st_thresholds [3 ] = samples_per_row / (width / 5 );
561+ st.st_thresholds [4 ] = samples_per_row / (width / 6 );
562+ st.st_thresholds [5 ] = samples_per_row / (width / 8 );
563+ st.st_thresholds [6 ] = std::numeric_limits<int >::max ();
564+ for (size_t lpc = 0 ; lpc < 6 ; lpc++) {
565+ if (st.st_thresholds [lpc] < lpc + 1 ) {
566+ st.st_thresholds [lpc] = lpc + 1 ;
567+ }
566568 }
567569
568570 auto & bm = this ->tss_view ->get_bookmarks ()[&textview_curses::BM_USER];
569571 bm.clear ();
570- auto [height, width] = this ->tss_view ->get_dimensions ();
571572 for (auto row = 0_vl; row < this ->ss_cached_line_count ; row += 1_vl) {
572573 spectrogram_request sr (sb);
573574
@@ -699,12 +700,12 @@ spectrogram_source::list_static_overlay(const listview_curses& lv,
699700 ANSI_ROLE (" " ) " 1-%'d " ANSI_ROLE (" " ) " %'d-%'d " ANSI_ROLE (
700701 " " ) " %'d+" ,
701702 lnav::enums::to_underlying (role_t ::VCR_LOW_THRESHOLD),
702- st.st_green_threshold - 1 ,
703+ st.st_thresholds [ 0 ] ,
703704 lnav::enums::to_underlying (role_t ::VCR_MED_THRESHOLD),
704- st.st_green_threshold ,
705- st.st_yellow_threshold - 1 ,
705+ st.st_thresholds [ 0 ] ,
706+ st.st_thresholds [ 3 ] ,
706707 lnav::enums::to_underlying (role_t ::VCR_HIGH_THRESHOLD),
707- st.st_yellow_threshold );
708+ st.st_thresholds [ 5 ] );
708709 auto buflen = strlen (buf);
709710 if (line.length () + buflen + 20 < width) {
710711 line.append (width / 2 - buflen / 3 - line.length (), ' ' );
0 commit comments