efn/c_indent.c

26 lines
494 B
C
Raw Normal View History

2022-04-02 16:12:22 +00:00
void
c_indent(char *c, char **argv) {
2022-04-02 16:12:22 +00:00
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) {
2022-04-02 16:12:22 +00:00
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];
}
2022-04-02 21:08:42 +00:00
row->text[ROW_SIZE - 1] = 0;
2022-04-02 16:12:22 +00:00
}
2022-04-02 21:08:42 +00:00