Skip to content

Commit

Permalink
add reminder to delete MLE_LINENUM_REL
Browse files Browse the repository at this point in the history
  • Loading branch information
adsr committed Jun 23, 2024
1 parent 1a84280 commit 75b03cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bview.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ bview_t *bview_new(editor_t *editor, int type, char *opt_path, int opt_path_len,
self->rect_lines.bg = TB_BLACK;
self->rect_margin_left.fg = TB_RED;
self->rect_margin_right.fg = TB_RED;
self->rect_buffer.h = 10; // TODO hack to fix _bview_set_linenum_width before bview_resize
self->tab_width = editor->tab_width;
self->tab_to_space = editor->tab_to_space;
self->soft_wrap_type = editor->soft_wrap_type;
Expand Down Expand Up @@ -551,13 +550,21 @@ static void _bview_buffer_callback(buffer_t *buffer, baction_t *action, void *ud

// Set linenum_width and return 1 if changed
static int _bview_set_linenum_width(bview_t *self) {
int orig;
int orig, h;
orig = self->linenum_width;
// There is a chicken-egg scenario in MLE_LINENUM_REL mode.
// Notice below that `rel_linenum_width` is a function of
// `rect_buffer.h`. `rect_buffer` is calculated in
// `bview_resize`, but that function needs `linenum_width` to
// calculate other values. Consider deprecating MLE_LINENUM_REL
// if no one is using it. MLE_LINENUM_ABS and MLE_LINENUM_NONE
// would be more useful options probably.
h = self->is_resized ? self->rect_buffer.h : 10;
self->abs_linenum_width = MLE_MAX(1, (int)(floor(log10((double)self->buffer->line_count))) + 1);
if (self->editor->linenum_type != MLE_LINENUM_ABS) {
self->rel_linenum_width = MLE_MAX(
self->editor->linenum_type == MLE_LINENUM_BOTH ? 1 : self->abs_linenum_width,
(int)(floor(log10((double)self->rect_buffer.h))) + 1
(int)(floor(log10((double)h))) + 1
);
} else {
self->rel_linenum_width = 0;
Expand Down
2 changes: 2 additions & 0 deletions mle.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,8 @@ TODO bugs
TODO review
[ ] review error checking, esp catch ENOSPC, malloc fail
TODO new features/improvements
[ ] delete MLE_LINENUM_REL, MLE_LINENUM_BOTH
[ ] add MLE_LINENUM_NONE
[ ] make color_col per bview
[ ] save macro as flags
[ ] nested macros
Expand Down

0 comments on commit 75b03cb

Please sign in to comment.