Skip to content

Commit e0dbff8

Browse files
committed
[files-panel] limit file name width
Also, fix highlight for regex with '\x'
1 parent f154c0d commit e0dbff8

3 files changed

Lines changed: 22 additions & 12 deletions

File tree

src/base/snippet_highlighters.cc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,27 @@ regex_highlighter(attr_line_t& al, std::optional<int> x, line_range sub)
326326
alb.overlay_attr(line_range(lpc - 1, lpc + 1),
327327
VC_ROLE.value(role_t::VCR_ERROR));
328328
break;
329-
case '0':
330329
case 'x':
331330
if (safe_read(line, lpc + 1) == '{') {
332331
alb.overlay_attr(line_range(lpc - 1, lpc + 1),
333332
VC_ROLE.value(role_t::VCR_RE_SPECIAL));
334-
} else if (isdigit(safe_read(line, lpc + 1))
335-
&& isdigit(safe_read(line, lpc + 2)))
333+
} else if (isxdigit(safe_read(line, lpc + 1))
334+
&& isxdigit(safe_read(line, lpc + 2)))
335+
{
336+
alb.overlay_attr(line_range(lpc - 1, lpc + 3),
337+
VC_ROLE.value(role_t::VCR_RE_SPECIAL));
338+
} else {
339+
alb.overlay_attr(line_range(lpc - 1, lpc + 1),
340+
VC_STYLE.value(text_attrs::with_styles(
341+
text_attrs::style::bold,
342+
text_attrs::style::reverse)));
343+
alb.overlay_attr(line_range(lpc - 1, lpc + 1),
344+
VC_ROLE.value(role_t::VCR_ERROR));
345+
}
346+
break;
347+
case '0':
348+
if (isdigit(safe_read(line, lpc + 1))
349+
&& isdigit(safe_read(line, lpc + 2)))
336350
{
337351
alb.overlay_attr(line_range(lpc - 1, lpc + 3),
338352
VC_ROLE.value(role_t::VCR_RE_SPECIAL));

src/files_sub_source.cc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ from_selection(std::optional<vis_line_t> sel_vis)
9393
}
9494
} // namespace files_model
9595

96-
files_sub_source::files_sub_source() {}
97-
9896
bool
9997
files_sub_source::list_input_handle_key(listview_curses& lv, const ncinput& ch)
10098
{
@@ -261,11 +259,8 @@ files_sub_source::text_value_for_line(textview_curses& tc,
261259
role_t cursor_role = lnav_data.ld_mode == ln_mode_t::FILES
262260
? role_t::VCR_CURSOR_LINE
263261
: role_t::VCR_DISABLED_CURSOR_LINE;
264-
const auto dim = tc.get_dimensions();
265262
const auto& fc = lnav_data.ld_active_files;
266-
auto filename_width
267-
= std::min(fc.fc_largest_path_length,
268-
std::max((size_t) 40, (size_t) dim.second - 30));
263+
auto filename_width = std::min(fc.fc_largest_path_length, (size_t) 32);
269264

270265
this->fss_curr_line.clear();
271266
auto& al = this->fss_curr_line;
@@ -349,7 +344,7 @@ files_sub_source::text_value_for_line(textview_curses& tc,
349344
}
350345
al.append(" ");
351346
al.appendf(FMT_STRING("{:<{}}"), fn, filename_width);
352-
al.append(" ");
347+
al.append(" ");
353348
{
354349
auto ag = alb.with_attr(VC_ROLE.value(role_t::VCR_NUMBER));
355350

src/files_sub_source.hh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@
3131
#define files_sub_source_hh
3232

3333
#include <chrono>
34+
#include <map>
35+
#include <optional>
3436
#include <string>
3537
#include <vector>
3638

39+
#include "base/attr_line.hh"
3740
#include "file_collection.hh"
3841
#include "plain_text_source.hh"
3942
#include "textview_curses.hh"
@@ -43,8 +46,6 @@ class files_sub_source
4346
, public list_input_delegate
4447
, public text_delegate {
4548
public:
46-
files_sub_source();
47-
4849
bool empty() const override { return false; }
4950

5051
bool list_input_handle_key(listview_curses& lv, const ncinput& ch) override;

0 commit comments

Comments
 (0)