efn/c_indent.c

25 lines
467 B
C

void
c_indent(char *c) {
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) {
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;
}