Skip to content

Commit

Permalink
Add indent for region
Browse files Browse the repository at this point in the history
If a region is active, indentation is added to the whole region.
  • Loading branch information
abbec committed May 14, 2024
1 parent cd4829a commit e6387d3
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/dged/buffer_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,27 @@ void buffer_view_newline(struct buffer_view *view) {
}

void buffer_view_indent(struct buffer_view *view) {
view->dot = buffer_indent(view->buffer, view->dot);
struct region reg = region_new(view->dot, view->mark);
if (view->mark_set && region_has_size(reg)) {
for (uint32_t line = reg.begin.line; line <= reg.end.line; ++line) {
view->dot = buffer_indent(view->buffer,
(struct location){.line = line, .col = 0});
}
} else {
view->dot = buffer_indent(view->buffer, view->dot);
}
}

void buffer_view_indent_alt(struct buffer_view *view) {
view->dot = buffer_indent_alt(view->buffer, view->dot);
struct region reg = region_new(view->dot, view->mark);
if (view->mark_set && region_has_size(reg)) {
for (uint32_t line = reg.begin.line; line <= reg.end.line; ++line) {
view->dot = buffer_indent_alt(view->buffer,
(struct location){.line = line, .col = 0});
}
} else {
view->dot = buffer_indent_alt(view->buffer, view->dot);
}
}

void buffer_view_copy(struct buffer_view *view) {
Expand Down

0 comments on commit e6387d3

Please sign in to comment.