• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tstack / lnav / 20245728190-2749

15 Dec 2025 07:59PM UTC coverage: 68.864% (-0.07%) from 68.929%
20245728190-2749

push

github

tstack
[text_format] add plaintext type

Related to #1296

85 of 132 new or added lines in 24 files covered. (64.39%)

73 existing lines in 10 files now uncovered.

51605 of 74938 relevant lines covered (68.86%)

434003.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

84.08
/src/logfile_sub_source.hh
1
/**
2
 * Copyright (c) 2007-2012, Timothy Stack
3
 *
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * * Redistributions of source code must retain the above copyright notice, this
10
 * list of conditions and the following disclaimer.
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 * this list of conditions and the following disclaimer in the documentation
13
 * and/or other materials provided with the distribution.
14
 * * Neither the name of Timothy Stack nor the names of its contributors
15
 * may be used to endorse or promote products derived from this software
16
 * without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29
 * @file logfile_sub_source.hh
30
 */
31

32
#ifndef logfile_sub_source_hh
33
#define logfile_sub_source_hh
34

35
#include <array>
36
#include <utility>
37
#include <vector>
38

39
#include <limits.h>
40

41
#include "base/time_util.hh"
42
#include "big_array.hh"
43
#include "bookmarks.hh"
44
#include "document.sections.hh"
45
#include "filter_observer.hh"
46
#include "log_format.hh"
47
#include "logfile.hh"
48
#include "strong_int.hh"
49
#include "textview_curses.hh"
50

51
STRONG_INT_TYPE(uint64_t, content_line);
52

53
struct sqlite3_stmt;
54
extern "C"
55
{
56
int sqlite3_finalize(sqlite3_stmt* pStmt);
57
}
58

59
class logfile_sub_source;
60

61
class index_delegate {
62
public:
63
    virtual ~index_delegate() = default;
×
64

65
    virtual void index_start(logfile_sub_source& lss) {}
×
66

67
    virtual void index_line(logfile_sub_source& lss,
×
68
                            logfile* lf,
69
                            logfile::iterator ll)
70
    {
71
    }
72

73
    virtual void index_complete(logfile_sub_source& lss) {}
×
74
};
75

76
class sql_filter : public text_filter {
77
public:
78
    sql_filter(logfile_sub_source& lss,
7✔
79
               std::string stmt_str,
80
               sqlite3_stmt* stmt)
81
        : text_filter(EXCLUDE, filter_lang_t::SQL, std::move(stmt_str), 0),
7✔
82
          sf_log_source(lss)
7✔
83
    {
84
        this->sf_filter_stmt = stmt;
7✔
85
    }
7✔
86

87
    bool matches(std::optional<line_source> ls,
88
                 const shared_buffer_ref& line) override;
89

90
    std::string to_command() const override;
91

92
    auto_mem<sqlite3_stmt> sf_filter_stmt{sqlite3_finalize};
93
    logfile_sub_source& sf_log_source;
94
};
95

96
class log_location_history : public location_history {
97
public:
98
    explicit log_location_history(logfile_sub_source& lss)
1,168✔
99
        : llh_history(std::begin(this->llh_backing),
2,336✔
100
                      std::end(this->llh_backing)),
1,168✔
101
          llh_log_source(lss)
1,168✔
102
    {
103
    }
1,168✔
104

105
    ~log_location_history() override = default;
758✔
106

107
    void loc_history_append(vis_line_t top) override;
108

109
    std::optional<vis_line_t> loc_history_back(vis_line_t current_top) override;
110

111
    std::optional<vis_line_t> loc_history_forward(
112
        vis_line_t current_top) override;
113

114
private:
115
    nonstd::ring_span<content_line_t> llh_history;
116
    logfile_sub_source& llh_log_source;
117
    content_line_t llh_backing[MAX_SIZE];
118
};
119

120
class logline_window;
121

122
/**
123
 * Delegate class that merges the contents of multiple log files into a single
124
 * source of data for a text view.
125
 */
