efn/c_indent.c

26 lines
494 B
C

void
c_indent(char *c, char **argv) {
Row *row = b_getline(buffer, atoi(c + 2));
if (row == NULL) { puts ("invalid line"); return; }
for(int i = ROW_SIZE - 1; i >= 1; i--) {
row->text[i] = row->text[i - 1];
}
row->text[0] = '\t';
}
void
c_unindent(char *c, char **argv) {
Row *row = b_getline(buffer, atoi(c + 2));
if (row == NULL) { puts ("invalid line"); return; }
for(int i = 0; i < ROW_SIZE - 1; i++) {
row->text[i] = row->text[i + 1];
}
row->text[ROW_SIZE - 1] = 0;
}