126
class logfile_sub_source
127
    : public text_sub_source
128
    , public text_time_translator
129
    , public text_accel_source
130
    , public list_input_delegate
131
    , public text_anchors
132
    , public text_delegate
133
    , public text_detail_provider
134
    , public lnav_config_listener {
135
public:
136
    const static bookmark_type_t BM_FILES;
137

138
    virtual void text_filters_changed();
139

140
    logfile_sub_source();
141

142
    ~logfile_sub_source() = default;
758✔
143

144
    enum class line_context_t : uint8_t {
145
        filename,
146
        basename,
147
        none,
148
        time_column,
149
    };
150

151
    void increase_line_context();
152

153
    bool decrease_line_context();
154

155
    size_t get_filename_offset() const;
156

157
    line_context_t get_line_context() const { return this->lss_line_context; }
13✔
158

159
    void set_force_rebuild() { this->lss_force_rebuild = true; }
11✔
160

161
    bool is_rebuild_forced() const { return this->lss_force_rebuild; }
83✔
162

163
    bool list_input_handle_key(listview_curses& lv, const ncinput& ch);
164

165
    void set_marked_only(bool val)
8✔
166
    {
167
        if (this->lss_marked_only != val) {
8✔
168
            this->lss_marked_only = val;
2✔
169
            this->text_filters_changed();
2✔
170
        }
171
    }
8✔
172

173
    void update_filter_hash_state(hasher& h) const;
174

175
    bool get_marked_only() { return this->lss_marked_only; }
×
176

177
    size_t text_line_count() { return this->lss_filtered_index.size(); }
29,542✔
178

179
    size_t text_line_width(textview_curses& curses)
7,968✔
180
    {
181
        return this->lss_longest_line;
7,968✔
182
    }
183

184
    size_t file_count() const;
185

186
    bool empty() const { return this->lss_filtered_index.empty(); }
×
187

188
    line_info text_value_for_line(textview_curses& tc,
189
                                  int row,
190
                                  std::string& value_out,
191
                                  line_flags_t flags);
192

193
    void text_attrs_for_line(textview_curses& tc,
194
                             int row,
195
                             string_attrs_t& value_out);
196

197
    size_t text_size_for_line(textview_curses& tc, int row, line_flags_t flags);
198

199
    void text_mark(const bookmark_type_t* bm, vis_line_t line, bool added);
200

201
    void text_clear_marks(const bookmark_type_t* bm);
202

203
    bool insert_file(const std::shared_ptr<logfile>& lf);
204

205
    void remove_file(std::shared_ptr<logfile> lf);
206

207
    enum class rebuild_result {
208
        rr_no_change,
209
        rr_appended_lines,
210
        rr_partial_rebuild,
211
        rr_full_rebuild,
212
    };
213

214
    rebuild_result rebuild_index(std::optional<ui_clock::time_point> deadline
215
                                 = std::nullopt);
216

217
    void text_update_marks(vis_bookmarks& bm);
218

219
    void set_user_mark(const bookmark_type_t* bm, content_line_t cl)
29✔
220
    {
221
        this->lss_user_marks[bm].insert_once(cl);
29✔
222
    }
29✔
223

224
    bookmarks<content_line_t>::type& get_user_bookmarks()
23✔
225
    {
226
        return this->lss_user_marks;
23✔
227
    }
228

229
    bookmark_metadata& get_bookmark_metadata(content_line_t cl);
230

231
    bookmark_metadata& get_bookmark_metadata(vis_line_t vl)
25✔
232
    {
233
        return this->get_bookmark_metadata(this->at(vl));
25✔
234
    }
235

236
    struct bookmark_metadata_context {
237
        std::optional<vis_line_t> bmc_current;
238
        std::optional<bookmark_metadata*> bmc_current_metadata;
239
        std::optional<vis_line_t> bmc_next_line;
240
    };
241

242
    bookmark_metadata_context get_bookmark_metadata_context(
243
        vis_line_t vl,
244
        bookmark_metadata::categories desired
245
        = bookmark_metadata::categories::any) const;
246

247
    std::optional<bookmark_metadata*> find_bookmark_metadata(
248
        content_line_t cl) const;
249

250
    std::optional<bookmark_metadata*> find_bookmark_metadata(
23,700✔
251
        vis_line_t vl) const
252
    {
253
        if (vl >= vis_line_t(this->lss_filtered_index.size())) {
23,700✔
254
            return std::nullopt;
×
255
        }
256
        return this->find_bookmark_metadata(this->at(vl));
23,700✔
257
    }
258

259
    void erase_bookmark_metadata(content_line_t cl);
260

261
    void erase_bookmark_metadata(vis_line_t vl)
26✔
262
    {
263
        this->erase_bookmark_metadata(this->at(vl));
26✔
264
    }
26✔
265

266
    void clear_bookmark_metadata();
267

268
    int get_filtered_count() const
1,837✔
269
    {
270
        return this->lss_index.size() - this->lss_filtered_index.size();
1,837✔
271
    }
272

273
    int get_filtered_count_for(size_t filter_index) const;
274

275
    Result<void, lnav::console::user_message> set_sql_filter(
276
        std::string stmt_str, sqlite3_stmt* stmt);
277

278
    Result<void, lnav::console::user_message> set_sql_marker(
279
        std::string stmt_str, sqlite3_stmt* stmt);
280

281
    Result<void, lnav::console::user_message> set_preview_sql_filter(
282
        sqlite3_stmt* stmt);
283

284
    std::string get_sql_filter_text()
51✔
285
    {
286
        auto filt = this->get_sql_filter();
51✔
287

288
        if (filt) {
51✔
289
            return filt.value()->get_id();
1✔
290
        }
291
        return "";
100✔
292
    }
51✔
293

294
    std::optional<std::shared_ptr<text_filter>> get_sql_filter();
295

296
    std::string get_sql_marker_text() const
47✔
297
    {
298
        return this->lss_marker_stmt_text;
47✔
299
    }
300

301
    std::shared_ptr<logfile> find(const char* fn, content_line_t& line_base);
302

303
    std::shared_ptr<logfile> find(content_line_t& line) const
27,879✔
304
    {
305
        std::shared_ptr<logfile> retval;
27,879✔
306

307
        retval = this->lss_files[line / MAX_LINES_PER_FILE]->get_file();
27,879✔
308
        line = content_line_t(line % MAX_LINES_PER_FILE);
27,879✔
309

310
        return retval;
27,879✔
311
    }
312

313
    logfile* find_file_ptr(content_line_t& line) const
350,661✔
314
    {
315
        auto* retval
316
            = this->lss_files[line / MAX_LINES_PER_FILE]->get_file_ptr();
350,661✔
317
        line = content_line_t(line % MAX_LINES_PER_FILE);
350,661✔
318

319
        return retval;
350,661✔
320
    }
321

322
    logline* find_line(content_line_t line) const
222,361✔
323
    {
324
        logline* retval = nullptr;
222,361✔
325
        auto lf = this->find_file_ptr(line);
222,361✔
326

327
        if (lf != nullptr) {
222,361✔
328
            auto ll_iter = lf->begin() + line;
222,361✔
329

330
            retval = &(*ll_iter);
222,361✔
331
        }
332

333
        return retval;
222,361✔
334
    }
335

336
    std::optional<std::pair<std::shared_ptr<logfile>, logfile::iterator>>
337
    find_line_with_file(content_line_t line) const
24,927✔
338
    {
339
        std::shared_ptr<logfile> lf = this->find(line);
24,927✔
340

341
        if (lf != nullptr) {
24,927✔
342
            auto ll_iter = lf->begin() + line;
24,927✔
343

344
            return std::make_pair(lf, ll_iter);
24,927✔
345
        }
346

347
        return std::nullopt;
×
348
    }
24,927✔
349

350
    std::optional<std::pair<std::shared_ptr<logfile>, logfile::iterator>>
351
    find_line_with_file(std::optional<vis_line_t> vl) const
747✔
352
    {
353
        if (vl && vl.value() >= 0_vl
1,494✔
354
            && vl.value() < vis_line_t(this->lss_filtered_index.size()))
1,494✔
355
        {
356
            return this->find_line_with_file(this->at(vl.value()));
747✔
357
        }
358

359
        return std::nullopt;
×
360
    }
361

362
    std::optional<vis_line_t> find_from_time(const timeval& start) const;
363

364
    std::optional<vis_line_t> find_from_time(time_t start) const
×
365
    {
366
        const auto tv = timeval{start, 0};
×
367

368
        return this->find_from_time(tv);
×
369
    }
370

371
    std::optional<vis_line_t> find_from_time(const exttm& etm) const
×
372
    {
373
        return this->find_from_time(etm.to_timeval());
×
374
    }
375

376
    std::optional<vis_line_t> find_from_content(content_line_t cl);
377

378
    std::optional<row_info> time_for_row(vis_line_t row)
5,411✔
379
    {
380
        if (row >= 0_vl && row < (ssize_t) this->lss_filtered_index.size()) {
5,411✔
381
            auto cl = this->at(row);
3,770✔
382
            return row_info{
7,540✔
383
                this->find_line(cl)->get_timeval(),
3,770✔
384
                (int64_t) cl,
3,770✔
385
            };
3,770✔
386
        }
387
        return std::nullopt;
1,641✔
388
    }
389

390
    std::optional<vis_line_t> row_for(const row_info& ri);
391

392
    std::optional<vis_line_t> row_for_time(struct timeval time_bucket)
58✔
393
    {
394
        return this->find_from_time(time_bucket);
58✔
395
    }
396

397
    content_line_t at(vis_line_t vl) const
240,632✔
398
    {
399
        return this->lss_index[this->lss_filtered_index[vl]].value();
240,632✔
400
    }
401

402
    size_t get_filtered_before() const
×
403
    {
404
        return this->lss_filtered_index.empty() ? 0
×
405
                                                : this->lss_filtered_index[0];
×
406
    }
407

408
    size_t get_filtered_after() const
×
409
    {
410
        if (this->lss_filtered_index.empty()) {
×
411
            return 0;
×
412
        }
413

414
        return this->lss_index.size() - this->lss_filtered_index.back() - 1;
×
415
    }
416

417
    content_line_t at_base(vis_line_t vl)
431✔
418
    {
419
        while (vl > 0_vl
431✔
420
               && this->find_line(this->at(vl))->get_sub_offset() != 0)
431✔
421
        {
422
            --vl;
×
423
        }
424

425
        return this->at(vl);
431✔
426
    }
427

428
    std::unique_ptr<logline_window> window_at(vis_line_t start_vl,
429
                                              vis_line_t end_vl);
430

431
    std::unique_ptr<logline_window> window_at(vis_line_t start_vl);
432

433
    std::unique_ptr<logline_window> window_to_end(vis_line_t start_vl);
434

435
    /**
436
     * Container for logfile references that keeps of how many lines in the
437
     * logfile have been indexed.
438
     */
439
    struct logfile_data {
440
        logfile_data(size_t index,
519✔
441
                     filter_stack& fs,
442
                     const std::shared_ptr<logfile>& lf)
443
            : ld_file_index(index), ld_filter_state(fs, lf),
519✔
444
              ld_visible(lf->is_indexing())
519✔
445
        {
446
            lf->set_logline_observer(&this->ld_filter_state);
519✔
447
            this->ld_file_ptr = lf.get();
519✔
448
        }
519✔
449

450
        void clear()
519✔
451
        {
452
            this->ld_filter_state.lfo_filter_state.clear();
519✔
453
            this->ld_file_ptr = nullptr;
519✔
454
        }
519✔
455

UNCOV
456
        void set_file(const std::shared_ptr<logfile>& lf)
×
457
        {
UNCOV
458
            this->ld_filter_state.lfo_filter_state.tfs_logfile = lf;
×
UNCOV
459
            this->ld_file_ptr = lf.get();
×
UNCOV
460
            this->ld_lines_indexed = 0;
×
UNCOV
461
            this->ld_lines_watched = 0;
×
UNCOV
462
            this->ld_visible = lf->is_indexing();
×
UNCOV
463
            lf->set_logline_observer(&this->ld_filter_state);
×
464
        }
465

466
        std::shared_ptr<logfile> get_file() const
37,172✔
467
        {
468
            return this->ld_filter_state.lfo_filter_state.tfs_logfile;
37,172✔
469
        }
470

471
        logfile* get_file_ptr() const { return this->ld_file_ptr; }
489,898✔
472

473
        bool is_visible() const
15,665✔
474
        {
475
            return this->get_file_ptr() != nullptr && this->ld_visible;
15,665✔
476
        }
477

478
        void set_visibility(bool vis) { this->ld_visible = vis; }
526✔
479

480
        size_t ld_file_index;
481
        line_filter_observer ld_filter_state;
482
        size_t ld_lines_indexed{0};
483
        size_t ld_lines_watched{0};
484
        logfile* ld_file_ptr{nullptr};
485
        bool ld_visible;
486
    };
487

488
    using iterator = std::vector<std::unique_ptr<logfile_data>>::iterator;
489
    using const_iterator
490
        = std::vector<std::unique_ptr<logfile_data>>::const_iterator;
491

492
    size_t size() const { return this->lss_files.size(); }
×
493

494
    iterator begin() { return this->lss_files.begin(); }
1,683✔
495

496
    iterator end() { return this->lss_files.end(); }
1,869✔
497

498
    const_iterator cbegin() const { return this->lss_files.begin(); }
4,021✔
499

500
    const_iterator cend() const { return this->lss_files.end(); }
7,644✔
501

502
    iterator find_data(content_line_t& line)
4,411✔
503
    {
504
        auto retval = this->lss_files.begin();
4,411✔
505
        std::advance(retval, line / MAX_LINES_PER_FILE);
4,411✔
506
        line = content_line_t(line % MAX_LINES_PER_FILE);
4,411✔
507

508
        return retval;
4,411✔
509
    }
510

511
    iterator find_data(content_line_t line, uint64_t& offset_out)
101,994✔
512
    {
513
        auto retval = this->lss_files.begin();
101,994✔
514
        std::advance(retval, line / MAX_LINES_PER_FILE);
101,994✔
515
        offset_out = line % MAX_LINES_PER_FILE;
101,994✔
516

517
        return retval;
101,994✔
518
    }
519

520
    std::optional<logfile_data*> find_data(const std::shared_ptr<logfile>& lf)
55✔
521
    {
522
        for (auto& ld : *this) {
61✔
523
            if (ld->ld_filter_state.lfo_filter_state.tfs_logfile == lf) {
61✔
524
                return ld.get();
55✔
525
            }
526
        }
527
        return std::nullopt;
×
528
    }
529

530
    iterator find_data_i(const std::shared_ptr<const logfile>& lf)
121✔
531
    {
532
        for (auto iter = this->begin(); iter != this->end(); ++iter) {
122✔
533
            if ((*iter)->ld_filter_state.lfo_filter_state.tfs_logfile == lf) {
122✔
534
                return iter;
121✔
535
            }
536
        }
537

538
        return this->end();
×
539
    }
540

541
    content_line_t get_file_base_content_line(iterator iter)
49✔
542
    {
543
        ssize_t index = std::distance(this->begin(), iter);
49✔
544

545
        return content_line_t(index * MAX_LINES_PER_FILE);
49✔
546
    }
547

548
    void set_index_delegate(index_delegate* id)
634✔
549
    {
550
        if (id != this->lss_index_delegate) {
634✔
551
            this->lss_index_delegate = id;
634✔
552
            this->reload_index_delegate();
634✔
553
        }
554
    }
634✔
555

556
    index_delegate* get_index_delegate() const
557
    {
558
        return this->lss_index_delegate;
559
    }
560

561
    void reload_index_delegate();
562

563
    class meta_grepper
564
        : public grep_proc_source<vis_line_t>
565
        , public grep_proc_sink<vis_line_t> {
566
    public:
567
        meta_grepper(logfile_sub_source& source) : lmg_source(source) {}
1,168✔
568

569
        std::optional<line_info> grep_value_for_line(
570
            vis_line_t line, std::string& value_out) override;
571

572
        vis_line_t grep_initial_line(vis_line_t start,
573
                                     vis_line_t highest) override;
574

575
        void grep_next_line(vis_line_t& line) override;
576

577
        void grep_begin(grep_proc<vis_line_t>& gp,
578
                        vis_line_t start,
579
                        vis_line_t stop) override;
580

581
        void grep_end(grep_proc<vis_line_t>& gp) override;
582

583
        void grep_match(grep_proc<vis_line_t>& gp, vis_line_t line) override;
584

585
        logfile_sub_source& lmg_source;
586
        bool lmg_done{false};
587
    };
588

589
    std::optional<
590
        std::pair<grep_proc_source<vis_line_t>*, grep_proc_sink<vis_line_t>*>>
591
    get_grepper();
592

593
    std::optional<location_history*> get_location_history()
99✔
594
    {
595
        return &this->lss_location_history;
99✔
596
    }
597

598
    void text_crumbs_for_line(int line, std::vector<breadcrumb::crumb>& crumbs);
599

600
    bool text_handle_mouse(textview_curses& tc,
601
                           const listview_curses::display_line_content_t&,
602
                           mouse_event& me);
603

604
    Result<bool, lnav::console::user_message> eval_sql_filter(
605
        sqlite3_stmt* stmt, iterator ld, logfile::const_iterator ll);
606

607
    void invalidate_sql_filter();
608

609
    void set_line_meta_changed() { this->lss_line_meta_changed = true; }
34✔
610

611
    bool is_line_meta_changed() const { return this->lss_line_meta_changed; }
1,606✔
612

613
    void set_exec_context(exec_context* ec) { this->lss_exec_context = ec; }
634✔
614

615
    exec_context* get_exec_context() const { return this->lss_exec_context; }
616

617
    static constexpr uint64_t MAX_CONTENT_LINES = 1ULL << 40;
618
    static constexpr uint64_t MAX_LINES_PER_FILE = 1ULL << 27;
619
    static constexpr uint64_t MAX_FILES
620
        = (MAX_CONTENT_LINES / MAX_LINES_PER_FILE);
621

622
    std::function<void(logfile_sub_source&, file_off_t, file_size_t)>
623
        lss_sorting_observer;
624

625
    uint32_t lss_index_generation{0};
626

627
    void quiesce();
628

629
    struct __attribute__((__packed__)) indexed_content {
630
        enum class level_t : uint8_t {
631
            normal,
632
            warning,
633
            error,
634
        };
635

636
        static level_t level_from_log(const logfile::iterator iter)
13,843✔
637
        {
638
            if (!iter->is_message()) {
13,843✔
639
                return level_t::normal;
2,561✔
640
            }
641
            switch (iter->get_msg_level()) {
11,282✔
642
                case log_level_t::LEVEL_WARNING:
78✔
643
                    return level_t::warning;
78✔
644
                case log_level_t::LEVEL_ERROR:
1,663✔
645
                case log_level_t::LEVEL_FATAL:
646
                case log_level_t::LEVEL_CRITICAL:
647
                    return level_t::error;
1,663✔
648
                default:
9,541✔
649
                    return level_t::normal;
9,541✔
650
            }
651
        }
652

653
        indexed_content() = default;
654

655
        indexed_content(content_line_t cl, const logfile::iterator iter)
13,843✔
656
            : ic_value(cl),
13,843✔
657
              ic_level(lnav::enums::to_underlying(level_from_log(iter)))
13,843✔
658
        {
659
        }
13,843✔
660

661
        content_line_t value() const { return content_line_t(this->ic_value); }
487,064✔
662

663
        level_t level() const { return static_cast<level_t>(this->ic_level); }
17,361✔
664

665
        uint64_t ic_value : 38;
666
        uint8_t ic_level : 2;
667
    };
668

669
    big_array<indexed_content> lss_index;
670

671
    std::optional<vis_line_t> row_for_anchor(const std::string& id);
672

673
    std::optional<vis_line_t> adjacent_anchor(vis_line_t vl, direction dir);
674

675
    std::optional<std::string> anchor_for_row(vis_line_t vl);
676

677
    std::unordered_set<std::string> get_anchors();
678

679
    std::optional<json_string> text_row_details(const textview_curses& tc);
680

681
    void reload_config(error_reporter& reporter);
682

683
    bool is_indexing_in_progress() const
96✔
684
    {
685
        return this->lss_indexing_in_progress;
96✔
686
    }
687

688
    void clear_preview()
1✔
689
    {
690
        text_sub_source::clear_preview();
1✔
691

692
        this->set_preview_sql_filter(nullptr);
1✔
693
    }
1✔
694

695
    void add_commands_for_session(
696
        const std::function<void(const std::string&)>& receiver);
697

698
protected:
699
    void text_accel_display_changed() { this->clear_line_size_cache(); }
1✔
700

701
    logline* text_accel_get_line(vis_line_t vl)
2,274✔
702
    {
703
        return this->find_line(this->at(vl));
2,274✔
704
    }
705

706
private:
707
    static const size_t LINE_SIZE_CACHE_SIZE = 512;
708

709
    void clear_line_size_cache()
1,169✔
710
    {
711
        this->lss_line_size_cache.fill(std::make_pair(0, 0));
1,169✔
712
        this->lss_line_size_cache[0].first = -1;
1,169✔
713
    }
1,169✔
714

715
    bool check_extra_filters(iterator ld, logfile::iterator ll);
716

717
    size_t lss_basename_width = 0;
718
    size_t lss_filename_width = 0;
719
    line_context_t lss_line_context{line_context_t::none};
720
    bool lss_force_rebuild{false};
721
    std::vector<std::unique_ptr<logfile_data>> lss_files;
722
    unsigned int lss_all_timestamp_flags{0};
723

724
    std::vector<uint32_t> lss_filtered_index;
725
    auto_mem<sqlite3_stmt> lss_preview_filter_stmt{sqlite3_finalize};
726

727
    bookmarks<content_line_t>::type lss_user_marks{
728
        bookmarks<content_line_t>::create_array()};
729
    auto_mem<sqlite3_stmt> lss_marker_stmt{sqlite3_finalize};
730
    std::string lss_marker_stmt_text;
731

732
    line_flags_t lss_token_flags{0};
733
    iterator lss_token_file_data;
734
    std::shared_ptr<logfile> lss_token_file;
735
    std::string lss_token_value;
736
    string_attrs_t lss_token_attrs;
737
    lnav::document::metadata lss_token_meta;
738
    int lss_token_meta_line{-1};
739
    int lss_token_meta_size{0};
740
    size_t lss_time_column_size{0};
741
    size_t lss_time_column_padding{0};
742
    logline_value_vector lss_token_values;
743
    int lss_token_shift_start{0};
744
    int lss_token_shift_size{0};
745
    shared_buffer lss_share_manager;
746
    logfile::iterator lss_token_line;
747
    std::array<std::pair<int, size_t>, LINE_SIZE_CACHE_SIZE>
748
        lss_line_size_cache;
749
    bool lss_marked_only{false};
750
    index_delegate* lss_index_delegate{nullptr};
751
    size_t lss_longest_line{0};
752
    meta_grepper lss_meta_grepper;
753
    log_location_history lss_location_history;
754
    exec_context* lss_exec_context{nullptr};
755

756
    bool lss_in_value_for_line{false};
757
    bool lss_line_meta_changed{false};
758

759
    bool lss_indexing_in_progress{false};
760
};
761

762
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc